use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.
the class FileRecordJobIT method testPublishedDataset.
@Test
@Ignore
public /**
* Published datasets should not allow import jobs for now since it isn't in DRAFT mode
*/
void testPublishedDataset() {
try {
RestAssured.urlEncodingEnabled = false;
// publish the dataverse
System.out.println("DATAVERSE: http://localhost:8080/api/dataverses/" + testName + "/actions/:publish?key=" + token);
given().body("{}").contentType("application/json").post("/api/dataverses/" + testName + "/actions/:publish?key=" + token).then().assertThat().statusCode(200);
// publish the dataset
System.out.println("DATASET: http://localhost:8080/api/datasets/" + dsId + "/actions/:publish?type=major&key=" + token);
given().get("/api/datasets/" + dsId + "/actions/:publish?type=major&key=" + token).then().assertThat().statusCode(200);
isDraft = false;
JsonPath jsonPath = getFaileJobJson();
assertTrue(jsonPath.getString("status").equalsIgnoreCase("ERROR"));
assertTrue(jsonPath.getString("message").contains("Dataset isn't in DRAFT mode."));
} catch (Exception e) {
System.out.println("Error testChecksumImport: " + e.getMessage());
e.printStackTrace();
fail();
}
}
use of com.jayway.restassured.path.json.JsonPath in project dataverse by IQSS.
the class BatchImportIT method setUpClass.
@BeforeClass
public static void setUpClass() {
Response createUserResponse = createUser(getRandomUsername(), "firstName", "lastName");
// createUserResponse.prettyPrint();
assertEquals(200, createUserResponse.getStatusCode());
JsonPath createdUser1 = JsonPath.from(createUserResponse.body().asString());
apiToken1 = createdUser1.getString("data." + apiTokenKey);
username1 = createdUser1.getString("data.user." + usernameKey);
Response makeSuperuserResponse = makeSuperuser(username1);
assertEquals(200, makeSuperuserResponse.getStatusCode());
Response createUserResponse1 = createUser(getRandomUsername(), "firstName", "lastName");
// createUserResponse.prettyPrint();
assertEquals(200, createUserResponse1.getStatusCode());
JsonPath createdUser2 = JsonPath.from(createUserResponse1.body().asString());
apiToken2 = createdUser2.getString("data." + apiTokenKey);
username2 = createdUser2.getString("data.user." + usernameKey);
dataverseAlias = "dv" + getRandomIdentifier();
Response createDataverseResponse = createDataverse(dataverseAlias, apiToken1);
// createDataverseResponse.prettyPrint();
// assertEquals(201, createDataverseResponse.getStatusCode());
}
use of com.jayway.restassured.path.json.JsonPath in project components by Talend.
the class VersionControllerImplTest method testGetVersion.
@Test
public void testGetVersion() throws Exception {
Response r = //
given().accept(APPLICATION_JSON_UTF8_VALUE).expect().statusCode(200).log().ifError().with().port(//
localServerPort).get(getVersionPrefix() + "/version");
//
r.then().statusCode(HttpStatus.OK.value()).log().ifError().contentType(APPLICATION_JSON_UTF8_VALUE);
// We don't care what values are returned as long as they are filled.
JsonPath jsonPathEvaluator = r.jsonPath();
assertThat(jsonPathEvaluator.get("version"), allOf(notNullValue(), not(equalTo(VersionDto.N_A))));
assertThat(jsonPathEvaluator.get("commit"), allOf(notNullValue(), not(equalTo(VersionDto.N_A))));
assertThat(jsonPathEvaluator.get("time"), allOf(notNullValue(), not(equalTo(VersionDto.N_A))));
}
use of com.jayway.restassured.path.json.JsonPath in project data-prep by Talend.
the class PreparationAPITest method should_save_created_columns_ids_on_append.
@Test
public void should_save_created_columns_ids_on_append() throws Exception {
// when
final String preparationId = testClient.createPreparationFromFile("dataset/dataset.csv", "testPreparation", home.getId());
// when
testClient.applyActionFromFile(preparationId, "transformation/copy_firstname.json");
// then
final JsonPath jsonPath = given().get("/api/preparations/{preparation}/details", preparationId).jsonPath();
final List<String> createdColumns = jsonPath.getList("diff[0].createdColumns");
assertThat(createdColumns, hasSize(1));
assertThat(createdColumns, hasItem("0006"));
}
use of com.jayway.restassured.path.json.JsonPath in project opencast by opencast.
the class BundleInfoRestEndpointTest method testBundleInfoJsonSerialization.
@Test
public void testBundleInfoJsonSerialization() {
final JsonPath p = JsonPath.from(bundleInfoJson(bundleInfo("host", "bundle", 1L, "version", some("sha"))).toJson());
run(BundleInfo.class, new BundleInfo() {
@Override
public String getHost() {
assertEquals("host", p.getString("host"));
return null;
}
@Override
public String getBundleSymbolicName() {
assertEquals("bundle", p.getString("bundleSymbolicName"));
return null;
}
@Override
public long getBundleId() {
assertEquals(1L, p.getLong("bundleId"));
return 0;
}
@Override
public String getBundleVersion() {
assertEquals("bundle", p.getString("bundleSymbolicName"));
return null;
}
@Override
public Option<String> getBuildNumber() {
assertEquals("sha", p.getString("buildNumber"));
return null;
}
@Override
public BundleVersion getVersion() {
assertEquals("sha", p.getString("buildNumber"));
return null;
}
});
}
Aggregations