use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.
the class ClientAddressService method update.
@Override
public Response update(Serializable primaryKey, Request request) {
assert primaryKey instanceof String;
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 {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
ClientAddress managed = new ClientAddress((String) primaryKey, clientAddress, lastUpdatedId);
// checking the staffPerson county code
StaffPerson staffperson = staffpersonDao.find(managed.getLastUpdatedId());
if (staffperson != null && (triggerTablesDao.getLaCountySpecificCode().equals(staffperson.getCountyCode()))) {
laCountyTrigger.createClientAddressCountyTrigger(managed);
}
managed = clientAddressDao.update(managed);
return new gov.ca.cwds.rest.api.domain.cms.ClientAddress(managed, true);
} catch (EntityNotFoundException e) {
LOGGER.info("ClientAddress not found : {}", clientAddress);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.
the class LACountyTriggerTest method clientAddressfkAddressIdNullTest.
/*
* Test for checking clientAddress county trigger not created as FkAddress_T is null
*/
@SuppressWarnings("javadoc")
@Test
public void clientAddressfkAddressIdNullTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.ClientAddress validDomainClientAddress = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/fkAddressTNull.json"), gov.ca.cwds.rest.api.domain.cms.ClientAddress.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;
}
});
ClientAddress clientAddress = new ClientAddress("ABC1234567", validDomainClientAddress, "BTr");
laCountyTrigger.createClientAddressCountyTrigger(clientAddress);
assertThat(countyTrigger, is(equalTo(null)));
}
use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.
the class LACountyTriggerTest method clientAddressfkclientIdNullTest.
/*
* Test for checking clientAddress county trigger not created as FkClient_T is null
*/
@SuppressWarnings("javadoc")
@Test
public void clientAddressfkclientIdNullTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.ClientAddress validDomainClientAddress = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/fkClientTNull.json"), gov.ca.cwds.rest.api.domain.cms.ClientAddress.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;
}
});
ClientAddress clientAddress = new ClientAddress("ABC1234567", validDomainClientAddress, "BTr");
laCountyTrigger.createClientAddressCountyTrigger(clientAddress);
assertThat(countyTrigger, is(equalTo(null)));
}
use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.
the class LACountyTrigger method createClientAddressCountyTrigger.
/**
* @param object The object creates the county Trigger for the clientAddress
* @return the CountyTrigger created
*/
public boolean createClientAddressCountyTrigger(Object object) {
ClientAddress clientAddress;
if (object instanceof ClientAddress) {
clientAddress = (ClientAddress) object;
if (clientAddress.getFkClient() != "" && clientAddress.getFkClient() != null && clientAddress.getFkAddress() != "" && clientAddress.getFkAddress() != null) {
CountyTrigger countyTrigger1 = new CountyTrigger(clientAddress.getFkClient(), LA_COUNTY_SPECIFIC_CODE, CLIENT_COUNTYOWNERSHIP, new Date(), ClientAddress.class.getDeclaredAnnotation(Table.class).name());
CountyTrigger countyTrigger2 = new CountyTrigger(clientAddress.getFkAddress(), LA_COUNTY_SPECIFIC_CODE, ADDRESS_COUNTYOWNERSHIP, new Date(), ClientAddress.class.getDeclaredAnnotation(Table.class).name());
countyTriggerDao.create(countyTrigger1);
countyTriggerDao.create(countyTrigger2);
}
LOGGER.info("LA county clientAddress triggered");
}
return true;
}
use of gov.ca.cwds.data.persistence.cms.ClientAddress in project API by ca-cwds.
the class LACountyTriggerTest method createClientAddressCountyTriggerTest.
/*
* Test for checking the clientAddress county trigger created with the CL_ADDRT
*/
@SuppressWarnings("javadoc")
@Test
public void createClientAddressCountyTriggerTest() throws JsonParseException, JsonMappingException, IOException {
when(countyTriggerDao.find(any(String.class))).thenReturn(null);
gov.ca.cwds.rest.api.domain.cms.ClientAddress validDomainClientAddress = MAPPER.readValue(fixture("fixtures/legacy/business/rules/laCountyTrigger/validClientAddress.json"), gov.ca.cwds.rest.api.domain.cms.ClientAddress.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;
}
});
ClientAddress clientAddress = new ClientAddress("1234567ABC", validDomainClientAddress, "BTr");
laCountyTrigger.createClientAddressCountyTrigger(clientAddress);
assertThat(countyTrigger.getCountyTriggerEmbeddable().getCountyOwnershipT(), is(equalTo("1234567ABC")));
}
Aggregations