use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableMapSerializerExtensionTest method fromProxy.
@Test
public void fromProxy() {
TypeMirror typeMirror = declaredTypeOf(ImmutableMap.class, Integer.class, String.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
CodeBlock actualCodeBlock = serializer.fromProxy(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_immutableMap_serializerReturned.
@Test
public void getSerializer_immutableMap_serializerReturned() {
TypeMirror typeMirror = typeMirrorOf(ImmutableMap.class);
Serializer actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
assertThat(actualSerializer.getClass().getName()).contains("ImmutableMapSerializerExtension$ImmutableMapSerializer");
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class SerializerFactoryLoaderTest method getFactory_extensionsLoaded.
@Test
public void getFactory_extensionsLoaded() throws Exception {
SerializerFactory factory = SerializerFactoryLoader.getFactory(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 ImmutableListSerializerExtensionTest method getSerializer_immutableListWithSerializableContainedType_emptyReturned.
@Test
public void getSerializer_immutableListWithSerializableContainedType_emptyReturned() {
fakeSerializerFactory.setReturnIdentitySerializer(true);
TypeMirror typeMirror = typeMirrorOf(ImmutableList.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 OptionalSerializerExtensionTest method getSerializer_optional_serializerReturned.
@Test
public void getSerializer_optional_serializerReturned() {
TypeMirror typeMirror = typeMirrorOf(Optional.class);
Serializer actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
assertThat(actualSerializer.getClass().getName()).contains("OptionalSerializerExtension$OptionalSerializer");
}
Aggregations