use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method findReturnsCorrectStaffPersonWhenFound.
@SuppressWarnings("javadoc")
@Test
public void findReturnsCorrectStaffPersonWhenFound() throws Exception {
String id = "ABC";
StaffPerson expected = 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, expected, "2017-01-07");
when(staffPersonDao.find(id)).thenReturn(staffPerson);
StaffPerson found = staffPersonService.find(id);
assertThat(found, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method createReturnsPostedStaffPersonClass.
@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedStaffPersonClass() 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);
Response response = staffPersonService.create(request);
assertThat(response.getClass(), is(PostedStaffPerson.class));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method updateReturnsStaffPersonResponseOnSuccess.
@SuppressWarnings("javadoc")
@Test
public void updateReturnsStaffPersonResponseOnSuccess() throws Exception {
String id = "ABC";
StaffPerson expected = 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, expected, "2017-01-07");
when(staffPersonDao.find(id)).thenReturn(staffPerson);
when(staffPersonDao.update(any())).thenReturn(staffPerson);
Object retval = staffPersonService.update(id, expected);
assertThat(retval.getClass(), is(StaffPerson.class));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonServiceTest method failsWhenPostedStaffPersonIdBlank.
@SuppressWarnings("javadoc")
@Test
public void failsWhenPostedStaffPersonIdBlank() 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(" ", 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 failsWhenPostedStaffPersonIdEmmpty.
@SuppressWarnings("javadoc")
@Test
public void failsWhenPostedStaffPersonIdEmmpty() 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("", 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());
}
}
Aggregations