Search in sources :

Example 1 with Allegation

use of gov.ca.cwds.rest.api.domain.cms.Allegation 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;
}
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) 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) PostedReporter(gov.ca.cwds.rest.api.domain.cms.PostedReporter) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) Response(gov.ca.cwds.rest.api.Response) 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)

Example 2 with Allegation

use of gov.ca.cwds.rest.api.domain.cms.Allegation 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()));
}
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) 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) 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 3 with Allegation

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

the class AllegationResourceTest method updateValidatesEntity.

@Test
public void updateValidatesEntity() throws Exception {
    Allegation serialized = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/invalid/abuseEndDateWrongFormat.json"), Allegation.class);
    int status = inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(serialized, MediaType.APPLICATION_JSON)).getStatus();
    assertThat(status, is(422));
}
Also used : Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) Test(org.junit.Test)

Example 4 with Allegation

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

the class AllegationResourceTest method createValidatesEntity.

@Test
public void createValidatesEntity() throws Exception {
    Allegation serialized = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/invalid/abuseEndDateWrongFormat.json"), Allegation.class);
    int status = inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(serialized, MediaType.APPLICATION_JSON)).getStatus();
    assertThat(status, is(422));
}
Also used : Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) Test(org.junit.Test)

Example 5 with Allegation

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

the class ScreeningToReferralServiceTest method testWithReferralDoesNotExistFail.

@SuppressWarnings("javadoc")
@Test
public void testWithReferralDoesNotExistFail() throws Exception {
    Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validReferral.json"), Referral.class);
    gov.ca.cwds.data.persistence.cms.Referral referralToCreate = new gov.ca.cwds.data.persistence.cms.Referral("0123456ABC", referralDomain, "2016-10-31");
    when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referralToCreate);
    when(referralDao.find("0123456ABC")).thenReturn(referralToCreate);
    ChildClient childClient = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/childClient.json"), ChildClient.class);
    gov.ca.cwds.data.persistence.cms.ChildClient childClientToCreate = new gov.ca.cwds.data.persistence.cms.ChildClient("1234567ABC", childClient, "0XA");
    when(childClientDao.create(any(gov.ca.cwds.data.persistence.cms.ChildClient.class))).thenReturn(childClientToCreate);
    Set<Client> clientDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validClient.json"), new TypeReference<Set<Client>>() {
    });
    gov.ca.cwds.data.persistence.cms.Client clientToCreate = new gov.ca.cwds.data.persistence.cms.Client("1234567ABC", (Client) clientDomain.toArray()[0], "2016-10-31");
    when(clientDao.create(any(gov.ca.cwds.data.persistence.cms.Client.class))).thenReturn(clientToCreate);
    Set<ReferralClient> referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validReferralClient.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");
    when(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(referralClientToCreate);
    Set<Allegation> allegationDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validAllegation.json"), new TypeReference<Set<Allegation>>() {
    });
    gov.ca.cwds.data.persistence.cms.Allegation allegationToCreate = new gov.ca.cwds.data.persistence.cms.Allegation("2345678ABC", (Allegation) allegationDomain.toArray()[0], "2016-10-31");
    when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(allegationToCreate);
    Set<CrossReport> crossReportDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validCrossReport.json"), new TypeReference<Set<CrossReport>>() {
    });
    gov.ca.cwds.data.persistence.cms.CrossReport crossReportToCreate = new gov.ca.cwds.data.persistence.cms.CrossReport("3456789ABC", // ((CrossReport) crossReportDomain).getThirdId(),
    (CrossReport) crossReportDomain.toArray()[0], "OXA");
    when(crossReportDao.create(any(gov.ca.cwds.data.persistence.cms.CrossReport.class))).thenReturn(crossReportToCreate);
    Reporter reporterDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validReporter.json"), Reporter.class);
    gov.ca.cwds.data.persistence.cms.Reporter reporterToCreate = new gov.ca.cwds.data.persistence.cms.Reporter(reporterDomain, "ABC");
    when(reporterDao.create(any(gov.ca.cwds.data.persistence.cms.Reporter.class))).thenReturn(reporterToCreate);
    Address addressDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validAddress.json"), Address.class);
    gov.ca.cwds.data.persistence.cms.Address addressToCreate = new gov.ca.cwds.data.persistence.cms.Address("345678ABC", addressDomain, "ABC");
    when(addressDao.create(any(gov.ca.cwds.data.persistence.cms.Address.class))).thenReturn(addressToCreate);
    ClientAddress clientAddressDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validClientAddress.json"), ClientAddress.class);
    gov.ca.cwds.data.persistence.cms.ClientAddress clientAddressToCreate = new gov.ca.cwds.data.persistence.cms.ClientAddress("456789ABC", clientAddressDomain, "ABC");
    when(clientAddressDao.create(any(gov.ca.cwds.data.persistence.cms.ClientAddress.class))).thenReturn(clientAddressToCreate);
    LongText longTextDomain = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/valid/validLongText.json"), LongText.class);
    gov.ca.cwds.data.persistence.cms.LongText longTextToCreate = new gov.ca.cwds.data.persistence.cms.LongText("567890ABC", longTextDomain, "ABC");
    when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(longTextToCreate);
    ScreeningToReferral screeningToReferral = MAPPER.readValue(fixture("fixtures/domain/ScreeningToReferral/invalid/withReferralIdNotExist.json"), ScreeningToReferral.class);
    Boolean theErrorDetected = false;
    Response response = screeningToReferralService.create(screeningToReferral);
    if (response.hasMessages()) {
        Set<ErrorMessage> messages = response.getMessages();
        for (ErrorMessage message : messages) {
            if (message != null) {
                if (message.getMessage().contains("Legacy Id does not correspond to an existing CMS/CWS Referral")) {
                    theErrorDetected = true;
                }
            }
        }
        assertThat(theErrorDetected, is(equalTo(true)));
    } else {
        Assert.fail("Expected error messages were not thrown");
    }
}
Also used : Set(java.util.Set) LinkedHashSet(java.util.LinkedHashSet) Address(gov.ca.cwds.rest.api.domain.cms.Address) ClientAddress(gov.ca.cwds.rest.api.domain.cms.ClientAddress) ClientAddress(gov.ca.cwds.rest.api.domain.cms.ClientAddress) ChildClient(gov.ca.cwds.rest.api.domain.cms.ChildClient) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) Client(gov.ca.cwds.rest.api.domain.cms.Client) ChildClient(gov.ca.cwds.rest.api.domain.cms.ChildClient) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) LongText(gov.ca.cwds.rest.api.domain.cms.LongText) Reporter(gov.ca.cwds.rest.api.domain.cms.Reporter) Response(gov.ca.cwds.rest.api.Response) CrossReport(gov.ca.cwds.rest.api.domain.cms.CrossReport) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) Referral(gov.ca.cwds.rest.api.domain.cms.Referral) CmsReferral(gov.ca.cwds.rest.api.domain.cms.CmsReferral) ScreeningToReferral(gov.ca.cwds.rest.api.domain.ScreeningToReferral) PostedScreeningToReferral(gov.ca.cwds.rest.api.domain.PostedScreeningToReferral) ScreeningToReferral(gov.ca.cwds.rest.api.domain.ScreeningToReferral) ErrorMessage(gov.ca.cwds.rest.api.domain.error.ErrorMessage) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Aggregations

Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)59 Test (org.junit.Test)56 Client (gov.ca.cwds.rest.api.domain.cms.Client)46 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)46 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)46 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)46 LinkedHashSet (java.util.LinkedHashSet)46 Referral (gov.ca.cwds.rest.api.domain.cms.Referral)45 Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)45 Set (java.util.Set)45 Response (gov.ca.cwds.rest.api.Response)44 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)42 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)42 Address (gov.ca.cwds.rest.api.domain.cms.Address)42 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)42 ClientAddress (gov.ca.cwds.rest.api.domain.cms.ClientAddress)42 LongText (gov.ca.cwds.rest.api.domain.cms.LongText)42 ErrorMessage (gov.ca.cwds.rest.api.domain.error.ErrorMessage)22 ExpectedException (org.junit.rules.ExpectedException)17 PostedAllegation (gov.ca.cwds.rest.api.domain.cms.PostedAllegation)13