### Question:
RevokeHandler extends HttpResource { protected FullHttpResponse doRevoke(String authHeader, String token) { if(StringUtils.isBlank(token)) { return OAuthUtil.badRequest("token is missing"); } BasicAuthCredentials creds = BasicAuthCredentials.fromAuthHeaderString(authHeader); Pair<UUID, Integer> personWithTtl = oauthDao.getPersonWithRefresh(creds.getUsername(), token); if(personWithTtl == null) { personWithTtl = oauthDao.getPersonWithAccess(creds.getUsername(), token); } if(personWithTtl != null) { triggerPlaceDeauthorizedIfNecessary(creds.getUsername(), personWithTtl.getKey()); oauthDao.removePersonAndTokens(creds.getUsername(), personWithTtl.getKey()); } return OAuthUtil.ok(); } @Inject  RevokeHandler(
         ApplicationAuth authorizer,
         BridgeMetrics metrics,
         OAuthDAO oauthDao,
         PlaceSelectionHandler placeSelectionHandler
   ); @Override FullHttpResponse respond(FullHttpRequest req, ChannelHandlerContext ctx);  }### Answer:
@Test public void testTokenRequired() { FullHttpResponse response = handler.doRevoke(AUTH_HEADER, null); assertEquals(HttpResponseStatus.BAD_REQUEST, response.getStatus()); }
@Test public void testRemovedViaRefresh() { EasyMock.expect(mockDao.getPersonWithRefresh("app1", token)).andReturn(new ImmutablePair<>(person, (int) TimeUnit.DAYS.toSeconds(5))); EasyMock.expect(mockDao.getAttrs("app1", person)).andReturn(ImmutableMap.of()).anyTimes(); mockDao.removePersonAndTokens("app1", person); EasyMock.expectLastCall(); replay(); FullHttpResponse response = handler.doRevoke(AUTH_HEADER, token); assertEquals(HttpResponseStatus.OK, response.getStatus()); verify(); }
@Test public void testRemovedViaAccess() { EasyMock.expect(mockDao.getPersonWithRefresh("app1", token)).andReturn(null); EasyMock.expect(mockDao.getPersonWithAccess("app1", token)).andReturn(new ImmutablePair<>(person, (int) TimeUnit.DAYS.toSeconds(5))); EasyMock.expect(mockDao.getAttrs("app1", person)).andReturn(ImmutableMap.of()).anyTimes(); mockDao.removePersonAndTokens("app1", person); EasyMock.expectLastCall(); replay(); FullHttpResponse response = handler.doRevoke(AUTH_HEADER, token); assertEquals(HttpResponseStatus.OK, response.getStatus()); verify(); }
@Test public void testNoPersonFound() { EasyMock.expect(mockDao.getPersonWithRefresh("app1", token)).andReturn(null); EasyMock.expect(mockDao.getPersonWithAccess("app1", token)).andReturn(null); replay(); FullHttpResponse response = handler.doRevoke(AUTH_HEADER, token); assertEquals(HttpResponseStatus.OK, response.getStatus()); verify(); }