Search in sources :

Example 16 with Address

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

the class ScreeningResourceTest method updateDelegatesToResourceDelegate.

/*
   * Update Tests
   */
@Test
public void updateDelegatesToResourceDelegate() throws Exception {
    Address address = new Address("", "", "10 main st", "Sacramento", "CA", 95814, "home");
    ImmutableList.Builder<Long> builder = ImmutableList.builder();
    ScreeningRequest screeningRequest = new ScreeningRequest("X5HNJK", "1973-11-22", "Amador", "1973-11-22", "Home", "email", "First screening", "immediate", "accept_for_investigation", "2016-10-11", "first narrative", address);
    inMemoryResource.client().target(FOUND_RESOURCE).request().accept(MediaType.APPLICATION_JSON).put(Entity.entity(screeningRequest, MediaType.APPLICATION_JSON));
    verify(resourceDelegate).update(eq(new Long(1)), eq(screeningRequest));
}
Also used : Address(gov.ca.cwds.rest.api.domain.Address) ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) ImmutableList(com.google.common.collect.ImmutableList) Test(org.junit.Test)

Example 17 with Address

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

the class AddressServiceTest method testCreateExistsError.

@SuppressWarnings("javadoc")
@Test
public void testCreateExistsError() throws Exception {
    gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address((long) 1, "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
    Address request = new Address(toCreate);
    when(addressDao.create(any(gov.ca.cwds.data.persistence.ns.Address.class))).thenReturn(toCreate);
    PostedAddress expected = new PostedAddress(1, "", "", "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
    PostedAddress returned = addressService.create(request);
    // String e = MAPPER.writeValueAsString(expected);
    // System.out.println(e);
    // String r = MAPPER.writeValueAsString(returned);
    // System.out.println(r);
    assertThat(returned, is(expected));
}
Also used : PostedAddress(gov.ca.cwds.rest.api.domain.PostedAddress) Address(gov.ca.cwds.rest.api.domain.Address) PostedAddress(gov.ca.cwds.rest.api.domain.PostedAddress) Test(org.junit.Test)

Example 18 with Address

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

the class AddressResourceTest method testPostDelegatesToResourceDelegate.

/*
   * Create Tests
   */
@SuppressWarnings("javadoc")
@Test
public void testPostDelegatesToResourceDelegate() throws Exception {
    Address address = new Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "Home");
    inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(address, MediaType.APPLICATION_JSON)).getStatus();
    verify(resourceDelegate, atLeastOnce()).create(eq(address));
}
Also used : Address(gov.ca.cwds.rest.api.domain.Address) Test(org.junit.Test)

Example 19 with Address

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

the class ParticipantResourceTest method testPostValidatesEntity.

@Override
@Test
public void testPostValidatesEntity() throws Exception {
    roles.add("victim");
    Address address = new Address("", "", "123 First St", "San Jose", "CA", 94321, "Home");
    addresses.add(address);
    Participant participant = new Participant(1, "", "", "Marge", "Simpson", "Female", "11122333", "11-01-2017", 123, 456, roles, addresses);
    int status = inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(participant, MediaType.APPLICATION_JSON)).getStatus();
    assertThat(status, is(422));
}
Also used : Address(gov.ca.cwds.rest.api.domain.Address) Participant(gov.ca.cwds.rest.api.domain.Participant) Test(org.junit.Test)

Example 20 with Address

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

the class ParticipantResourceTest method testDelete200ResourceSuccess.

@Override
@Test
public void testDelete200ResourceSuccess() throws Exception {
    roles.add("victim");
    Address address = new Address("", "", "123 First St", "San Jose", "CA", 94321, "Home");
    addresses.add(address);
    Participant participant = new Participant(1, "", "", "Marge", "Simpson", "Female", "111223333", "2017-01-23", 123, 456, roles, addresses);
    int status = inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(participant, MediaType.APPLICATION_JSON)).getStatus();
    assertThat(status, is(204));
}
Also used : Address(gov.ca.cwds.rest.api.domain.Address) Participant(gov.ca.cwds.rest.api.domain.Participant) Test(org.junit.Test)

Aggregations

Address (gov.ca.cwds.rest.api.domain.Address)21 Test (org.junit.Test)19 PostedAddress (gov.ca.cwds.rest.api.domain.PostedAddress)7 PersonAddress (gov.ca.cwds.data.persistence.ns.PersonAddress)3 Participant (gov.ca.cwds.rest.api.domain.Participant)3 Ethnicity (gov.ca.cwds.rest.api.domain.Ethnicity)2 Language (gov.ca.cwds.rest.api.domain.Language)2 Person (gov.ca.cwds.rest.api.domain.Person)2 PhoneNumber (gov.ca.cwds.rest.api.domain.PhoneNumber)2 PostedPerson (gov.ca.cwds.rest.api.domain.PostedPerson)2 Race (gov.ca.cwds.rest.api.domain.Race)2 HashSet (java.util.HashSet)2 ImmutableList (com.google.common.collect.ImmutableList)1 PersonEthnicity (gov.ca.cwds.data.persistence.ns.PersonEthnicity)1 PersonLanguage (gov.ca.cwds.data.persistence.ns.PersonLanguage)1 PersonPhone (gov.ca.cwds.data.persistence.ns.PersonPhone)1 PersonRace (gov.ca.cwds.data.persistence.ns.PersonRace)1 ScreeningRequest (gov.ca.cwds.rest.api.domain.ScreeningRequest)1