Search in sources :

Example 1 with PostedAddress

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

the class AddressServiceTest method testCreateReturnsPostedClass.

@Override
@Test
public void testCreateReturnsPostedClass() throws Exception {
    gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address(1L, "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 postedAddress = addressService.create(request);
    assertThat(postedAddress.getClass(), is(PostedAddress.class));
}
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 2 with PostedAddress

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

the class AddressServiceTest method testCreateReturnsCorrectEntity.

@Override
@Test
public void testCreateReturnsCorrectEntity() throws Exception {
    gov.ca.cwds.data.persistence.ns.Address toCreate = new gov.ca.cwds.data.persistence.ns.Address(10L, "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(10, "", "", "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
    PostedAddress returned = addressService.create(request);
    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 3 with PostedAddress

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

the class AddressService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public PostedAddress create(Request request) {
    assert request instanceof Address;
    Address address = (Address) request;
    gov.ca.cwds.data.persistence.ns.Address managed = new gov.ca.cwds.data.persistence.ns.Address(address, null, null);
    managed = addressDao.create(managed);
    return new PostedAddress(managed);
}
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)

Example 4 with PostedAddress

use of gov.ca.cwds.rest.api.domain.PostedAddress 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)

Aggregations

Address (gov.ca.cwds.rest.api.domain.Address)4 PostedAddress (gov.ca.cwds.rest.api.domain.PostedAddress)4 Test (org.junit.Test)3