JmxRequest { public JSONObject toJSON() { JSONObject ret = new JSONObject(); ret.put("type",type.getName()); if (targetConfig != null) { ret.put("target", targetConfig.toJSON()); } if (pathParts != null) { try { ret.put("path",getPath()); } catch (UnsupportedOperationException exp) { } } return ret; } protected  JmxRequest(RequestType pType, List<String> pPathParts, ProcessingParameters pProcessingParams);  JmxRequest(Map<String, ?> pMap, ProcessingParameters pInitParams); private  JmxRequest(RequestType pType, HttpMethod pMethod, List<String> pPathParts, ProcessingParameters pProcessingParams); RequestType getType(); String getParameter(ConfigKey pConfigKey); int getParameterAsInt(ConfigKey pConfigKey); Boolean getParameterAsBool(ConfigKey pConfigKey); ProxyTargetConfig getTargetConfig(); HttpMethod getHttpMethod(); ValueFaultHandler getValueFaultHandler(); List<String> getPathParts(); String getPath(); JSONObject toJSON();  }
@Test public void readRequestMultiAttributes() { for (JmxReadRequest req : new JmxReadRequest[] { JmxRequestFactory.createGetRequest("read/java.lang:type=Memory/Heap!/Memory!/Usage,NonHeapMemoryUsage", procParams), JmxRequestFactory.createPostRequest( createMap("type", "read", "mbean", "java.lang:type=Memory", "attribute",Arrays.asList("Heap/Memory/Usage","NonHeapMemoryUsage")),procParams) }) { assertTrue(req.isMultiAttributeMode()); for (List list : new List[] { (List) req.toJSON().get("attribute"), req.getAttributeNames() }) { assertEquals(list.size(), 2); assertTrue(list.contains("Heap/Memory/Usage")); assertTrue(list.contains("NonHeapMemoryUsage")); assertTrue(req.toString().contains("attribute=[")); try { req.getAttributeName(); fail(); } catch (IllegalStateException exp) { assertTrue(exp.getMessage().contains("getAttributeNames")); } } } }
@Test public void readRequestNullArguments() { for (JmxReadRequest req : new JmxReadRequest[] { (JmxReadRequest) JmxRequestFactory.createGetRequest("read/java.lang:type=Memory", procParams), (JmxReadRequest) JmxRequestFactory.createPostRequest( createMap("type", "read", "mbean", "java.lang:type=Memory"),procParams) }) { assertFalse(req.isMultiAttributeMode()); assertFalse(req.hasAttribute()); assertNull(req.getAttributeName()); for (List list : new List[] { (List) req.toJSON().get("attribute"), req.getAttributeNames() }) { assertNull(list); } } }