use of gov.ca.cwds.rest.api.domain.ScreeningReference 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());
}
use of gov.ca.cwds.rest.api.domain.ScreeningReference 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()));
}
use of gov.ca.cwds.rest.api.domain.ScreeningReference 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));
}
use of gov.ca.cwds.rest.api.domain.ScreeningReference in project API by ca-cwds.
the class ScreeningResourceTest method createDelegatesToResourceDelegate.
/*
* Create Tests
*/
@Test
public void createDelegatesToResourceDelegate() throws Exception {
ScreeningReference screeningReference = new ScreeningReference("reference");
inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(screeningReference, MediaType.APPLICATION_JSON));
verify(resourceDelegate).create(eq(screeningReference));
}
use of gov.ca.cwds.rest.api.domain.ScreeningReference 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));
}
Aggregations