use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class PotentialDuplicatesTests method shouldGetDuplicatesByTei.
@Test
public void shouldGetDuplicatesByTei() {
String teiA = createTei();
String teiB = createTei();
String teiC = createTei();
String teiD = createTei();
potentialDuplicatesActions.createPotentialDuplicate(teiA, teiB, "OPEN").validate().statusCode(200);
potentialDuplicatesActions.createPotentialDuplicate(teiC, teiA, "INVALID").validate().statusCode(200);
potentialDuplicatesActions.createPotentialDuplicate(teiD, teiA, "OPEN").validate().statusCode(200);
potentialDuplicatesActions.get("", new QueryParamsBuilder().add("teis=" + teiA)).validate().statusCode(200).body("identifiableObjects", hasSize(2));
potentialDuplicatesActions.get("", new QueryParamsBuilder().addAll("teis=" + teiB + "," + teiC, "status=ALL")).validate().statusCode(200).body("identifiableObjects", hasSize(2));
potentialDuplicatesActions.get("", new QueryParamsBuilder().addAll("teis=" + teiA, "status=INVALID")).validate().statusCode(200).body("identifiableObjects", hasSize(1));
potentialDuplicatesActions.get("", new QueryParamsBuilder().addAll("teis=" + teiA, "status=OPEN")).validate().statusCode(200).body("identifiableObjects", hasSize(2));
potentialDuplicatesActions.get("", new QueryParamsBuilder().addAll("teis=" + teiA, "status=MERGED")).validate().statusCode(200).body("identifiableObjects", hasSize(0));
potentialDuplicatesActions.get("", new QueryParamsBuilder().addAll("teis=" + teiA, "status=ALL")).validate().statusCode(200).body("identifiableObjects", hasSize(3));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EventImportDataValueValidationTests method shouldValidateCompletedOnInsert.
@Test
public void shouldValidateCompletedOnInsert() {
programActions.programStageActions.setValidationStrategy(programStageId, "ON_UPDATE_AND_INSERT");
JsonObject event = eventActions.createEventBody(OU_ID, programId, programStageId);
event.addProperty("status", "COMPLETED");
ApiResponse response = eventActions.post(event, new QueryParamsBuilder().add("skipCache=true"));
response.validate().statusCode(409).body("status", equalTo("ERROR")).rootPath("response").body("ignored", equalTo(1)).body("imported", equalTo(0)).body("importSummaries[0].conflicts[0].value", equalTo("value_required_but_not_provided"));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class EnrollmentAttributeTests method shouldAddAttributeValue.
@Test
public void shouldAddAttributeValue() throws Exception {
String tei = importTei();
JsonObject payload = new EnrollmentDataBuilder().setTei(tei).addAttribute(optionSetAttributeId, "TA_YES").array(programId, Constants.ORG_UNIT_IDS[1]);
trackerActions.postAndGetJobReport(payload, new QueryParamsBuilder().add("async=false")).validateSuccessfulImport();
trackerActions.getTrackedEntity(tei + "?program=" + programId).validateStatus(200).validate().statusCode(200).body("attributes", hasSize(greaterThanOrEqualTo(1))).body("attributes.attribute", hasItem(optionSetAttributeId)).body("attributes.value", hasItem("TA_YES"));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class RelationshipsTests method shouldImportObjectsWithRelationship.
@ParameterizedTest
@ValueSource(strings = { "src/test/resources/tracker/importer/teis/teisAndRelationship.json", "src/test/resources/tracker/importer/teis/teisWithRelationship.json" })
public void shouldImportObjectsWithRelationship(String file) throws Exception {
JsonObject jsonObject = new FileReaderUtils().read(new File(file)).get(JsonObject.class);
TrackerApiResponse response = trackerActions.postAndGetJobReport(jsonObject).validateSuccessfulImport();
response.validate().body("stats.total", equalTo(3));
createdRelationships = response.extractImportedRelationships();
ApiResponse relationshipResponse = trackerActions.get("/relationships/" + createdRelationships.get(0));
relationshipResponse.validate().statusCode(200).body("from.trackedEntity", notNullValue()).body("to.trackedEntity", notNullValue());
response.extractImportedTeis().forEach(tei -> {
teiActions.get(tei, new QueryParamsBuilder().add("fields=relationships")).validate().statusCode(200).body("relationships.relationship", contains(createdRelationships.get(0)));
});
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class TeiUpdateTests method shouldNotUpdateImmutableProperties.
@Test
public void shouldNotUpdateImmutableProperties() throws Exception {
// arrange
String tei = importTei();
String trackedEntityType = new TrackedEntityTypeActions().create();
JsonObject body = trackerActions.getTrackedEntity(tei).getBodyAsJsonBuilder().addProperty("trackedEntity", tei).addProperty("trackedEntityType", trackedEntityType).wrapIntoArray("trackedEntities");
// assert
trackerActions.postAndGetJobReport(body, new QueryParamsBuilder().add("importStrategy=UPDATE")).validateErrorReport().body("errorCode", Matchers.hasItem("E1126")).body("message", Matchers.hasItem(Matchers.containsString("trackedEntityType")));
}
Aggregations