Search in sources :

Example 1 with PostedPhoneNumber

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

the class PhoneNumberServiceTest method testCreateReturnsPostedClass.

@Test
@Override
public void testCreateReturnsPostedClass() throws Exception {
    gov.ca.cwds.data.persistence.ns.PhoneNumber toCreate = new gov.ca.cwds.data.persistence.ns.PhoneNumber(1L, "408 987-6543", "Home");
    PhoneNumber request = new PhoneNumber(toCreate);
    when(phoneNumberDao.create(any(gov.ca.cwds.data.persistence.ns.PhoneNumber.class))).thenReturn(toCreate);
    PostedPhoneNumber postedPhoneNumber = phoneNumberService.create(request);
    assertThat(postedPhoneNumber.getClass(), is(PostedPhoneNumber.class));
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Example 2 with PostedPhoneNumber

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

the class PhoneNumberServiceTest method testCreateReturnsCorrectEntity.

@Test
@Override
public void testCreateReturnsCorrectEntity() throws Exception {
    gov.ca.cwds.data.persistence.ns.PhoneNumber toCreate = new gov.ca.cwds.data.persistence.ns.PhoneNumber(10L, "408 987-6543", "Home");
    PhoneNumber request = new PhoneNumber(toCreate);
    when(phoneNumberDao.create(any(gov.ca.cwds.data.persistence.ns.PhoneNumber.class))).thenReturn(toCreate);
    PostedPhoneNumber expected = new PostedPhoneNumber(10, "408 987-6543", "Home");
    PostedPhoneNumber returned = phoneNumberService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Example 3 with PostedPhoneNumber

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

the class PhoneNumberServiceTest method testCreateExistsError.

@SuppressWarnings("javadoc")
@Test
public void testCreateExistsError() throws Exception {
    gov.ca.cwds.data.persistence.ns.PhoneNumber toCreate = new gov.ca.cwds.data.persistence.ns.PhoneNumber((long) 1, "408 987-6543", "Home");
    PhoneNumber request = new PhoneNumber(toCreate);
    when(phoneNumberDao.create(any(gov.ca.cwds.data.persistence.ns.PhoneNumber.class))).thenReturn(toCreate);
    PostedPhoneNumber expected = new PostedPhoneNumber(1, "408 987-6543", "Home");
    PostedPhoneNumber returned = phoneNumberService.create(request);
    assertThat(returned, is(expected));
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) Test(org.junit.Test)

Example 4 with PostedPhoneNumber

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

the class PhoneNumberService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public PostedPhoneNumber create(Request request) {
    assert request instanceof PhoneNumber;
    PhoneNumber phoneNumber = (PhoneNumber) request;
    gov.ca.cwds.data.persistence.ns.PhoneNumber managed = new gov.ca.cwds.data.persistence.ns.PhoneNumber(phoneNumber, null, null);
    managed = phoneNumberDao.create(managed);
    return new PostedPhoneNumber(managed);
}
Also used : PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PostedPhoneNumber(gov.ca.cwds.rest.api.domain.PostedPhoneNumber) PhoneNumber(gov.ca.cwds.rest.api.domain.PhoneNumber)

Aggregations

PhoneNumber (gov.ca.cwds.rest.api.domain.PhoneNumber)4 PostedPhoneNumber (gov.ca.cwds.rest.api.domain.PostedPhoneNumber)4 Test (org.junit.Test)3