Search in sources :

Example 1 with Screening

use of gov.ca.cwds.data.persistence.ns.Screening 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 2 with Screening

use of gov.ca.cwds.data.persistence.ns.Screening 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 3 with Screening

use of gov.ca.cwds.data.persistence.ns.Screening in project API by ca-cwds.

the class ScreeningServiceTest method updateReturnsScreeningResponseOnSuccess.

@Test
public void updateReturnsScreeningResponseOnSuccess() throws Exception {
    gov.ca.cwds.rest.api.domain.Address domainAddress = new gov.ca.cwds.rest.api.domain.Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "home");
    ScreeningRequest screeningRequest = new ScreeningRequest("ref", "2016-10-31", "Sac", "2016-10-31", "loc", "comm", "name", "now", "sure", "2016-10-31", "narrative", domainAddress);
    gov.ca.cwds.data.persistence.ns.Screening screening = new gov.ca.cwds.data.persistence.ns.Screening(1L, screeningRequest, new Address(domainAddress, null, null), null, null, null);
    when(screeningDao.find(new Long(123))).thenReturn(screening);
    when(screeningDao.update(any())).thenReturn(screening);
    Object retval = screeningService.update(1L, screeningRequest);
    assertThat(retval.getClass(), is(ScreeningResponse.class));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) Test(org.junit.Test)

Example 4 with Screening

use of gov.ca.cwds.data.persistence.ns.Screening in project API by ca-cwds.

the class ScreeningServiceTest method updateReturnsCorrectScreeningResponseOnSuccess.

@Test
public void updateReturnsCorrectScreeningResponseOnSuccess() throws Exception {
    roles.add("victim");
    gov.ca.cwds.rest.api.domain.Address domainAddress = new gov.ca.cwds.rest.api.domain.Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "home");
    addresses.add(domainAddress);
    ScreeningRequest screeningRequest = new ScreeningRequest("ref", "2016-10-31", "Sac", "2016-10-31", "loc", "comm", "name", "now", "sure", "2016-10-31", "narrative", domainAddress);
    Participant bart = new Participant(1, "", "", "Bart", "Simpson", "male", "123456789", "2016-10-31", 1234, 1234, roles, addresses);
    Participant maggie = new Participant(2, "", "", "Maggie", "Simpson", "female", "123456789", "2016-10-31", 1234, 1234, roles, addresses);
    // Participant bart = new Participant(1, 123, "Bart", "Simpson", "M", "2016-10-31",
    // "123456789");
    // Participant maggie = new Participant(2, 1, "Maggie", "Simpson", "M", "2016-10-31",
    // "123456789");
    ImmutableSet.Builder<gov.ca.cwds.data.persistence.ns.Participant> peopleListBuilder = ImmutableSet.builder();
    ImmutableSet<gov.ca.cwds.data.persistence.ns.Participant> people = peopleListBuilder.add(new gov.ca.cwds.data.persistence.ns.Participant(bart, null, null)).add(new gov.ca.cwds.data.persistence.ns.Participant(maggie, null, null)).build();
    gov.ca.cwds.data.persistence.ns.Screening screening = new gov.ca.cwds.data.persistence.ns.Screening(1L, screeningRequest, new Address(domainAddress, null, null), people, null, null);
    when(screeningDao.find(new Long(123))).thenReturn(screening);
    when(screeningDao.update(any())).thenReturn(screening);
    ScreeningResponse expected = new ScreeningResponse(screening, people);
    ScreeningResponse updated = screeningService.update(1L, screeningRequest);
    assertThat(updated, is(expected));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.data.persistence.ns.Screening) Participant(gov.ca.cwds.rest.api.domain.Participant) ImmutableSet(com.google.common.collect.ImmutableSet) Screening(gov.ca.cwds.data.persistence.ns.Screening) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) Test(org.junit.Test)

Example 5 with Screening

use of gov.ca.cwds.data.persistence.ns.Screening 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

Screening (gov.ca.cwds.data.persistence.ns.Screening)5 PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)5 Test (org.junit.Test)5 ScreeningReference (gov.ca.cwds.rest.api.domain.ScreeningReference)3 Address (gov.ca.cwds.data.persistence.ns.Address)2 ScreeningRequest (gov.ca.cwds.rest.api.domain.ScreeningRequest)2 ScreeningResponse (gov.ca.cwds.rest.api.domain.ScreeningResponse)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Participant (gov.ca.cwds.rest.api.domain.Participant)1