Search in sources :

Example 26 with Allegation

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

the class AllegationServiceTest method testCreateReturnsNonNull.

@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() throws Exception {
    String id = "Aaeae9r0F4";
    Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
    gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
    Allegation request = new Allegation(toCreate);
    when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
    PostedAllegation postedAllegation = allegationService.create(request);
    assertThat(postedAllegation, is(notNullValue()));
}
Also used : PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Test(org.junit.Test)

Example 27 with Allegation

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

the class AllegationServiceTest method testCreateReturnsCorrectEntity.

@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
    String id = "Aaeae9r0F4";
    Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
    gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
    Allegation request = new Allegation(toCreate);
    when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
    PostedAllegation expected = new PostedAllegation(toCreate);
    PostedAllegation returned = allegationService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Test(org.junit.Test)

Example 28 with Allegation

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

the class AllegationServiceTest method createReturnsGeneratedId.

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

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

Example 29 with Allegation

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

the class AllegationServiceTest method testCreateReturnsPostedClass.

// create test
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
    String id = "Aaeae9r0F4";
    Allegation allegationDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
    gov.ca.cwds.data.persistence.cms.Allegation toCreate = new gov.ca.cwds.data.persistence.cms.Allegation(id, allegationDomain, "ABC");
    Allegation request = new Allegation(toCreate);
    when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
    Response response = allegationService.create(request);
    assertThat(response.getClass(), is(PostedAllegation.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Test(org.junit.Test)

Example 30 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)

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