}
@Test
public void testCreateUpdateWithLinksRemovePlatform() throws Exception {
Resource resource = new Resource();
resource.setResourceName("dummy-test");
resource.setTypeName("Linux");
Response response =
given()
.header(acceptXml)
.contentType(ContentType.JSON)
.body(resource)
.expect()
.statusCode(201)
.log().ifError()
.when()
.post("/resource/platforms");
int platformId=0;
try {
XmlPath xmlPath = response.xmlPath();
Node resource1 = xmlPath.get("resource");
Node platformIdNode = resource1.get("resourceId");
platformId = Integer.parseInt(platformIdNode.value());
// Now update the description
resource.setDescription("li la lu");
resource.setLocation("Datacenter 1");
resource.setResourceName("DummY");
/* Now add links -- JSON looks like this:
"links": [
{
"operationDefinitions": {
"href": "http://localhost:7080/rest/operation/definitions?resourceId=10584"
}
},
*/
List<Map> links = new ArrayList<Map>(1);
Map<String,Map<String,String>> map = new HashMap<String, Map<String,String>>(1);
Map<String,String> link = new HashMap<String, String>(1);
link.put("href","http:/abc");
map.put("self",link);
links.add(map);
resource.setLinks(links);
given()
.pathParam("id",platformId)
.body(resource)