use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class LACountyTriggerTest method createReferralClientCountyTriggerTest.
/*
* Test for checking the referralClient county trigger created with the FKClient_T
*/
@SuppressWarnings("javadoc")
@Test
public void createReferralClientCountyTriggerTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.ReferralClient validDomainReferralClient = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/validReferralClient.json"), gov.ca.cwds.rest.api.domain.cms.ReferralClient.class);
when(countyTriggerDao.create(any(CountyTrigger.class))).thenAnswer(new Answer<CountyTrigger>() {
@Override
public CountyTrigger answer(InvocationOnMock invocation) throws Throwable {
CountyTrigger report = (CountyTrigger) invocation.getArguments()[0];
countyTrigger = report;
return report;
}
});
ReferralClient referralClient = new ReferralClient(validDomainReferralClient, "BTr");
laCountyTrigger.createCountyTrigger(referralClient);
assertThat(countyTrigger.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(equalTo("ABC1234567")));
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient 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);
}
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientDaoIT method testUpdateEntityNotFoundException.
@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
thrown.expect(EntityNotFoundException.class);
ReferralClient referralClient = new ReferralClient("ZZuzMKw06s", "AazXkWY06s", "", (short) 122, (short) 681, "S", null, "N", "N", "", (short) 2, "", "", "Y", "N", "N");
referralClientDao.update(referralClient);
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientDaoIT method testFindEntityNotFoundException.
@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
ReferralClient found = referralClientDao.find(new PrimaryKey("ZZZZZZZ999", "XXXXXXX000"));
assertThat(found, is(nullValue()));
}
use of gov.ca.cwds.data.persistence.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientDaoIT method testDelete.
@Override
@Test
public void testDelete() throws Exception {
ReferralClient delete = referralClientDao.delete(new PrimaryKey("LNuzMKw06s", "AazXkWY06s"));
assertThat(delete.getClientId(), is("AazXkWY06s"));
assertThat(delete.getReferralId(), is("LNuzMKw06s"));
}
Aggregations