use of com.jayway.restassured.specification.RequestSpecification in project data-prep by Talend.
the class PreparationClientTest method getDetails.
/**
* Return the details of a preparation at a given (optional) step.
*
* @param preparationId the wanted preparation id.
* @param wantedStepId the optional wanted step id.
* @return the details of a preparation at a given (optional) step.
*/
public PreparationMessage getDetails(String preparationId, String wantedStepId) {
final RequestSpecification specs = given();
if (StringUtils.isNotBlank(wantedStepId)) {
specs.queryParam("stepId", wantedStepId);
}
final Response response = specs.when().get("/preparations/{id}/details", preparationId);
if (response.getStatusCode() != 200) {
throw new MockTDPException(response);
}
try {
return mapper.readerFor(PreparationMessage.class).readValue(response.asString());
} catch (IOException e) {
throw new TDPException(UNABLE_TO_READ_CONTENT);
}
}
use of com.jayway.restassured.specification.RequestSpecification in project dataverse by IQSS.
the class UtilIT method returnDatasetToAuthor.
static Response returnDatasetToAuthor(String datasetPersistentId, JsonObject jsonObject, String apiToken) {
String jsonIn = jsonObject.toString();
RequestSpecification requestSpecification = given();
if (apiToken != null) {
requestSpecification = given().header(UtilIT.API_TOKEN_HTTP_HEADER, apiToken).body(jsonIn).contentType("application/json");
}
return requestSpecification.post("/api/datasets/:persistentId/returnToAuthor?persistentId=" + datasetPersistentId);
}
use of com.jayway.restassured.specification.RequestSpecification in project dataverse by IQSS.
the class UtilIT method dataCaptureModuleChecksumValidation.
static Response dataCaptureModuleChecksumValidation(String datasetPersistentId, JsonObject jsonObject, String apiToken) {
// Assume it's a number.
String persistentIdInPath = datasetPersistentId;
// If datasetPersistentId is a number we'll just put it in the path.
String optionalQueryParam = "";
if (!NumberUtils.isNumber(datasetPersistentId)) {
persistentIdInPath = ":persistentId";
optionalQueryParam = "?persistentId=" + datasetPersistentId;
}
RequestSpecification requestSpecification = given();
if (apiToken != null) {
requestSpecification = given().body(jsonObject.toString()).contentType(ContentType.JSON).header(UtilIT.API_TOKEN_HTTP_HEADER, apiToken);
}
return requestSpecification.post("/api/datasets/" + persistentIdInPath + "/dataCaptureModule/checksumValidation" + optionalQueryParam);
}
use of com.jayway.restassured.specification.RequestSpecification in project camunda-bpm-platform by camunda.
the class AuthorizationRestServiceQueryTest method testCompleteGetParameters.
@Test
public void testCompleteGetParameters() {
List<Authorization> mockAuthorizations = MockProvider.createMockGlobalAuthorizations();
AuthorizationQuery mockQuery = setUpMockQuery(mockAuthorizations);
Map<String, String> queryParameters = getCompleteStringQueryParameters();
RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
}
requestSpecification.expect().statusCode(Status.OK.getStatusCode()).when().get(SERVICE_PATH);
verify(mockQuery).authorizationId(MockProvider.EXAMPLE_AUTHORIZATION_ID);
verify(mockQuery).authorizationType(MockProvider.EXAMPLE_AUTHORIZATION_TYPE);
verify(mockQuery).userIdIn(new String[] { MockProvider.EXAMPLE_USER_ID, MockProvider.EXAMPLE_USER_ID2 });
verify(mockQuery).groupIdIn(new String[] { MockProvider.EXAMPLE_GROUP_ID, MockProvider.EXAMPLE_GROUP_ID2 });
verify(mockQuery).resourceType(MockProvider.EXAMPLE_RESOURCE_TYPE_ID);
verify(mockQuery).resourceId(MockProvider.EXAMPLE_RESOURCE_ID);
verify(mockQuery).list();
}
use of com.jayway.restassured.specification.RequestSpecification in project camunda-bpm-platform by camunda.
the class GroupRestServiceQueryTest method testCompleteGetParameters.
@Test
public void testCompleteGetParameters() {
Map<String, String> queryParameters = getCompleteStringQueryParameters();
RequestSpecification requestSpecification = given().contentType(POST_JSON_CONTENT_TYPE);
for (Entry<String, String> paramEntry : queryParameters.entrySet()) {
requestSpecification.parameter(paramEntry.getKey(), paramEntry.getValue());
}
requestSpecification.expect().statusCode(Status.OK.getStatusCode()).when().get(GROUP_QUERY_URL);
verify(mockQuery).groupName(MockProvider.EXAMPLE_GROUP_NAME);
verify(mockQuery).groupNameLike("%" + MockProvider.EXAMPLE_GROUP_NAME + "%");
verify(mockQuery).groupType(MockProvider.EXAMPLE_GROUP_TYPE);
verify(mockQuery).groupMember(MockProvider.EXAMPLE_USER_ID);
verify(mockQuery).memberOfTenant(MockProvider.EXAMPLE_TENANT_ID);
verify(mockQuery).list();
}
Aggregations