Search in sources :

Example 31 with Reporter

use of gov.ca.cwds.rest.api.domain.cms.Reporter 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));
}
Also used : LinkedHashSet(java.util.LinkedHashSet) PostedCmsReferral(gov.ca.cwds.rest.api.domain.cms.PostedCmsReferral) CmsReferral(gov.ca.cwds.rest.api.domain.cms.CmsReferral) LinkedHashSet(java.util.LinkedHashSet) Set(java.util.Set) PostedCmsReferral(gov.ca.cwds.rest.api.domain.cms.PostedCmsReferral) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) Client(gov.ca.cwds.rest.api.domain.cms.Client) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) CrossReport(gov.ca.cwds.rest.api.domain.cms.CrossReport) Referral(gov.ca.cwds.rest.api.domain.cms.Referral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) PostedCmsReferral(gov.ca.cwds.rest.api.domain.cms.PostedCmsReferral) CmsReferral(gov.ca.cwds.rest.api.domain.cms.CmsReferral) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 32 with Reporter

use of gov.ca.cwds.rest.api.domain.cms.Reporter in project API by ca-cwds.

the class ReporterServiceTest method createReturnsNonNull.

@SuppressWarnings("javadoc")
@Test
public void createReturnsNonNull() throws Exception {
    Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/valid/valid.json"), Reporter.class);
    gov.ca.cwds.data.persistence.cms.Reporter toCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "last_update");
    Reporter request = new Reporter(toCreate);
    when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(toCreate);
    PostedReporter postedReporter = reporterService.create(request);
    assertThat(postedReporter, is(notNullValue()));
}
Also used : PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Test(org.junit.Test)

Example 33 with Reporter

use of gov.ca.cwds.rest.api.domain.cms.Reporter in project API by ca-cwds.

the class ReporterServiceTest method createReturnsCorrectPostedPerson.

@SuppressWarnings("javadoc")
@Test
public void createReturnsCorrectPostedPerson() throws Exception {
    Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/valid/valid.json"), Reporter.class);
    gov.ca.cwds.data.persistence.cms.Reporter toCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "last_update");
    Reporter request = new Reporter(toCreate);
    when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(toCreate);
    PostedReporter expected = new PostedReporter(toCreate);
    PostedReporter returned = reporterService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Test(org.junit.Test)

Example 34 with Reporter

use of gov.ca.cwds.rest.api.domain.cms.Reporter in project API by ca-cwds.

the class ReporterServiceTest method createReturnsPostedReporterClass.

@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedReporterClass() throws Exception {
    Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/valid/valid.json"), Reporter.class);
    gov.ca.cwds.data.persistence.cms.Reporter toCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "last_update");
    Reporter request = new Reporter(toCreate);
    when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(toCreate);
    Response response = reporterService.create(request);
    assertThat(response.getClass(), is(PostedReporter.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Test(org.junit.Test)

Example 35 with Reporter

use of gov.ca.cwds.rest.api.domain.cms.Reporter in project API by ca-cwds.

the class ReporterServiceTest method updateReturnsReporterResponseOnSuccess.

@SuppressWarnings("javadoc")
@Test
public void updateReturnsReporterResponseOnSuccess() throws Exception {
    Reporter expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Reporter/valid/valid.json"), Reporter.class);
    gov.ca.cwds.data.persistence.cms.Reporter reporter = new gov.ca.cwds.data.persistence.cms.Reporter(expected, "ABC");
    when(reporterDao.find("ABC1234567")).thenReturn(reporter);
    when(reporterDao.update(any())).thenReturn(reporter);
    Object retval = reporterService.update("ABC1234567", expected);
    assertThat(retval.getClass(), is(Reporter.class));
}
Also used : PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) Test(org.junit.Test)

Aggregations

Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)58 Test (org.junit.Test)54 Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)45 Client (gov.ca.cwds.rest.api.domain.cms.Client)45 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)45 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)45 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)45 LinkedHashSet (java.util.LinkedHashSet)45 Referral (gov.ca.cwds.rest.api.domain.cms.Referral)44 Set (java.util.Set)44 Response (gov.ca.cwds.rest.api.Response)43 Address (gov.ca.cwds.rest.api.domain.cms.Address)42 ClientAddress (gov.ca.cwds.rest.api.domain.cms.ClientAddress)42 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)41 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)41 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)41 LongText (gov.ca.cwds.rest.api.domain.cms.LongText)41 ErrorMessage (gov.ca.cwds.rest.api.domain.error.ErrorMessage)21 ExpectedException (org.junit.rules.ExpectedException)17 PostedReporter (gov.ca.cwds.rest.api.domain.cms.PostedReporter)11