Search in sources :

Example 1 with Client

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

the class ClientDaoIT method testFindAllReturnsCorrectList.

@SuppressWarnings("unchecked")
@Override
@Test
public void testFindAllReturnsCorrectList() {
    Query query = session.getNamedQuery("gov.ca.cwds.data.persistence.cms.Client.findAll");
    final List<Client> list = query.list();
    System.out.println("size of query list is: " + list.size());
    for (Client c : list) {
        System.out.println("id " + c.getId() + " " + c.getSensitivityIndicator() + " " + c.getSoc158SealedClientIndicator() + " " + c.getLastUpdatedTime());
    }
    assertThat(query.list().size(), is(4));
}
Also used : Query(org.hibernate.Query) Client(gov.ca.cwds.data.persistence.cms.Client) Test(org.junit.Test)

Example 2 with Client

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

the class ClientDaoIT method testDelete.

@Override
@Test
public void testDelete() {
    String id = "AaiU7IW0Rt";
    Client deleted = clientDao.delete(id);
    assertThat(deleted.getId(), is(id));
}
Also used : Client(gov.ca.cwds.data.persistence.cms.Client) Test(org.junit.Test)

Example 3 with Client

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

the class ClientDaoIT method testCreate.

@Override
@Test
public void testCreate() throws Exception {
    Client vc = validClient();
    Client pers = new Client(vc.getAdjudicatedDelinquentIndicator(), vc.getAdoptionStatusCode(), vc.getAlienRegistrationNumber(), vc.getBirthCity(), vc.getBirthCountryCodeType(), vc.getBirthDate(), vc.getBirthFacilityName(), vc.getBirthStateCodeType(), vc.getBirthplaceVerifiedIndicator(), vc.getChildClientIndicatorVar(), vc.getClientIndexNumber(), vc.getCommentDescription(), vc.getCommonFirstName(), vc.getCommonLastName(), vc.getCommonMiddleName(), vc.getConfidentialityActionDate(), vc.getConfidentialityInEffectIndicator(), vc.getCreationDate(), vc.getCurrCaChildrenServIndicator(), vc.getCurrentlyOtherDescription(), vc.getCurrentlyRegionalCenterIndicator(), vc.getDeathDate(), vc.getDeathDateVerifiedIndicator(), vc.getDeathPlace(), vc.getDeathReasonText(), vc.getDriverLicenseNumber(), vc.getDriverLicenseStateCodeType(), vc.getEmailAddress(), vc.getEstimatedDobCode(), vc.getEthUnableToDetReasonCode(), vc.getFatherParentalRightTermDate(), vc.getGenderCode(), vc.getHealthSummaryText(), vc.getHispUnableToDetReasonCode(), vc.getHispanicOriginCode(), vc.getId(), vc.getImmigrationCountryCodeType(), vc.getImmigrationStatusType(), vc.getIncapacitatedParentCode(), vc.getIndividualHealthCarePlanIndicator(), vc.getLimitationOnScpHealthIndicator(), vc.getLiterateCode(), vc.getMaritalCohabitatnHstryIndicatorVar(), vc.getMaritalStatusType(), vc.getMilitaryStatusCode(), vc.getMotherParentalRightTermDate(), vc.getNamePrefixDescription(), vc.getNameType(), vc.getOutstandingWarrantIndicator(), vc.getPrevCaChildrenServIndicator(), vc.getPrevOtherDescription(), vc.getPrevRegionalCenterIndicator(), vc.getPrimaryEthnicityType(), vc.getPrimaryLanguageType(), vc.getReligionType(), vc.getSecondaryLanguageType(), vc.getSensitiveHlthInfoOnFileIndicator(), vc.getSensitivityIndicator(), vc.getSoc158PlacementCode(), vc.getSoc158SealedClientIndicator(), vc.getSocialSecurityNumChangedCode(), vc.getSocialSecurityNumber(), vc.getSuffixTitleDescription(), vc.getTribalAncestryClientIndicatorVar(), vc.getTribalMembrshpVerifctnIndicatorVar(), vc.getUnemployedParentCode(), vc.getZippyCreatedIndicator(), null);
    Client created = clientDao.create(pers);
    assertThat(created, is(pers));
}
Also used : Client(gov.ca.cwds.data.persistence.cms.Client) Test(org.junit.Test)

Example 4 with Client

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

the class ClientDaoIT method testUpdateEntityNotFoundException.

@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
    thrown.expect(EntityNotFoundException.class);
    Client vc = validClient();
    Client pers = new Client(vc.getAdjudicatedDelinquentIndicator(), vc.getAdoptionStatusCode(), vc.getAlienRegistrationNumber(), vc.getBirthCity(), vc.getBirthCountryCodeType(), vc.getBirthDate(), vc.getBirthFacilityName(), vc.getBirthStateCodeType(), vc.getBirthplaceVerifiedIndicator(), vc.getChildClientIndicatorVar(), vc.getClientIndexNumber(), vc.getCommentDescription(), vc.getCommonFirstName(), vc.getCommonLastName(), vc.getCommonMiddleName(), vc.getConfidentialityActionDate(), vc.getConfidentialityInEffectIndicator(), vc.getCreationDate(), vc.getCurrCaChildrenServIndicator(), vc.getCurrentlyOtherDescription(), vc.getCurrentlyRegionalCenterIndicator(), vc.getDeathDate(), vc.getDeathDateVerifiedIndicator(), vc.getDeathPlace(), vc.getDeathReasonText(), vc.getDriverLicenseNumber(), vc.getDriverLicenseStateCodeType(), vc.getEmailAddress(), vc.getEstimatedDobCode(), vc.getEthUnableToDetReasonCode(), vc.getFatherParentalRightTermDate(), vc.getGenderCode(), vc.getHealthSummaryText(), vc.getHispUnableToDetReasonCode(), vc.getHispanicOriginCode(), "AasRx3r0Ha", vc.getImmigrationCountryCodeType(), vc.getImmigrationStatusType(), vc.getIncapacitatedParentCode(), vc.getIndividualHealthCarePlanIndicator(), vc.getLimitationOnScpHealthIndicator(), vc.getLiterateCode(), vc.getMaritalCohabitatnHstryIndicatorVar(), vc.getMaritalStatusType(), vc.getMilitaryStatusCode(), vc.getMotherParentalRightTermDate(), vc.getNamePrefixDescription(), vc.getNameType(), vc.getOutstandingWarrantIndicator(), vc.getPrevCaChildrenServIndicator(), vc.getPrevOtherDescription(), vc.getPrevRegionalCenterIndicator(), vc.getPrimaryEthnicityType(), vc.getPrimaryLanguageType(), vc.getReligionType(), vc.getSecondaryLanguageType(), vc.getSensitiveHlthInfoOnFileIndicator(), vc.getSensitivityIndicator(), vc.getSoc158PlacementCode(), vc.getSoc158SealedClientIndicator(), vc.getSocialSecurityNumChangedCode(), vc.getSocialSecurityNumber(), vc.getSuffixTitleDescription(), vc.getTribalAncestryClientIndicatorVar(), vc.getTribalMembrshpVerifctnIndicatorVar(), vc.getUnemployedParentCode(), vc.getZippyCreatedIndicator(), null);
    clientDao.update(pers);
}
Also used : Client(gov.ca.cwds.data.persistence.cms.Client) Test(org.junit.Test)

Example 5 with Client

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

the class ClientService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public PostedClient create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.Client;
    gov.ca.cwds.rest.api.domain.cms.Client client = (gov.ca.cwds.rest.api.domain.cms.Client) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        Client managed = new Client(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), client, lastUpdatedId);
        managed = clientDao.create(managed);
        // checking the staffPerson county code
        StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
        if (staffperson != null && !(triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
            nonLaCountyTriggers.createClientCountyTrigger(managed);
        }
        return new PostedClient(managed, false);
    } catch (EntityExistsException e) {
        LOGGER.info("Client already exists : {}", client);
        throw new ServiceException(e);
    }
}
Also used : PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient) StaffPerson(gov.ca.cwds.data.persistence.cms.StaffPerson) EntityExistsException(javax.persistence.EntityExistsException) ServiceException(gov.ca.cwds.rest.services.ServiceException) Client(gov.ca.cwds.data.persistence.cms.Client) PostedClient(gov.ca.cwds.rest.api.domain.cms.PostedClient)

Aggregations

Client (gov.ca.cwds.data.persistence.cms.Client)12 Test (org.junit.Test)9 PostedClient (gov.ca.cwds.rest.api.domain.cms.PostedClient)2 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 CountyOwnership (gov.ca.cwds.data.persistence.cms.CountyOwnership)1 StaffPerson (gov.ca.cwds.data.persistence.cms.StaffPerson)1 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)1 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 Query (org.hibernate.Query)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1