use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method createCountyTriggerForLACounty.
/*
* Test for checking the staffperson county Code
*/
@SuppressWarnings("javadoc")
@Test
public void createCountyTriggerForLACounty() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient toCreate = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientDomain, "BTr");
ReferralClient request = new ReferralClient(toCreate);
when(triggerTablesDao.getLaCountySpecificCode()).thenReturn("19");
StaffPerson staffPerson = new StaffPerson("BTr", null, "External Interface", "external interface", "SCXCIN7", " ", "", BigDecimal.valueOf(9165672100L), 0, null, " ", "N", "MIZN02k00E", " ", " ", "19", "N", "3XPCP92q38", null);
when(staffpersonDao.find(any(String.class))).thenReturn(staffPerson);
when(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
when(laCountyTrigger.createCountyTrigger(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenAnswer(new Answer<Boolean>() {
@Override
public Boolean answer(InvocationOnMock invocation) throws Throwable {
isLaCountyTrigger = true;
return true;
}
});
referralClientService.create(request);
assertThat(isLaCountyTrigger, is(true));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method updateThrowsExceptionWhenReferralClientNotFound.
@SuppressWarnings("javadoc")
@Test
public void updateThrowsExceptionWhenReferralClientNotFound() throws Exception {
try {
ReferralClient referralClientRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.json"), ReferralClient.class);
gov.ca.cwds.data.persistence.cms.ReferralClient referralClient = new gov.ca.cwds.data.persistence.cms.ReferralClient(referralClientRequest, "ABC");
when(referralClientDao.find(referralClient.getPrimaryKey().toString())).thenReturn(referralClient);
when(referralClientDao.update(any())).thenReturn(referralClient);
referralClientService.update("referralId=ZZZZZZZABC,clientId=ABCZZZZZZZ", referralClientRequest);
} catch (ServiceException e) {
assertEquals(e.getClass(), ServiceException.class);
}
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method createReturnsPostedReferralClient.
@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedReferralClient() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
Response response = referralClientService.create(request);
assertThat(response.getClass(), is(ReferralClient.class));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method createReturnsCorrectPostedPerson.
@SuppressWarnings("javadoc")
@Test
public void createReturnsCorrectPostedPerson() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
ReferralClient expected = new ReferralClient(toCreate);
ReferralClient returned = referralClientService.create(request);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.ReferralClient in project API by ca-cwds.
the class ReferralClientServiceTest method createReturnsPostedReferralClientClass.
@SuppressWarnings("javadoc")
@Test
public void createReturnsPostedReferralClientClass() throws Exception {
ReferralClient referralClientDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/ReferralClient/valid/valid.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(referralClientDao.create(any(gov.ca.cwds.data.persistence.cms.ReferralClient.class))).thenReturn(toCreate);
Response response = referralClientService.create(request);
assertThat(response.getClass(), is(ReferralClient.class));
}
Aggregations