JanusRestClient implements Janus { @Override public List<EntityMetadata> getSpList() { Map<String, String> parameters = new HashMap<String, String>(); final Collection metadataAsStrings = CollectionUtils.collect(Arrays.asList(Metadata.values()), new Transformer() { @Override public Object transform(Object input) { return ((Metadata) input).val(); } }); parameters.put("keys", StringUtils.join(metadataAsStrings, ',')); URI signedUri; try { signedUri = sign("getSpList", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final Map<String, Map<String, Object>> restResponse = restTemplate.getForObject(signedUri, Map.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } List<EntityMetadata> entities = new ArrayList<EntityMetadata>(); for (Map.Entry<String, Map<String, Object>> entry : restResponse.entrySet()) { String entityId = entry.getKey(); final EntityMetadata e = EntityMetadata.fromMetadataMap(entry.getValue()); e.setAppEntityId(entityId); entities.add(e); } return entities; } catch (IOException e) { LOG.error("While doing Janus-request", e); } return null; } JanusRestClient(); @Override EntityMetadata getMetadataByEntityId(String entityId); @Override List<String> getEntityIdsByMetaData(Metadata key, String value); @Override List<String> getAllowedSps(String idpentityid); @Override List<String> getAllowedSps(String idpentityid, String revision); @Override List<EntityMetadata> getSpList(); @Override List<EntityMetadata> getIdpList(); @Override ARP getArp(String entityId); @Override boolean isConnectionAllowed(String spEntityId, String idpEntityId); @Override JanusEntity getEntity(String entityId); void setRestTemplate(RestTemplate restTemplate); void setJanusUri(URI janusUri); void setUser(String user); void setSecret(String secret);  }
@Test public void getSpList() { ArgumentCaptor<URI> captor = ArgumentCaptor.forClass(URI.class); final Map<String, Map<String, Object>> data = new HashMap<String, Map<String, Object>>(); data.put("entityid", new HashMap<String, Object>()); when(restTemplate.getForObject((URI) anyObject(), eq(Map.class))).thenReturn(data); List<EntityMetadata> result = janusRestClient.getSpList(); assertNotNull(result.get(0)); verify(restTemplate).getForObject(captor.capture(), eq(Map.class)); assertTrue("Query string should contain correct method", captor.getValue().getQuery().contains ("method=getSpList")); assertTrue("Query string should contain correct user", captor.getValue().getQuery().contains("userid=user")); assertTrue("Query string should contain correct metadata field names", captor.getValue().getQuery().contains (Janus.Metadata.NAMEIDFORMAT.val())); }