use of org.hisp.dhis.actions.RestApiActions in project dhis2-core by dhis2.
the class SideEffectsTests method shouldSendNotificationIfNotSkipSideEffects.
@ParameterizedTest
@ValueSource(strings = { "true", "false" })
public void shouldSendNotificationIfNotSkipSideEffects(Boolean shouldSkipSideEffects) {
JsonObject object = new TeiDataBuilder().buildWithEnrollmentAndEvent(Constants.TRACKED_ENTITY_TYPE, Constants.ORG_UNIT_IDS[0], trackerProgramId, trackerProgramStageId, "COMPLETED");
ApiResponse response = new RestApiActions("/messageConversations").get("", new QueryParamsBuilder().add("fields=*"));
int size = response.getBody().getAsJsonArray("messageConversations").size();
trackerActions.postAndGetJobReport(object, new QueryParamsBuilder().add("skipSideEffects=" + shouldSkipSideEffects)).validateSuccessfulImport();
int expectedCount = (shouldSkipSideEffects) ? size : size + 1;
response = messageConversationsActions.waitForNotification(expectedCount);
response.validate().statusCode(200).body("messageConversations", hasSize(expectedCount));
if (shouldSkipSideEffects) {
return;
}
response.validate().body("messageConversations.subject", hasItem("TA program stage completion"));
}
use of org.hisp.dhis.actions.RestApiActions in project dhis2-core by dhis2.
the class SideEffectsTests method setupData.
private void setupData() throws Exception {
ProgramStageActions programStageActions = new ProgramStageActions();
JsonArray array = new FileReaderUtils().read(new File("src/test/resources/tracker/notificationTemplates.json")).get(JsonObject.class).getAsJsonArray("programNotificationTemplates");
array.forEach(nt -> {
String programNotificationTemplate = new RestApiActions("/programNotificationTemplates").post(nt.getAsJsonObject()).extractUid();
JsonObject programStage = JsonObjectBuilder.jsonObject(programStageActions.get(trackerProgramStageId).getBody()).addOrAppendToArray("notificationTemplates", new JsonObjectBuilder().addProperty("id", programNotificationTemplate).build()).build();
programStageActions.update(trackerProgramStageId, programStage).validate().statusCode(200);
programStageActions.get(trackerProgramStageId).validate().body("notificationTemplates.id", hasItem(programNotificationTemplate));
});
}
use of org.hisp.dhis.actions.RestApiActions in project dhis2-core by dhis2.
the class DataElementsTest method beforeAll.
@BeforeAll
public void beforeAll() {
dataElementActions = new DataElementActions();
categoryComboActions = new RestApiActions("/categoryCombos");
loginActions = new LoginActions();
loginActions.loginAsSuperUser();
}
use of org.hisp.dhis.actions.RestApiActions in project dhis2-core by dhis2.
the class MetadataPatchTests method before.
@BeforeAll
public void before() {
dataElementActions = new DataElementActions();
loginActions = new LoginActions();
dataElementGroupActions = new RestApiActions("/dataElementGroups");
sharingActions = new SharingActions();
loginActions.loginAsAdmin();
dataElementId = dataElementActions.create(dataElementActions.body("SUM", "AGGREGATE", "TEXT"));
dataElementGroupId = dataElementGroupActions.create(new JsonObjectBuilder().addProperty("name", DataGenerator.randomString()).addArray("dataElements", new JsonObjectBuilder().addProperty("id", dataElementId).build()).build());
}
use of org.hisp.dhis.actions.RestApiActions in project dhis2-core by dhis2.
the class OrgUnitProfileTests method beforeAll.
@BeforeAll
public void beforeAll() {
loginActions = new LoginActions();
attributeActions = new AttributeActions();
orgUnitProfileActions = new RestApiActions("/organisationUnitProfile");
loginActions.loginAsSuperUser();
orgUnitId = new OrgUnitActions().createOrgUnit();
}
Aggregations