Search in sources :

Example 6 with AllegationPerpetratorHistory

use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryServiceTest method testFindReturnsCorrectEntity.

@Override
@Test
public void testFindReturnsCorrectEntity() throws Exception {
    String id = "AbjFyc80It";
    AllegationPerpetratorHistory expected = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
    gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(id, expected, "0XA");
    when(allegationPerpetratorHistoryDao.find(id)).thenReturn(allegationPerpetratorHistory);
    AllegationPerpetratorHistory found = allegationPerpetratorHistoryService.find(id);
    assertThat(found, is(expected));
}
Also used : PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) AllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Example 7 with AllegationPerpetratorHistory

use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsNonNull.

@SuppressWarnings("javadoc")
@Test
public void testCreateReturnsNonNull() throws Exception {
    String id = "AbjFyc80It";
    AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
    gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory toCreate = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(id, allegationPerpetratorHistoryDomain, "ABC");
    AllegationPerpetratorHistory request = new AllegationPerpetratorHistory(toCreate);
    when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenReturn(toCreate);
    PostedAllegationPerpetratorHistory postedAllegationPerpetratorHistory = allegationPerpetratorHistoryService.create(request);
    assertThat(postedAllegationPerpetratorHistory, is(notNullValue()));
}
Also used : PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) AllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Example 8 with AllegationPerpetratorHistory

use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryServiceTest method createReturnsGeneratedId.

/*
   * Test for checking the new Allegation Id generated and lenght is 10
   */
@SuppressWarnings("javadoc")
@Test
public void createReturnsGeneratedId() throws Exception {
    AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
    when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenAnswer(new Answer<gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory>() {

        @Override
        public gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory answer(InvocationOnMock invocation) throws Throwable {
            gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = (gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) invocation.getArguments()[0];
            return allegationPerpetratorHistory;
        }
    });
    PostedAllegationPerpetratorHistory returned = allegationPerpetratorHistoryService.create(allegationPerpetratorHistoryDomain);
    assertEquals(returned.getId().length(), 10);
    PostedAllegationPerpetratorHistory newReturned = allegationPerpetratorHistoryService.create(allegationPerpetratorHistoryDomain);
    Assert.assertNotEquals(returned.getId(), newReturned.getId());
}
Also used : PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) InvocationOnMock(org.mockito.invocation.InvocationOnMock) PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) AllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Example 9 with AllegationPerpetratorHistory

use of gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryServiceTest method testCreateNullIDError.

@Override
@Test
public void testCreateNullIDError() throws Exception {
    try {
        AllegationPerpetratorHistory allegationPerpetratorHistoryDomain = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
        gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory toCreate = new gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory(null, allegationPerpetratorHistoryDomain, "ABC");
        when(allegationPerpetratorHistoryDao.create(any(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory.class))).thenReturn(toCreate);
        PostedAllegationPerpetratorHistory expected = new PostedAllegationPerpetratorHistory(toCreate);
    } catch (ServiceException e) {
        assertEquals("AllegationPerpetratorHistory ID cannot be blank", e.getMessage());
    }
}
Also used : PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) ServiceException(gov.ca.cwds.rest.services.ServiceException) PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) AllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Aggregations

AllegationPerpetratorHistory (gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory)9 PostedAllegationPerpetratorHistory (gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory)9 Test (org.junit.Test)9 ServiceException (gov.ca.cwds.rest.services.ServiceException)3 Response (gov.ca.cwds.rest.api.Response)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1 ExpectedException (org.junit.rules.ExpectedException)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1