Search in sources :

Example 31 with LongText

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());
}
Also used : InvocationOnMock(org.mockito.invocation.InvocationOnMock) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) LongText(gov.ca.cwds.rest.api.domain.cms.LongText) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) Test(org.junit.Test)

Example 32 with LongText

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));
}
Also used : PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) LongText(gov.ca.cwds.rest.api.domain.cms.LongText) Test(org.junit.Test)

Example 33 with LongText

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));
}
Also used : PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) LongText(gov.ca.cwds.rest.api.domain.cms.LongText) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) Test(org.junit.Test)

Example 34 with LongText

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));
}
Also used : Response(gov.ca.cwds.rest.api.Response) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) LongText(gov.ca.cwds.rest.api.domain.cms.LongText) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) Test(org.junit.Test)

Example 35 with LongText

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();
}
Also used : LongText(gov.ca.cwds.rest.api.domain.cms.LongText) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText) PostedLongText(gov.ca.cwds.rest.api.domain.cms.PostedLongText)

Aggregations

LongText (gov.ca.cwds.rest.api.domain.cms.LongText)56 Test (org.junit.Test)54 Response (gov.ca.cwds.rest.api.Response)43 PostedScreeningToReferral (gov.ca.cwds.rest.api.domain.PostedScreeningToReferral)42 ScreeningToReferral (gov.ca.cwds.rest.api.domain.ScreeningToReferral)42 Address (gov.ca.cwds.rest.api.domain.cms.Address)42 Allegation (gov.ca.cwds.rest.api.domain.cms.Allegation)42 ChildClient (gov.ca.cwds.rest.api.domain.cms.ChildClient)42 Client (gov.ca.cwds.rest.api.domain.cms.Client)42 ClientAddress (gov.ca.cwds.rest.api.domain.cms.ClientAddress)42 CmsReferral (gov.ca.cwds.rest.api.domain.cms.CmsReferral)42 CrossReport (gov.ca.cwds.rest.api.domain.cms.CrossReport)42 Referral (gov.ca.cwds.rest.api.domain.cms.Referral)42 ReferralClient (gov.ca.cwds.rest.api.domain.cms.ReferralClient)42 LinkedHashSet (java.util.LinkedHashSet)42 Set (java.util.Set)42 Reporter (gov.ca.cwds.rest.api.domain.cms.Reporter)41 ErrorMessage (gov.ca.cwds.rest.api.domain.error.ErrorMessage)22 ExpectedException (org.junit.rules.ExpectedException)17 PostedLongText (gov.ca.cwds.rest.api.domain.cms.PostedLongText)10