+ "/StateModelDefs/MasterSlave";
Reference resourceRef = new Reference(httpUrlBase);
Request request = new Request(Method.GET, resourceRef);
Client client = new Client(Protocol.HTTP);
Response response = client.handle(request);
Representation result = response.getEntity();
StringWriter sw = new StringWriter();
result.write(sw);
ObjectMapper mapper = new ObjectMapper();
ZNRecord zn = mapper.readValue(new StringReader(sw.toString()), ZNRecord.class);
Map<String, String> paraMap = new HashMap<String, String>();
paraMap.put(JsonParameters.MANAGEMENT_COMMAND,
ClusterSetup.addStateModelDef);
ZNRecord r = new ZNRecord("Test");
r.merge(zn);
StateModelDefinition newStateModel = new StateModelDefinition(r);
httpUrlBase =
"http://localhost:" + ADMIN_PORT + "/clusters/" + clusterName + "/StateModelDefs";
resourceRef = new Reference(httpUrlBase);
request = new Request(Method.POST, resourceRef);
request.setEntity(JsonParameters.JSON_PARAMETERS + "="
+ ClusterRepresentationUtil.ObjectToJson(paraMap) + "&"
+ JsonParameters.NEW_STATE_MODEL_DEF + "="
+ ClusterRepresentationUtil.ZNRecordToJson(r),
MediaType.APPLICATION_ALL);
client = new Client(Protocol.HTTP);
response = client.handle(request);
result = response.getEntity();
sw = new StringWriter();
result.write(sw);
// System.out.println(sw.toString());
AssertJUnit.assertTrue(sw.toString().contains("Test"));
}