use of gov.ca.cwds.rest.api.domain.cms.PostedLongText in project API by ca-cwds.
the class LongTextService method create.
/**
* {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
*/
@Override
public PostedLongText create(Request request) {
assert request instanceof gov.ca.cwds.rest.api.domain.cms.LongText;
gov.ca.cwds.rest.api.domain.cms.LongText longText = (gov.ca.cwds.rest.api.domain.cms.LongText) request;
try {
String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
LongText managed = new LongText(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), longText, lastUpdatedId);
managed = longTextDao.create(managed);
return new PostedLongText(managed);
} catch (EntityExistsException e) {
LOGGER.info("LongText already exists : {}", longText);
throw new ServiceException(e);
}
}
use of gov.ca.cwds.rest.api.domain.cms.PostedLongText in project API by ca-cwds.
the class LongTextServiceTest method testCreateBlankIDError.
@Override
@Test
public void testCreateBlankIDError() throws Exception {
try {
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(" ", longTextDomain, "q27");
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(toCreate);
PostedLongText expected = new PostedLongText(toCreate);
} catch (ServiceException e) {
assertEquals("LongText ID cannot be blank", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.PostedLongText 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();
}
use of gov.ca.cwds.rest.api.domain.cms.PostedLongText in project API by ca-cwds.
the class LongTextServiceTest method testCreateNullIDError.
@Override
@Test
public void testCreateNullIDError() throws Exception {
try {
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(null, longTextDomain, "q27");
when(longTextDao.create(any(gov.ca.cwds.data.persistence.cms.LongText.class))).thenReturn(toCreate);
PostedLongText expected = new PostedLongText(toCreate);
} catch (ServiceException e) {
assertEquals("LongText ID cannot be blank", e.getMessage());
}
}
use of gov.ca.cwds.rest.api.domain.cms.PostedLongText in project API by ca-cwds.
the class LongTextServiceTest method testCreateReturnsNonNull.
@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() 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 postedLongText = longTextService.create(request);
assertThat(postedLongText, is(notNullValue()));
}
Aggregations