@Test public void testWithAccountId() { final Map<String, Object> requestAttributes = new HashMap<String, Object>(); final Form headers = new Form(); headers.add("accountid", "testaccountid"); requestAttributes.put("org.restlet.http.headers", headers); mockery.checking(new Expectations() { { allowing(request).getAttributes(); will(returnValue(requestAttributes)); allowing(accountIdPrincipalDao).execute("testaccountid"); will(returnValue(principal)); } }); assertEquals(principal, sut.transform(request)); mockery.assertIsSatisfied(); }
@Override public Principal transform(final Request inRequest) { String accountid = null; Principal result = null; if (inRequest.getAttributes().containsKey("org.restlet.http.headers")) { Form httpHeaders = (Form) inRequest.getAttributes().get("org.restlet.http.headers"); if (httpHeaders.getFirstValue("accountid") != null) { log.debug("Found accountid header: " + accountid); accountid = httpHeaders.getFirstValue("accountid"); } } if (accountid != null) { result = accountIdPrincipalDao.execute(accountid); } else { String osId = inRequest.getOriginalRef().getQueryAsForm().getFirstValue("opensocial_viewer_id"); if (osId != null) { result = openSocialIdPrincipalDao.execute(osId); } } return result; }
OAuthRequestToPrincipalTransformer implements Transformer<Request, Principal> { @Override public Principal transform(final Request inRequest) { String accountid = null; Principal result = null; if (inRequest.getAttributes().containsKey("org.restlet.http.headers")) { Form httpHeaders = (Form) inRequest.getAttributes().get("org.restlet.http.headers"); if (httpHeaders.getFirstValue("accountid") != null) { log.debug("Found accountid header: " + accountid); accountid = httpHeaders.getFirstValue("accountid"); } } if (accountid != null) { result = accountIdPrincipalDao.execute(accountid); } else { String osId = inRequest.getOriginalRef().getQueryAsForm().getFirstValue("opensocial_viewer_id"); if (osId != null) { result = openSocialIdPrincipalDao.execute(osId); } } return result; } }
OAuthRequestToPrincipalTransformer implements Transformer<Request, Principal> { @Override public Principal transform(final Request inRequest) { String accountid = null; Principal result = null; if (inRequest.getAttributes().containsKey("org.restlet.http.headers")) { Form httpHeaders = (Form) inRequest.getAttributes().get("org.restlet.http.headers"); if (httpHeaders.getFirstValue("accountid") != null) { log.debug("Found accountid header: " + accountid); accountid = httpHeaders.getFirstValue("accountid"); } } if (accountid != null) { result = accountIdPrincipalDao.execute(accountid); } else { String osId = inRequest.getOriginalRef().getQueryAsForm().getFirstValue("opensocial_viewer_id"); if (osId != null) { result = openSocialIdPrincipalDao.execute(osId); } } return result; } OAuthRequestToPrincipalTransformer(final DomainMapper<String, Principal> inAccountIdPrincipalDao,
            final DomainMapper<String, Principal> inOpenSocialIdPrincipalDao); }
OAuthRequestToPrincipalTransformer implements Transformer<Request, Principal> { @Override public Principal transform(final Request inRequest) { String accountid = null; Principal result = null; if (inRequest.getAttributes().containsKey("org.restlet.http.headers")) { Form httpHeaders = (Form) inRequest.getAttributes().get("org.restlet.http.headers"); if (httpHeaders.getFirstValue("accountid") != null) { log.debug("Found accountid header: " + accountid); accountid = httpHeaders.getFirstValue("accountid"); } } if (accountid != null) { result = accountIdPrincipalDao.execute(accountid); } else { String osId = inRequest.getOriginalRef().getQueryAsForm().getFirstValue("opensocial_viewer_id"); if (osId != null) { result = openSocialIdPrincipalDao.execute(osId); } } return result; } OAuthRequestToPrincipalTransformer(final DomainMapper<String, Principal> inAccountIdPrincipalDao,
            final DomainMapper<String, Principal> inOpenSocialIdPrincipalDao); @Override Principal transform(final Request inRequest); }
OAuthRequestToPrincipalTransformer implements Transformer<Request, Principal> { @Override public Principal transform(final Request inRequest) { String accountid = null; Principal result = null; if (inRequest.getAttributes().containsKey("org.restlet.http.headers")) { Form httpHeaders = (Form) inRequest.getAttributes().get("org.restlet.http.headers"); if (httpHeaders.getFirstValue("accountid") != null) { log.debug("Found accountid header: " + accountid); accountid = httpHeaders.getFirstValue("accountid"); } } if (accountid != null) { result = accountIdPrincipalDao.execute(accountid); } else { String osId = inRequest.getOriginalRef().getQueryAsForm().getFirstValue("opensocial_viewer_id"); if (osId != null) { result = openSocialIdPrincipalDao.execute(osId); } } return result; } OAuthRequestToPrincipalTransformer(final DomainMapper<String, Principal> inAccountIdPrincipalDao,
            final DomainMapper<String, Principal> inOpenSocialIdPrincipalDao); @Override Principal transform(final Request inRequest);  }