use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class PotentialDuplicatesEnrollmentsTests method shouldBeManuallyMerged.
@Test
public void shouldBeManuallyMerged() {
String teiA = createTeiWithEnrollmentsAndEvents(TRACKER_PROGRAM_ID, TRACKER_PROGRAM_STAGE_ID).extractImportedTeis().get(0);
TrackerApiResponse teiBResponse = createTeiWithEnrollmentsAndEvents(Constants.ANOTHER_TRACKER_PROGRAM_ID, "PaOOjwLVW2X");
String teiB = teiBResponse.extractImportedTeis().get(0);
String enrollmentToMerge = teiBResponse.extractImportedEnrollments().get(0);
String potentialDuplicate = potentialDuplicatesActions.createPotentialDuplicate(teiA, teiB, "OPEN").validateStatus(200).extractString("id");
potentialDuplicatesActions.manualMergePotentialDuplicate(potentialDuplicate, new JsonObjectBuilder().addArray("enrollments", Arrays.asList(enrollmentToMerge)).build()).validate().statusCode(200);
trackerActions.getTrackedEntity(teiA + "?fields=enrollments").validate().statusCode(200).body("enrollments", hasSize(2));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class PotentialDuplicatesRelationshipTests method shouldManuallyMergeRelationship.
@Test
public void shouldManuallyMergeRelationship() {
String teiA = createTei();
String teiB = createTei();
String teiC = createTei();
String relationship = createRelationship(teiB, teiC).extractImportedRelationships().get(0);
String potentialDuplicate = potentialDuplicatesActions.createAndValidatePotentialDuplicate(teiA, teiB, "OPEN");
potentialDuplicatesActions.manualMergePotentialDuplicate(potentialDuplicate, new JsonObjectBuilder().addArray("relationships", Arrays.asList(relationship)).build()).validate().statusCode(200);
trackerActions.getTrackedEntity(teiA + "?fields=*").validate().statusCode(200).body("relationships", hasSize(1)).body("relationships.relationship", hasItems(relationship));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class EventImportDataValueValidationTests method setupData.
private void setupData() throws Exception {
programId = new IdGenerator().generateUniqueId();
programStageId = new IdGenerator().generateUniqueId();
JsonObject jsonObject = new JsonObjectBuilder(new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/tracker/eventProgram.json"))).addPropertyByJsonPath("programStages[0].program.id", programId).addPropertyByJsonPath("programs[0].id", programId).addPropertyByJsonPath("programs[0].programStages[0].id", programStageId).addPropertyByJsonPath("programStages[0].id", programStageId).addPropertyByJsonPath("programStages[0].programStageDataElements", null).build();
new MetadataActions().importAndValidateMetadata(jsonObject);
String dataElementId = dataElementActions.get("?fields=id&filter=domainType:eq:TRACKER&filter=valueType:eq:TEXT&pageSize=1").extractString("dataElements.id[0]");
assertNotNull(dataElementId, "Failed to create data elements");
mandatoryDataElementId = dataElementId;
programActions.addDataElement(programStageId, dataElementId, true).validate().statusCode(200);
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class ProgramRemovalTest method setupData.
private void setupData() throws Exception {
programId = programActions.createProgram("WITH_REGISTRATION").extractUid();
assertNotNull(programId, "Failed to create program");
JsonObject relationshipType = new FileReaderUtils().read(new File("src/test/resources/tracker/relationshipTypes.json")).replacePropertyValuesWithIds("id").get(JsonObject.class).getAsJsonArray("relationshipTypes").get(0).getAsJsonObject();
new JsonObjectBuilder(relationshipType).addObject("toConstraint", new JsonObjectBuilder().addProperty("relationshipEntity", "PROGRAM_STAGE_INSTANCE").addObject("program", new JsonObjectBuilder().addProperty("id", programId))).build();
relationshipTypeId = relationshipTypeActions.create(relationshipType);
assertNotNull(relationshipTypeId, "Failed to create relationshipType");
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class EnrollmentsTests method shouldAddNote.
@Test
public void shouldAddNote() {
String enrollmentId = trackerActions.postAndGetJobReport(new TeiDataBuilder().buildWithEnrollment(Constants.ORG_UNIT_IDS[0], Constants.TRACKER_PROGRAM_ID)).extractImportedEnrollments().get(0);
JsonObject payload = trackerActions.getEnrollment(enrollmentId).getBodyAsJsonBuilder().addOrAppendToArray("notes", new JsonObjectBuilder().addProperty("value", DataGenerator.randomString()).build()).wrapIntoArray("enrollments");
trackerActions.postAndGetJobReport(payload).validateSuccessfulImport().validate().body("stats.updated", equalTo(1));
trackerActions.getEnrollment(enrollmentId + "?fields=notes").validate().statusCode(200).rootPath("notes").body("note", notNullValue()).body("storedAt", notNullValue()).body("updatedAt", notNullValue()).body("value", notNullValue()).body("storedBy", CoreMatchers.everyItem(equalTo("taadmin")));
}
Aggregations