@SuppressWarnings("unchecked")
@Test
public void testSerializerDuplication() {

	TypeSerializer<String> statefulSerializer = mock(TypeSerializer.class);
	when(statefulSerializer.duplicate()).thenAnswer(new Answer<TypeSerializer<String>>() {
		@Override
		public TypeSerializer<String> answer(InvocationOnMock invocation) throws Throwable {
			return mock(TypeSerializer.class);
		}
	});
	ListStateDescriptor<String> descr = new ListStateDescriptor<>("foobar", statefulSerializer);
	TypeSerializer<String> serializerA = descr.getElementSerializer();
	TypeSerializer<String> serializerB = descr.getElementSerializer();
	// check that the retrieved serializers are not the same
	assertNotSame(serializerA, serializerB);
	TypeSerializer<List<String>> listSerializerA = descr.getSerializer();
	TypeSerializer<List<String>> listSerializerB = descr.getSerializer();
	assertNotSame(listSerializerA, listSerializerB);
}