String bytes_value = uploadToAs(TEST_WAR_PATH);
System.out.println("sha: " + bytes_value);
System.out.println();
ASConnection connection = getDomainControllerASConnection();
Operation op = addDeployment(TEST_WAR_FILE_NAME, bytes_value);
JsonNode ret = connection.executeRaw(op);
System.out.println("Add to /deploy done " + ret);
System.out.flush();
assert ret.toString().contains("success") : ret;
Address serverGroupAddress = new Address();
serverGroupAddress.add("server-group", "main-server-group");
serverGroupAddress.add("deployment", TEST_WAR_FILE_NAME);
Operation attach = new Operation("add", serverGroupAddress);
attach.addAdditionalProperty("enabled", true);
System.out.flush();
ret = connection.executeRaw(attach);
System.out.println("Add to server group done: " + ret);
System.out.flush();
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "add to sg was no success " + ret.getTextValue();
Result depRes;// = connection.execute(deploy);
Thread.sleep(500);
Operation undeploy = new Operation("undeploy", serverGroupAddress);
depRes = connection.execute(undeploy);
assert depRes.isSuccess() : "Undeploy went wrong: " + depRes.getFailureDescription();
// Now tear down stuff again
Operation unattach = new Remove(serverGroupAddress);
ret = connection.executeRaw(unattach);
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from sg was no success "
+ ret.getTextValue();
// remove from domain
Operation remove = new Remove("deployment", TEST_WAR_FILE_NAME);
ret = connection.executeRaw(remove);
assert ret.has("outcome") : "Ret not valid " + ret.toString();
assert ret.get("outcome").getTextValue().equals("success") : "remove from domain was no success "
+ ret.getTextValue();