use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testCreateEmptyIDError.
@Override
@Test
public void testCreateEmptyIDError() throws Exception {
try {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral toCreate = new gov.ca.cwds.data.persistence.cms.Referral("", referralDomain, "0XA");
Referral request = new Referral(toCreate);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
@SuppressWarnings("unused") PostedReferral returned = referralService.create(request);
} catch (ServiceException e) {
assertEquals("Referral ID cannot be empty", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testUpdateReturnsDomain.
@Override
@Test
public void testUpdateReturnsDomain() throws Exception {
Referral expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral referral = new gov.ca.cwds.data.persistence.cms.Referral("1234567ABC", expected, "ABC");
when(referralDao.update(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(referral);
Object retval = referralService.update("1234567ABC", expected);
assertThat(retval.getClass(), is(Referral.class));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method createReturnsGeneratedId.
/*
* Test for checking the new Referral Id generated and lenght is 10
*/
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.Referral>() {
@Override
public gov.ca.cwds.data.persistence.cms.Referral answer(InvocationOnMock invocation) throws Throwable {
gov.ca.cwds.data.persistence.cms.Referral report = (gov.ca.cwds.data.persistence.cms.Referral) invocation.getArguments()[0];
return report;
}
});
PostedReferral returned = referralService.create(referralDomain);
assertEquals(returned.getId().length(), 10);
PostedReferral newReturned = referralService.create(referralDomain);
Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testCreateReturnsCorrectReferralId.
@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsCorrectReferralId() throws Exception {
Referral referralDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral toCreate = new gov.ca.cwds.data.persistence.cms.Referral("1234567ABC", referralDomain, "0XA");
Referral request = new Referral(toCreate);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
PostedReferral returned = referralService.create(request);
assertThat(returned.getId(), is("1234567ABC"));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testFindReturnsCorrectEntity.
@Override
@Test
public void testFindReturnsCorrectEntity() throws Exception {
Referral expected = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
gov.ca.cwds.data.persistence.cms.Referral referral = new gov.ca.cwds.data.persistence.cms.Referral("1234567ABC", expected, "0XA");
when(referralDao.find("1234567ABC")).thenReturn(referral);
Referral found = referralService.find("1234567ABC");
assertThat(found, is(expected));
}
Aggregations