use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReferralClientServiceTest method updateThrowsExceptionWhenReferralClientNotFound.
@SuppressWarnings("javadoc")
@Test
public void updateThrowsExceptionWhenReferralClientNotFound() throws Exception {
try {
ReferralClient referralClientRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient referralClient = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientRequest, "ABC");
when(referralClientDao.find(referralClient.getPrimaryKey().toString())).thenReturn(referralClient);
when(referralClientDao.update(any())).thenReturn(referralClient);
referralClientService.update("referralId=ZZZZZZZABC,clientId=ABCZZZZZZZ", referralClientRequest);
} catch (ServiceException e) {
assertEquals(e.getClass(), ServiceException.class);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReferralServiceTest method testCreateEmptyIDError.
@Override
@Test
public void testCreateEmptyIDError() throws Exception {
try {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral toCreate = new gov.ca.cwds.data.persistence.cms.Referral("", referralDomain, "0XA");
Referral request = new Referral(toCreate);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
@SuppressWarnings("unused") PostedReferral returned = referralService.create(request);
} catch (ServiceException e) {
assertEquals("Referral ID cannot be empty", e.getMessage());
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReporterServiceTest method updateThrowsExceptionWhenReporterNotFound.
@SuppressWarnings("javadoc")
@Test
public void updateThrowsExceptionWhenReporterNotFound() throws Exception {
try {
Reporter reporterRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/valid/valid.json"), Reporter.class);
when(reporterDao.update(any())).thenThrow(EntityNotFoundException.class);
reporterService.update("ZZZZZZZZZZ", reporterRequest);
Assert.fail("Expected ServiceException was not thrown");
} catch (Exception ex) {
assertEquals(ex.getClass(), ServiceException.class);
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class ReporterServiceTest method failsWhenPostedReporterServiceEmpty.
@Test
public void failsWhenPostedReporterServiceEmpty() throws Exception {
try {
Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/invalid/referralIdEmpty.json"), Reporter.class);
gov.ca.cwds.data.persistence.cms.Reporter toCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "last_update");
when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(toCreate);
PostedReporter expected = new PostedReporter(toCreate);
Assert.fail("Expected ServiceException was not thrown");
} catch (ServiceException e) {
assertEquals("Referral ID cannot be empty for Reporter", e.getMessage());
}
}
use of gov.ca.cwds.rest.services.ServiceException in project API by ca-cwds.
the class LongTextServiceTest method testCreateBlankIDError.
@Override
@Test
public void testCreateBlankIDError() throws Exception {
try {
LongText longTextDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/LongText/valid/valid.json"), LongText.class);
gov.ca.cwds.data.persistence.cms.LongText toCreate = new gov.ca.cwds.data.persistence.cms.LongText(" ", longTextDomain, "q27");
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(toCreate);
PostedLongText expected = new PostedLongText(toCreate);
} catch (ServiceException e) {
assertEquals("LongText ID cannot be blank", e.getMessage());
}
}
Aggregations