Search in sources :

Example 1 with PostedScreening

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

the class ScreeningService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public PostedScreening create(Request request) {
    assert request instanceof ScreeningReference;
    ScreeningReference screeningReference = (ScreeningReference) request;
    gov.ca.cwds.data.persistence.ns.Screening managed = new gov.ca.cwds.data.persistence.ns.Screening(screeningReference.getReference());
    managed = screeningDao.create(managed);
    return new PostedScreening(managed.getId(), managed.getReference());
}
Also used : PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.rest.api.domain.Screening) Restrictions(org.hibernate.criterion.Restrictions) ScreeningReference(gov.ca.cwds.rest.api.domain.ScreeningReference) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening)

Example 2 with PostedScreening

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

the class ScreeningServiceTest method createReturnsNonNull.

@Test
public void createReturnsNonNull() throws Exception {
    Screening screeningMock = mock(Screening.class);
    when(screeningMock.getReference()).thenReturn("some_reference");
    when(screeningMock.getId()).thenReturn(1L);
    ScreeningReference request = new ScreeningReference("some_reference");
    when(screeningDao.create(any(gov.ca.cwds.data.persistence.ns.Screening.class))).thenReturn(screeningMock);
    PostedScreening postedScreening = screeningService.create(request);
    assertThat(postedScreening, is(notNullValue()));
}
Also used : PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningReference(gov.ca.cwds.rest.api.domain.ScreeningReference) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Test(org.junit.Test)

Example 3 with PostedScreening

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

the class ScreeningServiceTest method createReturnsReturnsCorrectPostedScreening.

@Test
public void createReturnsReturnsCorrectPostedScreening() throws Exception {
    Screening screeningMock = mock(Screening.class);
    when(screeningMock.getReference()).thenReturn("some_reference");
    when(screeningMock.getId()).thenReturn(1L);
    ScreeningReference request = new ScreeningReference("some_reference");
    when(screeningDao.create(any(gov.ca.cwds.data.persistence.ns.Screening.class))).thenReturn(screeningMock);
    PostedScreening expected = new PostedScreening(1L, "some_reference");
    PostedScreening returned = screeningService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningReference(gov.ca.cwds.rest.api.domain.ScreeningReference) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Test(org.junit.Test)

Example 4 with PostedScreening

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

the class ScreeningServiceTest method createReturnsPostedScreeningClass.

@Test
public void createReturnsPostedScreeningClass() throws Exception {
    Screening screeningMock = mock(Screening.class);
    when(screeningMock.getReference()).thenReturn("some_reference");
    when(screeningMock.getId()).thenReturn(1L);
    ScreeningReference request = new ScreeningReference("some_reference");
    when(screeningDao.create(any(gov.ca.cwds.data.persistence.ns.Screening.class))).thenReturn(screeningMock);
    PostedScreening postedScreening = screeningService.create(request);
    assertThat(postedScreening.getClass(), is(PostedScreening.class));
}
Also used : PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningReference(gov.ca.cwds.rest.api.domain.ScreeningReference) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Test(org.junit.Test)

Aggregations

PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)4 ScreeningReference (gov.ca.cwds.rest.api.domain.ScreeningReference)4 Screening (gov.ca.cwds.data.persistence.ns.Screening)3 Test (org.junit.Test)3 Screening (gov.ca.cwds.rest.api.domain.Screening)1 Restrictions (org.hibernate.criterion.Restrictions)1