Search in sources :

Example 1 with ClientUc

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

the class ClientUcServiceTest method testUpdateThrowsExceptionWhenNotFound.

@SuppressWarnings("javadoc")
@Test
public void testUpdateThrowsExceptionWhenNotFound() throws Exception {
    try {
        ClientUc clientUcRquest = MAPPER.readValue(fixture("fixtures/domain/legacy/ClientUc/valid/valid.json"), ClientUc.class);
        when(clientUcDao.update(any())).thenThrow(EntityNotFoundException.class);
        clientUcService.update("ZZZZZZZZZZ", clientUcRquest);
    } catch (Exception e) {
        assertEquals(e.getClass(), ServiceException.class);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.rest.api.domain.cms.ClientUc) EntityNotFoundException(javax.persistence.EntityNotFoundException) ServiceException(gov.ca.cwds.rest.services.ServiceException) ExpectedException(org.junit.rules.ExpectedException) Test(org.junit.Test)

Example 2 with ClientUc

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

the class ClientUcServiceTest method testFindReturnsCorrectEntity.

@Override
@Test
public void testFindReturnsCorrectEntity() throws Exception {
    String id = "KFXgqgo0JG";
    ClientUc expected = MAPPER.readValue(fixture("fixtures/domain/legacy/ClientUc/valid/valid.json"), ClientUc.class);
    gov.ca.cwds.data.persistence.cms.ClientUc clientUc = new gov.ca.cwds.data.persistence.cms.ClientUc(expected, "q27");
    when(clientUcDao.find(id)).thenReturn(clientUc);
    ClientUc found = clientUcService.find(id);
    assertThat(found, is(expected));
}
Also used : ClientUc(gov.ca.cwds.rest.api.domain.cms.ClientUc) Test(org.junit.Test)

Example 3 with ClientUc

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

the class ClientUcServiceTest method testUpdateReturnsCorrectEntity.

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

Example 4 with ClientUc

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

the class ClientUcServiceTest method testCreateBlankIDError.

@Override
@Test
public void testCreateBlankIDError() throws Exception {
    try {
        ClientUc clientUcDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ClientUc/valid/valid.json"), ClientUc.class);
        gov.ca.cwds.data.persistence.cms.ClientUc toCreate = new gov.ca.cwds.data.persistence.cms.ClientUc(clientUcDomain, "q27");
        when(clientUcDao.create(any(gov.ca.cwds.data.persistence.cms.ClientUc.class))).thenReturn(toCreate);
        ClientUc expected = new ClientUc(toCreate);
    } catch (ServiceException e) {
        assertEquals("LongText ID cannot be blank", e.getMessage());
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.rest.api.domain.cms.ClientUc) Test(org.junit.Test)

Example 5 with ClientUc

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

the class ClientUcServiceTest method testCreateNullIDError.

@Override
@Test
public void testCreateNullIDError() throws Exception {
    try {
        ClientUc clientUcDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ClientUc/valid/valid.json"), ClientUc.class);
        gov.ca.cwds.data.persistence.cms.ClientUc toCreate = new gov.ca.cwds.data.persistence.cms.ClientUc(clientUcDomain, "q27");
        when(clientUcDao.create(any(gov.ca.cwds.data.persistence.cms.ClientUc.class))).thenReturn(toCreate);
        ClientUc expected = new ClientUc(toCreate);
    } catch (ServiceException e) {
        assertEquals("Client ID cannot be blank", e.getMessage());
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.rest.api.domain.cms.ClientUc) Test(org.junit.Test)

Aggregations

ClientUc (gov.ca.cwds.rest.api.domain.cms.ClientUc)6 Test (org.junit.Test)5 ServiceException (gov.ca.cwds.rest.services.ServiceException)3 Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)1 Client (gov.ca.cwds.rest.api.domain.cms.Client)1 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)1 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)1 PostedAllegation (gov.ca.cwds.rest.api.domain.cms.PostedAllegation)1 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)1 PostedCmsReferral (gov.ca.cwds.rest.api.domain.cms.PostedCmsReferral)1 PostedReferral (gov.ca.cwds.rest.api.domain.cms.PostedReferral)1 PostedReporter (gov.ca.cwds.rest.api.domain.cms.PostedReporter)1 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)1 Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)1 UnitOfWork (io.dropwizard.hibernate.UnitOfWork)1 ArrayList (java.util.ArrayList)1 LinkedHashSet (java.util.LinkedHashSet)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 ExpectedException (org.junit.rules.ExpectedException)1