use of de.symeda.sormas.api.EntityDtoAccessHelper.CachedReferenceDtoResolver in project SORMAS-Project by hzi-braunschweig.
the class EntityDtoAccessHelperTest method readCachedReferencedEntityDto.
@Test
public void readCachedReferencedEntityDto() {
IReferenceDtoResolver mockResolver = mock(IReferenceDtoResolver.class);
CachedReferenceDtoResolver cachedReferenceDtoResolver = new CachedReferenceDtoResolver(mockResolver);
when(mockResolver.resolve(personReferenceDto)).thenReturn(personDto);
caseDataDto.setPerson(personReferenceDto);
assertEquals("Tenzing", EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "person.firstName", cachedReferenceDtoResolver));
assertEquals("Tenzing", EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "person.firstName", cachedReferenceDtoResolver));
verify(mockResolver, times(1)).resolve(personReferenceDto);
}
use of de.symeda.sormas.api.EntityDtoAccessHelper.CachedReferenceDtoResolver in project SORMAS-Project by hzi-braunschweig.
the class EntityDtoAccessHelperTest method failOnImplausibleProperty.
@Test
public void failOnImplausibleProperty() {
try {
EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "blubber.blubber");
fail("expected: IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertEquals("In CaseData: No property blubber in class CaseData", e.getMessage());
}
try {
EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "disease.blubber");
fail("expected: IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertEquals("In CaseData.disease: Disease.blubber cannot be resolved.", e.getMessage());
}
IReferenceDtoResolver mockResolver = mock(IReferenceDtoResolver.class);
CachedReferenceDtoResolver cachedReferenceDtoResolver = new CachedReferenceDtoResolver(mockResolver);
when(mockResolver.resolve(personReferenceDto)).thenReturn(personDto);
caseDataDto.setPerson(personReferenceDto);
try {
EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "person.blubber", cachedReferenceDtoResolver);
fail("expected: IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertEquals("In CaseData.person: No property blubber in class Person", e.getMessage());
}
try {
EntityDtoAccessHelper.getPropertyPathValue(caseDataDto, "person.firstName.blubber", cachedReferenceDtoResolver);
fail("expected: IllegalArgumentException");
} catch (IllegalArgumentException e) {
assertEquals("In CaseData.person.firstName: String.blubber cannot be resolved.", e.getMessage());
}
}
Aggregations