Search in sources :

Example 6 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 7 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 8 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)

Example 9 with Referral

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

the class ReferralServiceTest method testCreateReturnsPostedClass.

@Override
@Test
public void testCreateReturnsPostedClass() 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 = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
    when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
    Response response = referralService.create(request);
    assertThat(response.getClass(), is(PostedReferral.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) 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 10 with Referral

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

the class ReferralResourceTest method testPost204ResourceSuccess.

@SuppressWarnings("javadoc")
public // @Test
void testPost204ResourceSuccess() throws Exception {
    Referral serialized = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
    Integer status = inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(serialized, MediaType.APPLICATION_JSON)).getStatus();
    assertThat(status, is(204));
}
Also used : Referral(gov.ca.cwds.rest.api.domain.cms.Referral)

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