Search in sources :

Example 6 with RestApiActions

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"));
}
Also used : TeiDataBuilder(org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder) RestApiActions(org.hisp.dhis.actions.RestApiActions) QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 7 with RestApiActions

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));
    });
}
Also used : JsonArray(com.google.gson.JsonArray) RestApiActions(org.hisp.dhis.actions.RestApiActions) FileReaderUtils(org.hisp.dhis.helpers.file.FileReaderUtils) ProgramStageActions(org.hisp.dhis.actions.metadata.ProgramStageActions) JsonObject(com.google.gson.JsonObject) JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) File(java.io.File)

Example 8 with RestApiActions

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();
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) DataElementActions(org.hisp.dhis.actions.metadata.DataElementActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 9 with RestApiActions

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());
}
Also used : RestApiActions(org.hisp.dhis.actions.RestApiActions) SharingActions(org.hisp.dhis.actions.metadata.SharingActions) DataElementActions(org.hisp.dhis.actions.metadata.DataElementActions) LoginActions(org.hisp.dhis.actions.LoginActions) JsonObjectBuilder(org.hisp.dhis.helpers.JsonObjectBuilder) BeforeAll(org.junit.jupiter.api.BeforeAll)

Example 10 with RestApiActions

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();
}
Also used : OrgUnitActions(org.hisp.dhis.actions.metadata.OrgUnitActions) RestApiActions(org.hisp.dhis.actions.RestApiActions) AttributeActions(org.hisp.dhis.actions.metadata.AttributeActions) LoginActions(org.hisp.dhis.actions.LoginActions) BeforeAll(org.junit.jupiter.api.BeforeAll)

Aggregations

RestApiActions (org.hisp.dhis.actions.RestApiActions)20 LoginActions (org.hisp.dhis.actions.LoginActions)13 BeforeAll (org.junit.jupiter.api.BeforeAll)10 JsonObject (com.google.gson.JsonObject)8 ApiResponse (org.hisp.dhis.dto.ApiResponse)7 File (java.io.File)5 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)4 UserActions (org.hisp.dhis.actions.UserActions)3 MetadataActions (org.hisp.dhis.actions.metadata.MetadataActions)3 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 SchemasActions (org.hisp.dhis.actions.SchemasActions)2 DataElementActions (org.hisp.dhis.actions.metadata.DataElementActions)2 OrgUnitActions (org.hisp.dhis.actions.metadata.OrgUnitActions)2 EventActions (org.hisp.dhis.actions.tracker.EventActions)2 TEIActions (org.hisp.dhis.actions.tracker.TEIActions)2 SchemaProperty (org.hisp.dhis.dto.schemas.SchemaProperty)2 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)2 QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2