use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class RelationshipsTests method shouldDeleteRelationshipWithDeleteStrategy.
@Test
public void shouldDeleteRelationshipWithDeleteStrategy() {
// arrage
TrackerApiResponse response = trackerActions.postAndGetJobReport(new File("src/test/resources/tracker/importer/teis/teisAndRelationship.json")).validateSuccessfulImport();
List<String> teis = response.extractImportedTeis();
String relationship = response.extractImportedRelationships().get(0);
JsonObject obj = new JsonObjectBuilder().addObject("from", JsonObjectBuilder.jsonObject().addProperty("trackedEntity", teis.get(0))).addObject("to", JsonObjectBuilder.jsonObject().addProperty("trackedEntity", teis.get(1))).addProperty("relationshipType", relationshipType).addProperty("relationship", relationship).wrapIntoArray("relationships");
// act
response = trackerActions.postAndGetJobReport(obj, new QueryParamsBuilder().add("importStrategy=DELETE"));
// assert
response.validate().body("status", equalTo("OK")).body("stats.deleted", equalTo(1));
trackerActions.get("/relationships/" + relationship).validate().statusCode(404);
trackerActions.getTrackedEntity(teis.get(0) + "?fields=relationships").validate().body("relationships", Matchers.empty());
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiUpdateTests method shouldUpdateWithUpdateStrategy.
@Test
public void shouldUpdateWithUpdateStrategy() throws Exception {
// arrange
String teiId = importTei();
JsonObject teiBody = trackerActions.getTrackedEntity(teiId).getBody();
teiBody = JsonObjectBuilder.jsonObject(teiBody).addProperty("trackedEntity", teiId).wrapIntoArray("trackedEntities");
// act
ApiResponse response = trackerActions.postAndGetJobReport(teiBody, new QueryParamsBuilder().add("importStrategy=UPDATE"));
// assert
response.validate().statusCode(200).body("status", equalTo("OK")).body("stats.updated", equalTo(1));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiUpdateTests method shouldReturnErrorWhenTeiDoesntExist.
@ParameterizedTest
@ValueSource(strings = { "UPDATE", "DELETE" })
public void shouldReturnErrorWhenTeiDoesntExist(String importStrategy) throws Exception {
JsonObject teiBody = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/importer/teis/tei.json"));
ApiResponse response = trackerActions.postAndGetJobReport(teiBody, new QueryParamsBuilder().add(String.format("importStrategy=%s", importStrategy)));
response.validate().statusCode(200).body("status", equalTo("ERROR")).body("stats.ignored", equalTo(1)).body("validationReport.errorReports", notNullValue()).rootPath("validationReport.errorReports[0]").body("errorCode", equalTo("E1063")).body("message", containsStringIgnoringCase("does not exist"));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class DataImportTest method dataValuesCanBeImportedAsync.
@Test
public void dataValuesCanBeImportedAsync() {
ApiResponse response = dataValueSetActions.postFile(new File("src/test/resources/aggregate/dataValues_bulk.json"), new QueryParamsBuilder().addAll("reportMode=DEBUG", "async=true")).validateStatus(200);
String taskId = response.extractString("response.id");
// Validate that job was successful
systemActions.waitUntilTaskCompleted("DATAVALUE_IMPORT", taskId).validate().body("message", Matchers.containsInAnyOrder("Process started", "Importing data values", "Import done"));
// validate task summaries were created
ApiResponse taskSummariesResponse = systemActions.waitForTaskSummaries("DATAVALUE_IMPORT", taskId);
taskSummariesResponse.validate().statusCode(200).body("status", equalTo("SUCCESS")).rootPath("importCount").body("deleted", equalTo(0)).body("ignored", equalTo(0));
ImportSummary importSummary = taskSummariesResponse.getImportSummaries().get(0);
assertThat(taskSummariesResponse.getAsString(), importSummary.getImportCount().getImported() + importSummary.getImportCount().getUpdated(), greaterThan(0));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class SharingActions method setupSharingForConfiguredUserGroup.
public void setupSharingForConfiguredUserGroup(String type, String id) {
JsonObject jsonObject = this.get(new QueryParamsBuilder().add("type=" + type).add("id=" + id).build()).getBody();
jsonObject.add("object", JsonObjectBuilder.jsonObject().addProperty("publicAccess", "--------").addUserGroupAccess().build());
this.post(jsonObject, new QueryParamsBuilder().add("type=" + type).add("id=" + id)).validate().statusCode(200);
}
Aggregations