Search in sources :

Example 1 with UserCredentials

use of org.hisp.dhis.android.core.user.UserCredentials 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)

Aggregations

ContentValues (android.content.ContentValues)1 Date (java.util.Date)1 D2 (org.hisp.dhis.android.core.D2)1 AssetsFileReader (org.hisp.dhis.android.core.data.file.AssetsFileReader)1 Dhis2MockServer (org.hisp.dhis.android.core.data.server.Dhis2MockServer)1 User (org.hisp.dhis.android.core.user.User)1 UserCredentials (org.hisp.dhis.android.core.user.UserCredentials)1 Before (org.junit.Before)1