Search in sources :

Example 81 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class SystemSettingsTests method getDefaultSystemSettingAsText.

@Test
public void getDefaultSystemSettingAsText() {
    ApiResponse response = systemSettingActions.get(MAX_SYNC_ATTEMPTS_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_SYNC_ATTEMPTS_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(MAX_PASSWORD_LENGTH_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_PASSWORD_LENGTH_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(EMAIL_SENDER_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(EMAIL_SENDER_DEFAULT_VALUE));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 82 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class SystemSettingsTests method getDefaultSystemSettingAsJson.

@Test
public void getDefaultSystemSettingAsJson() {
    ApiResponse response = systemSettingActions.get(MAX_SYNC_ATTEMPTS_KEY, ContentType.JSON.toString(), ContentType.JSON.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_SYNC_ATTEMPTS_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(MAX_PASSWORD_LENGTH_KEY, ContentType.JSON.toString(), ContentType.JSON.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_PASSWORD_LENGTH_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(EMAIL_SENDER_KEY, ContentType.JSON.toString(), ContentType.JSON.toString(), new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(EMAIL_SENDER_DEFAULT_VALUE));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 83 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class SystemSettingsTests method returnDefaultValueWhenTranslationIsNotAvailable.

@Test
public void returnDefaultValueWhenTranslationIsNotAvailable() {
    prepareData();
    ApiResponse response = systemSettingActions.get(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder().add("locale=pl"));
    response.validate().statusCode(200).body(containsString(DEFAULT_INTRO));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 84 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class SystemSettingsTests method deleteTranslationForGivenLocaleAndSettingKey.

@Test
public void deleteTranslationForGivenLocaleAndSettingKey() {
    prepareData();
    ApiResponse response = systemSettingActions.delete(APPLICATION_INTRO_KEY, new QueryParamsBuilder().add("locale=fr"));
    response.validate().statusCode(204);
    response = systemSettingActions.get(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder().add("locale=fr"));
    response.validate().statusCode(200).body(containsString(DEFAULT_INTRO));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 85 with QueryParamsBuilder

use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.

the class SystemSettingsTests method prepareData.

private void prepareData() {
    QueryParamsBuilder params = new QueryParamsBuilder();
    params.add("value=" + DEFAULT_FOOTER);
    systemSettingActions.post(APPLICATION_FOOTER_KEY, ContentType.TEXT.toString(), new JsonObject(), params);
    // ------------------------
    params = new QueryParamsBuilder();
    params.add("value=" + DEFAULT_INTRO);
    systemSettingActions.post(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), new JsonObject(), params);
    // ------------------------
    params = new QueryParamsBuilder();
    params.add("value=" + ENGLISH_INTRO);
    params.add("locale=en");
    systemSettingActions.post(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), new JsonObject(), params);
    // ------------------------
    params = new QueryParamsBuilder();
    params.add("value=" + FRENCH_INTRO);
    params.add("locale=fr");
    systemSettingActions.post(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), new JsonObject(), params);
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject)

Aggregations

QueryParamsBuilder (org.hisp.dhis.helpers.QueryParamsBuilder)90 JsonObject (com.google.gson.JsonObject)54 Test (org.junit.jupiter.api.Test)51 ApiResponse (org.hisp.dhis.dto.ApiResponse)49 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)43 ApiTest (org.hisp.dhis.ApiTest)27 TrackerApiResponse (org.hisp.dhis.dto.TrackerApiResponse)21 File (java.io.File)20 TrackerNtiApiTest (org.hisp.dhis.tracker.TrackerNtiApiTest)20 FileReaderUtils (org.hisp.dhis.helpers.file.FileReaderUtils)14 MethodSource (org.junit.jupiter.params.provider.MethodSource)13 ValueSource (org.junit.jupiter.params.provider.ValueSource)9 JsonObjectBuilder (org.hisp.dhis.helpers.JsonObjectBuilder)8 EventDataBuilder (org.hisp.dhis.tracker.importer.databuilder.EventDataBuilder)6 TeiDataBuilder (org.hisp.dhis.tracker.importer.databuilder.TeiDataBuilder)5 ProgramActions (org.hisp.dhis.actions.metadata.ProgramActions)4 JsonArray (com.google.gson.JsonArray)3 HashMap (java.util.HashMap)3 ProgramStageActions (org.hisp.dhis.actions.metadata.ProgramStageActions)3 ImportSummary (org.hisp.dhis.dto.ImportSummary)3