Search in sources :

Example 6 with ExportHistory

use of net.geoprism.registry.etl.export.ExportHistory in project geoprism-registry by terraframe.

the class DHIS2ServiceTest method testExportGeoObjects.

@Request
@Test
public void testExportGeoObjects() throws InterruptedException {
    SynchronizationConfig config = createSyncConfig(this.system, null);
    SynchronizationConfigService service = new SynchronizationConfigService();
    JsonObject joHist = service.run(testData.clientSession.getSessionId(), config.getOid());
    ExportHistory hist = ExportHistory.get(joHist.get("historyId").getAsString());
    SchedulerTestUtils.waitUntilStatus(hist.getOid(), AllJobStatus.SUCCESS);
    hist = ExportHistory.get(hist.getOid());
    Assert.assertEquals(new Long(1), hist.getWorkTotal());
    Assert.assertEquals(new Long(1), hist.getWorkProgress());
    Assert.assertEquals(ImportStage.COMPLETE.name(), hist.getStage().get(0).name());
    LinkedList<Dhis2Payload> payloads = this.dhis2.getPayloads();
    Assert.assertEquals(1, payloads.size());
    Dhis2Payload payload = payloads.get(0);
    JsonObject data = JsonParser.parseString(payload.getData()).getAsJsonObject();
    JsonArray orgUnits = data.get("organisationUnits").getAsJsonArray();
    Assert.assertEquals(1, orgUnits.size());
    JsonObject orgUnit = orgUnits.get(0).getAsJsonObject();
    Assert.assertEquals("AllAttrGO_ALL", orgUnit.get("code").getAsString());
}
Also used : JsonArray(com.google.gson.JsonArray) ExportHistory(net.geoprism.registry.etl.export.ExportHistory) SynchronizationConfigService(net.geoprism.registry.service.SynchronizationConfigService) JsonObject(com.google.gson.JsonObject) SynchronizationConfig(net.geoprism.registry.SynchronizationConfig) Dhis2Payload(net.geoprism.registry.etl.DHIS2TestService.Dhis2Payload) Test(org.junit.Test) Request(com.runwaysdk.session.Request)

Aggregations

ExportHistory (net.geoprism.registry.etl.export.ExportHistory)6 JsonObject (com.google.gson.JsonObject)4 Request (com.runwaysdk.session.Request)4 DataExportJob (net.geoprism.registry.etl.export.DataExportJob)4 GeoprismUser (net.geoprism.GeoprismUser)3 SynchronizationConfig (net.geoprism.registry.SynchronizationConfig)3 JsonArray (com.google.gson.JsonArray)2 Dhis2Payload (net.geoprism.registry.etl.DHIS2TestService.Dhis2Payload)2 QueryFactory (com.runwaysdk.query.QueryFactory)1 HashMap (java.util.HashMap)1 LinkedList (java.util.LinkedList)1 DataExportJobQuery (net.geoprism.registry.etl.export.DataExportJobQuery)1 ExportHistoryQuery (net.geoprism.registry.etl.export.ExportHistoryQuery)1 SynchronizationConfigService (net.geoprism.registry.service.SynchronizationConfigService)1 JsonWrapper (net.geoprism.registry.view.JsonWrapper)1 AttributeBooleanType (org.commongeoregistry.adapter.metadata.AttributeBooleanType)1 AttributeDateType (org.commongeoregistry.adapter.metadata.AttributeDateType)1 AttributeFloatType (org.commongeoregistry.adapter.metadata.AttributeFloatType)1 AttributeIntegerType (org.commongeoregistry.adapter.metadata.AttributeIntegerType)1 AttributeTermType (org.commongeoregistry.adapter.metadata.AttributeTermType)1