use of org.springframework.cloud.gcp.data.spanner.core.convert.TestEntities.TestEntity in project spring-cloud-gcp by spring-cloud.
the class ConverterAwareMappingSpannerEntityWriterTests method writeNullColumnsTest.
@Test
public void writeNullColumnsTest() {
TestEntity t = new TestEntity();
t.dateField = null;
t.doubleList = null;
WriteBuilder writeBuilder = mock(WriteBuilder.class);
ValueBinder<WriteBuilder> dateFieldBinder = mock(ValueBinder.class);
when(dateFieldBinder.to((Date) any())).thenReturn(null);
when(writeBuilder.set(eq("dateField"))).thenReturn(dateFieldBinder);
ValueBinder<WriteBuilder> doubleListFieldBinder = mock(ValueBinder.class);
when(doubleListFieldBinder.toFloat64Array((Iterable<Double>) any())).thenReturn(null);
when(writeBuilder.set(eq("doubleList"))).thenReturn(doubleListFieldBinder);
this.spannerEntityWriter.write(t, writeBuilder::set, Collections.unmodifiableSet(new HashSet<String>(Arrays.asList("dateField", "doubleList"))));
verify(dateFieldBinder, times(1)).to((Date) isNull());
verify(doubleListFieldBinder, times(1)).toFloat64Array((Iterable<Double>) isNull());
}
Aggregations