@Test public void getEntityIdsByMetadata() { ArgumentCaptor<URI> captor = ArgumentCaptor.forClass(URI.class); final List<String> ids = new ArrayList<String>(Arrays.asList("id1", "id2")); when(restTemplate.getForObject((URI) anyObject(), eq(List.class))).thenReturn(ids); List<String> result = janusRestClient.getEntityIdsByMetaData(Janus.Metadata.OAUTH_CONSUMERKEY, "foobar"); assertEquals("id1", result.get(0)); assertEquals("id2", result.get(1)); verify(restTemplate).getForObject(captor.capture(), eq(List.class)); assertTrue("Query string should contain correct key (the consumer key metadata name)", captor.getValue().getQuery().contains("key=coin:gadgetbaseurl")); assertTrue("Query string should contain correct value (the consumer key metadata value)", captor.getValue().getQuery().contains("value=foobar")); assertTrue("Query string should contain correct method", captor.getValue().getQuery().contains ("method=findIdentifiersByMetadata")); assertTrue("Query string should contain correct user", captor.getValue().getQuery().contains("userid=user")); }
@Override public List<String> getEntityIdsByMetaData(Metadata key, String value) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("key", key.val()); parameters.put("value", value); URI signedUri; try { signedUri = sign("findIdentifiersByMetadata", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final List<String> restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return restResponse; } catch (IOException e) { LOG.error("While doing Janus-request", e); } return null; }
JanusRestClient implements Janus { @Override public List<String> getEntityIdsByMetaData(Metadata key, String value) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("key", key.val()); parameters.put("value", value); URI signedUri; try { signedUri = sign("findIdentifiersByMetadata", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final List<String> restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return restResponse; } catch (IOException e) { LOG.error("While doing Janus-request", e); } return null; } }
JanusRestClient implements Janus { @Override public List<String> getEntityIdsByMetaData(Metadata key, String value) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("key", key.val()); parameters.put("value", value); URI signedUri; try { signedUri = sign("findIdentifiersByMetadata", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final List<String> restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return restResponse; } catch (IOException e) { LOG.error("While doing Janus-request", e); } return null; } JanusRestClient(); }
JanusRestClient implements Janus { @Override public List<String> getEntityIdsByMetaData(Metadata key, String value) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("key", key.val()); parameters.put("value", value); URI signedUri; try { signedUri = sign("findIdentifiersByMetadata", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final List<String> restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return restResponse; } 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); }
JanusRestClient implements Janus { @Override public List<String> getEntityIdsByMetaData(Metadata key, String value) { Map<String, String> parameters = new HashMap<String, String>(); parameters.put("key", key.val()); parameters.put("value", value); URI signedUri; try { signedUri = sign("findIdentifiersByMetadata", parameters); if (LOG.isTraceEnabled()) { LOG.trace("Signed Janus-request is: {}", signedUri); } @SuppressWarnings("unchecked") final List<String> restResponse = restTemplate.getForObject(signedUri, List.class); if (LOG.isTraceEnabled()) { LOG.trace("Janus-request returned: {}", restResponse.toString()); } return restResponse; } 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);  }