use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class PotentialDuplicatesAttributeMergeTests method shouldManuallyMergeAttributeWithDifferentValues.
@Test
public void shouldManuallyMergeAttributeWithDifferentValues() {
String teiA = createTeiWithAttributes(createAttribute(attributes.get(0), "attribute 1"));
String teiB = createTeiWithAttributes(createAttribute(attributes.get(0), "attribute 2"));
String potentialDuplicate = potentialDuplicatesActions.createAndValidatePotentialDuplicate(teiA, teiB, "OPEN");
potentialDuplicatesActions.manualMergePotentialDuplicate(potentialDuplicate, new JsonObjectBuilder().addArray("trackedEntityAttributes", Arrays.asList(attributes.get(0))).build()).validate().statusCode(200);
trackerActions.getTrackedEntity(teiA).validate().body("attributes", hasSize(1)).body("attributes[0].value", equalTo("attribute 2"));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class PotentialDuplicatesAttributeMergeTests method shouldMoveChangelogs.
@Test
public void shouldMoveChangelogs() {
String teiA = createTeiWithAttributes(createAttribute(attributes.get(0), "attribute A"));
String teiB = createTeiWithAttributes(createAttribute(attributes.get(0), "attribute A - changed"), createAttribute(attributes.get(1), "attribute B"));
String potentialDuplicate = potentialDuplicatesActions.createAndValidatePotentialDuplicate(teiA, teiB, "OPEN");
potentialDuplicatesActions.manualMergePotentialDuplicate(potentialDuplicate, new JsonObjectBuilder().addArray("trackedEntityAttributes", Arrays.asList(attributes.get(0), attributes.get(1))).build()).validate().statusCode(200);
new AuditActions().getTrackedEntityAttributeValueAudits(teiA).validate().statusCode(200).rootPath("trackedEntityAttributeValueAudits").body("", hasSize(greaterThanOrEqualTo(2))).appendRootPath(String.format("find{it.trackedEntityAttribute.id=='%s'}", attributes.get(1))).body("value", equalTo("attribute B")).body("auditType", equalTo("CREATE")).rootPath(String.format("trackedEntityAttributeValueAudits.find{it.trackedEntityAttribute.id=='%s'}", attributes.get(0))).body("value", equalTo("attribute A - changed")).body("auditType", equalTo("UPDATE"));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class ProgramStagesTest method shouldAddProgramStageToProgram.
@Test
public void shouldAddProgramStageToProgram() {
// arrange
JsonObject programBody = programActions.get(programId).getBodyAsJsonBuilder().addArray("programStages", new JsonObjectBuilder().addProperty("id", programStageId).build()).build();
// act
ApiResponse response = programActions.update(programId, programBody);
// assert
ResponseValidationHelper.validateObjectUpdate(response, 200);
response = programActions.get(programId);
response.validate().statusCode(200).body("programStages", not(emptyArray())).body("programStages.id", not(emptyArray())).body("programStages.id", hasItem(programStageId));
response = programStageActions.get(programStageId);
response.validate().statusCode(200).body("program", notNullValue()).body("program.id", equalTo(programId));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class MetadataPatchTests method shouldAddToArrays.
@Test
public void shouldAddToArrays() {
JsonObject operation = buildOperation("add", "/dataElements/-", new JsonObjectBuilder().addProperty("id", dataElementId).build());
dataElementGroupActions.patch(dataElementGroupId, Arrays.asList(operation)).validate().statusCode(200);
dataElementActions.get(dataElementId).validate().body("dataElementGroups.id", Matchers.contains(dataElementGroupId));
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class MetadataImportImportStrategyTests method shouldCreateMetadataWithCodeIdentifier.
@Test
public void shouldCreateMetadataWithCodeIdentifier() {
JsonObject object = JsonObjectBuilder.jsonObject(DataGenerator.generateObjectForEndpoint("/dataElementGroup")).addProperty("code", "TA_CODE_DATAELEMENT_GROUP").addArray("userGroupAccesses", new JsonObjectBuilder().addProperty("access", "rw------").addProperty("code", "TA_USER_GROUP").build()).wrapIntoArray("dataElementGroups");
ApiResponse response = metadataActions.importMetadata(object, "identifier=CODE");
response.validate().statusCode(200).body("response.stats.created", equalTo(1));
response = metadataActions.importMetadata(object, "identifier=CODE");
response.validate().statusCode(200).body("response.stats.updated", equalTo(1));
}
Aggregations