Search in sources :

Example 1 with Address

use of gov.ca.cwds.data.persistence.ns.Address in project API by ca-cwds.

the class AddressDaoIT method testUpdate.

@Override
@Test
public void testUpdate() {
    Address address = new Address(1L, "123 Main Street", "SAC", "CA", 95757, "Home");
    Address updated = addressDao.update(address);
    assertThat(updated, is(address));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) Test(org.junit.Test)

Example 2 with Address

use of gov.ca.cwds.data.persistence.ns.Address in project API by ca-cwds.

the class AddressDaoIT method testFind.

@Override
@Test
public void testFind() {
    long id = 1;
    Address found = addressDao.find(id);
    assertThat(found.getId(), is(id));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) Test(org.junit.Test)

Example 3 with Address

use of gov.ca.cwds.data.persistence.ns.Address in project API by ca-cwds.

the class AddressDaoIT method testDeleteEntityNotFoundException.

@Override
@Test
public void testDeleteEntityNotFoundException() throws Exception {
    Address updated = addressDao.delete((long) 99);
    assertThat(updated, is(nullValue()));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) Test(org.junit.Test)

Example 4 with Address

use of gov.ca.cwds.data.persistence.ns.Address in project API by ca-cwds.

the class AddressDaoIT method testCreate.

@Override
@Test
public void testCreate() {
    Address address = new Address(null, "123 Main Street", "SAC", "CA", 95757, "Home");
    Address created = addressDao.create(address);
    assertThat(created, is(address));
}
Also used : Address(gov.ca.cwds.data.persistence.ns.Address) Test(org.junit.Test)

Example 5 with Address

use of gov.ca.cwds.data.persistence.ns.Address in project API by ca-cwds.

the class ScreeningService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public ScreeningResponse update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof Long;
    assert request instanceof ScreeningRequest;
    ScreeningRequest screeningRequest = (ScreeningRequest) request;
    Set<gov.ca.cwds.data.persistence.ns.Participant> participants = new HashSet<>();
    Address address = new Address(screeningRequest.getAddress(), null, null);
    gov.ca.cwds.data.persistence.ns.Screening screening = new gov.ca.cwds.data.persistence.ns.Screening((Long) primaryKey, screeningRequest, address, participants, null, null);
    screening = screeningDao.update(screening);
    if (screeningDao.getSessionFactory() != null) {
        screeningDao.getSessionFactory().getCurrentSession().flush();
        screeningDao.getSessionFactory().getCurrentSession().refresh(screening);
    }
    return new ScreeningResponse(screening, screening.getParticipants());
}
Also used : ScreeningRequest(gov.ca.cwds.rest.api.domain.ScreeningRequest) Address(gov.ca.cwds.data.persistence.ns.Address) Restrictions(org.hibernate.criterion.Restrictions) PostedScreening(gov.ca.cwds.rest.api.domain.PostedScreening) Screening(gov.ca.cwds.rest.api.domain.Screening) ScreeningResponse(gov.ca.cwds.rest.api.domain.ScreeningResponse) HashSet(java.util.HashSet)

Aggregations

Address (gov.ca.cwds.data.persistence.ns.Address)11 Test (org.junit.Test)10 PostedScreening (gov.ca.cwds.rest.api.domain.PostedScreening)3 ScreeningRequest (gov.ca.cwds.rest.api.domain.ScreeningRequest)3 ScreeningResponse (gov.ca.cwds.rest.api.domain.ScreeningResponse)3 Screening (gov.ca.cwds.data.persistence.ns.Screening)2 ImmutableSet (com.google.common.collect.ImmutableSet)1 Participant (gov.ca.cwds.rest.api.domain.Participant)1 Screening (gov.ca.cwds.rest.api.domain.Screening)1 HashSet (java.util.HashSet)1 Restrictions (org.hibernate.criterion.Restrictions)1