use of gov.ca.cwds.data.persistence.cms.Referral in project API by ca-cwds.
the class LACountyTriggerTest method referralFkAddresssIdNullTest.
/*
* Test for checking referral county trigger not created as FkAddress_T is null
*/
@SuppressWarnings("javadoc")
@Test
public void referralFkAddresssIdNullTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.Referral validDomainReferral = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/allegesAbuseOccurredAtAddressIdNull.json"), gov.ca.cwds.rest.api.domain.cms.Referral.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;
}
});
Referral referral = new Referral("ABC1234567", validDomainReferral, "BTr");
laCountyTrigger.createCountyTrigger(referral);
assertThat(countyTrigger, is(equalTo(null)));
}
use of gov.ca.cwds.data.persistence.cms.Referral in project API by ca-cwds.
the class ReferralService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedReferral create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Referral;
gov.ca.cwds.rest.api.domain.cms.Referral referral = (gov.ca.cwds.rest.api.domain.cms.Referral) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Referral managed = new Referral(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), referral, lastUpdatedId);
managed = referralDao.create(managed);
if (managed.getId() == null) {
throw new ServiceException("Referral ID cannot be null");
}
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
}
return new PostedReferral(managed);
} catch (EntityExistsException e) {
LOGGER.info("Referral already exists : {}", referral);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.Referral in project API by ca-cwds.
the class ReferralService 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.Referral update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
assert request instanceof gov.ca.cwds.rest.api.domain.cms.Referral;
gov.ca.cwds.rest.api.domain.cms.Referral referral = (gov.ca.cwds.rest.api.domain.cms.Referral) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
Referral managed = new Referral((String) primaryKey, referral, lastUpdatedId);
managed = referralDao.update(managed);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createCountyTrigger(managed);
}
return new gov.ca.cwds.rest.api.domain.cms.Referral(managed);
} catch (EntityNotFoundException e) {
final String msg = "Referral not found : " + referral;
LOGGER.error("Referral not found : {}", referral);
throw new ServiceException(msg, e);
}
}
use of gov.ca.cwds.data.persistence.cms.Referral in project API by ca-cwds.
the class ReferralDaoIT method testCreateExistingEntityException.
@Override
@Test
public void testCreateExistingEntityException() throws Exception {
thrown.expect(EntityExistsException.class);
Referral referral = new Referral("AbiQCgu0Hj", " ", "N", "N", "D5YRVOm0Ht", (short) 122, " ", (Date) null, (short) 409, "", "", "L3H7sSC0Ht", "", "N", "N", (short) 1118, " ", "N", "N", (Date) null, "Verification (R3)", " ", (Date) null, (Date) null, (short) 1520, (short) 0, (Date) null, (Date) null, "", "", " ", " ", " ", "", "", "0Ht", "0Ht", "51", "N", "N", "N", "N", (Date) null, "C", (short) 0, (Date) null, "", (Date) null, null, null, null, null);
referralDao.create(referral);
}
use of gov.ca.cwds.data.persistence.cms.Referral in project API by ca-cwds.
the class ReferralDaoIT method testUpdateEntityNotFoundException.
@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
thrown.expect(EntityNotFoundException.class);
Referral referral = new Referral("ZZZZZZZZZ", " ", "N", "N", "D5YRVOm0Ht", (short) 122, " ", (Date) null, (short) 409, "", "", "L3H7sSC0Ht", "", "N", "N", (short) 1118, " ", "N", "N", (Date) null, "Verification (R3)", " ", (Date) null, (Date) null, (short) 1520, (short) 0, (Date) null, (Date) null, "", "", " ", " ", " ", "", "", "0Ht", "0Ht", "51", "N", "N", "N", "N", (Date) null, "C", (short) 0, (Date) null, "", (Date) null, null, null, null, null);
referralDao.update(referral);
}
Aggregations