use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class MetadataImportTest method shouldSkipSharing.
@Test
public void shouldSkipSharing() {
JsonObject metadata = generateMetadataObjectWithInvalidSharing();
ApiResponse response = metadataActions.post(metadata, new QueryParamsBuilder().add("skipSharing=true"));
response.validate().statusCode(200).rootPath("response").body("status", is(oneOf("SUCCESS", "OK"))).body("stats.created", equalTo(1));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class MetadataImportTest method shouldReturnImportSummariesWhenImportingInvalidMetadataAsync.
@Test
public void shouldReturnImportSummariesWhenImportingInvalidMetadataAsync() throws Exception {
// arrange
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder();
queryParamsBuilder.addAll("async=true", "importReportMode=DEBUG", "importStrategy=CREATE_AND_UPDATE", "atomicMode=NONE");
JsonObject metadata = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/metadata/uniqueMetadata.json"));
metadata.getAsJsonArray("organisationUnits").get(0).getAsJsonObject().addProperty("shortName", RandomStringUtils.random(51));
// act
ApiResponse response = metadataActions.post(metadata, queryParamsBuilder);
response.validate().statusCode(200).body(notNullValue()).body("response.name", equalTo("metadataImport")).body("response.jobType", equalTo("METADATA_IMPORT"));
String taskId = response.extractString("response.id");
// Validate that job was successful
systemActions.waitUntilTaskCompleted("METADATA_IMPORT", taskId).validate().body("message", hasItem(containsString("Import:Start"))).body("message", hasItem(containsString("Import:Done")));
// validate task summaries were created
systemActions.waitForTaskSummaries("METADATA_IMPORT", taskId).validate().body(notNullValue()).body("status", equalTo("WARNING")).body("typeReports", notNullValue()).rootPath("typeReports").body("stats.total", everyItem(greaterThan(0))).body("stats.ignored", hasSize(greaterThanOrEqualTo(1))).body("objectReports", notNullValue()).body("objectReports", hasSize(greaterThanOrEqualTo(1))).body("objectReports.errorReports", notNullValue());
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class MetadataImportTest method shouldImportUniqueMetadataAndReturnObjectReports.
@Test
public void shouldImportUniqueMetadataAndReturnObjectReports() throws Exception {
// arrange
JsonObject object = new FileReaderUtils().readJsonAndGenerateData(new File("src/test/resources/metadata/uniqueMetadata.json"));
// act
ApiResponse response = metadataActions.post(object, new QueryParamsBuilder().addAll("async=false", "importReportMode=DEBUG", "importStrategy=CREATE"));
// assert
response.validate().statusCode(200).rootPath("response").body("stats", notNullValue()).body("stats.total", greaterThan(0)).body("typeReports", notNullValue()).body("typeReports.stats", notNullValue()).body("typeReports.objectReports", Matchers.notNullValue());
List<HashMap> stats = response.extractList("response.typeReports.stats");
stats.forEach(x -> {
assertEquals(x.get("total"), x.get("created"));
});
List<ObjectReport> objectReports = getObjectReports(response.getTypeReports());
assertNotNull(objectReports);
validateCreatedEntities(objectReports);
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class LoginTests method shouldBeAbleToGetRefreshToken.
@Test
public void shouldBeAbleToGetRefreshToken() {
loginActions.addAuthenticationHeader(oauthClientId, secret);
JsonObject object = new JsonObject();
object.addProperty("password", password);
object.addProperty("grant_type", "password");
object.addProperty("username", userName);
ApiResponse passwordGrantTypeResponse = uaaActions.post("oauth/token", new JsonObject(), new QueryParamsBuilder().addAll("password=" + password, "username=" + userName, "grant_type=password"));
passwordGrantTypeResponse.validate().statusCode(200);
loginActions.addAuthenticationHeader(oauthClientId, secret);
ApiResponse refreshTokenResponse = uaaActions.post("oauth/token", new JsonObject(), new QueryParamsBuilder().addAll("grant_type=refresh_token", "refresh_token=" + passwordGrantTypeResponse.extractString("refresh_token")));
refreshTokenResponse.validate().statusCode(200).body("access_token", notNullValue()).body("token_type", notNullValue()).body("refresh_token", notNullValue()).body("expires_in", notNullValue()).body("scope", notNullValue()).body("access_token", not(equalTo(passwordGrantTypeResponse.extractString("access_token"))));
}
use of org.hisp.dhis.helpers.QueryParamsBuilder in project dhis2-core by dhis2.
the class AnalyticsDimensionsTest method shouldOrder.
@MethodSource
@ParameterizedTest
public void shouldOrder(String property, String direction) {
QueryParamsBuilder queryParamsBuilder = new QueryParamsBuilder().add("order", String.format("%s:%s", property, direction));
analyticsEnrollmentsActions.query().getDimensions(trackerProgram.getUid(), queryParamsBuilder).validate().body("dimensions", hasSize(greaterThanOrEqualTo(1))).body("dimensions." + property, Sorted.by(direction));
analyticsEventActions.query().getDimensions(trackerProgram.getProgramStages().get(0), queryParamsBuilder).validate().body("dimensions", hasSize(greaterThanOrEqualTo(1))).body("dimensions." + property, Sorted.by(direction));
}
Aggregations