Search in sources :

Example 76 with QueryParamsBuilder

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

the class MetadataImportTest method shouldNotSkipSharing.

@Test
public void shouldNotSkipSharing() {
    JsonObject object = generateMetadataObjectWithInvalidSharing();
    ApiResponse response = metadataActions.post(object, new QueryParamsBuilder().add("skipSharing=false"));
    response.validate().statusCode(409).rootPath("response").body("status", equalTo("ERROR")).body("stats.created", equalTo(0)).body("typeReports[0].objectReports[0].errorReports[0].message", stringContainsInOrder("Invalid reference", "for association `userGroupAccesses`"));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) ApiTest(org.hisp.dhis.ApiTest)

Example 77 with QueryParamsBuilder

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

the class LoginTests method shouldBeAbleToLoginWithOAuth2.

@Test
public void shouldBeAbleToLoginWithOAuth2() {
    loginActions.addAuthenticationHeader(oauthClientId, secret);
    ApiResponse response = uaaActions.post("oauth/token", new JsonObject(), new QueryParamsBuilder().addAll("username=" + userName, "password=" + password, "grant_type=password"));
    response.validate().statusCode(200).body("access_token", notNullValue()).body("token_type", notNullValue()).body("refresh_token", notNullValue()).body("expires_in", notNullValue()).body("scope", notNullValue());
    loginActions.loginWithToken(response.extractString("access_token"));
    loginActions.getLoggedInUserInfo().validate().statusCode(200).body("username", equalTo(userName));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test)

Example 78 with QueryParamsBuilder

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

the class SystemSettingsTests method returnTranslationForGivenLocale.

@Test
public void returnTranslationForGivenLocale() {
    prepareData();
    ApiResponse response = systemSettingActions.get(APPLICATION_INTRO_KEY, ContentType.TEXT.toString(), ContentType.TEXT.toString(), new QueryParamsBuilder().add("locale=fr"));
    response.validate().statusCode(200).body(containsString(FRENCH_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 79 with QueryParamsBuilder

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

the class SystemSettingsTests method addSystemSetting.

@Test
public void addSystemSetting() {
    String specificFooter = "Learn more at ";
    QueryParamsBuilder params = new QueryParamsBuilder();
    params.add("value=" + specificFooter);
    ApiResponse response = systemSettingActions.post(APPLICATION_FOOTER_KEY, ContentType.TEXT.toString(), new JsonObject(), params);
    response.validate().statusCode(200).body(containsString(specificFooter));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) JsonObject(com.google.gson.JsonObject) Matchers.containsString(org.hamcrest.Matchers.containsString) ApiResponse(org.hisp.dhis.dto.ApiResponse) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 80 with QueryParamsBuilder

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

the class SystemSettingsTests method getDefaultSystemSettingWithNonSpecifiedContentTypeAndAccept.

@Test
public void getDefaultSystemSettingWithNonSpecifiedContentTypeAndAccept() {
    ApiResponse response = systemSettingActions.get(MAX_SYNC_ATTEMPTS_KEY, "", "", new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_SYNC_ATTEMPTS_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(MAX_PASSWORD_LENGTH_KEY, "", "", new QueryParamsBuilder());
    response.validate().statusCode(200).body(containsString(String.valueOf(MAX_PASSWORD_LENGTH_DEFAULT_VALUE)));
    // -----------------------------------------
    response = systemSettingActions.get(EMAIL_SENDER_KEY, "", "", 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)

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