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));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralServiceTest method testCreateReturnsPostedClass.
@Override
@Test
public void testCreateReturnsPostedClass() 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 = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
when(referralDao.create(any(gov.ca.cwds.data.persistence.cms.Referral.class))).thenReturn(toCreate);
Response response = referralService.create(request);
assertThat(response.getClass(), is(PostedReferral.class));
}
use of gov.ca.cwds.rest.api.domain.cms.Referral in project API by ca-cwds.
the class ReferralResourceTest method testPost204ResourceSuccess.
@SuppressWarnings("javadoc")
public // @Test
void testPost204ResourceSuccess() throws Exception {
Referral serialized = MAPPER.readValue(fixture("fixtures/domain/legacy/Referral/valid/valid.json"), Referral.class);
Integer status = inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(serialized, MediaType.APPLICATION_JSON)).getStatus();
assertThat(status, is(204));
}
Aggregations