Search in sources :

Example 41 with RowCallbackHandler

use of org.springframework.jdbc.core.RowCallbackHandler in project dhis2-core by dhis2.

the class TrackedEntityProgramAttributeEncryptionTest method testTrackedEntityProgramAttributeEncryptedValue.

@Test
void testTrackedEntityProgramAttributeEncryptedValue() throws IOException {
    TrackerImportParams trackerImportParams = fromJson("tracker/te_program_with_tea_encryption_data.json");
    TrackerBundle trackerBundle = trackerBundleService.create(trackerImportParams);
    trackerBundleService.commit(trackerBundle);
    List<TrackedEntityInstance> trackedEntityInstances = manager.getAll(TrackedEntityInstance.class);
    assertEquals(1, trackedEntityInstances.size());
    TrackedEntityInstance trackedEntityInstance = trackedEntityInstances.get(0);
    List<TrackedEntityAttributeValue> attributeValues = trackedEntityAttributeValueService.getTrackedEntityAttributeValues(trackedEntityInstance);
    assertEquals(5, attributeValues.size());
    // not really a great test, but we are using a random seed for salt, so
    // it changes on every run... we might want to
    // add another EncryptionConfig test profile
    RowCallbackHandler handler = resultSet -> assertNotNull(resultSet.getString("encryptedvalue"));
    jdbcTemplate.query("select * from trackedentityattributevalue where encryptedvalue is not null ", handler);
}
Also used : Assertions.assertNotNull(org.junit.jupiter.api.Assertions.assertNotNull) TrackedEntityAttributeValueService(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValueService) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) Autowired(org.springframework.beans.factory.annotation.Autowired) IOException(java.io.IOException) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) JdbcTemplate(org.springframework.jdbc.core.JdbcTemplate) Test(org.junit.jupiter.api.Test) TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) List(java.util.List) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) TrackerTest(org.hisp.dhis.tracker.TrackerTest) IdentifiableObjectManager(org.hisp.dhis.common.IdentifiableObjectManager) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) TrackerImportParams(org.hisp.dhis.tracker.TrackerImportParams) TrackedEntityAttributeValue(org.hisp.dhis.trackedentityattributevalue.TrackedEntityAttributeValue) TrackedEntityInstance(org.hisp.dhis.trackedentity.TrackedEntityInstance) RowCallbackHandler(org.springframework.jdbc.core.RowCallbackHandler) Test(org.junit.jupiter.api.Test) TrackerTest(org.hisp.dhis.tracker.TrackerTest)

Aggregations

RowCallbackHandler (org.springframework.jdbc.core.RowCallbackHandler)41 ResultSet (java.sql.ResultSet)38 SQLException (java.sql.SQLException)37 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)6 LinkedHashMap (java.util.LinkedHashMap)4 MapSqlParameterSource (org.springframework.jdbc.core.namedparam.MapSqlParameterSource)4 DataPointVO (com.serotonin.m2m2.vo.DataPointVO)3 Date (java.util.Date)3 Map (java.util.Map)3 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)3 JdbcTemplate (org.springframework.jdbc.core.JdbcTemplate)3 ExportDataValue (com.serotonin.m2m2.vo.export.ExportDataValue)2 ExportPointInfo (com.serotonin.m2m2.vo.export.ExportPointInfo)2 TIntArrayList (gnu.trove.list.array.TIntArrayList)2 IOException (java.io.IOException)2 LinkedList (java.util.LinkedList)2 List (java.util.List)2 Calendar (org.hisp.dhis.calendar.Calendar)2 PeriodType (org.hisp.dhis.period.PeriodType)2