Search in sources :

Example 1 with AssetsFileReader

use of org.hisp.dhis.android.core.data.file.AssetsFileReader 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 2 with AssetsFileReader

use of org.hisp.dhis.android.core.data.file.AssetsFileReader in project dhis2-android-sdk by dhis2.

the class EventEndPointCallMockIntegrationShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
}
Also used : Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) Before(org.junit.Before)

Example 3 with AssetsFileReader

use of org.hisp.dhis.android.core.data.file.AssetsFileReader in project dhis2-android-sdk by dhis2.

the class OrganisationUnitCallMockIntegrationShould method setUp.

@Before
@Override
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    D2 d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
    dhis2MockServer.enqueueMockResponse("admin/organisation_units.json");
    List<OrganisationUnit> organisationUnits = Collections.singletonList(OrganisationUnit.create("O6uvpzGd5pu", null, null, null, null, null, null, null, null, null, null, "/ImspTQPwCqd/O6uvpzGd5pu", null, null, null, null, null, null, false));
    UserCredentials userCredentials = UserCredentials.create("credentials_uid", "code", "name", null, null, null, null, null, null);
    // dependencies for the OrganisationUnitCall:
    OrganisationUnitService organisationUnitService = d2.retrofit().create(OrganisationUnitService.class);
    // Create a user with the root as assigned organisation unit (for the test):
    User user = User.create("user_uid", "code", "name", "display_name", new Date(), new Date(), "birthday", "education", "gender", "job_title", "surname", "firstName", "introduction", "employer", "interests", "languages", "email", "phoneNumber", "nationality", userCredentials, organisationUnits, organisationUnits, organisationUnits, false);
    ContentValues userContentValues = new ContentValues();
    userContentValues.put(UserModel.Columns.ID, "user_uid");
    database().insert(UserModel.TABLE, null, userContentValues);
    // inserting programs for creating OrgUnitProgramLinks
    String programUid = "uy2gU8kT1jF";
    String programUid1 = "q04UBOqq3rp";
    String programUid2 = "VBqh0ynB2wv";
    String programUid3 = "eBAyeGv0exc";
    String programUid4 = "kla3mAPgvCH";
    String programUid5 = "lxAQ7Zs9VYR";
    String programUid6 = "IpHINAT79UW";
    String programUid7 = "WSGAb5XwJ3Y";
    String programUid8 = "ur1Edk5Oe2n";
    insertProgramWithUid(programUid);
    insertProgramWithUid(programUid1);
    insertProgramWithUid(programUid2);
    insertProgramWithUid(programUid3);
    insertProgramWithUid(programUid4);
    insertProgramWithUid(programUid5);
    insertProgramWithUid(programUid6);
    insertProgramWithUid(programUid7);
    insertProgramWithUid(programUid8);
    Set<String> programUids = Sets.newHashSet(Lists.newArrayList(programUid, programUid1, programUid2, programUid3, programUid4, programUid5, programUid6, programUid7, programUid8));
    GenericHandler<OrganisationUnit, OrganisationUnitModel> organisationUnitHandler = OrganisationUnitHandler.create(databaseAdapter(), programUids, OrganisationUnitModel.Scope.SCOPE_DATA_CAPTURE, user);
    genericCallData = GenericCallData.create(databaseAdapter(), d2.retrofit());
    organisationUnitCall = new OrganisationUnitCall(user, organisationUnitService, genericCallData, organisationUnitHandler);
}
Also used : Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) ContentValues(android.content.ContentValues) User(org.hisp.dhis.android.core.user.User) D2(org.hisp.dhis.android.core.D2) Date(java.util.Date) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) UserCredentials(org.hisp.dhis.android.core.user.UserCredentials) Before(org.junit.Before)

Example 4 with AssetsFileReader

use of org.hisp.dhis.android.core.data.file.AssetsFileReader in project dhis2-android-sdk by dhis2.

the class TrackerDataCallMockIntegrationShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    d2 = D2Factory.create(dhis2MockServer.getBaseEndpoint(), databaseAdapter());
    trackedEntityInstanceStore = new TrackedEntityInstanceStoreImpl(databaseAdapter());
    resourceStore = new ResourceStoreImpl(databaseAdapter());
    enrollmentStore = new EnrollmentStoreImpl(databaseAdapter());
}
Also used : Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) TrackedEntityInstanceStoreImpl(org.hisp.dhis.android.core.trackedentity.TrackedEntityInstanceStoreImpl) EnrollmentStoreImpl(org.hisp.dhis.android.core.enrollment.EnrollmentStoreImpl) ResourceStoreImpl(org.hisp.dhis.android.core.resource.ResourceStoreImpl) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) Before(org.junit.Before)

Example 5 with AssetsFileReader

use of org.hisp.dhis.android.core.data.file.AssetsFileReader in project dhis2-android-sdk by dhis2.

the class CategoryEndpointCallShould method setUp.

@Override
@Before
public void setUp() throws IOException {
    super.setUp();
    dhis2MockServer = new Dhis2MockServer(new AssetsFileReader());
    Retrofit retrofit = new Retrofit.Builder().baseUrl(dhis2MockServer.getBaseEndpoint()).addConverterFactory(JacksonConverterFactory.create(new ObjectMapper())).addConverterFactory(FilterConverterFactory.create()).addConverterFactory(FieldsConverterFactory.create()).build();
    categoryService = retrofit.create(CategoryService.class);
}
Also used : Dhis2MockServer(org.hisp.dhis.android.core.data.server.Dhis2MockServer) Retrofit(retrofit2.Retrofit) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) AssetsFileReader(org.hisp.dhis.android.core.data.file.AssetsFileReader) Before(org.junit.Before)

Aggregations

AssetsFileReader (org.hisp.dhis.android.core.data.file.AssetsFileReader)11 Dhis2MockServer (org.hisp.dhis.android.core.data.server.Dhis2MockServer)9 Before (org.junit.Before)9 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)4 D2 (org.hisp.dhis.android.core.D2)3 ContentValues (android.content.ContentValues)2 Date (java.util.Date)2 ResourceStoreImpl (org.hisp.dhis.android.core.resource.ResourceStoreImpl)2 HashSet (java.util.HashSet)1 ObjectStyle (org.hisp.dhis.android.core.common.ObjectStyle)1 ObjectStyleModel (org.hisp.dhis.android.core.common.ObjectStyleModel)1 Payload (org.hisp.dhis.android.core.common.Payload)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 RelationshipTypeStoreImpl (org.hisp.dhis.android.core.relationship.RelationshipTypeStoreImpl)1 ResourceStore (org.hisp.dhis.android.core.resource.ResourceStore)1 TrackedEntityAttributeStore (org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeStore)1 TrackedEntityAttributeStoreImpl (org.hisp.dhis.android.core.trackedentity.TrackedEntityAttributeStoreImpl)1 TrackedEntityInstanceStoreImpl (org.hisp.dhis.android.core.trackedentity.TrackedEntityInstanceStoreImpl)1