Search in sources :

Example 6 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class OptimisticLockingTest method testNoTimestampPropagationToUI.

@Test
public void testNoTimestampPropagationToUI() throws Exception {
    cleanAllAndInsert("/dbunit/OptimisticLocking.xml");
    final ChildClientHolder childClientHolder = new ChildClientHolder();
    // read entity from DB
    executeInTransaction(sessionFactory, (sessionFactory) -> {
        Client client = dao.find(ID);
        assertNotNull(client);
        assertTrue(client instanceof ChildClient);
        ChildClient childClient = (ChildClient) client;
        assertEquals(AdoptionStatus.NOT_FREE, childClient.getAdoptionStatus());
        childClientHolder.setChildClient(childClient);
    });
    // UI edit
    childClientHolder.getChildClient().setLastUpdateTime(null);
    childClientHolder.getChildClient().setAdoptionStatus(AdoptionStatus.TOTALLY_FREE);
    // recreate entity  and attempt to persist
    try {
        executeInTransaction(sessionFactory, (sessionFactory) -> {
            Session session = sessionFactory.getCurrentSession();
            ChildClient childClient = childClientHolder.getChildClient();
            // populate lastUpdateTime by current time
            childClient.setLastUpdateTime(Timestamp.valueOf(LocalDateTime.now()));
            dao.update(childClient);
        });
        fail("OptimisticLockException should be thrown");
    } catch (OptimisticLockException e) {
    }
}
Also used : OptimisticLockException(javax.persistence.OptimisticLockException) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Client(gov.ca.cwds.data.legacy.cms.entity.Client) ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Session(org.hibernate.Session) Test(org.junit.Test) BaseCwsCmsInMemoryPersistenceTest(gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)

Example 7 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class R10104Test method birthDateAndTribalDateAreNotPresent.

@Test
public void birthDateAndTribalDateAreNotPresent() throws Exception {
    ChildClient childClient = ClientTestUtil.childClient(ClientTestUtil.CHILD_CLIENT_ID);
    clientEntityAwareDTO.setEntity(childClient);
    checkRuleSatisfied(RULE_NAME);
}
Also used : ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test)

Example 8 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class R10326Test method testScreeningDateNull.

@Test
public void testScreeningDateNull() throws Exception {
    ChildClient childClient = childClient(SOME_DATE);
    checkRuleSatisfied(dto(childClient, healthScreening(childClient, null)), RULE_NAME);
}
Also used : ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test)

Example 9 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class R10326Test method testScreeningDateEqBirthDate.

@Test
public void testScreeningDateEqBirthDate() throws Exception {
    ChildClient childClient = childClient(SOME_DATE);
    checkRuleSatisfied(dto(childClient, healthScreening(childClient, SOME_DATE)), RULE_NAME);
}
Also used : ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test)

Example 10 with ChildClient

use of gov.ca.cwds.data.legacy.cms.entity.ChildClient in project api-core by ca-cwds.

the class R10326Test method testBirthDateNull.

@Test
public void testBirthDateNull() throws Exception {
    ChildClient childClient = childClient(null);
    checkRuleSatisfied(dto(childClient, healthScreening(childClient, SOME_DATE)), RULE_NAME);
}
Also used : ChildClient(gov.ca.cwds.data.legacy.cms.entity.ChildClient) Test(org.junit.Test)

Aggregations

ChildClient (gov.ca.cwds.data.legacy.cms.entity.ChildClient)42 Test (org.junit.Test)32 BaseCwsCmsInMemoryPersistenceTest (gov.ca.cwds.data.legacy.cms.persistence.BaseCwsCmsInMemoryPersistenceTest)7 Client (gov.ca.cwds.data.legacy.cms.entity.Client)5 FCEligibility (gov.ca.cwds.data.legacy.cms.entity.FCEligibility)3 Timestamp (java.sql.Timestamp)3 OptimisticLockException (javax.persistence.OptimisticLockException)2 Session (org.hibernate.Session)2 Before (org.junit.Before)2 ClientOtherEthnicity (gov.ca.cwds.data.legacy.cms.entity.ClientOtherEthnicity)1 MedicalEligibilityApplication (gov.ca.cwds.data.legacy.cms.entity.MedicalEligibilityApplication)1