use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection in project IPK-BrAPI-Validator by plantbreeding.
the class WeeklyJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
LOGGER.info("Weekly is executing.");
ObjectMapper mapper = new ObjectMapper();
InputStream inJson = TestCollection.class.getResourceAsStream("/collections/CompleteBrapiTest." + Config.get("testedVersion") + ".json");
TestCollection tc;
try {
tc = mapper.readValue(inJson, TestCollection.class);
RunnerService.TestAllEndpointsWithFreq(tc, "weekly");
RunnerService.TestAllPublicEndpoints(tc);
} catch (IOException | SQLException e1) {
e1.printStackTrace();
}
}
use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection in project IPK-BrAPI-Validator by plantbreeding.
the class AdminResource method generalTest.
/**
* Run the default test on all public resources
*
* @return Empty response with status code
*/
@GET
@Path("/testallpublic")
public Response generalTest(@Context HttpHeaders headers, @QueryParam("version") @DefaultValue("") String version) {
if (Config.get("advancedMode") == null) {
return Response.status(Status.NOT_FOUND).build();
}
LOGGER.debug("New GET /admin/testallpublic call.");
try {
// Check auth header
if (!auth(headers)) {
String e = JsonMessageManager.jsonMessage(401, "unauthorized", 4002);
return Response.status(Status.UNAUTHORIZED).entity(e).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();
}
ObjectMapper mapper = new ObjectMapper();
InputStream inJson = TestCollection.class.getResourceAsStream("/collections/CompleteBrapiTest." + version + ".json");
TestCollection tc = mapper.readValue(inJson, TestCollection.class);
List<Resource> publicResources = ResourceService.getAllPublicEndpoints();
publicResources.forEach(resource -> {
try {
RunnerService.TestEndpointWithCallAndSaveReport(resource, tc);
} catch (SQLException | JsonProcessingException e) {
e.printStackTrace();
}
});
System.out.println("Done");
return Response.ok().build();
} catch (SQLException | IOException e) {
e.printStackTrace();
String e1 = JsonMessageManager.jsonMessage(500, "internal server error", 5003);
return Response.status(Status.INTERNAL_SERVER_ERROR).entity(e1).build();
}
}
use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection 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.config.TestCollection in project IPK-BrAPI-Validator by plantbreeding.
the class DailyJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
LOGGER.info("Daily is executing.");
ObjectMapper mapper = new ObjectMapper();
InputStream inJson = TestCollection.class.getResourceAsStream("/collections/CompleteBrapiTest." + Config.get("testedVersion") + ".json");
TestCollection tc;
try {
tc = mapper.readValue(inJson, TestCollection.class);
RunnerService.TestAllEndpointsWithFreq(tc, "daily");
} catch (IOException | SQLException e1) {
e1.printStackTrace();
}
}
use of de.ipk_gatersleben.bit.bi.bridge.brapicomp.testing.config.TestCollection in project IPK-BrAPI-Validator by plantbreeding.
the class MonthlyJob method execute.
public void execute(JobExecutionContext context) throws JobExecutionException {
LOGGER.info("Monthly is executing.");
ObjectMapper mapper = new ObjectMapper();
InputStream inJson = TestCollection.class.getResourceAsStream("/collections/CompleteBrapiTest." + Config.get("testedVersion") + ".json");
TestCollection tc;
try {
tc = mapper.readValue(inJson, TestCollection.class);
RunnerService.TestAllEndpointsWithFreq(tc, "monthly");
} catch (IOException | SQLException e1) {
e1.printStackTrace();
}
}
Aggregations