Commit b732a00a authored by Salva5297's avatar Salva5297
Browse files

Solved Themis and OOPS

parent d6228900
Loading
Loading
Loading
Loading
+11 −10
Original line number Original line Diff line number Diff line
@@ -140,15 +140,15 @@ public class Clause_9_5_Checker extends AbstractClauseChecker {
		OkHttpClient httpClient = new OkHttpClient().newBuilder().build();
		OkHttpClient httpClient = new OkHttpClient().newBuilder().build();
		MediaType mediaType = MediaType.parse("application/json");
		MediaType mediaType = MediaType.parse("application/json");
		String jsonRequest = "{\"ontologiesCode\":[\""
		String jsonRequest = "{\"ontologiesCode\":[\""
				+ versionRDFXML.toString().replace("\\\"", "\\\\\"").replace("\"", "\\\"").replace("\t", " ")
				+ versionRDFXML.toString().replaceAll("\\\"", "\\\\\"").replaceAll("\"", "\\\"").replaceAll("\t", " ")
				+ "\"]," + "\"testfile\":[\"" + requirementsRDFXML.toString().replace("\\\"", "\\\\\"")
				+ "\"]," + "\"testfile\":[\"" + requirementsRDFXML.toString().replaceAll("\\\"", "\\\\\"")
						.replace("\"", "\\\"").replace("\t", " ")
						.replaceAll("\"", "\\\"").replaceAll("\t", " ")
				+ "\"]," + "\"format\":\"junit\"}";
				+ "\"]," + "\"format\":\"junit\"}";

		RequestBody body = RequestBody.create(jsonRequest, mediaType);
		RequestBody body = RequestBody.create(jsonRequest, mediaType);
		Request request = new Request.Builder().url("http://themis.linkeddata.es/rest/api/results").method("POST", body)
		Request request = new Request.Builder().url("http://themis.linkeddata.es/rest/api/results").method("POST", body)
				.addHeader("accept", "application/json").addHeader("Content-Type", "application/json").build();
				.addHeader("accept", "application/json").addHeader("Content-Type", "application/json").build();



		try {
		try {
			Response response = httpClient.newCall(request).execute();
			Response response = httpClient.newCall(request).execute();
			if (response.code() != 200) {
			if (response.code() != 200) {
@@ -163,14 +163,15 @@ public class Clause_9_5_Checker extends AbstractClauseChecker {
				org.w3c.dom.Node node = nodeList.item(temp);
				org.w3c.dom.Node node = nodeList.item(temp);
				if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
				if (node.getNodeType() == org.w3c.dom.Node.ELEMENT_NODE) {
					Element element = (Element) node;
					Element element = (Element) node;
					if (((Element) node).getElementsByTagName("error").item(0) != null) {
						String id = element.getAttributeNode("id").toString();
						String id = element.getAttributeNode("id").toString();
						String name = element.getAttributeNode("name").toString();
						String name = element.getAttributeNode("name").toString();
					String message = ((Element) node).getElementsByTagName("error").item(0).getAttributes()
						String message = ((Element) node).getElementsByTagName("error").item(0).getAttributes().getNamedItem("message").toString();
							.getNamedItem("message").toString();
						String themisError = String.format("%s, %s, %s", id, name, message);
						String themisError = String.format("%s, %s, %s", id, name, message);
						themisErrors.add(themisError);
						themisErrors.add(themisError);
					}
					}
				}
				}
			}
			if (!themisErrors.isEmpty()) {
			if (!themisErrors.isEmpty()) {
				String data = themisErrors.stream().map(e -> e.toString())
				String data = themisErrors.stream().map(e -> e.toString())
						.collect(Collectors.joining("\n- ", "\n\n- ", "\n\n"));
						.collect(Collectors.joining("\n- ", "\n\n- ", "\n\n"));
+1 −1
Original line number Original line Diff line number Diff line
missing=The `tests` directory should contain a file `tests.csv`. This file shall conform to the requirements specification as defined in clause 9.5.2 in TS 103 673.
missing=The `tests` directory should contain a file `tests.csv`. This file shall conform to the requirements specification as defined in clause 9.5.2 in TS 103 673.
line=The `tests` specification shall be a CSV (Comma-Separated Values) file encoded in UTF-8. The first line of the file shall be the following: `Id;Requirement;Category;Test`
line=The `tests` specification shall be a CSV (Comma-Separated Values) file encoded in UTF-8. The first line of the file shall be the following: `Id;Requirement;Category;Test`
ioexception=Error while checking the `tests` directory
ioexception=Error while checking the `tests` directory
themis=OOPS found some problems. Violations are: %s
themis=Themis found some problems. Violations are: %s
themisError=Themis error. The service may be under maintenance.
themisError=Themis error. The service may be under maintenance.
 No newline at end of file