use of gov.ca.cwds.rest.api.domain.Person in project API by ca-cwds.
the class PersonServiceTest method findReturnsNullWhenNotFound.
@Test
public void findReturnsNullWhenNotFound() throws Exception {
when(personDao.find(new Long(-1))).thenReturn(null);
Person found = personService.find(new Long(-1));
assertThat(found, is(nullValue()));
}
use of gov.ca.cwds.rest.api.domain.Person in project API by ca-cwds.
the class PersonServiceTest method createReturnsNonNull.
@Test
public void createReturnsNonNull() throws Exception {
gov.ca.cwds.data.persistence.ns.Address toCreateAddress = new gov.ca.cwds.data.persistence.ns.Address(1L, "742 Evergreen Terrace", "Springfield", "WA", new Integer(98700), "Home");
Set<PersonAddress> personAddresses = new HashSet<>();
PersonAddress personAddress = new PersonAddress();
personAddress.setAddress(toCreateAddress);
personAddresses.add(personAddress);
gov.ca.cwds.data.persistence.ns.Person toCreate = new gov.ca.cwds.data.persistence.ns.Person(2L, "Bart", "Simpson", "M", DomainChef.uncookDateString("2016-10-31"), "1234556789", personAddresses, null, null, null, null);
Person request = new Person(toCreate);
when(personDao.create(any(gov.ca.cwds.data.persistence.ns.Person.class))).thenReturn(toCreate);
when(personDao.find(any(gov.ca.cwds.data.persistence.ns.Person.class))).thenReturn(toCreate);
PostedPerson postedPerson = personService.create(request);
assertThat(postedPerson, is(notNullValue()));
}
use of gov.ca.cwds.rest.api.domain.Person in project API by ca-cwds.
the class PersonServiceTest method updateThrowsNullPointeException.
/*
* update tests
*/
@Test
public void updateThrowsNullPointeException() throws Exception {
thrown.expect(NullPointerException.class);
Address address = new Address("", "", "742 Evergreen Terrace", "Springfield", "WA", 98700, "Home");
Set<Address> addresses = new HashSet<>();
addresses.add(address);
Person toUpdate = new Person("Bart", "Simpson", "M", "2013-10-31", "1234556789", addresses, null, null, null, null);
personService.update(1L, toUpdate);
}
use of gov.ca.cwds.rest.api.domain.Person in project API by ca-cwds.
the class PersonResourceTest method createDelegatesToCrudsResource.
/**
* Create Tests
*
* @throws Exception required for test compilation
*/
@Test
public void createDelegatesToCrudsResource() throws Exception {
Person person = new Person("firstname", "last", "M", "1990-11-22", "000000000", null, null, null, null, null);
inMemoryResource.client().target(ROOT_RESOURCE).request().accept(MediaType.APPLICATION_JSON).post(Entity.entity(person, MediaType.APPLICATION_JSON));
verify(resourceDelegate, atLeastOnce()).create(eq(person));
}
use of gov.ca.cwds.rest.api.domain.Person in project API by ca-cwds.
the class PersonService method update.
/**
* <strong>NOT IMPLEMENTED! REQUIRED BY {@link CrudsService}!</strong> {@inheritDoc}
*
* @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
* gov.ca.cwds.rest.api.Request)
*/
@Override
public Response update(final Serializable primaryKey, Request request) {
assert primaryKey instanceof Long;
assert request instanceof Person;
Person person = (Person) request;
gov.ca.cwds.data.persistence.ns.Person managedPerson = new gov.ca.cwds.data.persistence.ns.Person(person, null, null);
managedPerson = personDao.update(managedPerson);
populatePersonDetails(person, managedPerson);
managedPerson = personDao.find(managedPerson.getId());
PostedPerson postedPerson = new PostedPerson(managedPerson);
return postedPerson;
}
Aggregations