use of gov.ca.cwds.rest.api.domain.cms.LongText in project API by ca-cwds.
the class LongTextServiceTest method createReturnsGeneratedId.
/*
* Test for checking the new Allegation Id generated and lenght is 10
*/
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
LongText longTextDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/LongText/valid/valid.json"), LongText.class);
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.LongText>() {
@Override
public gov.ca.cwds.data.persistence.cms.LongText answer(InvocationOnMock invocation) throws Throwable {
gov.ca.cwds.data.persistence.cms.LongText report = (gov.ca.cwds.data.persistence.cms.LongText) invocation.getArguments()[0];
return report;
}
});
PostedLongText returned = longTextService.create(longTextDomain);
assertEquals(returned.getId().length(), 10);
PostedLongText newReturned = longTextService.create(longTextDomain);
Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
use of gov.ca.cwds.rest.api.domain.cms.LongText in project API by ca-cwds.
the class LongTextServiceTest method testUpdateReturnsCorrectEntity.
@Override
@Test
public void testUpdateReturnsCorrectEntity() throws Exception {
String id = "AaoDyiJq27";
LongText expected = MAPPER.readValue(fixture("fixtures/domain/legacy/LongText/valid/valid.json"), LongText.class);
gov.ca.cwds.data.persistence.cms.LongText longText = new gov.ca.cwds.data.persistence.cms.LongText(id, expected, "q27");
when(longTextDao.find("ABC1234567")).thenReturn(longText);
when(longTextDao.update(any())).thenReturn(longText);
Object retval = longTextService.update("ABC1234567", expected);
assertThat(retval.getClass(), is(LongText.class));
}
use of gov.ca.cwds.rest.api.domain.cms.LongText in project API by ca-cwds.
the class LongTextServiceTest method testCreateReturnsCorrectEntity.
@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
String id = "AaoDyiJq27";
LongText longTextDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/LongText/valid/valid.json"), LongText.class);
gov.ca.cwds.data.persistence.cms.LongText toCreate = new gov.ca.cwds.data.persistence.cms.LongText(id, longTextDomain, "q27");
LongText request = new LongText(toCreate);
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(toCreate);
PostedLongText expected = new PostedLongText(toCreate);
PostedLongText returned = longTextService.create(request);
assertThat(returned, is(expected));
}
use of gov.ca.cwds.rest.api.domain.cms.LongText in project API by ca-cwds.
the class LongTextServiceTest method testCreateReturnsPostedClass.
// create test
@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
String id = "AaoDyiJq27";
LongText longTextDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/LongText/valid/valid.json"), LongText.class);
gov.ca.cwds.data.persistence.cms.LongText toCreate = new gov.ca.cwds.data.persistence.cms.LongText(id, longTextDomain, "q27");
LongText request = new LongText(toCreate);
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(toCreate);
Response response = longTextService.create(request);
assertThat(response.getClass(), is(PostedLongText.class));
}
use of gov.ca.cwds.rest.api.domain.cms.LongText in project API by ca-cwds.
the class ScreeningToReferralService method createLongText.
private String createLongText(String countySpecificCode, String textDescription, Set<ErrorMessage> messages) throws ServiceException {
LongText longText = new LongText(countySpecificCode, textDescription);
PostedLongText postedLongText = longTextService.create(longText);
buildErrors(messages, validator.validate(longText));
return postedLongText.getId();
}
Aggregations