Search in sources :

Example 1 with AllegationPerpetratorHistory

use of gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryDaoIT method testFindEntityNotFoundException.

@Override
@Test
public void testFindEntityNotFoundException() throws Exception {
    AllegationPerpetratorHistory found = allegationPerpetratorHistoryDao.find("9999999ZZZ");
    assertThat(found, is(nullValue()));
}
Also used : AllegationPerpetratorHistory(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Example 2 with AllegationPerpetratorHistory

use of gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryDaoIT method testDelete.

/**
   * Delete JUnit test
   */
@Override
@Test
public void testDelete() throws Exception {
    AllegationPerpetratorHistory deleted = allegationPerpetratorHistoryDao.delete(id);
    assertThat(deleted.getId(), is(id));
}
Also used : AllegationPerpetratorHistory(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Example 3 with AllegationPerpetratorHistory

use of gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryService method update.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#update(java.io.Serializable,
   *      gov.ca.cwds.rest.api.Request)
   */
@Override
public gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory update(Serializable primaryKey, Request request) {
    assert primaryKey instanceof String;
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory;
    gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = (gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        AllegationPerpetratorHistory managed = new AllegationPerpetratorHistory((String) primaryKey, allegationPerpetratorHistory, lastUpdatedId);
        managed = allegationPerpetratorHistoryDao.update(managed);
        return new gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory(managed);
    } catch (EntityNotFoundException e) {
        LOGGER.info("AllegationPerpetratorHistory not found : {}", allegationPerpetratorHistory);
        throw new ServiceException(e);
    }
}
Also used : ServiceException(gov.ca.cwds.rest.services.ServiceException) AllegationPerpetratorHistory(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) EntityNotFoundException(javax.persistence.EntityNotFoundException)

Example 4 with AllegationPerpetratorHistory

use of gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryService method create.

/**
   * {@inheritDoc}
   * 
   * @see gov.ca.cwds.rest.services.CrudsService#create(gov.ca.cwds.rest.api.Request)
   */
@Override
public PostedAllegationPerpetratorHistory create(Request request) {
    assert request instanceof gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory;
    gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory allegationPerpetratorHistory = (gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory) request;
    try {
        String lastUpdatedId = staffPersonIdRetriever.getStaffPersonId();
        AllegationPerpetratorHistory managed = new AllegationPerpetratorHistory(CmsKeyIdGenerator.cmsIdGenertor(lastUpdatedId), allegationPerpetratorHistory, lastUpdatedId);
        managed = allegationPerpetratorHistoryDao.create(managed);
        return new PostedAllegationPerpetratorHistory(managed);
    } catch (EntityExistsException e) {
        LOGGER.info("AllegationPerpetratorHistory already exists : {}", allegationPerpetratorHistory);
        throw new ServiceException(e);
    }
}
Also used : PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) AllegationPerpetratorHistory(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) PostedAllegationPerpetratorHistory(gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory) EntityExistsException(javax.persistence.EntityExistsException) ServiceException(gov.ca.cwds.rest.services.ServiceException)

Example 5 with AllegationPerpetratorHistory

use of gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory in project API by ca-cwds.

the class AllegationPerpetratorHistoryDaoIT method testCreate.

/**
   * Create JUnit test
   */
@Override
@Test
public void testCreate() throws Exception {
    gov.ca.cwds.rest.api.domain.cms.AllegationPerpetratorHistory vdaph = validDomainAllegationPerpetratorHistory();
    AllegationPerpetratorHistory allegationPerpetratorHistory = new AllegationPerpetratorHistory("1234567ABC", vdaph.getCountySpecificCode(), vdaph.getVictimClientId(), vdaph.getAllegationId(), DomainChef.uncookDateString(vdaph.getPerpetratorUpdateDate()));
    AllegationPerpetratorHistory create = allegationPerpetratorHistoryDao.create(allegationPerpetratorHistory);
    assertThat(allegationPerpetratorHistory, is(create));
}
Also used : AllegationPerpetratorHistory(gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory) Test(org.junit.Test)

Aggregations

AllegationPerpetratorHistory (gov.ca.cwds.data.persistence.cms.AllegationPerpetratorHistory)10 Test (org.junit.Test)8 PostedAllegationPerpetratorHistory (gov.ca.cwds.rest.api.domain.cms.PostedAllegationPerpetratorHistory)2 ServiceException (gov.ca.cwds.rest.services.ServiceException)2 EntityExistsException (javax.persistence.EntityExistsException)1 EntityNotFoundException (javax.persistence.EntityNotFoundException)1