use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport in project IPK-BrAPI-Validator by plantbreeding.
the class CallTestSuiteRunner method runTests.
/**
* Run the tests
*
* @return Test report
*/
public TestSuiteReport runTests() {
TestSuiteReport testSuiteReport = new TestSuiteReport(id, url);
TestCollectionRunner testCollectionRunner = new TestCollectionRunner(testCollection, url);
TestCollectionReport tcr = testCollectionRunner.runTestsFromCall();
testSuiteReport.addTestCollectionReport(tcr);
return testSuiteReport;
}
use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport in project IPK-BrAPI-Validator by plantbreeding.
the class SingleTestResource method callTest.
/**
* Run a call test
*
* @param url Url of the BrAPI server. Example: https://test.brapi.org/brapi/v1/
* @return Response with json report
*/
@GET
@Path("/call")
@Produces(MediaType.APPLICATION_JSON)
public Response callTest(@QueryParam("url") String url, @QueryParam("brapiversion") @DefaultValue("") String version) {
LOGGER.debug("New GET /call call.");
try {
if (url.equals("")) {
String jsonError = JsonMessageManager.jsonMessage(400, "Missing or invalid url parameter", 4202);
return Response.status(Status.BAD_REQUEST).encoding(jsonError).build();
}
if (!version.equals("v1.0") && !version.equals("v1.1")) {
String jsonError = JsonMessageManager.jsonMessage(400, "Missing or invalid version parameter", 4202);
return Response.status(Status.BAD_REQUEST).encoding(jsonError).build();
}
String collectionResource;
ObjectMapper mapper = new ObjectMapper();
collectionResource = "/collections/CompleteBrapiTest." + version + ".json";
InputStream inJson = TestCollection.class.getResourceAsStream(collectionResource);
TestCollection tc = mapper.readValue(inJson, TestCollection.class);
Resource res = new Resource(url);
TestSuiteReport testSuiteReport = RunnerService.testEndpointWithCall(res, tc);
TestReport report = new TestReport(res, mapper.writeValueAsString(testSuiteReport));
return Response.ok().entity(report).build();
} catch (IllegalArgumentException e) {
e.printStackTrace();
String e1 = JsonMessageManager.jsonMessage(400, "invalid URL: port must be 80", 5201);
return Response.status(Status.BAD_REQUEST).entity(e1).build();
} catch (IOException e) {
// Thrown by .getResourceAsStream(""). Most probably because of missing file or wrong config structure.
e.printStackTrace();
String e1 = JsonMessageManager.jsonMessage(500, "internal server error", 5201);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e1).build();
}
}
use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport in project IPK-BrAPI-Validator by plantbreeding.
the class CustomTestSuiteRunner method runTests.
/**
* Run the tests
*
* @return Test report
*/
public TestSuiteReport runTests() {
TestSuiteReport testSuiteReport = new TestSuiteReport(id, url);
TestCollectionRunner testCollectionRunner = new TestCollectionRunner(testCollection, url);
TestCollectionReport tcr = testCollectionRunner.runTests();
testSuiteReport.addTestCollectionReport(tcr);
return testSuiteReport;
}
Aggregations