DATAGEODE-105 - Polish.

This commit is contained in:
John Blum
2018-05-15 23:22:20 -07:00
parent b5fe5f8c8d
commit 5d7da850c8
3 changed files with 57 additions and 33 deletions

View File

@@ -73,7 +73,6 @@ import org.springframework.data.mapping.model.ParameterValueProvider;
* @author John Blum
* @see org.junit.Rule
* @see org.junit.Test
* @see org.junit.rules.ExpectedException
* @see org.junit.runner.RunWith
* @see org.mockito.Mock
* @see org.mockito.Mockito
@@ -87,20 +86,20 @@ import org.springframework.data.mapping.model.ParameterValueProvider;
@RunWith(MockitoJUnitRunner.class)
public class MappingPdxSerializerUnitTests {
ConversionService conversionService;
private ConversionService conversionService;
@Mock
EntityInstantiator mockInstantiator;
private EntityInstantiator mockInstantiator;
GemfireMappingContext mappingContext;
private GemfireMappingContext mappingContext;
MappingPdxSerializer pdxSerializer;
private MappingPdxSerializer pdxSerializer;
@Mock
PdxReader mockReader;
private PdxReader mockReader;
@Mock
PdxWriter mockWriter;
private PdxWriter mockWriter;
@Before
public void setUp() {
@@ -531,9 +530,19 @@ public class MappingPdxSerializerUnitTests {
verify(mockProperty, times(1)).isTransient();
}
@Test
public void resolveTypeWithNonNullType() {
assertThat(this.pdxSerializer.resolveType("test")).isEqualTo(String.class);
}
@Test
public void resolveTypeWithNullType() {
assertThat(this.pdxSerializer.resolveType(null)).isNull();
}
@Test
@SuppressWarnings("unchecked")
public void fromDataDeserializesPdxBytesAndMapsToApplicationDomainObject() {
public void fromDataDeserializesPdxBytesAndMapsToEntity() {
Address expectedAddress = new Address();
@@ -637,7 +646,7 @@ public class MappingPdxSerializerUnitTests {
}
@Test
public void fromDataWithTypeFilterAcceptsApplicationDomainTypes() {
public void fromDataWithTypeFilterAcceptsDeclaredEntityTypes() {
this.pdxSerializer.setTypeFilters(type -> User.class.getPackage().equals(type.getPackage()));
@@ -665,7 +674,12 @@ public class MappingPdxSerializerUnitTests {
}
@Test
public void fromDataWithTypeFilterFiltersApplicationDomainTypeReturnsNull() {
public void fromDataWithTypeFilterFiltersNullTypeReturnsNull() {
assertThat(this.pdxSerializer.fromData(null, this.mockReader)).isNull();
}
@Test
public void fromDataWithTypeFilterFiltersUndeclaredEntityTypesReturnsNull() {
this.pdxSerializer.setTypeFilters(type -> !ApplicationDomainType.class.equals(type));
@@ -673,12 +687,7 @@ public class MappingPdxSerializerUnitTests {
}
@Test
public void fromDataWithTypeFilterFiltersNullTypeReturnsNull() {
assertThat(this.pdxSerializer.fromData(null, this.mockReader)).isNull();
}
@Test
public void toDataSerializesApplicationDomainObjectToPdxBytes() {
public void toDataSerializesEntityToPdxBytes() {
Address address = new Address();
@@ -760,6 +769,14 @@ public class MappingPdxSerializerUnitTests {
}
}
@Test
public void toDataFiltersUndeclaredEntityTypeReturnsFalse() {
this.pdxSerializer.setTypeFilters(type -> !ApplicationDomainType.class.equals(type));
assertThat(this.pdxSerializer.toData(new ApplicationDomainType(), this.mockWriter)).isFalse();
}
@Test
public void toDataFiltersNullTypeReturnsFalse() {
assertThat(this.pdxSerializer.toData(null, this.mockWriter)).isFalse();
@@ -771,15 +788,7 @@ public class MappingPdxSerializerUnitTests {
}
@Test
public void toDataFiltersApplicationDomainTypeReturnsFalse() {
this.pdxSerializer.setTypeFilters(type -> !ApplicationDomainType.class.equals(type));
assertThat(this.pdxSerializer.toData(new ApplicationDomainType(), this.mockWriter)).isFalse();
}
@Test
public void toDataAcceptsApplicationDomainObjectTypeReturnsTrue() {
public void toDataAcceptsDeclaredEntityTypeReturnsTrue() {
org.springframework.data.gemfire.test.model.Person jonDoe =
new org.springframework.data.gemfire.test.model.Person("Jon", "Doe",

View File

@@ -119,6 +119,21 @@ public class FilterUnitTests {
verify(mockFilter, times(1)).accept(eq("test"));
}
@Test
@SuppressWarnings("unchecked")
public void negateReturnsTrueForFalse() {
Filter<Object> mockFilter = mock(Filter.class);
when(mockFilter.accept(any())).thenReturn(false);
when(mockFilter.negate()).thenCallRealMethod();
when(mockFilter.test(any())).thenCallRealMethod();
assertThat(mockFilter.negate().test("test")).isTrue();
verify(mockFilter, times(1)).accept(eq("test"));
}
@Test
@SuppressWarnings("unchecked")
public void predicateTestCallsFilterAcceptReturnsTrue() {