use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class SerializerFactoryImplTest method getSerializer_factoriesProvided_factoryReturned.
@Test
public void getSerializer_factoriesProvided_factoryReturned() throws Exception {
SerializerFactoryImpl factory = new SerializerFactoryImpl(ImmutableList.of(new TestStringSerializerFactory()), mockProcessingEnvironment);
Serializer actualSerializer = factory.getSerializer(typeMirrorOf(String.class));
assertThat(actualSerializer.getClass().getName()).contains("TestStringSerializerFactory$TestStringSerializer");
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableMapSerializerExtensionTest method getSerializer_nonImmutableMap_emptyReturned.
@Test
public void getSerializer_nonImmutableMap_emptyReturned() {
TypeMirror typeMirror = typeMirrorOf(String.class);
Optional<Serializer> actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment);
assertThat(actualSerializer).isEmpty();
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableMapSerializerExtensionTest method toProxy.
@Test
public void toProxy() {
TypeMirror typeMirror = declaredTypeOf(ImmutableMap.class, Integer.class, String.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
CodeBlock actualCodeBlock = serializer.toProxy(CodeBlock.of("x"));
assertThat(actualCodeBlock.toString()).isEqualTo(String.format("x.entrySet().stream().collect(%s.toImmutableMap(value$ -> %s.<%s," + " %s>wrapper(element$ -> element$).apply(value$.getKey()), value$ -> %s.<%s," + " %s>wrapper(element$ -> element$).apply(value$.getValue())))", IMMUTABLE_MAP, FUNCTION_WITH_EXCEPTIONS, INTEGER, INTEGER, FUNCTION_WITH_EXCEPTIONS, STRING, STRING));
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableMapSerializerExtensionTest method getSerializer_immutableMapWithSerializableContainedTypes_emptyReturned.
@Test
public void getSerializer_immutableMapWithSerializableContainedTypes_emptyReturned() {
fakeSerializerFactory.setReturnIdentitySerializer(true);
TypeMirror typeMirror = typeMirrorOf(ImmutableMap.class);
Optional<Serializer> actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment);
assertThat(actualSerializer).isEmpty();
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableMapSerializerExtensionTest method proxyFieldType.
@Test
public void proxyFieldType() {
TypeMirror typeMirror = declaredTypeOf(ImmutableMap.class, Integer.class, String.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
TypeMirror actualTypeMirror = serializer.proxyFieldType();
assertThat(typeUtils.isSameType(actualTypeMirror, typeMirror)).isTrue();
}
Aggregations