use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method createReturnsNonNull.
@SuppressWarnings("javadoc")
@Test
public void createReturnsNonNull() throws Exception {
String id = "ABC";
StaffPerson staffPersonDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/StaffPerson/valid/valid.json"), StaffPerson.class);
gov.ca.cwds.data.persistence.cms.StaffPerson toCreate = new gov.ca.cwds.data.persistence.cms.StaffPerson(id, staffPersonDomain, "2017-01-07");
StaffPerson request = new StaffPerson(toCreate);
when(staffPersonDao.create(any(gov.ca.cwds.data.persistence.cms.StaffPerson.class))).thenReturn(toCreate);
PostedStaffPerson postedStaffPerson = staffPersonService.create(request);
assertThat(postedStaffPerson, is(notNullValue()));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method updateThrowsExceptionWhenStaffPersonNotFound.
@SuppressWarnings("javadoc")
@Test
public void updateThrowsExceptionWhenStaffPersonNotFound() throws Exception {
try {
String id = "ABC";
StaffPerson staffPersonRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/StaffPerson/valid/valid.json"), StaffPerson.class);
when(staffPersonDao.update(any())).thenThrow(EntityNotFoundException.class);
staffPersonService.update("ZZZ", staffPersonRequest);
Assert.fail("Expected EntityNotFoundException was not thrown");
} catch (Exception ex) {
assertEquals(ex.getClass(), ServiceException.class);
}
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method updateReturnsCorrectStaffPersonOnSuccess.
@SuppressWarnings("javadoc")
@Test
public void updateReturnsCorrectStaffPersonOnSuccess() throws Exception {
String id = "ABC";
StaffPerson staffPersonRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/StaffPerson/valid/valid.json"), StaffPerson.class);
gov.ca.cwds.data.persistence.cms.StaffPerson staffPerson = new gov.ca.cwds.data.persistence.cms.StaffPerson(id, staffPersonRequest, "2017-01-07");
when(staffPersonDao.find(id)).thenReturn(staffPerson);
when(staffPersonDao.update(any())).thenReturn(staffPerson);
StaffPerson expected = new StaffPerson(staffPerson);
StaffPerson updated = staffPersonService.update(id, expected);
assertThat(updated, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method failsWhenPostedStaffPersonIdNull.
@SuppressWarnings("javadoc")
@Test
public void failsWhenPostedStaffPersonIdNull() throws Exception {
try {
StaffPerson staffPersonDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/StaffPerson/valid/valid.json"), StaffPerson.class);
gov.ca.cwds.data.persistence.cms.StaffPerson toCreate = new gov.ca.cwds.data.persistence.cms.StaffPerson(null, staffPersonDomain, "2017-01-07");
when(staffPersonDao.create(any(gov.ca.cwds.data.persistence.cms.StaffPerson.class))).thenReturn(toCreate);
PostedStaffPerson expected = new PostedStaffPerson(toCreate);
Assert.fail("Expected AssertionError not thrown");
} catch (ServiceException e) {
assertEquals("StaffPerson ID cannot be empty", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method createReturnsCorrectPostedPerson.
@SuppressWarnings("javadoc")
@Test
public void createReturnsCorrectPostedPerson() throws Exception {
String id = "ABC";
StaffPerson staffPersonDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/StaffPerson/valid/valid.json"), StaffPerson.class);
gov.ca.cwds.data.persistence.cms.StaffPerson toCreate = new gov.ca.cwds.data.persistence.cms.StaffPerson(id, staffPersonDomain, "2017-01-07");
StaffPerson request = new StaffPerson(toCreate);
when(staffPersonDao.create(any(gov.ca.cwds.data.persistence.cms.StaffPerson.class))).thenReturn(toCreate);
PostedStaffPerson expected = new PostedStaffPerson(toCreate);
PostedStaffPerson returned = staffPersonService.create(request);
assertThat(returned, is(expected));
}
Aggregations