@Test public void testHandle() throws Exception { currentUser("testuser"); Response response = underTest.handle(context); assertThat(response.getStatus().getCode(), is(200)); assertThat(IOUtils.toString(response.getPayload().openInputStream()), is("{\"username\":\"testuser\"}")); }
@Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { User user = securitySystem.currentUser(); Username username = new Username(user == null ? "anonymous" : user.getUserId()); StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON); return HttpResponses.ok(payload); }
NpmWhoamiHandler implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { User user = securitySystem.currentUser(); Username username = new Username(user == null ? "anonymous" : user.getUserId()); StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON); return HttpResponses.ok(payload); } }
NpmWhoamiHandler implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { User user = securitySystem.currentUser(); Username username = new Username(user == null ? "anonymous" : user.getUserId()); StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON); return HttpResponses.ok(payload); } @Inject  NpmWhoamiHandler(final SecuritySystem securitySystem, final ObjectMapper objectMapper); }
NpmWhoamiHandler implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { User user = securitySystem.currentUser(); Username username = new Username(user == null ? "anonymous" : user.getUserId()); StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON); return HttpResponses.ok(payload); } @Inject  NpmWhoamiHandler(final SecuritySystem securitySystem, final ObjectMapper objectMapper); @Nonnull @Override Response handle(@Nonnull final Context context); }
NpmWhoamiHandler implements Handler { @Nonnull @Override public Response handle(@Nonnull final Context context) throws Exception { User user = securitySystem.currentUser(); Username username = new Username(user == null ? "anonymous" : user.getUserId()); StringPayload payload = new StringPayload(objectMapper.writeValueAsString(username), APPLICATION_JSON); return HttpResponses.ok(payload); } @Inject  NpmWhoamiHandler(final SecuritySystem securitySystem, final ObjectMapper objectMapper); @Nonnull @Override Response handle(@Nonnull final Context context);  }