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());
}
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonResourceTest method createDelegatesToResourceDelegate.
/**
* Create Tests
*
* @throws Exception required for test compilation
*/
@Test
public void createDelegatesToResourceDelegate() throws Exception {
StaffPerson staffperson = new StaffPerson("1969-01-01", "Bart", "Student", "Simpson", "Q", "", new BigDecimal(9165551212L), 124, "1969-01-01", "", true, "abcdefghij", "description", "id", "03", false, "1234567890", "emailaddy");
final Response resp = inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(staffperson, MediaType.APPLICATION_JSON));
ValidationErrorMessage msg = resp.readEntity(ValidationErrorMessage.class);
if (msg != null) {
final List<String> errors = msg.getErrors();
if (errors != null && errors.size() > 0) {
for (String err : errors) {
System.out.println("ERROR: " + err);
}
}
}
verify(resourceDelegate).create(eq(staffperson));
}
use of gov.ca.cwds.rest.api.domain.cms.StaffPerson in project API by ca-cwds.
the class StaffPersonResourceTest method updateValidatesEntity.
@Test
public void updateValidatesEntity() throws Exception {
StaffPerson staffperson = new StaffPerson("1969-01-01", "Bart", "Student", "Simpson", "Q", "", new BigDecimal(9165551212L), 124, "1969-01-01", "", true, "abcdefghij", "description", "id", "WILL_NOT_VALIDATE", false, "1234567890", "emailaddy");
int status = inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(staffperson, MediaType.APPLICATION_JSON)).getStatus();
assertThat(status, is(422));
}
Aggregations