Search in sources :

Example 1 with MetadataActions

use of org.hisp.dhis.actions.metadata.MetadataActions in project dhis2-core by dhis2.

the class MetadataImportTest method before.

@BeforeAll
public void before() {
    metadataActions = new MetadataActions();
    systemActions = new SystemActions();
    new LoginActions().loginAsSuperUser();
}
Also used : SystemActions(org.hisp.dhis.actions.SystemActions) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 2 with MetadataActions

use of org.hisp.dhis.actions.metadata.MetadataActions in project dhis2-core by dhis2.

the class MetadataSetupExtension method beforeAll.

@Override
public void beforeAll(ExtensionContext context) {
    if (!started) {
        started = true;
        logger.info("Importing metadata for tests");
        // The following line registers a callback hook when the root test
        // context is shut down
        context.getRoot().getStore(GLOBAL).put("MetadataSetupExtension", this);
        MetadataActions metadataActions = new MetadataActions();
        new LoginActions().loginAsDefaultUser();
        String[] files = { "src/test/resources/setup/userGroups.json", "src/test/resources/setup/metadata.json", // importing for the second time to make sure all sharing is set up correctly - there are bugs in metadata importer
        "src/test/resources/setup/metadata.json", "src/test/resources/setup/tracker_metadata.json", "src/test/resources/setup/userRoles.json", "src/test/resources/setup/users.json" };
        String queryParams = "async=false";
        for (String fileName : files) {
            metadataActions.importAndValidateMetadata(new File(fileName), queryParams);
        }
        setupUsers();
        createdData.putAll(TestRunStorage.getCreatedEntities());
        TestRunStorage.removeAllEntities();
    }
}
Also used : MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) File(java.io.File)

Example 3 with MetadataActions

use of org.hisp.dhis.actions.metadata.MetadataActions in project dhis2-core by dhis2.

the class DataImportTest method before.

@BeforeAll
public void before() {
    dataValueSetActions = new DataValueSetActions();
    metadataActions = new MetadataActions();
    dataValueActions = new DataValueActions();
    systemActions = new SystemActions();
    new LoginActions().loginAsSuperUser();
    metadataActions.importMetadata(new File("src/test/resources/aggregate/metadata.json"), "async=false").validate().statusCode(200);
}
Also used : SystemActions(org.hisp.dhis.actions.SystemActions) DataValueSetActions(org.hisp.dhis.actions.aggregate.DataValueSetActions) DataValueActions(org.hisp.dhis.actions.aggregate.DataValueActions) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) File(java.io.File) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 4 with MetadataActions

use of org.hisp.dhis.actions.metadata.MetadataActions in project dhis2-core by dhis2.

the class UserAssignmentTests method beforeAll.

@BeforeAll
public void beforeAll() {
    metadataActions = new MetadataActions();
    programActions = new ProgramActions();
    eventActions = new EventActions();
    loginActions = new LoginActions();
    loginActions.loginAsSuperUser();
    metadataActions.importAndValidateMetadata(new File("src/test/resources/tracker/eventProgram.json"));
}
Also used : ProgramActions(org.hisp.dhis.actions.metadata.ProgramActions) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) EventActions(org.hisp.dhis.actions.tracker.EventActions) File(java.io.File) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 5 with MetadataActions

use of org.hisp.dhis.actions.metadata.MetadataActions in project dhis2-core by dhis2.

the class TrackedEntityInstanceAclReadTests method before.

@BeforeAll
public void before() throws Exception {
    teiActions = new TEIActions();
    metadataActions = new MetadataActions();
    userActions = new UserActions();
    // Setup as SuperUser
    new LoginActions().loginAsDefaultUser();
    // Set up metadata (Import twice to connect all references)
    metadataActions.importAndValidateMetadata(new File("src/test/resources/tracker/acl/metadata.json"));
    metadataActions.importAndValidateMetadata(new File("src/test/resources/tracker/acl/metadata.json"));
    // Import test data
    teiActions.postFile(new File("src/test/resources/tracker/acl/data.json"));
    // Set up all users for testing
    users.add(new User("User A", "O2PajOxjJSa", "UserA!123"));
    users.add(new User("User B", "aDy67f9ijOe", "UserB!123"));
    users.add(new User("User C", "CKrrGm5Be8O", "UserC!123"));
    users.add(new User("User D", "Lpa5INiC3Qf", "UserD!123"));
    users.add(new User("User ALL", "GTqb3WOZMop", "UserALL!123"));
    // Update passwords, so we can log in as them
    // Set AllAuth if user has it and ou scopes.
    // Map metadata and data sharing
    users.forEach(this::setupUser);
}
Also used : User(org.hisp.dhis.helpers.models.User) UserActions(org.hisp.dhis.actions.UserActions) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) LoginActions(org.hisp.dhis.actions.LoginActions) TEIActions(org.hisp.dhis.actions.tracker.TEIActions) File(java.io.File) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

MetadataActions (org.hisp.dhis.actions.metadata.MetadataActions)15 File (java.io.File)12 BeforeAll (org.junit.jupiter.api.BeforeAll)11 LoginActions (org.hisp.dhis.actions.LoginActions)10 JsonObject (com.google.gson.JsonObject)3 RestApiActions (org.hisp.dhis.actions.RestApiActions)3 UserActions (org.hisp.dhis.actions.UserActions)3 EventActions (org.hisp.dhis.actions.tracker.EventActions)3 SystemActions (org.hisp.dhis.actions.SystemActions)2 ProgramActions (org.hisp.dhis.actions.metadata.ProgramActions)2 TEIActions (org.hisp.dhis.actions.tracker.TEIActions)2 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)2 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)2 JsonArray (com.google.gson.JsonArray)1 ApiTest (org.hisp.dhis.ApiTest)1 IdGenerator (org.hisp.dhis.actions.IdGenerator)1 MessageConversationsActions (org.hisp.dhis.actions.MessageConversationsActions)1 DataValueActions (org.hisp.dhis.actions.aggregate.DataValueActions)1 DataValueSetActions (org.hisp.dhis.actions.aggregate.DataValueSetActions)1 OrgUnitActions (org.hisp.dhis.actions.metadata.OrgUnitActions)1