use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class NonLACountyTriggersTest method testForReferralClientUpdatedCountyOwnership.
/*
* Test for checking the referral Client CountyOnwership updated
*/
@SuppressWarnings("javadoc")
@Test
public void testForReferralClientUpdatedCountyOwnership() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/legacy/business/rules/nonLaCountyTrigger/referralClientValid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "ABC");
ReferralClient request = new ReferralClient(toCreate);
when(countyOwnershipDao.find(any(String.class))).thenReturn(new CountyOwnership());
when(countyOwnershipDao.update(any(CountyOwnership.class))).thenAnswer(new Answer<CountyOwnership>() {
@Override
public CountyOwnership answer(InvocationOnMock invocation) throws Throwable {
CountyOwnership report = (CountyOwnership) invocation.getArguments()[0];
countyOwnership = report;
return report;
}
});
nonLaCountyTriggers.createAndUpdateReferralClientCoutyOwnership(toCreate);
Assert.assertNotNull(countyOwnership);
assertThat(countyOwnership.getCounty62Flag(), is(equalTo("Y")));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class CmsReferralServiceTest method createReturnsCorrectPostedCmsReferral.
@Test
public void createReturnsCorrectPostedCmsReferral() 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<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("1234567ABC", (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");
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");
Referral referralRequest = new Referral(referralToCreate);
ReferralClient referralClientRequest = new ReferralClient(referralClientToCreate);
Set<ReferralClient> referralClientRequestSet = new LinkedHashSet<>();
referralClientRequestSet.add(referralClientRequest);
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);
Client clientRequest = new Client(clientToCreate, false);
Set<Client> clientRequestSet = new LinkedHashSet<>();
clientRequestSet.add(clientRequest);
PostedReferral postedReferral = new PostedReferral(referralToCreate);
ReferralClient postedReferralClient = new ReferralClient(referralClientToCreate);
Set<ReferralClient> postedReferralClientSet = new LinkedHashSet<>();
postedReferralClientSet.add(postedReferralClient);
PostedAllegation postedAllegation = new PostedAllegation(allegationToCreate);
Set<PostedAllegation> postedAllegationSet = new LinkedHashSet<>();
postedAllegationSet.add(postedAllegation);
CrossReport postedCrossReport = new CrossReport(crossReportToCreate);
Set<CrossReport> postedCrossReportSet = new LinkedHashSet<>();
postedCrossReportSet.add(postedCrossReport);
PostedReporter postedReporter = new PostedReporter(reporterToCreate);
PostedClient postedClient = new PostedClient(clientToCreate, false);
Set<PostedClient> postedClientSet = new LinkedHashSet<>();
postedClientSet.add(postedClient);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referralToCreate);
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);
when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(clientToCreate);
CmsReferral cmsReferralToCreate = new CmsReferral(referralRequest, clientRequestSet, allegationRequestSet, crossReportRequestSet, referralClientRequestSet, reporterRequest);
CmsReferralService cmsReferralRequest = new CmsReferralService(referralService, clientService, allegationService, crossReportService, referralClientService, reporterService, clientUcService);
PostedCmsReferral expected = new PostedCmsReferral(postedReferral, postedClientSet, postedAllegationSet, postedCrossReportSet, postedReferralClientSet, postedReporter);
PostedCmsReferral returned = (PostedCmsReferral) cmsReferralRequest.create(cmsReferralToCreate);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method updateReturnsCorrectReferralClientOnSuccess.
@SuppressWarnings("javadoc")
@Test
public void updateReturnsCorrectReferralClientOnSuccess() throws Exception {
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);
ReferralClient expected = new ReferralClient(referralClient);
ReferralClient updated = referralClientService.update(referralClient.getPrimaryKey().toString(), expected);
assertThat(updated, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method deleteReturnsReferralClientResponseOnSuccess.
@SuppressWarnings("javadoc")
@Test
public void deleteReturnsReferralClientResponseOnSuccess() throws Exception {
ReferralClient expected = 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(expected, "ABC");
when(referralClientDao.delete(any())).thenReturn(referralClient);
Object retval = referralClientService.delete(referralClient.getPrimaryKey().toString());
assertThat(retval.getClass(), is(ReferralClient.class));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method updateReturnsReferralClientResponseOnSuccess.
@SuppressWarnings("javadoc")
@Test
public void updateReturnsReferralClientResponseOnSuccess() throws Exception {
ReferralClient expected = 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(expected, "ABC");
when(referralClientDao.find(referralClient.getPrimaryKey().toString())).thenReturn(referralClient);
when(referralClientDao.update(any())).thenReturn(referralClient);
Object retval = referralClientService.update(referralClient.getPrimaryKey().toString(), expected);
assertThat(retval.getClass(), is(ReferralClient.class));
}
Aggregations