Search in sources :

Example 56 with Allegation

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

the class AllegationServiceTest method testCreateNullIDError.

@Override
@Test
public void testCreateNullIDError() throws Exception {
    try {
        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(null, allegationDomain, "ABC");
        when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
        PostedAllegation expected = new PostedAllegation(toCreate);
    } catch (ServiceException e) {
        assertEquals("Allegation ID cannot be blank", e.getMessage());
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) 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 57 with Allegation

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

the class AllegationServiceTest method testCreateBlankIDError.

@Override
@Test
public void testCreateBlankIDError() throws Exception {
    try {
        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("    ", allegationDomain, "ABC");
        when(allegationDao.create(any(gov.ca.cwds.data.persistence.cms.Allegation.class))).thenReturn(toCreate);
        PostedAllegation expected = new PostedAllegation(toCreate);
    } catch (ServiceException e) {
        assertEquals("Allegation ID cannot be blank", e.getMessage());
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) 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 58 with Allegation

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

the class AllegationServiceTest method testUpdateReturnsCorrectEntity.

@Override
@Test
public void testUpdateReturnsCorrectEntity() throws Exception {
    String id = "Aaeae9r0F4";
    Allegation expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
    gov.ca.cwds.data.persistence.cms.Allegation allegation = new gov.ca.cwds.data.persistence.cms.Allegation(id, expected, "ABC");
    when(allegationDao.find("ABC1234567")).thenReturn(allegation);
    when(allegationDao.update(any())).thenReturn(allegation);
    Object retval = allegationService.update("ABC1234567", expected);
    assertThat(retval.getClass(), is(Allegation.class));
}
Also used : PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) Test(org.junit.Test)

Example 59 with Allegation

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

the class AllegationServiceTest method testUpdateThrowsExceptionWhenNotFound.

@SuppressWarnings("javadoc")
@Test
public void testUpdateThrowsExceptionWhenNotFound() throws Exception {
    try {
        Allegation allegationRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/Allegation/valid/valid.json"), Allegation.class);
        when(allegationDao.update(any())).thenThrow(EntityNotFoundException.class);
        allegationService.update("ZZZZZZZZZZ", allegationRequest);
    } catch (Exception e) {
        assertEquals(e.getClass(), ServiceException.class);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) PostedAllegation(gov.ca.cwds.rest.api.domain.cms.PostedAllegation) Allegation(gov.ca.cwds.rest.api.domain.cms.Allegation) EntityNotFoundException(javax.persistence.EntityNotFoundException) ExpectedException(org.junit.rules.ExpectedException) ServiceException(gov.ca.cwds.rest.services.ServiceException) 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