use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableListSerializerExtensionTest method getSerializer_immutableList_serializerReturned.
@Test
public void getSerializer_immutableList_serializerReturned() {
TypeMirror typeMirror = typeMirrorOf(ImmutableList.class);
Serializer actualSerializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
assertThat(actualSerializer.getClass().getName()).contains("ImmutableListSerializerExtension$ImmutableListSerializer");
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableListSerializerExtensionTest method toProxy.
@Test
public void toProxy() {
TypeMirror typeMirror = declaredTypeOf(ImmutableList.class, Integer.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
CodeBlock actualCodeBlock = serializer.toProxy(CodeBlock.of("x"));
assertThat(actualCodeBlock.toString()).isEqualTo(String.format("x.stream().map(%s.wrapper(value$ -> value$)).collect(%s.toImmutableList())", FUNCTION_WITH_EXCEPTIONS, IMMUTABLE_LIST));
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class ImmutableListSerializerExtensionTest method fromProxy.
@Test
public void fromProxy() {
TypeMirror typeMirror = declaredTypeOf(ImmutableList.class, Integer.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
CodeBlock actualCodeBlock = serializer.fromProxy(CodeBlock.of("x"));
assertThat(actualCodeBlock.toString()).isEqualTo(String.format("x.stream().map(%s.wrapper(value$ -> value$)).collect(%s.toImmutableList())", FUNCTION_WITH_EXCEPTIONS, IMMUTABLE_LIST));
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class OptionalSerializerExtensionTest method toProxy.
@Test
public void toProxy() {
TypeMirror typeMirror = declaredTypeOf(Optional.class, Integer.class);
Serializer serializer = extension.getSerializer(typeMirror, fakeSerializerFactory, mockProcessingEnvironment).get();
CodeBlock actualCodeBlock = serializer.toProxy(CodeBlock.of("x"));
assertThat(actualCodeBlock.toString()).isEqualTo("x.isPresent() ? x.get() : null");
}
use of com.google.auto.value.extension.serializable.serializer.interfaces.Serializer in project auto by google.
the class SerializerFactoryImplTest method getSerializer_emptyFactories_identitySerializerReturned.
@Test
public void getSerializer_emptyFactories_identitySerializerReturned() throws Exception {
SerializerFactoryImpl factory = new SerializerFactoryImpl(ImmutableList.of(), mockProcessingEnvironment);
Serializer actualSerializer = factory.getSerializer(typeMirrorOf(String.class));
assertThat(actualSerializer.getClass().getName()).contains("IdentitySerializerFactory$IdentitySerializer");
}
Aggregations