use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testFindReturnsCorrectEntity.
@Override
@Test
public void testFindReturnsCorrectEntity() 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, "0XA");
when(allegationPerpetratorHistoryDao.find(id)).thenReturn(allegationPerpetratorHistory);
AllegationPerpetratorHistory found = allegationPerpetratorHistoryService.find(id);
assertThat(found, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsNonNull.
@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() 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 postedAllegationPerpetratorHistory = allegationPerpetratorHistoryService.create(request);
assertThat(postedAllegationPerpetratorHistory, is(notNullValue()));
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method createReturnsGeneratedId.
/*
* Test for checking the new Allegation Id generated and lenght is 10
*/
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory>() {
@Override
public gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory answer(InvocationOnMock invocation) throws Throwable {
gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = (gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) invocation.getArguments()[0];
return allegationPerpetratorHistory;
}
});
PostedAllegationPerpetratorHistory returned = allegationPerpetratorHistoryService.create(allegationPerpetratorHistoryDomain);
assertEquals(returned.getId().length(), 10);
PostedAllegationPerpetratorHistory newReturned = allegationPerpetratorHistoryService.create(allegationPerpetratorHistoryDomain);
Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.
the class AllegationPerpetratorHistoryServiceTest method testCreateNullIDError.
@Override
@Test
public void testCreateNullIDError() 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(null, 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