Search in sources :

Example 1 with TestSuiteReport

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;
}
Also used : TestCollectionReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport) TestSuiteReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport)

Example 2 with 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();
    }
}
Also used : TestReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.dbentities.TestReport) InputStream(java.io.InputStream) Resource(de.ipk_gatersleben.bit.bi.bridge.brapicomp.dbentities.Resource) TestSuiteReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport) IOException(java.io.IOException) TestCollection(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Path(javax.ws.rs.Path) Produces(javax.ws.rs.Produces) GET(javax.ws.rs.GET)

Example 3 with TestSuiteReport

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;
}
Also used : TestCollectionReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport) TestSuiteReport(de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport)

Aggregations

TestSuiteReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestSuiteReport)3 TestCollectionReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.reports.TestCollectionReport)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Resource (de.ipk_gatersleben.bit.bi.bridge.brapicomp.dbentities.Resource)1 TestReport (de.ipk_gatersleben.bit.bi.bridge.brapicomp.dbentities.TestReport)1 TestCollection (de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 GET (javax.ws.rs.GET)1 Path (javax.ws.rs.Path)1 Produces (javax.ws.rs.Produces)1