Search in sources :

Example 36 with ReferralClient

use of gov.ca.cwds.rest.api.domain.cms.ReferralClient 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);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 37 with ReferralClient

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

the class ReferralClientServiceTest method createReturnsPostedReferralClient.

@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedReferralClient() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
    Response response = referralClientService.create(request);
    assertThat(response.getClass(), is(ReferralClient.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 38 with ReferralClient

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

the class ReferralClientServiceTest method createReturnsCorrectPostedPerson.

@SuppressWarnings("javadoc")
@Test
public void createReturnsCorrectPostedPerson() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
    ReferralClient expected = new ReferralClient(toCreate);
    ReferralClient returned = referralClientService.create(request);
    assertThat(returned, is(expected));
}
Also used : ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 39 with ReferralClient

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

the class ReferralClientServiceTest method createReturnsPostedReferralClientClass.

@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedReferralClientClass() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
    Response response = referralClientService.create(request);
    assertThat(response.getClass(), is(ReferralClient.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Example 40 with ReferralClient

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

the class ReferralClientServiceTest method createReturnsNonNull.

@SuppressWarnings("javadoc")
@Test
public void createReturnsNonNull() throws Exception {
    ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
    ReferralClient postedReferralClient = referralClientService.create(request);
    assertThat(postedReferralClient, is(notNullValue()));
}
Also used : ReferralClient(gov.ca.cwds.rest.api.domain.cms.ReferralClient) Test(org.junit.Test)

Aggregations

ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)65 Test (org.junit.Test)61 Client (gov.ca.cwds.rest.api.domain.cms.Client)47 Response (gov.ca.cwds.rest.api.Response)46 Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)46 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)46 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)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 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)43 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 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)16 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)5