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));
}
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));
}
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));
}
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);
}
Aggregations