use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class AnalyticsDimensionsTest method shouldReturnAssociatedCategoriesWhenProgramHasCatCombo.
@Test
public void shouldReturnAssociatedCategoriesWhenProgramHasCatCombo() {
String programWithCatCombo = programActions.get("?filter=categoryCombo.code:!eq:default&filter=programType:eq:WITH_REGISTRATION").extractString("programs.id[0]");
String programStage = programActions.get(programWithCatCombo + "/programStages").extractString("programStages[0].id");
assertNotNull(programStage);
Consumer<ApiResponse> validate = response -> {
response.validate().body("dimensions", hasSize(greaterThanOrEqualTo(1))).body("dimensions.dimensionType", everyItem(startsWith("CATEGORY"))).body("dimensions.dimensionType", hasItems("CATEGORY", "CATEGORY_OPTION_GROUP_SET"));
};
validate.accept(analyticsEventActions.aggregate().getDimensions(programStage, new QueryParamsBuilder().add("filter", "dimensionType:like:CATEGORY")));
validate.accept(analyticsEventActions.query().getDimensions(programStage, new QueryParamsBuilder().add("filter", "dimensionType:like:CATEGORY")));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class DataImportTest method dataValuesCanBeImportedInBulk.
@Test
public void dataValuesCanBeImportedInBulk() {
ApiResponse response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_bulk.json"), new QueryParamsBuilder().add("importReportMode=FULL"));
response.validate().statusCode(200).rootPath("response").body("status", equalTo("SUCCESS")).body("conflicts", empty()).body("importCount", notNullValue()).rootPath("importCount").body("ignored", not(greaterThan(0))).body("deleted", not(greaterThan(0)));
ImportSummary importSummary = response.getImportSummaries().get(0);
assertThat(response.getAsString(), importSummary.getImportCount().getImported() + importSummary.getImportCount().getUpdated(), greaterThan(0));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class DataImportTest method cleanUp.
@AfterAll
public void cleanUp() {
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll("importReportMode=FULL", "importStrategy=DELETE");
ApiResponse response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_bulk.json"), queryParamsBuilder);
response.validate().statusCode(200);
response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_single_dataset.json"), queryParamsBuilder);
response.validate().statusCode(200);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class ProgramActions method addDataElement.
public ApiResponse addDataElement(String programStageId, String dataElementId, boolean isMandatory) {
JsonObject object = programStageActions.get(programStageId, new QueryParamsBuilder().add("fields=*")).getBody();
JsonObjectBuilder.jsonObject(object).addOrAppendToArray("programStageDataElements", new JsonObjectBuilder().addProperty("compulsory", String.valueOf(isMandatory)).addObject("dataElement", new JsonObjectBuilder().addProperty("id", dataElementId)).build());
return programStageActions.update(programStageId, object);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder 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);
}
Aggregations