Search in sources :

Example 1 with MetadataApiResponse

use of org.hisp.dhis.dto.MetadataApiResponse in project dhis2-core by dhis2.

the class MetadataActions method importMetadata.

public MetadataApiResponse importMetadata(JsonObject object, String... queryParams) {
    QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
    queryParamsBuilder.addAll(queryParams);
    queryParamsBuilder.addAll("atomicMode=OBJECT", "importReportMode=FULL");
    ApiResponse response = post(object, queryParamsBuilder);
    response.validate().statusCode(200);
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 2 with MetadataApiResponse

use of org.hisp.dhis.dto.MetadataApiResponse in project dhis2-core by dhis2.

the class MetadataActions method importMetadata.

public MetadataApiResponse importMetadata(File file, String... queryParams) {
    QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
    queryParamsBuilder.addAll(queryParams);
    queryParamsBuilder.addAll("importReportMode=FULL");
    ApiResponse response = postFile(file, queryParamsBuilder);
    response.validate().statusCode(200);
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 3 with MetadataApiResponse

use of org.hisp.dhis.dto.MetadataApiResponse in project dhis2-core by dhis2.

the class MetadataActions method importAndValidateMetadata.

public MetadataApiResponse importAndValidateMetadata(JsonObject object, String... queryParams) {
    ApiResponse response = importMetadata(object, queryParams);
    response.validate().body("response.stats.ignored", not(equalTo(response.extract("response.stats.total"))));
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 4 with MetadataApiResponse

use of org.hisp.dhis.dto.MetadataApiResponse in project dhis2-core by dhis2.

the class MetadataActions method importAndValidateMetadata.

public MetadataApiResponse importAndValidateMetadata(File file, String... queryParams) {
    ApiResponse response = importMetadata(file, queryParams);
    response.validate().body("response.stats.ignored", not(equalTo(response.extract("response.stats.total"))));
    return new MetadataApiResponse(response);
}
Also used : MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) ApiResponse(org.hisp.dhis.dto.ApiResponse) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse)

Example 5 with MetadataApiResponse

use of org.hisp.dhis.dto.MetadataApiResponse in project dhis2-core by dhis2.

the class OrgUnitProfileTests method shouldApplyGroupSets.

@Test
public void shouldApplyGroupSets() {
    // arrange
    MetadataApiResponse response = new MetadataActions().importAndValidateMetadata(new File("src/test/resources/metadata/orgunits/ou_with_group_and_set.json"));
    String groupSet = response.extractObjectUid("OrganisationUnitGroupSet").get(0);
    String ou = response.extractObjectUid("OrganisationUnit").get(0);
    JsonArray array = new JsonArray();
    array.add(groupSet);
    JsonObject profileBody = new JsonObjectBuilder().addArray("groupSets", array).build();
    // act
    orgUnitProfileActions.post(profileBody).validate().statusCode(200);
    // assert
    orgUnitProfileActions.get().validate().body("groupSets", hasSize(greaterThanOrEqualTo(1)));
    orgUnitProfileActions.get("/" + ou + "/data").validate().statusCode(200).body("groupSets", hasSize(1)).rootPath("groupSets[0]").body("id", equalTo(groupSet)).body("label", notNullValue()).body("value", notNullValue());
}
Also used : JsonArray(com.google.gson.JsonArray) MetadataApiResponse(org.hisp.dhis.dto.MetadataApiResponse) JsonObject(com.google.gson.JsonObject) MetadataActions(org.hisp.dhis.actions.metadata.MetadataActions) JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) File(java.io.File) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Aggregations

MetadataApiResponse (org.hisp.dhis.dto.MetadataApiResponse)5 ApiResponse (org.hisp.dhis.dto.ApiResponse)4 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)2 JsonArray (com.google.gson.JsonArray)1 JsonObject (com.google.gson.JsonObject)1 File (java.io.File)1 ApiTest (org.hisp.dhis.ApiTest)1 MetadataActions (org.hisp.dhis.actions.metadata.MetadataActions)1 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)1 Test (org.junit.jupiter.api.Test)1