use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testUpdateThrowsExceptionWhenNotFound.
@SuppressWarnings("javadoc")
@Test
public void testUpdateThrowsExceptionWhenNotFound() throws Exception {
try {
AllegationPerpetratorHistory allegationPerpetratorHistoryRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
when(allegationPerpetratorHistoryDao.update(any())).thenThrow(EntityNotFoundException.class);
allegationPerpetratorHistoryService.update("ZZZZZZZZZZ", allegationPerpetratorHistoryRequest);
} catch (Exception e) {
assertEquals(e.getClass(), ServiceException.class);
}
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsPostedClass.
// create test
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
String id = "AbjFyc80It";
AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory toCreate = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(id, allegationPerpetratorHistoryDomain, "ABC");
AllegationPerpetratorHistory request = new AllegationPerpetratorHistory(toCreate);
when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenReturn(toCreate);
Response response = allegationPerpetratorHistoryService.create(request);
assertThat(response.getClass(), is(PostedAllegationPerpetratorHistory.class));
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testUpdateReturnsCorrectEntity.
@Override
@Test
public void testUpdateReturnsCorrectEntity() throws Exception {
String id = "AbjFyc80It";
AllegationPerpetratorHistory expected = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(id, expected, "ABC");
when(allegationPerpetratorHistoryDao.find("ABC1234567")).thenReturn(allegationPerpetratorHistory);
when(allegationPerpetratorHistoryDao.update(any())).thenReturn(allegationPerpetratorHistory);
Object retval = allegationPerpetratorHistoryService.update("ABC1234567", expected);
assertThat(retval.getClass(), is(AllegationPerpetratorHistory.class));
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsCorrectEntity.
@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
String id = "AbjFyc80It";
AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory toCreate = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(id, allegationPerpetratorHistoryDomain, "ABC");
AllegationPerpetratorHistory request = new AllegationPerpetratorHistory(toCreate);
when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenReturn(toCreate);
PostedAllegationPerpetratorHistory expected = new PostedAllegationPerpetratorHistory(toCreate);
PostedAllegationPerpetratorHistory returned = allegationPerpetratorHistoryService.create(request);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testCreateBlankIDError.
@Override
@Test
public void testCreateBlankIDError() throws Exception {
try {
AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory toCreate = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(" ", allegationPerpetratorHistoryDomain, "ABC");
when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenReturn(toCreate);
PostedAllegationPerpetratorHistory expected = new PostedAllegationPerpetratorHistory(toCreate);
} catch (ServiceException e) {
assertEquals("AllegationPerpetratorHistory ID cannot be blank", e.getMessage());
}
}
Aggregations