JmxRequestFactory { public static List<JmxRequest> createPostRequests(List pJsonRequests, ProcessingParameters pProcessingParams) { List<JmxRequest> ret = new ArrayList<JmxRequest>(); for (Object o : pJsonRequests) { if (!(o instanceof Map)) { throw new IllegalArgumentException("Not a request within the list of requests " + pJsonRequests + ". Expected map, but found: " + o); } ret.add(createPostRequest((Map<String,?>) o,pProcessingParams)); } return ret; } private  JmxRequestFactory(); static R createGetRequest(String pPathInfo, ProcessingParameters pProcessingParameters); static R createPostRequest(Map<String, ?> pRequestMap, ProcessingParameters pProcessingParams); static List<JmxRequest> createPostRequests(List pJsonRequests, ProcessingParameters pProcessingParams);  }
@Test public void multiPostRequests() { Map<String,Object> req1Map = createMap( "type","read", "mbean","java.lang:type=Memory", "attribute","HeapMemoryUsage"); Map<String,Object> req2Map = createMap( "type","list"); List<JmxRequest> req = JmxRequestFactory.createPostRequests(Arrays.asList(req1Map, req2Map),procParams); assertEquals(req.get(0).getType(), RequestType.READ); assertEquals(req.get(1).getType(), RequestType.LIST); }
@Test(expectedExceptions = { IllegalArgumentException.class }) public void multiPostRequestsWithWrongArg() { Map<String,Object> reqMap = createMap( "type", "list"); JmxRequestFactory.createPostRequests(Arrays.asList(reqMap, "Wrong"),procParams); }