Search in sources :

Example 6 with ClientUc

use of gov.ca.cwds.data.persistence.cms.ClientUc in project API by ca-cwds.

the class ClientUcDaoIT method testFindEntityNotFoundException.

@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
    ClientUc found = clientUcDao.find("9999999ZZZ");
    assertThat(found, is(nullValue()));
}
Also used : ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) Test(org.junit.Test)

Example 7 with ClientUc

use of gov.ca.cwds.data.persistence.cms.ClientUc in project API by ca-cwds.

the class ClientUcService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.ClientUc update(Serializable primaryKey, Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientUc;
    gov.ca.cwds.rest.api.domain.cms.ClientUc clientUc = (gov.ca.cwds.rest.api.domain.cms.ClientUc) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ClientUc managed = new ClientUc(clientUc, lastUpdatedId);
        managed = clientucDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.ClientUc(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("Client not found : {}", clientUc);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 8 with ClientUc

use of gov.ca.cwds.data.persistence.cms.ClientUc in project API by ca-cwds.

the class ClientUcService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.ClientUc create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientUc;
    gov.ca.cwds.rest.api.domain.cms.ClientUc clientUc = (gov.ca.cwds.rest.api.domain.cms.ClientUc) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ClientUc managed = new ClientUc(clientUc, lastUpdatedId);
        // NOSONAR
        managed = clientucDao.create(managed);
        return mockDomain;
    } catch (EntityExistsException e) {
        LOGGER.info("Client already exists : {}", clientUc);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) EntityExistsException(javax.persistence.EntityExistsException)

Example 9 with ClientUc

use of gov.ca.cwds.data.persistence.cms.ClientUc in project API by ca-cwds.

the class ClientUcDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    gov.ca.cwds.rest.api.domain.cms.ClientUc vcluc = validDomainClientUc();
    ClientUc clientUc = new ClientUc("ABC1234567", vcluc.getSourceTableCode(), vcluc.getCommonFirstName(), vcluc.getCommonLastName(), vcluc.getCommonMiddleName());
    clientUcDao.update(clientUc);
}
Also used : ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) Test(org.junit.Test)

Example 10 with ClientUc

use of gov.ca.cwds.data.persistence.cms.ClientUc in project API by ca-cwds.

the class ClientUcDaoIT method testCreate.

/**
   * Create JUnit test
   */
@Override
@Test
public void testCreate() throws Exception {
    gov.ca.cwds.rest.api.domain.cms.ClientUc vcluc = validDomainClientUc();
    ClientUc clientUc = new ClientUc("ABC1234567", vcluc.getSourceTableCode(), vcluc.getCommonFirstName(), vcluc.getCommonLastName(), vcluc.getCommonMiddleName());
    ClientUc create = clientUcDao.create(clientUc);
    assertThat(clientUc, is(create));
}
Also used : ClientUc(gov.ca.cwds.data.persistence.cms.ClientUc) Test(org.junit.Test)

Aggregations

ClientUc (gov.ca.cwds.data.persistence.cms.ClientUc)10 Test (org.junit.Test)8 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1