use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class CmsReferralServiceTest method cmsReferralServiceResponse.
public Response cmsReferralServiceResponse() throws Exception {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/referralCmsReferral.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral referralToCreate = new gov.ca.cwds.data.persistence.cms.Referral("ABC1234567", referralDomain, "2016-10-31");
Set<Client> clientDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/clientCmsReferral.json"), new TypeReference<Set<Client>>() {
});
gov.ca.cwds.data.persistence.cms.Client clientToCreate = new gov.ca.cwds.data.persistence.cms.Client("ABC1234567", (Client) clientDomain.toArray()[0], "2016-10-31");
Set<ReferralClient> referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/referralClientCmsReferral.json"), new TypeReference<Set<ReferralClient>>() {
});
gov.ca.cwds.data.persistence.cms.ReferralClient referralClientToCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient((ReferralClient) referralClientDomain.toArray()[0], "2016-10-31");
Set<Allegation> allegationDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/allegationCmsReferral.json"), new TypeReference<Set<Allegation>>() {
});
gov.ca.cwds.data.persistence.cms.Allegation allegationToCreate = new gov.ca.cwds.data.persistence.cms.Allegation("ABC1234567", (Allegation) allegationDomain.toArray()[0], "2016-10-31");
Set<CrossReport> crossReportDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/crossReportCmsReferral.json"), new TypeReference<Set<CrossReport>>() {
});
gov.ca.cwds.data.persistence.cms.CrossReport crossReportToCreate = new gov.ca.cwds.data.persistence.cms.CrossReport("1234ABC123", // ((CrossReport) crossReportDomain).getThirdId(),
(CrossReport) crossReportDomain.toArray()[0], "OXA");
Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/reporterCmsReferral.json"), Reporter.class);
gov.ca.cwds.data.persistence.cms.Reporter reporterToCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "OXA");
Referral referralRequest = new Referral(referralToCreate);
ReferralClient referralClientRequest = new ReferralClient(referralClientToCreate);
Set<ReferralClient> referralClientRequestSet = new LinkedHashSet<>();
referralClientRequestSet.add(referralClientRequest);
Client clientRequest = new Client(clientToCreate, false);
Set<Client> clientRequestSet = new LinkedHashSet<>();
clientRequestSet.add(clientRequest);
Allegation allegationRequest = new Allegation(allegationToCreate);
Set<Allegation> allegationRequestSet = new LinkedHashSet<>();
allegationRequestSet.add(allegationRequest);
CrossReport crossReportRequest = new CrossReport(crossReportToCreate);
Set<CrossReport> crossReportRequestSet = new LinkedHashSet<>();
crossReportRequestSet.add(crossReportRequest);
Reporter reporterRequest = new Reporter(reporterToCreate);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referralToCreate);
when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(clientToCreate);
when(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(referralClientToCreate);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(allegationToCreate);
when(crossReportDao.create(any(gov.ca.cwds.data.persistence.cms.CrossReport.class))).thenReturn(crossReportToCreate);
when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(reporterToCreate);
CmsReferral cmsReferral = new CmsReferral(referralRequest, clientRequestSet, allegationRequestSet, crossReportRequestSet, referralClientRequestSet, reporterRequest);
Response response = cmsReferralService.create(cmsReferral);
return response;
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class CmsReferralServiceTest method createReturnsNonNull.
@Test
public void createReturnsNonNull() throws Exception {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/referralCmsReferral.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral referralToCreate = new gov.ca.cwds.data.persistence.cms.Referral("ABC1234567", referralDomain, "2016-10-31");
Set<Client> clientDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/clientCmsReferral.json"), new TypeReference<Set<Client>>() {
});
gov.ca.cwds.data.persistence.cms.Client clientToCreate = new gov.ca.cwds.data.persistence.cms.Client("ABC1234567", (Client) clientDomain.toArray()[0], "2016-10-31");
Set<ReferralClient> referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/referralClientCmsReferral.json"), new TypeReference<Set<ReferralClient>>() {
});
gov.ca.cwds.data.persistence.cms.ReferralClient referralClientToCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient((ReferralClient) referralClientDomain.toArray()[0], "2016-10-31");
Set<Allegation> allegationDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/allegationCmsReferral.json"), new TypeReference<Set<Allegation>>() {
});
gov.ca.cwds.data.persistence.cms.Allegation allegationToCreate = new gov.ca.cwds.data.persistence.cms.Allegation("ABC1234567", (Allegation) allegationDomain.toArray()[0], "2016-10-31");
Set<CrossReport> crossReportDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/crossReportCmsReferral.json"), new TypeReference<Set<CrossReport>>() {
});
gov.ca.cwds.data.persistence.cms.CrossReport crossReportToCreate = new gov.ca.cwds.data.persistence.cms.CrossReport("1234ABC123", (CrossReport) crossReportDomain.toArray()[0], "2016-10-31");
Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/cms/CmsReferral/valid/reporterCmsReferral.json"), Reporter.class);
gov.ca.cwds.data.persistence.cms.Reporter reporterToCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "2016-10-31");
Referral referralRequest = new Referral(referralToCreate);
ReferralClient referralClientRequest = new ReferralClient(referralClientToCreate);
Set<ReferralClient> referralClientRequestSet = new LinkedHashSet<>();
referralClientRequestSet.add(referralClientRequest);
Client clientRequest = new Client(clientToCreate, false);
Set<Client> clientRequestSet = new LinkedHashSet<>();
clientRequestSet.add(clientRequest);
Allegation allegationRequest = new Allegation(allegationToCreate);
Set<Allegation> allegationRequestSet = new LinkedHashSet<>();
allegationRequestSet.add(allegationRequest);
CrossReport crossReportRequest = new CrossReport(crossReportToCreate);
Set<CrossReport> crossReportRequestSet = new LinkedHashSet<>();
crossReportRequestSet.add(crossReportRequest);
Reporter reporterRequest = new Reporter(reporterToCreate);
CmsReferral cmsReferralToCreate = new CmsReferral(referralRequest, clientRequestSet, allegationRequestSet, crossReportRequestSet, referralClientRequestSet, reporterRequest);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referralToCreate);
when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(clientToCreate);
when(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(referralClientToCreate);
when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(allegationToCreate);
when(crossReportDao.create(any(gov.ca.cwds.data.persistence.cms.CrossReport.class))).thenReturn(crossReportToCreate);
when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(reporterToCreate);
CmsReferralService cmsReferralRequest = new CmsReferralService(referralService, clientService, allegationService, crossReportService, referralClientService, reporterService, clientUcService);
PostedCmsReferral returned = (PostedCmsReferral) cmsReferralRequest.create(cmsReferralToCreate);
assertThat(returned, is(notNullValue()));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method createCountyTriggerForLACounty.
/*
* Test for checking the staffperson county Code
*/
@SuppressWarnings("javadoc")
@Test
public void createCountyTriggerForLACounty() throws Exception {
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("1234567ABC", referralDomain, "BTr");
Referral request = new Referral(toCreate);
when(triggerTablesDao.getLaCountySpecificCode()).thenReturn("19");
StaffPerson staffPerson = new StaffPerson("BTr", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "19", "N", "3XPCP92q38", null);
when(staffpersonDao.find(any(String.class))).thenReturn(staffPerson);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
when(laCountyTrigger.createCountyTrigger(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
isLaCountyTrigger = true;
return true;
}
});
referralService.create(request);
assertThat(isLaCountyTrigger, is(true));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral 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.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testUpdateReturnsDomain.
@Override
@Test
public void testUpdateReturnsDomain() throws Exception {
Referral expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral referral = new gov.ca.cwds.data.persistence.cms.Referral("1234567ABC", expected, "ABC");
when(referralDao.update(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referral);
Object retval = referralService.update("1234567ABC", expected);
assertThat(retval.getClass(), is(Referral.class));
}
Aggregations