### Question:
QueryCacheBean { @RolesAllowed({"Administrator", "JBossAdministrator"}) @JmxManaged public String listRunningQueries() { RunningQueries rq = getRunningQueries(); StringBuilder buf = new StringBuilder(); for (String query : rq.getQueries()) { buf.append(query).append("\n"); } return buf.toString(); }  @RolesAllowed({"Administrator", "JBossAdministrator"}) @JmxManaged String listRunningQueries(); @GET @Path("/listRunningQueries") @Produces({"application/xml", "text/xml", "application/json", "text/yaml", "text/x-yaml", "application/x-yaml", "text/html"}) @GZIP @RolesAllowed({"Administrator", "JBossAdministrator"}) RunningQueries getRunningQueries(); @RolesAllowed({"Administrator", "JBossAdministrator"}) @JmxManaged String cancelUserQuery(String id);  }### Answer:
@SuppressWarnings({"rawtypes", "unchecked"}) @Test public void testListRunningQueries() throws Exception { expect(altCache.iterator()).andReturn((Iterator<RunningQuery>) new HashMap().values().iterator()); Map<String,Pair<QueryLogic<?>,Connector>> snapshot = new HashMap<>(); snapshot.put("key", this.pair); expect(this.remoteCache.snapshot()).andReturn(snapshot); expect(this.pair.getFirst()).andReturn((QueryLogic) this.logic); PowerMock.replayAll(); QueryCacheBean subject = new QueryCacheBean(); setInternalState(subject, QueryCache.class, altCache); setInternalState(subject, CreatedQueryLogicCacheBean.class, remoteCache); String result1 = subject.listRunningQueries(); PowerMock.verifyAll(); assertNotNull("List of running queries should not be null", result1); }