Search in sources :

Example 31 with Referral

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

Example 32 with Referral

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));
}
Also used : Referral(gov.ca.cwds.rest.api.domain.cms.Referral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) Test(org.junit.Test)

Example 33 with Referral

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

the class ReferralServiceTest method createReturnsGeneratedId.

/*
   * Test for checking the new Referral Id generated and lenght is 10
   */
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
    Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
    when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.Referral>() {

        @Override
        public gov.ca.cwds.data.persistence.cms.Referral answer(InvocationOnMock invocation) throws Throwable {
            gov.ca.cwds.data.persistence.cms.Referral report = (gov.ca.cwds.data.persistence.cms.Referral) invocation.getArguments()[0];
            return report;
        }
    });
    PostedReferral returned = referralService.create(referralDomain);
    assertEquals(returned.getId().length(), 10);
    PostedReferral newReturned = referralService.create(referralDomain);
    Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
Also used : Referral(gov.ca.cwds.rest.api.domain.cms.Referral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) Test(org.junit.Test)

Example 34 with Referral

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

the class ReferralServiceTest method testCreateReturnsCorrectReferralId.

@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsCorrectReferralId() 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, "0XA");
    Referral request = new Referral(toCreate);
    when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
    PostedReferral returned = referralService.create(request);
    assertThat(returned.getId(), is("1234567ABC"));
}
Also used : Referral(gov.ca.cwds.rest.api.domain.cms.Referral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) Test(org.junit.Test)

Example 35 with Referral

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

the class ReferralServiceTest method testFindReturnsCorrectEntity.

@Override
@Test
public void testFindReturnsCorrectEntity() 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, "0XA");
    when(referralDao.find("1234567ABC")).thenReturn(referral);
    Referral found = referralService.find("1234567ABC");
    assertThat(found, is(expected));
}
Also used : Referral(gov.ca.cwds.rest.api.domain.cms.Referral) PostedReferral(gov.ca.cwds.rest.api.domain.cms.PostedReferral) Test(org.junit.Test)

Aggregations

Referral (gov.ca.cwds.rest.api.domain.cms.Referral)65 Test (org.junit.Test)56 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 Set (java.util.Set)45 Response (gov.ca.cwds.rest.api.Response)44 Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)44 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)43 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)43 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 PostedReferral (gov.ca.cwds.rest.api.domain.cms.PostedReferral)17 ExpectedException (org.junit.rules.ExpectedException)17