String cloudInventoryUrl = connectionsBaseUrl + "/" + cloud.getId() + "/inventory";
ConnectionInventoryResponseDTO cloudInventory =
jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));
InventoryItemResponseDTO iiDTO = null;
for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
iiDTO = inventoryItem;
break;
}
}
assertNotNull(iiDTO);
String currentState = iiDTO.getPayload().getString("state");
assertEquals(NodeState.RUNNING.toString(), currentState);
assertEquals("200",
makeRequest(inventoryItemBaseUrl + "/" + iiDTO.getId() + "/reboot", "PUT", null, authnToken));
cloudInventory = jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
TypeFactory.defaultInstance().constructType(InventoryItemResponseDTO.class));
for (InventoryItemResponseDTO inventoryItem : cloudInventory.getInventoryItems()) {
if (inventoryItem.getExternalId().equals(newNode.getProviderId())) {
iiDTO = inventoryItem;
break;
}
}
// There is no good way to test a reboot since it seems that these node reboots are too fast to see a state
// change so just ensure they are running after reboot.
currentState = iiDTO.getPayload().getString("state");
assertEquals(NodeState.RUNNING.toString(), currentState);
// Destroy the node
makeRequest(inventoryItemBaseUrl + "/" + iiDTO.getId(), "DELETE", null, authnToken);
cloudInventory = jsonToObject(makeRequest(cloudInventoryUrl, "GET", null, authnToken),
TypeFactory.defaultInstance().constructType(ConnectionInventoryResponseDTO.class));