modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
| 15
modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/helper/LinkDeserializer.java
| 28
modules/integration-tests/rest-api/pom.xml
| 11
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
| 337 +++++-----
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
| 4
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkDeserializer.java
| 18
modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkSerializer.java
| 53 +
7 files changed, 308 insertions(+), 158 deletions(-)
New commits:
commit ddef8592f462ec95309368170b1e6c60966b8d6b
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 25 17:17:27 2013 +0200
Make the parser check its input and bail out if it is not valid.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/helper/LinkDeserializer.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/helper/LinkDeserializer.java
index e9582d4..f320d09 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/helper/LinkDeserializer.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/helper/LinkDeserializer.java
@@ -20,7 +20,11 @@
package org.rhq.enterprise.server.rest.helper;
import java.io.IOException;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+import org.codehaus.jackson.JsonLocation;
+import org.codehaus.jackson.JsonParseException;
import org.codehaus.jackson.JsonParser;
import org.codehaus.jackson.JsonProcessingException;
import org.codehaus.jackson.map.DeserializationContext;
@@ -44,25 +48,47 @@ import org.rhq.enterprise.server.rest.domain.Link;
*/
public class LinkDeserializer extends JsonDeserializer<Link>{
+ Pattern textPattern = Pattern.compile("\\S+"); // Non whitespace; could
possibly be narrowed
+
@Override
public Link deserialize(JsonParser jp, DeserializationContext ctxt) throws
IOException, JsonProcessingException {
String tmp = jp.getText(); // {
+ validate(jp, tmp,"{");
jp.nextToken(); // skip over { to the rel
String rel = jp.getText();
+ validateText(jp, rel);
jp.nextToken(); // skip over {
tmp = jp.getText();
+ validate(jp, tmp,"{");
jp.nextToken(); // skip over "href"
tmp = jp.getText();
-// jp.nextToken(); // skip over :
+ validate(jp, tmp,"href");
jp.nextToken(); // skip to "http:// ... "
String href = jp.getText();
+ validateText(jp, href);
jp.nextToken(); // skip }
tmp = jp.getText();
+ validate(jp, tmp, "}");
jp.nextToken(); // skip }
+ tmp = jp.getText();
+ validate(jp, tmp, "}");
Link link = new Link(rel,href);
return link;
}
+
+ private void validateText(JsonParser jsonParser, String input) throws
JsonProcessingException {
+ Matcher m = textPattern.matcher(input);
+ if (!m.matches()) {
+ throw new JsonParseException("Unexpected token: " + input,
jsonParser.getTokenLocation());
+ }
+ }
+
+ private void validate(JsonParser jsonParser, String input, String expected) throws
JsonProcessingException {
+ if (!input.equals(expected)) {
+ throw new JsonParseException("Unexpected token: " + input,
jsonParser.getTokenLocation());
+ }
+ }
}
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
index 3d39181..7789f9e 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
@@ -18,7 +18,6 @@
*/
package org.rhq.modules.integrationTests.restApi;
-import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -219,10 +218,61 @@ public class OperationsTest extends AbstractBase {
.when()
.delete("/operation/" + draftId);
}
+ }
+
+ @Test
+ public void testCatchBadLinkSerialization() throws Exception {
+
+ // Test that when we get Links back in bad format, we
+ // correctly bail out.
+
+ Operation draft = getADraftOperation(_platformId, discoveryDefinitionId);
+
+ int draftId = draft.getId();
+ draft.getParams().put("detailedDiscovery",true);
+
+ String jsonWithBadLinkSer = //
+ "{\n" +
+ " \"id\": " + draftId + ",\n" +
+ " \"name\": \"discovery\",\n" +
+ " \"readyToSubmit\": false,\n" +
+ " \"resourceId\": " + _platformId + ",\n" +
+ " \"definitionId\": " + discoveryDefinitionId +
",\n" +
+ " \"params\": {\n" +
+ " \"detailedDiscovery\": true\n" +
+ " },\n" +
+ " \"links\": [\n" +
+ " {\n" +
+ " \"rel\": \"edit\",\n" +
+ " \"href\":
\"http://localhost:7080/rest/operation/" + draftId + "\"\n" +
+ " }\n" +
+ " ]\n" +
+ "}";
+
+ try {
+ given()
+ .contentType(ContentType.JSON)
+ .pathParam("id", draftId)
+ .body(jsonWithBadLinkSer)
+ .log().everything()
+ .expect()
+ .statusCode(503)
+ .log().ifError()
+ .when()
+ .put("/operation/{id}");
+ } finally {
+ // delete the draft again
+ expect()
+ .statusCode(204)
+ .when()
+ .delete("/operation/" + draftId);
+ }
}
+
+
@Test
public void testCreateDraftOperationAndScheduleExecution() throws Exception {
commit 32395046687dcfd0cd9e46164a9ce4b6a82d1752
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 25 14:57:07 2013 +0200
Add a LinkSerializer to send links in correct format (one could argue not to send
links at all).
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
index 57c1a49..3d39181 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
@@ -318,8 +318,6 @@ public class OperationsTest extends AbstractBase {
assert draft != null;
assert draft.getDefinitionId() == definitionId;
- draft.setLinks(new ArrayList<Link>()); // Clean out links TODO
-
System.out.println("--- Draft created --");
System.out.flush();
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
index c3f7b2b..c199729 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
@@ -20,11 +20,13 @@
package org.rhq.modules.integrationTests.restApi.d;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
/**
* A Link inside objects
* @author Heiko W. Rupp
*/
+@JsonSerialize(using = LinkSerializer.class)
@JsonDeserialize(using = LinkDeserializer.class)
public class Link {
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkSerializer.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkSerializer.java
new file mode 100644
index 0000000..759c8dc
--- /dev/null
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkSerializer.java
@@ -0,0 +1,53 @@
+/*
+ * RHQ Management Platform
+ * Copyright (C) 2005-2013 Red Hat, Inc.
+ * All rights reserved.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation version 2 of the License.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
+ */
+
+package org.rhq.modules.integrationTests.restApi.d;
+
+import java.io.IOException;
+
+import com.fasterxml.jackson.core.JsonGenerator;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.databind.JsonSerializer;
+import com.fasterxml.jackson.databind.SerializerProvider;
+
+/**
+ * Special serializer for Link objects that does not map the classical {rel:abc,
href:xyz} scheme,
+ * but which puts the rel name "at the outside" like { abc : { href : xyz }}
to make it easier for
+ * clients to access the link.
+ * See also
https://bugzilla.redhat.com/show_bug.cgi?id=845244
+ * @author Heiko W. Rupp
+ * @see LinkDeserializer
+ */
+public class LinkSerializer extends JsonSerializer<Link> {
+
+ @Override
+ public void serialize(Link link, JsonGenerator jsonGenerator,
+ SerializerProvider serializerProvider) throws IOException,
JsonProcessingException {
+
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeFieldName(link.getRel());
+
+ jsonGenerator.writeStartObject();
+ jsonGenerator.writeFieldName("href");
+ jsonGenerator.writeString(link.getHref());
+ jsonGenerator.writeEndObject();
+
+ jsonGenerator.writeEndObject();
+ }
+}
commit 83336d77e19949e332d29e936ce6739aded399da
Author: Heiko W. Rupp <hwr(a)redhat.com>
Date: Thu Jul 25 12:55:54 2013 +0200
BZ 974963 Allow to schedule operations that have no parameters.
diff --git
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
index 5e8e68e..070675e 100644
---
a/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
+++
b/modules/enterprise/server/jar/src/main/java/org/rhq/enterprise/server/rest/OperationsHandlerBean.java
@@ -303,12 +303,15 @@ public class OperationsHandlerBean extends AbstractRestBean {
// Validate parameters
ConfigurationDefinition parameterDefinition =
opDef.getParametersConfigurationDefinition();
- List<String> errorMessages =
ConfigurationHelper.checkConfigurationWrtDefinition(parameters, parameterDefinition);
-
- if (errorMessages.size()>0) {
- // Configuration is not ok
- operation.setReadyToSubmit(false);
- throw new BadArgumentException("Validation of parameters
failed", StringUtils.getListAsString(errorMessages,", "));
+ if (parameterDefinition!=null) {
+ // There are parameters defined, so lets validate them.
+ List<String> errorMessages =
ConfigurationHelper.checkConfigurationWrtDefinition(parameters, parameterDefinition);
+
+ if (errorMessages.size()>0) {
+ // Configuration is not ok
+ operation.setReadyToSubmit(false);
+ throw new BadArgumentException("Validation of parameters
failed", StringUtils.getListAsString(errorMessages,", "));
+ }
}
}
diff --git a/modules/integration-tests/rest-api/pom.xml
b/modules/integration-tests/rest-api/pom.xml
index 47bfe18..5d7bde5 100644
--- a/modules/integration-tests/rest-api/pom.xml
+++ b/modules/integration-tests/rest-api/pom.xml
@@ -18,7 +18,7 @@
<properties>
<surefire-plugin.version>2.10</surefire-plugin.version>
- <jackson.version>1.9.5</jackson.version>
+ <jackson.version>2.0.5</jackson.version>
<rest-assured.version>1.8.1</rest-assured.version>
</properties>
@@ -53,15 +53,14 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
-
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
<version>${jackson.version}</version>
<scope>test</scope>
</dependency>
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
index 7800e5c..57c1a49 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/OperationsTest.java
@@ -18,6 +18,7 @@
*/
package org.rhq.modules.integrationTests.restApi;
+import java.util.ArrayList;
import java.util.List;
import java.util.Map;
@@ -42,7 +43,8 @@ import static org.hamcrest.core.Is.is;
*/
public class OperationsTest extends AbstractBase {
- private int definitionId;
+ private int discoveryDefinitionId;
+ private int viewPLDefinitionId;
@Before
public void setUp() throws Exception {
@@ -58,15 +60,20 @@ public class OperationsTest extends AbstractBase {
.when()
.get("/operation/definitions");
- definitionId = -1;
+ discoveryDefinitionId = -1;
List<Map<String,Object>> list = r.as(List.class);
for (Map<String,Object> map : list) {
- if (map.get("name").equals("discovery")) {
- definitionId = (Integer) map.get("id");
+ String name = (String) map.get("name");
+ Integer id = (Integer) map.get("id");
+ if (name.equals("discovery")) {
+ discoveryDefinitionId = id;
+ }
+ if (name.equals("viewProcessList")) {
+ viewPLDefinitionId = id;
}
}
- assert definitionId !=-1 : "No discovery operation found";
+ assert discoveryDefinitionId !=-1 : "No discovery operation found";
}
@Test
@@ -76,7 +83,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("did",definitionId)
+ .pathParam("did", discoveryDefinitionId)
.expect()
.statusCode(200)
.body("name",is("discovery"))
@@ -92,7 +99,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("did",-42)
+ .pathParam("did", -42)
.expect()
.statusCode(404)
.when()
@@ -107,7 +114,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
- .queryParam("resourceId",42)
+ .queryParam("resourceId", 42)
.expect()
.statusCode(404)
.when()
@@ -134,7 +141,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("did",-42)
+ .pathParam("did", -42)
.expect()
.statusCode(406)
.when()
@@ -150,7 +157,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
.queryParam("resourceId", 42)
- .pathParam("definitionId", definitionId)
+ .pathParam("definitionId", discoveryDefinitionId)
.expect()
.statusCode(404)
.when()
@@ -164,7 +171,7 @@ public class OperationsTest extends AbstractBase {
given()
.header(acceptJson)
- .pathParam("definitionId", definitionId)
+ .pathParam("definitionId", discoveryDefinitionId)
.expect()
.statusCode(406)
.when()
@@ -174,20 +181,7 @@ public class OperationsTest extends AbstractBase {
@Test
public void testCreateDraftOperation() throws Exception {
- Operation draft =
- given()
- .header(acceptJson)
- .pathParam("definitionId",definitionId)
- .queryParam("resourceId",_platformId)
- .expect()
- .statusCode(200)
- .log().ifError()
- .when()
- .post("/operation/definition/{definitionId}")
- .as(Operation.class);
-
- assert draft != null;
- assert draft.getDefinitionId() == definitionId;
+ Operation draft = getADraftOperation(_platformId, discoveryDefinitionId);
int draftId = draft.getId();
@@ -202,29 +196,17 @@ public class OperationsTest extends AbstractBase {
@Test
public void testCreateAndUpdateDraftOperation() throws Exception {
- Operation draft =
- given()
- .header(acceptJson)
- .pathParam("definitionId",definitionId)
- .queryParam("resourceId",_platformId)
- .expect()
- .statusCode(200)
- .log().ifError()
- .when()
- .post("/operation/definition/{definitionId}")
- .as(Operation.class);
-
- assert draft != null;
- assert draft.getDefinitionId() == definitionId;
+ Operation draft = getADraftOperation(_platformId, discoveryDefinitionId);
int draftId = draft.getId();
- draft.getParams().put("detailed",true);
+ draft.getParams().put("detailedDiscovery",true);
try {
given()
.contentType(ContentType.JSON)
.pathParam("id", draftId)
.body(draft)
+ .log().everything()
.expect()
.statusCode(200)
.log().ifError()
@@ -246,25 +228,51 @@ public class OperationsTest extends AbstractBase {
int platformId = findIdOfARealPlatform();
- Operation draft =
+ Operation draft = getADraftOperation(platformId, discoveryDefinitionId);
+
+ int draftId = draft.getId();
+
+ draft.setReadyToSubmit(true);
+ draft.getParams().put("detailedDiscovery", false);
+
+ // update to schedule
+ Operation scheduled =
given()
- .header(acceptJson)
- .pathParam("definitionId",definitionId)
- .queryParam("resourceId",platformId)
+ .contentType(ContentType.JSON)
+ .pathParam("id",draftId)
+ .body(draft)
.expect()
.statusCode(200)
.log().ifError()
.when()
- .post("/operation/definition/{definitionId}")
+ .put("/operation/{id}")
.as(Operation.class);
- assert draft != null;
- assert draft.getDefinitionId() == definitionId;
+ System.out.println(scheduled.getId());
+ String history = findHistoryItem(scheduled);
+
+ String historyId = history.substring(history.lastIndexOf("/")+1);
+ try {
+ waitAndCheckStatus(platformId, historyId);
+
+ } finally {
+
+ // Wait until the operation has finished and then delete
+ waitForTerminationAndDelete(historyId);
+
+ }
+ }
+
+ @Test
+ public void testCreateDraftOperationNoParamsAndScheduleExecution() throws Exception
{
+
+ int platformId = findIdOfARealPlatform();
+
+ Operation draft = getADraftOperation(platformId, viewPLDefinitionId);
int draftId = draft.getId();
draft.setReadyToSubmit(true);
- draft.getParams().put("detailedDiscovery", false);
// update to schedule
Operation scheduled =
@@ -280,6 +288,45 @@ public class OperationsTest extends AbstractBase {
.as(Operation.class);
System.out.println(scheduled.getId());
+ String history = findHistoryItem(scheduled);
+
+ String historyId = history.substring(history.lastIndexOf("/")+1);
+ try {
+ waitAndCheckStatus(platformId, historyId);
+
+ } finally {
+
+ // Wait until the operation has finished and then delete
+ waitForTerminationAndDelete(historyId);
+
+ }
+ }
+
+ private Operation getADraftOperation(int platformId, int definitionId) {
+ Operation draft =
+ given()
+ .header(acceptJson)
+ .pathParam("definitionId", definitionId)
+ .queryParam("resourceId",platformId)
+ .expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .post("/operation/definition/{definitionId}")
+ .as(Operation.class);
+
+ assert draft != null;
+ assert draft.getDefinitionId() == definitionId;
+
+ draft.setLinks(new ArrayList<Link>()); // Clean out links TODO
+
+ System.out.println("--- Draft created --");
+ System.out.flush();
+
+ return draft;
+ }
+
+ private String findHistoryItem(Operation scheduled) {
String history = null;
List<Link> links = scheduled.getLinks();
for (Link link : links) {
@@ -288,76 +335,74 @@ public class OperationsTest extends AbstractBase {
}
}
assert history != null;
+ return history;
+ }
- String historyId = history.substring(history.lastIndexOf("/")+1);
- try {
- Thread.sleep(15000); // we need to wait a little as the execution may take
time
+ private void waitAndCheckStatus(int platformId, String historyId) throws
InterruptedException {
+ Thread.sleep(15000); // we need to wait a little as the execution may take time
- given()
- .pathParam("hid",historyId)
- .expect()
- .statusCode(200)
- .log().ifError()
- .when()
- .get("/operation/history/{hid}");
+ given()
+ .pathParam("hid", historyId)
+ .expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .get("/operation/history/{hid}");
+
+ // See if we also find it when we are looking for histories on the resource
+ Response response =
+ given()
+ .queryParam("resourceId", platformId)
+ .header(acceptJson)
+ .expect()
+ .statusCode(200)
+ .log().ifError()
+ .when()
+ .get("/operation/history");
- // See if we also find it when we are looking for histories on the resource
+ // compare
+ List<Map<String,Object>> list = response.as(List.class);
+ boolean found = false;
+ for (Map<String,Object> map : list) {
+ if (map.get("jobId").equals(historyId)) {
+ found = true;
+ }
+ }
+ assert found;
+ }
+
+ private void waitForTerminationAndDelete(String historyId) throws
InterruptedException {
+ boolean done = false;
+ int count = 0;
+ while (!done) {
Response response =
given()
- .queryParam("resourceId",platformId)
.header(acceptJson)
- .expect()
- .statusCode(200)
- .log().ifError()
+ .pathParam("hid", historyId)
.when()
- .get("/operation/history");
-
- // compare
- List<Map<String,Object>> list = response.as(List.class);
- boolean found = false;
- for (Map<String,Object> map : list) {
- if (map.get("jobId").equals(historyId)) {
- found = true;
- }
- }
- assert found;
+ .get("/operation/history/{hid}");
- } finally {
+ JsonPath jsonPath = response.jsonPath();
+ String status= jsonPath.getString("status");
+ int code = response.statusCode();
- // Wait until the operation has finished and then delete
- boolean done = false;
- int count = 0;
- while (!done) {
- Response response =
- given()
- .header(acceptJson)
- .pathParam("hid", historyId)
- .when()
- .get("/operation/history/{hid}");
-
- JsonPath jsonPath = response.jsonPath();
- String status= jsonPath.getString("status");
- int code = response.statusCode();
-
- if (code==200 && (status.equals("Success") ||
status.equals("Failed"))) {
- done = true;
- } else {
- Thread.sleep(2000);
- }
- count ++;
- assert count < 10 :"Waited for 20sec -- something is
wrong";
+ if (code==200 && (status.equals("Success") ||
status.equals("Failed"))) {
+ done = true;
+ } else {
+ Thread.sleep(2000);
}
-
- // Delete the history item
- given()
- .pathParam("hid",historyId)
- .expect()
- .statusCode(204)
- .log().ifError()
- .when()
- .delete("/operation/history/{hid}");
-
+ count ++;
+ assert count < 10 :"Waited for 20sec -- something is wrong";
}
+
+ // Delete the history item
+ given()
+ .pathParam("hid", historyId)
+ .expect()
+ .statusCode(204)
+ .log().ifError()
+ .when()
+ .delete("/operation/history/{hid}");
}
@Test
@@ -365,20 +410,7 @@ public class OperationsTest extends AbstractBase {
int platformId = findIdOfARealPlatform();
- Operation draft =
- given()
- .header(acceptJson)
- .pathParam("definitionId",definitionId)
- .queryParam("resourceId",platformId)
- .expect()
- .statusCode(200)
- .log().ifError()
- .when()
- .post("/operation/definition/{definitionId}")
- .as(Operation.class);
-
- assert draft != null;
- assert draft.getDefinitionId() == definitionId;
+ Operation draft = getADraftOperation(platformId, discoveryDefinitionId);
int draftId = draft.getId();
@@ -423,20 +455,7 @@ public class OperationsTest extends AbstractBase {
int platformId = findIdOfARealPlatform();
- Operation draft =
- given()
- .header(acceptJson)
- .pathParam("definitionId",definitionId)
- .queryParam("resourceId",platformId)
- .expect()
- .statusCode(200)
- .log().ifError()
- .when()
- .post("/operation/definition/{definitionId}")
- .as(Operation.class);
-
- assert draft != null;
- assert draft.getDefinitionId() == definitionId;
+ Operation draft = getADraftOperation(platformId, discoveryDefinitionId);
int draftId = draft.getId();
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
index e16213c..c3f7b2b 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/Link.java
@@ -19,7 +19,7 @@
package org.rhq.modules.integrationTests.restApi.d;
-import org.codehaus.jackson.map.annotate.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
/**
* A Link inside objects
diff --git
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkDeserializer.java
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkDeserializer.java
index 5d45724..c138761 100644
---
a/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkDeserializer.java
+++
b/modules/integration-tests/rest-api/src/test/java/org/rhq/modules/integrationTests/restApi/d/LinkDeserializer.java
@@ -21,19 +21,19 @@ package org.rhq.modules.integrationTests.restApi.d;
import java.io.IOException;
-import org.codehaus.jackson.JsonNode;
-import org.codehaus.jackson.JsonParser;
-import org.codehaus.jackson.JsonProcessingException;
-import org.codehaus.jackson.ObjectCodec;
-import org.codehaus.jackson.map.DeserializationContext;
-import org.codehaus.jackson.map.JsonDeserializer;
+import com.fasterxml.jackson.core.JsonParser;
+import com.fasterxml.jackson.core.JsonProcessingException;
+import com.fasterxml.jackson.core.ObjectCodec;
+import com.fasterxml.jackson.databind.DeserializationContext;
+import com.fasterxml.jackson.databind.JsonDeserializer;
+import com.fasterxml.jackson.databind.JsonNode;
/**
* Custom deserializer for link object that are now in the form { relname : {
"href": link}}
*
* @author Heiko W. Rupp
*/
-public class LinkDeserializer extends JsonDeserializer<Link>{
+public class LinkDeserializer extends JsonDeserializer<Link> {
@Override
public Link deserialize(JsonParser jsonParser,
@@ -41,8 +41,8 @@ public class LinkDeserializer extends JsonDeserializer<Link>{
ObjectCodec oc = jsonParser.getCodec();
JsonNode node = oc.readTree(jsonParser);
- String rel = node.getFieldNames().next();
- String href = node.getElements().next().get("href").getTextValue();
+ String rel = node.fieldNames().next();
+ String href = node.elements().next().get("href").textValue();
return new Link(rel,href);