Skip to content

Commit

Permalink
log failure
Browse files Browse the repository at this point in the history
  • Loading branch information
ndr-brt committed Jun 25, 2024
1 parent 203e2e4 commit 1db3414
Showing 1 changed file with 19 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

package org.eclipse.edc.connector.controlplane.test.system.utils;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import io.restassured.specification.RequestSpecification;
import jakarta.json.Json;
Expand Down Expand Up @@ -243,7 +244,6 @@ public JsonArray getCatalogDatasets(Participant provider, JsonObject querySpec)
* @return dataset.
*/
public JsonObject getDatasetForAsset(Participant provider, String assetId) {
var datasetReference = new AtomicReference<JsonObject>();
var requestBody = createObjectBuilder()
.add(CONTEXT, createObjectBuilder().add(VOCAB, EDC_NAMESPACE))
.add(TYPE, "DatasetRequest")
Expand All @@ -253,25 +253,24 @@ public JsonObject getDatasetForAsset(Participant provider, String assetId) {
.add("protocol", protocol)
.build();

await().atMost(timeout).untilAsserted(() -> {
var response = managementEndpoint.baseRequest()
.contentType(JSON)
.when()
.body(requestBody)
.post("/v3/catalog/dataset/request")
.then()
.log().ifValidationFails()
.statusCode(200)
.extract().body().asString();

var compacted = objectMapper.readValue(response, JsonObject.class);

var dataset = jsonLd.expand(compacted).orElseThrow(f -> new EdcException(f.getFailureDetail()));

datasetReference.set(dataset);
});

return datasetReference.get();
var response = managementEndpoint.baseRequest()
.contentType(JSON)
.when()
.body(requestBody)
.post("/v3/catalog/dataset/request")
.then()
.statusCode(200)
.contentType(JSON)
.log().ifValidationFails()
.extract();

try {
var responseBody = response.body().asString();
var compacted = objectMapper.readValue(responseBody, JsonObject.class);
return jsonLd.expand(compacted).orElseThrow(f -> new EdcException(f.getFailureDetail()));
} catch (JsonProcessingException e) {
throw new EdcException("Cannot deserialize dataset", e);
}
}

/**
Expand Down

0 comments on commit 1db3414

Please sign in to comment.