Search in sources :

Example 31 with QueryParamsBuilder

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

the class MetadataExportTests method shouldNotExportUserMetadataWithoutAuthority.

@Test
public void shouldNotExportUserMetadataWithoutAuthority() {
    loginActions.loginAsUser(userWithoutAccessUsername, userWithoutAccessPassword);
    metadataActions.get("", new QueryParamsBuilder().add("users=true")).validate().statusCode(409).body("message", equalTo("Exporting user metadata requires the 'F_USER_VIEW' authority."));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) Test(org.junit.jupiter.api.Test) ApiTest(org.hisp.dhis.ApiTest)

Example 32 with QueryParamsBuilder

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

the class PotentialDuplicatesTests method shouldFilterByStatus.

@ParameterizedTest
@ValueSource(strings = { "OPEN", "INVALID", "MERGED" })
public void shouldFilterByStatus(String status) {
    String teiA = createTei();
    String teiB = createTei();
    potentialDuplicatesActions.createPotentialDuplicate(teiA, teiB, status).validate().statusCode(200);
    ApiResponse response = potentialDuplicatesActions.get("", new QueryParamsBuilder().add("status=" + status));
    response.validate().body("identifiableObjects", hasSize(greaterThanOrEqualTo(1))).body("identifiableObjects.status", everyItem(equalTo(status)));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) ApiResponse(org.hisp.dhis.dto.ApiResponse) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 33 with QueryParamsBuilder

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

the class PotentialDuplicatesTests method shouldReturnAllStatuses.

@Test
public void shouldReturnAllStatuses() {
    Arrays.asList("OPEN", "MERGED", "INVALID").forEach(status -> {
        String teiA = createTei();
        String teiB = createTei();
        potentialDuplicatesActions.createPotentialDuplicate(teiA, teiB, status).validate().statusCode(200);
    });
    potentialDuplicatesActions.get("", new QueryParamsBuilder().add("status=ALL")).validate().body("identifiableObjects", hasSize(greaterThanOrEqualTo(1))).body("identifiableObjects.status", allOf(hasItem("OPEN"), hasItem("INVALID"), hasItem("MERGED")));
}
Also used : QueryParamsBuilder(org.hisp.dhis.helpers.QueryParamsBuilder) Test(org.junit.jupiter.api.Test) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 34 with QueryParamsBuilder

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

the class EventImportDataValueValidationTests method shouldNotValidateDataValuesOnUpdateWithOnCompleteStrategy.

@Test
public void shouldNotValidateDataValuesOnUpdateWithOnCompleteStrategy() {
    programActions.programStageActions.setValidationStrategy(programStageId, "ON_COMPLETE");
    JsonObject events = eventActions.createEventBody(OU_ID, programId, programStageId);
    ApiResponse response = eventActions.post(events, new QueryParamsBuilder().add("skipCache=true"));
    response.validate().statusCode(200).body("status", equalTo("OK")).body("response.ignored", equalTo(0)).body("response.imported", equalTo(1));
}
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) ApiTest(org.hisp.dhis.ApiTest)

Example 35 with QueryParamsBuilder

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

the class EventImportDataValueValidationTests method shouldValidateDataValuesOnCompleteWhenEventIsCompleted.

@Test
public void shouldValidateDataValuesOnCompleteWhenEventIsCompleted() {
    programActions.programStageActions.setValidationStrategy(programStageId, "ON_COMPLETE");
    JsonObject event = eventActions.createEventBody(OU_ID, programId, programStageId);
    event.addProperty("status", "COMPLETED");
    ApiResponse response = eventActions.post(event, new QueryParamsBuilder().add("skipCache=true"));
    response.validate().statusCode(409).body("status", equalTo("ERROR")).rootPath("response").body("ignored", equalTo(1)).body("imported", equalTo(0)).body("importSummaries[0].conflicts[0].value", equalTo("value_required_but_not_provided"));
}
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) 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