use of gov.ca.cwds.data.persistence.cms.CountyOwnership in project API by ca-cwds.
the class NonLACountyTriggersTest method testChecksReferralClientCreatedCountyOwnership.
/*
* Test for checking the referral Client CountyOnwership created or updated through the PUT method
*/
@SuppressWarnings("javadoc")
@Test
public void testChecksReferralClientCreatedCountyOwnership() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/legacy/business/rules/nonLaCountyTrigger/referralClientValid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "ABC");
ReferralClient request = new ReferralClient(toCreate);
when(countyOwnershipDao.find(any(String.class))).thenReturn(null);
when(countyOwnershipDao.create(any(CountyOwnership.class))).thenAnswer(new Answer<CountyOwnership>() {
@Override
public CountyOwnership answer(InvocationOnMock invocation) throws Throwable {
CountyOwnership report = (CountyOwnership) invocation.getArguments()[0];
countyOwnership = report;
return report;
}
});
nonLaCountyTriggers.createAndUpdateReferralClientCoutyOwnership(toCreate);
Assert.assertNotNull(countyOwnership);
assertThat(countyOwnership.getEntityCode(), is(equalTo("C")));
}
use of gov.ca.cwds.data.persistence.cms.CountyOwnership in project API by ca-cwds.
the class NonLACountyTriggers method createAndUpdateReferralClientCoutyOwnership.
/**
* @param managed referralClient creates or updates the countyOwnership with the client foreign
* key
*/
public void createAndUpdateReferralClientCoutyOwnership(ReferralClient managed) {
Boolean countyExists = true;
CountyOwnership countyOwnership = countyOwnershipDao.find(managed.getClientId());
if (countyOwnership == null) {
countyExists = false;
countyOwnership = new CountyOwnership();
countyOwnership.setEntityId(managed.getClientId());
countyOwnership.setEntityCode(CLIENT_ENTITY_CODE);
}
String methodName = SET_COUNTY + managed.getCountySpecificCode() + FLAG;
Method method = null;
try {
method = countyOwnership.getClass().getMethod(methodName, String.class);
method.invoke(countyOwnership, SET_FLAG);
} catch (NoSuchMethodException | SecurityException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
LOGGER.info("CountyOwnership Unable to Trigger : {}", countyOwnership);
LOGGER.error(e.getMessage(), e);
throw new TriggerTableException();
}
if (countyExists) {
countyOwnershipDao.update(countyOwnership);
} else {
countyOwnershipDao.create(countyOwnership);
}
}
use of gov.ca.cwds.data.persistence.cms.CountyOwnership in project API by ca-cwds.
the class NonLACountyTriggers method createClientCountyTrigger.
/**
* @param managed Client creates the countyOwnership with the client foreign key
*/
public void createClientCountyTrigger(Client managed) {
CountyOwnership countyOwnership = new CountyOwnership();
countyOwnership.setEntityId(managed.getPrimaryKey());
countyOwnership.setEntityCode(CLIENT_ENTITY_CODE);
countyOwnershipDao.create(countyOwnership);
}
use of gov.ca.cwds.data.persistence.cms.CountyOwnership in project API by ca-cwds.
the class CountyOwnershipDaoIT method testDelete.
@Override
@Test
public void testDelete() throws Exception {
CountyOwnership deleted = countyOwnershipDao.delete(id);
assertThat(deleted.getEntityId(), is(id));
}
use of gov.ca.cwds.data.persistence.cms.CountyOwnership in project API by ca-cwds.
the class CountyOwnershipDaoIT method testUpdateEntityNotFoundException.
@Override
@Test
public void testUpdateEntityNotFoundException() throws Exception {
thrown.expect(EntityNotFoundException.class);
CountyOwnership countyOwnership = new CountyOwnership("AaQshqm0ML", "C", "Y", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", "N", null);
countyOwnershipDao.update(countyOwnership);
}
Aggregations