use of org.onebusaway.admin.model.BundleValidationCheckResult in project onebusaway-application-modules by camsys.
the class RealtimeQueryResultChecker method checkResults.
@Override
public BundleValidationCheckResult checkResults(BundleValidateQuery query) {
BundleValidationCheckResult checkResult = new BundleValidationCheckResult();
String result = query.getQueryResult();
if (result.contains("ExpectedArrival") || result.contains("ExpectedDeparture")) {
checkResult.setTestStatus(PASS);
checkResult.setTestResult(query.getErrorMessage() + FOUND_REALTIME_INFO + query.getStopId());
} else {
checkResult.setTestStatus(FAIL);
checkResult.setTestResult(query.getErrorMessage() + DID_NOT_FIND_REALTIME_INFO + query.getStopId());
}
return checkResult;
}
use of org.onebusaway.admin.model.BundleValidationCheckResult in project onebusaway-application-modules by camsys.
the class StopForRouteResultChecker method checkResults.
@Override
public BundleValidationCheckResult checkResults(BundleValidateQuery query) {
ObjectMapper mapper = new ObjectMapper();
BundleValidationCheckResult checkResult = new BundleValidationCheckResult();
String result = query.getQueryResult();
mapper.configure(SerializationConfig.Feature.AUTO_DETECT_FIELDS, true);
Map<String, Object> parsedResult = new HashMap<String, Object>();
boolean parseFailed = false;
try {
parsedResult = mapper.readValue(result, HashMap.class);
} catch (JsonParseException e) {
_log.error("JsonParseException trying to parse query results.");
checkResult.setTestResult("JsonParseException trying to parse query results.");
parseFailed = true;
} catch (JsonMappingException e) {
_log.error("JsonMappingException trying to parse query results.");
checkResult.setTestResult("JsonMappingException trying to parse query results.");
parseFailed = true;
} catch (IOException e) {
_log.error("IOException trying to parse query results.");
checkResult.setTestResult("IOException trying to parse query results.");
parseFailed = true;
}
if (parseFailed) {
checkResult.setTestStatus(FAIL);
return checkResult;
}
// JSON successfully parsed, so continue processing
int httpCode = (Integer) parsedResult.get("code");
Map<String, Object> data = (Map<String, Object>) parsedResult.get("data");
Map<String, Object> entry = (Map<String, Object>) data.get("entry");
ArrayList<Object> routeIds = (ArrayList<Object>) entry.get("routeIds");
if (httpCode != 200 || routeIds == null || routeIds.size() == 0) {
// Call failed or didn't find any route entries
checkResult.setTestStatus(FAIL);
checkResult.setTestResult(query.getErrorMessage() + "Did not find any routes for stop #" + query.getStopId());
} else {
// Succeeded at finding stop info, but does it include this route?
if (routeIds.contains(query.getRouteId())) {
checkResult.setTestResult(query.getErrorMessage() + "Found stop #" + query.getStopId() + " on Route #" + query.getRouteId());
if (query.getSpecificTest().toLowerCase().equals("stop for route")) {
checkResult.setTestStatus(PASS);
} else {
checkResult.setTestStatus(FAIL);
}
} else {
// Didn't find that route for that stop
checkResult.setTestResult(query.getErrorMessage() + "Did not find stop #" + query.getStopId() + " on Route #" + query.getRouteId());
if (query.getSpecificTest().toLowerCase().equals("stop date at time")) {
checkResult.setTestStatus(FAIL);
} else {
checkResult.setTestStatus(PASS);
}
}
}
return checkResult;
}
use of org.onebusaway.admin.model.BundleValidationCheckResult in project onebusaway-application-modules by camsys.
the class ValidateBundleAction method runValidateBundle.
/**
* Uploads the bundle validate checks and uses them to test the validity of the bundle
*/
public String runValidateBundle() {
File inputFile;
Path csvTarget = null;
Reader csvInputFile = null;
if (wikiUrl.length() > 0) {
URL wikiInputUrl;
try {
wikiInputUrl = new URL(wikiUrl);
csvInputFile = new BufferedReader(new InputStreamReader(wikiInputUrl.openStream()));
} catch (MalformedURLException e) {
return "bundleValidationResults";
} catch (IOException e) {
e.printStackTrace();
return "bundleValidationResults";
}
} else if (csvFile.length() > 0) {
csvTarget = uploadCsvFile(csvFile);
inputFile = csvTarget.toFile();
try {
csvInputFile = new FileReader(inputFile);
} catch (FileNotFoundException e) {
e.printStackTrace();
return "bundleValidationResults";
}
} else {
return "bundleValidationResults";
}
BundleValidationParseResults parseResults = _bundleCheckParserService.parseBundleChecksFile(csvInputFile);
List<BundleValidateQuery> queryResults = _buildBundleQueriesService.buildQueries(parseResults.getParsedBundleChecks(), checkEnvironment);
for (BundleValidateQuery query : queryResults) {
String queryResult = getQueryResult(query);
query.setQueryResult(queryResult);
}
List<BundleValidationCheckResult> checkResults = checkResults(queryResults);
if (csvTarget != null) {
try {
Files.delete(csvTarget);
} catch (IOException e) {
_log.error("Exception while trying to delete temp .csv file");
e.printStackTrace();
}
}
bundleValidationResults = checkResults;
return "bundleValidationResults";
}
use of org.onebusaway.admin.model.BundleValidationCheckResult in project onebusaway-application-modules by camsys.
the class WeekendScheduleQueryResultChecker method checkResults.
@Override
public BundleValidationCheckResult checkResults(BundleValidateQuery query) {
BundleValidationCheckResult checkResult = new BundleValidationCheckResult();
String result = query.getQueryResult();
if (result.contains(CODE_200) && (result.contains("arrivalEnabled") || result.contains("departureEnabled"))) {
checkResult.setTestStatus(PASS);
checkResult.setTestResult(FOUND_SCHEDULE_ENTRIES);
} else {
checkResult.setTestStatus(FAIL);
checkResult.setTestResult(DID_NOT_FIND_SCHEDULE_ENTRIES);
}
return checkResult;
}
Aggregations