Search in sources :

Example 1 with ResourceStoreImpl

use of org.hisp.dhis.android.core.resource.ResourceStoreImpl in project dhis2-android-sdk by dhis2.

the class TrackedEntityCallMockIntegrationShould method setUp.

@Before
@Override
public void setUp() throws IOException {
    super.setUp();
    server = new MockWebServer();
    server.start();
    MockResponse response = new MockResponse();
    response.setHeader(HeaderUtils.DATE, "Tue, 21 Feb 2017 15:44:46 GMT");
    response.setResponseCode(200);
    response.setBody("{\n" + "  \"trackedEntities\": [\n" + "  {\n" + "    \"lastUpdated\": \"2014-04-14T13:54:54.497\",\n" + "    \"created\": \"2014-04-14T13:54:54.497\",\n" + "    \"name\": \"Lab sample\",\n" + "    \"id\": \"kIeke8tAQnd\",\n" + "    \"displayDescription\": \"Lab sample\",\n" + "    \"displayName\": \"Lab sample\",\n" + "    \"description\": \"Lab sample\"\n" + "  },\n" + "  {\n" + "    \"lastUpdated\": \"2015-10-14T13:36:53.063\",\n" + "    \"created\": \"2014-08-20T12:28:56.409\",\n" + "    \"name\": \"Person\",\n" + "    \"id\": \"nEenWmSyUEp\",\n" + "    \"displayDescription\": \"Person\",\n" + "    \"displayName\": \"Person\",\n" + "    \"description\": \"Person\"\n" + "  }\n" + " ]\n" + "}");
    server.enqueue(response);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setDateFormat(BaseIdentifiableObject.DATE_FORMAT.raw());
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    Retrofit retrofit = new Retrofit.Builder().baseUrl(// ??
    server.url("/")).addConverterFactory(JacksonConverterFactory.create(objectMapper)).addConverterFactory(FieldsConverterFactory.create()).addConverterFactory(FilterConverterFactory.create()).build();
    TrackedEntityService service = retrofit.create(TrackedEntityService.class);
    HashSet<String> uids = new HashSet<>(Arrays.asList("kIeke8tAQnd", "nEenWmSyUEp"));
    TrackedEntityStore trackedEntityStore = new TrackedEntityStoreImpl(databaseAdapter());
    ResourceStore resourceStore = new ResourceStoreImpl(databaseAdapter());
    trackedEntityCall = new TrackedEntityCall(uids, databaseAdapter(), trackedEntityStore, resourceStore, service, new Date());
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) ResourceStore(org.hisp.dhis.android.core.resource.ResourceStore) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) Date(java.util.Date) Retrofit(retrofit2.Retrofit) MockWebServer(okhttp3.mockwebserver.MockWebServer) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) Before(org.junit.Before)

Example 2 with ResourceStoreImpl

use of org.hisp.dhis.android.core.resource.ResourceStoreImpl in project dhis2-android-sdk by dhis2.

the class SystemInfoCallMockIntegrationShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    mockWebServer = new MockWebServer();
    mockWebServer.start();
    MockResponse mockResponse = new MockResponse();
    mockResponse.setBody("{\n" + "\n" + "    \"contextPath\": \"https://play.dhis2.org/dev\",\n" + "    \"userAgent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.12; rv:51.0) Gecko/20100101 Firefox/51.0\",\n" + "    \"calendar\": \"iso8601\",\n" + "    \"dateFormat\": \"yyyy-mm-dd\",\n" + "    \"serverDate\": \"2017-02-27T14:55:45.808\",\n" + "    \"lastAnalyticsTableSuccess\": \"2017-01-26T23:19:34.009\",\n" + "    \"intervalSinceLastAnalyticsTableSuccess\": \"759 h, 36 m, 11 s\",\n" + "    \"lastAnalyticsTableRuntime\": \"5 m, 17 s\",\n" + "    \"version\": \"2.27-SNAPSHOT\",\n" + "    \"revision\": \"0223dac\",\n" + "    \"buildTime\": \"2017-02-27T11:32:16.000\",\n" + "    \"jasperReportsVersion\": \"6.3.1\",\n" + "    \"environmentVariable\": \"DHIS2_HOME\",\n" + "    \"databaseInfo\": {\n" + "        \"type\": \"PostgreSQL\",\n" + "        \"spatialSupport\": true\n" + "    },\n" + "    \"encryption\": false,\n" + "    \"systemId\": \"eed3d451-4ff5-4193-b951-ffcc68954299\",\n" + "    \"systemName\": \"DHIS 2 Demo - Sierra Leone\",\n" + "    \"systemMetadataVersion\": \"Version_4\",\n" + "    \"isMetadataVersionEnabled\": true,\n" + "    \"isMetadataSyncEnabled\": false\n" + "\n" + "}");
    mockWebServer.enqueue(mockResponse);
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setDateFormat(BaseIdentifiableObject.DATE_FORMAT.raw());
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    Retrofit retrofit = new Retrofit.Builder().baseUrl(mockWebServer.url("/")).addConverterFactory(JacksonConverterFactory.create(objectMapper)).addConverterFactory(FieldsConverterFactory.create()).build();
    SystemInfoService systemInfoService = retrofit.create(SystemInfoService.class);
    SystemInfoStore systemInfoStore = new SystemInfoStoreImpl(databaseAdapter());
    ResourceStore resourceStore = new ResourceStoreImpl(databaseAdapter());
    systeminfoCall = new SystemInfoCall(databaseAdapter(), systemInfoStore, systemInfoService, resourceStore);
}
Also used : MockResponse(okhttp3.mockwebserver.MockResponse) Retrofit(retrofit2.Retrofit) MockWebServer(okhttp3.mockwebserver.MockWebServer) ResourceStore(org.hisp.dhis.android.core.resource.ResourceStore) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 3 with ResourceStoreImpl

use of org.hisp.dhis.android.core.resource.ResourceStoreImpl in project dhis2-android-sdk by dhis2.

the class ProgramCallMockIntegrationShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    D2 d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
    dhis2MockServer.enqueueMockResponse("programs_complete.json");
    ObjectMapper objectMapper = new ObjectMapper();
    objectMapper.setDateFormat(BaseIdentifiableObject.DATE_FORMAT.raw());
    objectMapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
    TrackedEntityAttributeStore trackedEntityAttributeStore = new TrackedEntityAttributeStoreImpl(databaseAdapter());
    ProgramTrackedEntityAttributeStore programTrackedEntityAttributeStore = new ProgramTrackedEntityAttributeStoreImpl(databaseAdapter());
    ProgramRuleVariableStore programRuleVariableStore = new ProgramRuleVariableStoreImpl(databaseAdapter());
    ProgramIndicatorStore programIndicatorStore = new ProgramIndicatorStoreImpl(databaseAdapter());
    ProgramStageSectionProgramIndicatorLinkStore programStageSectionProgramIndicatorLinkStore = new ProgramStageSectionProgramIndicatorLinkStoreImpl(databaseAdapter());
    ProgramRuleActionStore programRuleActionStore = new ProgramRuleActionStoreImpl(databaseAdapter());
    ProgramRuleStore programRuleStore = new ProgramRuleStoreImpl(databaseAdapter());
    GenericHandler<ObjectStyle, ObjectStyleModel> styleHandler = ObjectStyleHandler.create(databaseAdapter());
    DictionaryTableHandler<ValueTypeRendering> renderTypeHandler = ValueTypeRenderingHandler.create(databaseAdapter());
    RelationshipTypeStore relationshipStore = new RelationshipTypeStoreImpl(databaseAdapter());
    ProgramService programService = d2.retrofit().create(ProgramService.class);
    ProgramStore programStore = new ProgramStoreImpl(databaseAdapter());
    ResourceStore resourceStore = new ResourceStoreImpl(databaseAdapter());
    Set<String> uids = new HashSet<>();
    uids.add("uid1");
    uids.add("uids2");
    ContentValues categoryCombo = CreateCategoryComboUtils.create(1L, "nM3u9s5a52V");
    database().insert(CategoryComboModel.TABLE, null, categoryCombo);
    ContentValues categoryCombo2 = CreateCategoryComboUtils.create(2L, "x31y45jvIQL");
    database().insert(CategoryComboModel.TABLE, null, categoryCombo2);
    // inserting tracked entity
    ContentValues trackedEntity = CreateTrackedEntityUtils.create(1L, "nEenWmSyUEp");
    database().insert(TrackedEntityModel.TABLE, null, trackedEntity);
    programCall = new ProgramCall(programService, databaseAdapter(), resourceStore, uids, programStore, new Date(), trackedEntityAttributeStore, programTrackedEntityAttributeStore, programRuleVariableStore, programIndicatorStore, programStageSectionProgramIndicatorLinkStore, programRuleActionStore, programRuleStore, relationshipStore, styleHandler, renderTypeHandler);
}
Also used : TrackedEntityAttributeStoreImpl(org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeStoreImpl) RelationshipTypeStoreImpl(org.hisp.dhis.android.core.relationship.RelationshipTypeStoreImpl) ResourceStore(org.hisp.dhis.android.core.resource.ResourceStore) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) HashSet(java.util.HashSet) Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) ContentValues(android.content.ContentValues) ValueTypeRendering(org.hisp.dhis.android.core.common.ValueTypeRendering) D2(org.hisp.dhis.android.core.D2) Date(java.util.Date) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) ObjectStyle(org.hisp.dhis.android.core.common.ObjectStyle) TrackedEntityAttributeStore(org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeStore) ObjectStyleModel(org.hisp.dhis.android.core.common.ObjectStyleModel) RelationshipTypeStore(org.hisp.dhis.android.core.relationship.RelationshipTypeStore) Before(org.junit.Before)

Example 4 with ResourceStoreImpl

use of org.hisp.dhis.android.core.resource.ResourceStoreImpl in project dhis2-android-sdk by dhis2.

the class DataElementEndpointCallRealIntegrationShould method createCall.

private DataElementEndpointCall createCall() {
    ResourceHandler resourceHandler = new ResourceHandler(new ResourceStoreImpl(databaseAdapter()));
    GenericCallData data = GenericCallData.create(databaseAdapter(), resourceHandler, d2.retrofit());
    Set<String> uids = new HashSet<>();
    uids.add("FTRrcoaog83");
    uids.add("P3jJH5Tu5VC");
    uids.add("FQ2o8UBlcrS");
    return DataElementEndpointCall.FACTORY.create(data, uids);
}
Also used : ResourceHandler(org.hisp.dhis.android.core.resource.ResourceHandler) GenericCallData(org.hisp.dhis.android.core.common.GenericCallData) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) HashSet(java.util.HashSet)

Example 5 with ResourceStoreImpl

use of org.hisp.dhis.android.core.resource.ResourceStoreImpl in project dhis2-android-sdk by dhis2.

the class DataSetAccessEndpointCallRealIntegrationShould method createCall.

private DataSetAccessEndpointCall createCall() {
    ResourceHandler resourceHandler = new ResourceHandler(new ResourceStoreImpl(databaseAdapter()));
    GenericCallData data = GenericCallData.create(databaseAdapter(), resourceHandler, d2.retrofit());
    return DataSetAccessEndpointCall.FACTORY.create(data);
}
Also used : ResourceHandler(org.hisp.dhis.android.core.resource.ResourceHandler) GenericCallData(org.hisp.dhis.android.core.common.GenericCallData) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl)

Aggregations

ResourceStoreImpl (org.hisp.dhis.android.core.resource.ResourceStoreImpl)13 ResourceHandler (org.hisp.dhis.android.core.resource.ResourceHandler)8 ResourceStore (org.hisp.dhis.android.core.resource.ResourceStore)7 GenericCallData (org.hisp.dhis.android.core.common.GenericCallData)6 Before (org.junit.Before)6 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)5 HashSet (java.util.HashSet)5 Date (java.util.Date)4 MockResponse (okhttp3.mockwebserver.MockResponse)4 MockWebServer (okhttp3.mockwebserver.MockWebServer)4 Retrofit (retrofit2.Retrofit)4 ContentValues (android.content.ContentValues)2 AssetsFileReader (org.hisp.dhis.android.core.data.file.AssetsFileReader)2 Dhis2MockServer (org.hisp.dhis.android.core.data.server.Dhis2MockServer)2 D2 (org.hisp.dhis.android.core.D2)1 ObjectStyle (org.hisp.dhis.android.core.common.ObjectStyle)1 ObjectStyleModel (org.hisp.dhis.android.core.common.ObjectStyleModel)1 ValueTypeRendering (org.hisp.dhis.android.core.common.ValueTypeRendering)1 EnrollmentStoreImpl (org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl)1 RelationshipTypeStore (org.hisp.dhis.android.core.relationship.RelationshipTypeStore)1