Skip to content

Commit

Permalink
Add a test
Browse files Browse the repository at this point in the history
  • Loading branch information
jamesagnew committed Feb 19, 2020
1 parent a05c4ce commit 79ad0ae
Showing 1 changed file with 32 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,38 @@ public void testVRead() {
assertEquals(0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size());
}


@Test
public void testCreateWithClientAssignedId() {
myDaoConfig.setIndexMissingFields(DaoConfig.IndexEnabledEnum.DISABLED);

runInTransaction(() -> {
Patient p = new Patient();
p.getMaritalStatus().setText("123");
return myPatientDao.create(p).getId().toUnqualified();
});

myCaptureQueriesListener.clear();

runInTransaction(() -> {
Patient p = new Patient();
p.setId("AAA");
p.getMaritalStatus().setText("123");
return myPatientDao.update(p).getId().toUnqualified();
});

myCaptureQueriesListener.logSelectQueriesForCurrentThread();
assertEquals(1, myCaptureQueriesListener.getSelectQueriesForCurrentThread().size());
myCaptureQueriesListener.logUpdateQueriesForCurrentThread();
assertEquals(0, myCaptureQueriesListener.getUpdateQueriesForCurrentThread().size());
myCaptureQueriesListener.logInsertQueriesForCurrentThread();
assertEquals(4, myCaptureQueriesListener.getInsertQueriesForCurrentThread().size());
myCaptureQueriesListener.logDeleteQueriesForCurrentThread();
assertEquals(0, myCaptureQueriesListener.getDeleteQueriesForCurrentThread().size());
}



@AfterClass
public static void afterClassClearContext() {
TestUtil.clearAllStaticFieldsForUnitTest();
Expand Down

0 comments on commit 79ad0ae

Please sign in to comment.