Search in sources :

Example 16 with RestApiActions

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

the class EventFiltersTest method beforeAll.

@BeforeAll
public void beforeAll() {
    eventFiltersActions = new RestApiActions("/eventFilters");
    new LoginActions().loginAsSuperUser();
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 17 with RestApiActions

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

the class RelationshipsTests method beforeAll.

@BeforeAll
public void beforeAll() throws Exception {
    teiActions = new TEIActions();
    metadataActions = new MetadataActions();
    relationshipTypeActions = new RestApiActions("/relationshipTypes");
    loginActions.loginAsSuperUser();
    metadataActions.importAndValidateMetadata(new File("src/test/resources/tracker/relationshipTypes.json"));
    teis = importTeis();
    events = importEvents();
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) TEIActions(org.hisp.dhis.actions.tracker.TEIActions) File(java.io.File) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 18 with RestApiActions

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

the class ProgramRemovalTest method beforeEach.

@BeforeEach
public void beforeEach() throws Exception {
    programActions = new ProgramActions();
    relationshipTypeActions = new RestApiActions("/relationshipTypes");
    new LoginActions().loginAsSuperUser();
    setupData();
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) ProgramActions(org.hisp.dhis.actions.metadata.ProgramActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 19 with RestApiActions

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

the class DataGenerator method generateObjectMatchingSchema.

public static JsonObject generateObjectMatchingSchema(List<SchemaProperty> schemaProperties) {
    JsonObject objectBody = new JsonObject();
    for (SchemaProperty prop : schemaProperties) {
        JsonElement element;
        if (prop.getPropertyType() == PropertyType.REFERENCE) {
            List<SchemaProperty> referenceProperties = new SchemasActions().getRequiredProperties(prop.getName());
            JsonObject referenceObject = generateObjectMatchingSchema(referenceProperties);
            String uid = new RestApiActions(prop.getRelativeApiEndpoint()).post(referenceObject).extractUid();
            referenceObject.addProperty("id", uid);
            element = referenceObject;
        } else if (prop.getPropertyType() == PropertyType.IDENTIFIER) {
            if (!StringUtils.containsAny(prop.getName(), "id", "uid", "code")) {
                Schema schema = new SchemasActions().getSchema(prop.getName());
                JsonObject referenceObject = generateObjectMatchingSchema(schema.getRequiredProperties());
                String uid = new RestApiActions(schema.getPlural()).post(referenceObject).extractUid();
                element = new JsonPrimitive(uid);
            } else {
                element = new JsonPrimitive(new IdGenerator().generateUniqueId());
            }
        } else {
            element = generateRandomValueMatchingSchema(prop);
        }
        objectBody.add(prop.getName(), element);
    }
    return objectBody;
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) SchemaProperty(org.hisp.dhis.dto.schemas.SchemaProperty) JsonPrimitive(com.google.gson.JsonPrimitive) JsonElement(com.google.gson.JsonElement) SchemasActions(org.hisp.dhis.actions.SchemasActions) Schema(org.hisp.dhis.dto.schemas.Schema) JsonObject(com.google.gson.JsonObject) IdGenerator(org.hisp.dhis.actions.IdGenerator)

Example 20 with RestApiActions

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

the class LoginTests method preconditions.

@BeforeAll
public void preconditions() {
    oauth2Clients = new RestApiActions("/oAuth2Clients");
    uaaActions = new UaaActions();
    loginActions = new LoginActions();
    userActions = new UserActions();
    loginActions.loginAsSuperUser();
    addOAuthClient();
    userActions.addUser(userName, password);
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) UaaActions(org.hisp.dhis.actions.UaaActions) UserActions(org.hisp.dhis.actions.UserActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

RestApiActions (org.hisp.dhis.actions.RestApiActions)20 LoginActions (org.hisp.dhis.actions.LoginActions)13 BeforeAll (org.junit.jupiter.api.BeforeAll)10 JsonObject (com.google.gson.JsonObject)8 ApiResponse (org.hisp.dhis.dto.ApiResponse)7 File (java.io.File)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 UserActions (org.hisp.dhis.actions.UserActions)3 MetadataActions (org.hisp.dhis.actions.metadata.MetadataActions)3 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 SchemasActions (org.hisp.dhis.actions.SchemasActions)2 DataElementActions (org.hisp.dhis.actions.metadata.DataElementActions)2 OrgUnitActions (org.hisp.dhis.actions.metadata.OrgUnitActions)2 EventActions (org.hisp.dhis.actions.tracker.EventActions)2 TEIActions (org.hisp.dhis.actions.tracker.TEIActions)2 SchemaProperty (org.hisp.dhis.dto.schemas.SchemaProperty)2 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)2 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2