Search in sources :

Example 6 with StaffPerson

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

the class StaffPersonDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    StaffPerson staffPerson = new StaffPerson("q1q", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, "    ", "N", "MIZN02k00E", "  ", "    ", "99", "N", "3XPCP92q38", null);
    staffPersonDao.update(staffPerson);
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) Test(org.junit.Test)

Example 7 with StaffPerson

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

the class StaffPersonDaoIT method testCreate.

@Override
@Test
public void testCreate() throws Exception {
    StaffPerson staffPerson = new StaffPerson("q1k", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, "    ", "N", "MIZN02k00E", "  ", "    ", "99", "N", "3XPCP92q38", null);
    StaffPerson created = staffPersonDao.create(staffPerson);
    assertThat(created, is(staffPerson));
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) Test(org.junit.Test)

Example 8 with StaffPerson

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

the class StaffPersonDaoIT method testFind.

@Override
@Test
public void testFind() throws Exception {
    String id = "q1p";
    StaffPerson found = staffPersonDao.find(id);
    assertThat(found.getId(), is(id));
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) Test(org.junit.Test)

Example 9 with StaffPerson

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

the class ClientAddressService method create.

@Override
public Response create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ClientAddress;
    gov.ca.cwds.rest.api.domain.cms.ClientAddress clientAddress = (gov.ca.cwds.rest.api.domain.cms.ClientAddress) request;
    try {
        ClientAddress managedClientAddress = new ClientAddress(IdGenerator.randomString(10), clientAddress, "BTr");
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managedClientAddress.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createClientAddressCountyTrigger(managedClientAddress);
        }
        managedClientAddress = clientAddressDao.create(managedClientAddress);
        return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managedClientAddress, false);
    } catch (EntityExistsException e) {
        LOGGER.info("ClientAddress already exists : {}", clientAddress);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) ServiceException(gov.ca.cwds.rest.services.ServiceException) ClientAddress(gov.ca.cwds.data.persistence.cms.ClientAddress) EntityExistsException(javax.persistence.EntityExistsException)

Example 10 with StaffPerson

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

the class ReferralClientService method create.

@Override
public gov.ca.cwds.rest.api.domain.cms.ReferralClient create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.ReferralClient;
    gov.ca.cwds.rest.api.domain.cms.ReferralClient referralClient = (gov.ca.cwds.rest.api.domain.cms.ReferralClient) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        ReferralClient managed = new ReferralClient(referralClient, lastUpdatedId);
        managed = referralClientDao.create(managed);
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
        if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            laCountyTrigger.createCountyTrigger(managed);
        } else {
            nonLaTriggers.createAndUpdateReferralClientCoutyOwnership(managed);
        }
        return new gov.ca.cwds.rest.api.domain.cms.ReferralClient(managed);
    } catch (EntityExistsException e) {
        LOGGER.info("Referral Client already exists : {}", referralClient);
        throw new ServiceException(e);
    }
}
Also used : StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) EntityExistsException(javax.persistence.EntityExistsException) ServiceException(gov.ca.cwds.rest.services.ServiceException) ReferralClient(gov.ca.cwds.data.persistence.cms.ReferralClient)

Aggregations

StaffPerson (gov.ca.cwds.data.persistence.cms.StaffPerson)17 Test (org.junit.Test)10 ServiceException (gov.ca.cwds.rest.services.ServiceException)7 EntityExistsException (javax.persistence.EntityExistsException)4 PostedReferral (gov.ca.cwds.rest.api.domain.cms.PostedReferral)3 EntityNotFoundException (javax.persistence.EntityNotFoundException)3 ClientAddress (gov.ca.cwds.data.persistence.cms.ClientAddress)2 Referral (gov.ca.cwds.data.persistence.cms.Referral)2 ReferralClient (gov.ca.cwds.data.persistence.cms.ReferralClient)2 InvocationOnMock (org.mockito.invocation.InvocationOnMock)2 Client (gov.ca.cwds.data.persistence.cms.Client)1 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)1 Referral (gov.ca.cwds.rest.api.domain.cms.Referral)1 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)1