use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testCreateNullIDError.
@Override
@Test
public void testCreateNullIDError() throws Exception {
try {
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(null, allegationDomain, "ABC");
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
PostedAllegation expected = new PostedAllegation(toCreate);
} catch (ServiceException e) {
assertEquals("Allegation ID cannot be blank", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testCreateBlankIDError.
@Override
@Test
public void testCreateBlankIDError() throws Exception {
try {
Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(" ", allegationDomain, "ABC");
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
PostedAllegation expected = new PostedAllegation(toCreate);
} catch (ServiceException e) {
assertEquals("Allegation ID cannot be blank", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testUpdateReturnsCorrectEntity.
@Override
@Test
public void testUpdateReturnsCorrectEntity() throws Exception {
String id = "Aaeae9r0F4";
Allegation expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
gov.ca.cwds.data.persistence.cms.Allegation allegation = new gov.ca.cwds.data.persistence.cms.Allegation(id, expected, "ABC");
when(allegationDao.find("ABC1234567")).thenReturn(allegation);
when(allegationDao.update(any())).thenReturn(allegation);
Object retval = allegationService.update("ABC1234567", expected);
assertThat(retval.getClass(), is(Allegation.class));
}
use of gov.ca.cwds.rest.api.domain.cms.Allegation in project API by ca-cwds.
the class AllegationServiceTest method testUpdateThrowsExceptionWhenNotFound.
@SuppressWarnings("javadoc")
@Test
public void testUpdateThrowsExceptionWhenNotFound() throws Exception {
try {
Allegation allegationRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
when(allegationDao.update(any())).thenThrow(EntityNotFoundException.class);
allegationService.update("ZZZZZZZZZZ", allegationRequest);
} catch (Exception e) {
assertEquals(e.getClass(), ServiceException.class);
}
}
Aggregations