Update to be compatible with the current reasoner web service

Johannes Binder Johannes Binder 2014-12-03

changed resources/wsdls/dependencyreasoner.wsdl
changed resources/wsdls/dependencyreasoner.xsd
changed src/net/timbusproject/dpes/alternative/AlternativesBuilder/PackageAlternativesBuilder.java
changed src/net/timbusproject/dpes/alternative/ReasonerClient/REST/DependencyReasonerClient.java
changed src/net/timbusproject/dpes/alternative/ReasonerClient/SOAP/DependencyReasonerClient.java
changed test/net/timbusproject/dpes/alternative/AlternativesBuilder/PackageAlternativesBuilderTest.java
changed test/net/timbusproject/dpes/alternative/ReasonerClient/REST/ReasonerWebClientTest.java
changed test/net/timbusproject/dpes/alternative/ReasonerClient/common/TestHelper.java
copied src/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestData.java -> test/net/timbusproject/dpes/alternative/ReasonerClient/common/ResponseDataTest.java
copied test/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestDataTest.java -> test/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestDataTest.java
copied test/net/timbusproject/dpes/alternative/ReasonerClient/REST/ResponseDataTest.java -> src/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestData.java
resources/wsdls/dependencyreasoner.wsdl Diff Switch to side-by-side view
Loading...
resources/wsdls/dependencyreasoner.xsd Diff Switch to side-by-side view
Loading...
src/net/timbusproject/dpes/alternative/AlternativesBuilder/PackageAlternativesBuilder.java Diff Switch to side-by-side view
Loading...
src/net/timbusproject/dpes/alternative/ReasonerClient/REST/DependencyReasonerClient.java Diff Switch to side-by-side view
Loading...
src/net/timbusproject/dpes/alternative/ReasonerClient/SOAP/DependencyReasonerClient.java Diff Switch to side-by-side view
Loading...
test/net/timbusproject/dpes/alternative/AlternativesBuilder/PackageAlternativesBuilderTest.java Diff Switch to side-by-side view
Loading...
test/net/timbusproject/dpes/alternative/ReasonerClient/REST/ReasonerWebClientTest.java Diff Switch to side-by-side view
Loading...
test/net/timbusproject/dpes/alternative/ReasonerClient/common/TestHelper.java Diff Switch to side-by-side view
Loading...
src/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestData.java to test/net/timbusproject/dpes/alternative/ReasonerClient/common/ResponseDataTest.java
--- a/src/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestData.java
+++ b/test/net/timbusproject/dpes/alternative/ReasonerClient/common/ResponseDataTest.java
@@ -16,63 +16,38 @@
  * See the License for the specific language governing permissions and limitation under the License.
  */
 
-package net.timbusproject.dpes.alternative.ReasonerClient.REST;
+package net.timbusproject.dpes.alternative.ReasonerClient.common;
 
-import org.json.JSONArray;
 import org.json.JSONObject;
+import org.junit.Test;
 
+import java.io.IOException;
+import java.util.ArrayList;
 import java.util.List;
 
-public class RequestData {
+import static org.hamcrest.Matchers.containsInAnyOrder;
+import static org.junit.Assert.assertThat;
 
-    private final List<String> toInstall;
-    private final List<String> toRemove;
-    private final String target;
-    private final String dataset;
+public class ResponseDataTest {
 
-    public RequestData(List<String> toInstall, List<String> toRemove, String target, String dataset) {
-        this.toInstall = toInstall;
-        this.toRemove = toRemove;
-        this.target = target;
-        this.dataset = dataset;
+    @Test
+    public void createPI_validRequest_shouldReturnValidJSON() throws IOException {
+        List<String> expectedToInstall = new ArrayList<String> () {{ add("libsm6"); add("libx11-6"); add("libx11-data"); }};
+        List<String> expectedToRemove = new ArrayList<>();
+        String result = "{\n" +
+                "   \"install\": [\n" +
+                "     { \"package\": \"firefox\" }\n" +
+                "   ],\n" +
+                "   \"target\": \"4649fd96-cbe2-4f93-babf-4627ef9ee5e6\",\n" +
+                "   \"dataset\": \"examples_Health\",\n" +
+                "   \"uuid\": \"2df4935a-ba75-11e3-8f8d-b99a36fe516e\",\n" +
+                "   \"result\":\n" +
+                "     {\"installed\":[{\"name\":\"libsm6\",\"version\":\"1448\"},{\"name\":\"libx11-6\",\"version\":\"1456\"},{\"name\":\"libx11-data\",\"version\":\"1456\"}],\"removed\":[]},\n" +
+                "   \"*status*\": \"COMPLETED\"\n" +
+                "}\n";
+        ResponseData actual = new ResponseData(new JSONObject(result));
+        assertThat(expectedToInstall, containsInAnyOrder(actual.getPackagesToInstall().toArray()));
+        assertThat(expectedToRemove, containsInAnyOrder(actual.getPackagesToRemove().toArray()));
     }
 
-    public String toString() {
-        JSONObject json = new JSONObject();
-        if (toInstall.size() > 0) {
-            json.put("install", getPackageList(toInstall));
-        }
-        if (toRemove.size() > 0) {
-            json.put("remove", getPackageList(toRemove));
-        }
-        json.put("target", target);
-        json.put("dataset", dataset);
-        return json.toString();
-    }
-
-    private JSONArray getPackageList(List<String> packages) {
-        JSONArray result = new JSONArray();
-        for (String p : packages) {
-            JSONObject pkg = new JSONObject();
-            pkg.accumulate("package", p);
-            result.put(pkg);
-        }
-        return result;
-    }
-
-    public List<String> getToInstall() {
-        return toInstall;
-    }
-
-    public List<String> getToRemove() {
-        return toRemove;
-    }
-
-    public String getTarget() {
-        return target;
-    }
-
-    public String getDataset() {
-        return dataset;
-    }
 }
test/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestDataTest.java to test/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestDataTest.java
--- a/test/net/timbusproject/dpes/alternative/ReasonerClient/REST/RequestDataTest.java
+++ b/test/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestDataTest.java
@@ -16,9 +16,8 @@
  * See the License for the specific language governing permissions and limitation under the License.
  */
 
-package net.timbusproject.dpes.alternative.ReasonerClient.REST;
+package net.timbusproject.dpes.alternative.ReasonerClient.common;
 
-import net.timbusproject.dpes.alternative.ReasonerClient.common.TestHelper;
 import org.junit.Test;
 
 import java.io.IOException;
@@ -50,7 +49,7 @@
 
     @Test
     public void toString_packageToRemoveAndPackageToInstall_shouldReturnValidJSON() throws IOException {
-        String expected = "{\"install\":[{\"package\":\"jetty\"}],\"remove\":[{\"package\":\"tomcat\"}],\"dataset\":\"dataset01\",\"target\":\"target01\"}";
+        String expected = "{\"install\":[{\"package\":\"jetty\"}],\"remove\":[{\"package\":\"tomcat\"}],\"dataset\":\"dataset01\",\"target\":\"target01\",\"ontology\":\"ontology01\",\"universe\":\"universe01\"}";
         RequestData actual = TestHelper.createTestRequest();
         assertThat(actual.toString(), equalTo(expected));
     }
test/net/timbusproject/dpes/alternative/ReasonerClient/REST/ResponseDataTest.java to src/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestData.java
--- a/test/net/timbusproject/dpes/alternative/ReasonerClient/REST/ResponseDataTest.java
+++ b/src/net/timbusproject/dpes/alternative/ReasonerClient/common/RequestData.java
@@ -16,39 +16,91 @@
  * See the License for the specific language governing permissions and limitation under the License.
  */
 
-package net.timbusproject.dpes.alternative.ReasonerClient.REST;
+package net.timbusproject.dpes.alternative.ReasonerClient.common;
 
-import net.timbusproject.dpes.alternative.ReasonerClient.common.ResponseData;
+import org.json.JSONArray;
 import org.json.JSONObject;
-import org.junit.Test;
 
-import java.io.IOException;
-import java.util.ArrayList;
 import java.util.List;
 
-import static org.hamcrest.Matchers.containsInAnyOrder;
-import static org.junit.Assert.assertThat;
+public class RequestData {
 
-public class ResponseDataTest {
+    private final List<String> toInstall;
+    private final List<String> toRemove;
+    private final String target;
+    private final String dataset;
+    private final String ontology;
+    private final String universe;
 
-    @Test
-    public void createPI_validRequest_shouldReturnValidJSON() throws IOException {
-        List<String> expectedToInstall = new ArrayList<String> () {{ add("libsm6"); add("libx11-6"); add("libx11-data"); }};
-        List<String> expectedToRemove = new ArrayList<>();
-        String result = "{\n" +
-                "   \"install\": [\n" +
-                "     { \"package\": \"firefox\" }\n" +
-                "   ],\n" +
-                "   \"target\": \"4649fd96-cbe2-4f93-babf-4627ef9ee5e6\",\n" +
-                "   \"dataset\": \"examples_Health\",\n" +
-                "   \"uuid\": \"2df4935a-ba75-11e3-8f8d-b99a36fe516e\",\n" +
-                "   \"result\":\n" +
-                "     {\"installed\":[{\"name\":\"libsm6\",\"version\":\"1448\"},{\"name\":\"libx11-6\",\"version\":\"1456\"},{\"name\":\"libx11-data\",\"version\":\"1456\"}],\"removed\":[]},\n" +
-                "   \"*status*\": \"COMPLETED\"\n" +
-                "}\n";
-        ResponseData actual = new ResponseData(new JSONObject(result));
-        assertThat(expectedToInstall, containsInAnyOrder(actual.getPackagesToInstall().toArray()));
-        assertThat(expectedToRemove, containsInAnyOrder(actual.getPackagesToRemove().toArray()));
+    public RequestData(List<String> toInstall, List<String> toRemove, String target, String dataset) {
+        this.dataset = dataset;
+        this.target = target;
+        this.toRemove = toRemove;
+        this.toInstall = toInstall;
+        ontology = null;
+        universe = null;
+    }
+
+    public RequestData(List<String> toInstall, List<String> toRemove, String target, String dataset, String ontology, String universe) {
+        this.toInstall = toInstall;
+        this.toRemove = toRemove;
+        this.target = target;
+        this.dataset = dataset;
+        this.ontology = ontology;
+        this.universe = universe;
+    }
+
+    public String toString() {
+        JSONObject json = new JSONObject();
+        if (toInstall.size() > 0) {
+            json.put("install", getPackageList(toInstall));
+        }
+        if (toRemove.size() > 0) {
+            json.put("remove", getPackageList(toRemove));
+        }
+        json.put("target", target);
+        json.put("dataset", dataset);
+        if (ontology != null) {
+            json.put("ontology", ontology);
+        }
+        if (universe != null) {
+            json.put("universe", universe);
+        }
+        return json.toString();
+    }
+
+    private JSONArray getPackageList(List<String> packages) {
+        JSONArray result = new JSONArray();
+        for (String p : packages) {
+            JSONObject pkg = new JSONObject();
+            pkg.accumulate("package", p);
+            result.put(pkg);
+        }
+        return result;
+    }
+
+    public List<String> getToInstall() {
+        return toInstall;
+    }
+
+    public List<String> getToRemove() {
+        return toRemove;
+    }
+
+    public String getTarget() {
+        return target;
+    }
+
+    public String getDataset() {
+        return dataset;
+    }
+
+    public String getOntology() {
+        return ontology;
+    }
+
+    public String getUniverse() {
+        return universe;
     }
 
 }