use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class OrgUnitProfileTests method shouldApplyGroupSets.
@Test
public void shouldApplyGroupSets() {
// arrange
MetadataApiResponse response = new MetadataActions().importAndValidateMetadata(new File("src/test/resources/metadata/orgunits/ou_with_group_and_set.json"));
String groupSet = response.extractObjectUid("OrganisationUnitGroupSet").get(0);
String ou = response.extractObjectUid("OrganisationUnit").get(0);
JsonArray array = new JsonArray();
array.add(groupSet);
JsonObject profileBody = new JsonObjectBuilder().addArray("groupSets", array).build();
// act
orgUnitProfileActions.post(profileBody).validate().statusCode(200);
// assert
orgUnitProfileActions.get().validate().body("groupSets", hasSize(greaterThanOrEqualTo(1)));
orgUnitProfileActions.get("/" + ou + "/data").validate().statusCode(200).body("groupSets", hasSize(1)).rootPath("groupSets[0]").body("id", equalTo(groupSet)).body("label", notNullValue()).body("value", notNullValue());
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class OrgUnitProfileTests method shouldApplyDataItems.
@Test
public void shouldApplyDataItems() {
List<String> datItems = new DataItemActions().get("", new QueryParamsBuilder().add("filter=dimensionItemType:in:[DATA_ELEMENT,PROGRAM_INDICATOR]")).extractList("dataItems.id");
JsonArray array = new JsonArray();
datItems.forEach(p -> array.add(p));
orgUnitProfileActions.post(new JsonObjectBuilder().addArray("dataItems", array).build()).validate().statusCode(200);
orgUnitProfileActions.get().validate().body("dataItems", hasSize(greaterThanOrEqualTo(1)));
// todo add validation for organisationUnitProfile/id/data
}
use of org.hisp.dhis.helpers.JsonObjectBuilder in project dhis2-core by dhis2.
the class OrgUnitProfileTests method shouldApplyProfileAttributes.
@Test
public void shouldApplyProfileAttributes() {
// arrange
String attributeId = attributeActions.createAttribute("TEXT", false, "organisationUnit");
String attributeValue = DataGenerator.randomString();
new OrgUnitActions().addAttributeValue(orgUnitId, attributeId, attributeValue);
JsonArray array = new JsonArray();
array.add(attributeId);
JsonObject profileBody = orgUnitProfileActions.get().getBody();
// act
orgUnitProfileActions.post(new JsonObjectBuilder(profileBody).addArray("attributes", array).build()).validate().statusCode(200);
// assert
orgUnitProfileActions.get().validate().body("attributes", hasSize(greaterThanOrEqualTo(1)));
orgUnitProfileActions.get("/" + orgUnitId + "/data").validate().statusCode(200).body("attributes", hasSize(1)).rootPath("attributes[0]").body("value", equalTo(attributeValue)).body("id", equalTo(attributeId)).body("label", notNullValue());
}
Aggregations