Search in sources :

Example 1 with AllegationPerpetratorHistory

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

the class AllegationPerpetratorHistoryServiceTest method testUpdateThrowsExceptionWhenNotFound.

@SuppressWarnings("javadoc")
@Test
public void testUpdateThrowsExceptionWhenNotFound() throws Exception {
    try {
        AllegationPerpetratorHistory allegationPerpetratorHistoryRequest = MAPPER.readValue(fixture("fixtures/domain/legacy/AllegationPerpetratorHistory/valid/valid.json"), AllegationPerpetratorHistory.class);
        when(allegationPerpetratorHistoryDao.update(any())).thenThrow(EntityNotFoundException.class);
        allegationPerpetratorHistoryService.update("ZZZZZZZZZZ", allegationPerpetratorHistoryRequest);
    } catch (Exception e) {
        assertEquals(e.getClass(), ServiceException.class);
    }
}
Also used : 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) EntityNotFoundException(javax.persistence.EntityNotFoundException) ExpectedException(org.junit.rules.ExpectedException) ServiceException(gov.ca.cwds.rest.services.ServiceException) Test(org.junit.Test)

Example 2 with AllegationPerpetratorHistory

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

the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsPostedClass.

// create test
@Override
@Test
public void testCreateReturnsPostedClass() 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);
    Response response = allegationPerpetratorHistoryService.create(request);
    assertThat(response.getClass(), is(PostedAllegationPerpetratorHistory.class));
}
Also used : Response(gov.ca.cwds.rest.api.Response) 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 3 with AllegationPerpetratorHistory

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

the class AllegationPerpetratorHistoryServiceTest method testUpdateReturnsCorrectEntity.

@Override
@Test
public void testUpdateReturnsCorrectEntity() 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, "ABC");
    when(allegationPerpetratorHistoryDao.find("ABC1234567")).thenReturn(allegationPerpetratorHistory);
    when(allegationPerpetratorHistoryDao.update(any())).thenReturn(allegationPerpetratorHistory);
    Object retval = allegationPerpetratorHistoryService.update("ABC1234567", expected);
    assertThat(retval.getClass(), is(AllegationPerpetratorHistory.class));
}
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 4 with AllegationPerpetratorHistory

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

the class AllegationPerpetratorHistoryServiceTest method testCreateReturnsCorrectEntity.

@Override
@Test
public void testCreateReturnsCorrectEntity() 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 expected = new PostedAllegationPerpetratorHistory(toCreate);
    PostedAllegationPerpetratorHistory returned = allegationPerpetratorHistoryService.create(request);
    assertThat(returned, is(expected));
}
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 5 with AllegationPerpetratorHistory

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

the class AllegationPerpetratorHistoryServiceTest method testCreateBlankIDError.

@Override
@Test
public void testCreateBlankIDError() 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(" ", 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