@Test public void shouldDeleteTokenBasedOnTokenId() throws DeleteFailedException { String one = "one"; CTSPersistentStore store = mock(CTSPersistentStore.class); CoreTokenResource resource = new CoreTokenResource(mock(JSONSerialisation.class), store); resource.deleteInstance(null, one, mock(DeleteRequest.class), mock(ResultHandler.class)); verify(store).delete(one); }
public void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler) { try { store.delete(tokenId); Map<String, String> result = new HashMap<String, String>(); result.put(TOKEN_ID, tokenId); Resource resource = new Resource(tokenId, "0", new JsonValue(result)); handler.handleResult(resource); } catch (CoreTokenException e) { handler.handleError(generateException(e)); } }
CoreTokenResource implements CollectionResourceProvider { public void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler) { try { store.delete(tokenId); Map<String, String> result = new HashMap<String, String>(); result.put(TOKEN_ID, tokenId); Resource resource = new Resource(tokenId, "0", new JsonValue(result)); handler.handleResult(resource); } catch (CoreTokenException e) { handler.handleError(generateException(e)); } } }
CoreTokenResource implements CollectionResourceProvider { public void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler) { try { store.delete(tokenId); Map<String, String> result = new HashMap<String, String>(); result.put(TOKEN_ID, tokenId); Resource resource = new Resource(tokenId, "0", new JsonValue(result)); handler.handleResult(resource); } catch (CoreTokenException e) { handler.handleError(generateException(e)); } } CoreTokenResource(JSONSerialisation serialisation, CTSPersistentStore store); }
CoreTokenResource implements CollectionResourceProvider { public void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler) { try { store.delete(tokenId); Map<String, String> result = new HashMap<String, String>(); result.put(TOKEN_ID, tokenId); Resource resource = new Resource(tokenId, "0", new JsonValue(result)); handler.handleResult(resource); } catch (CoreTokenException e) { handler.handleError(generateException(e)); } } CoreTokenResource(JSONSerialisation serialisation, CTSPersistentStore store); void createInstance(ServerContext serverContext, CreateRequest createRequest, ResultHandler<Resource> handler); void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler); void readInstance(ServerContext serverContext, String tokenId, ReadRequest readRequest, ResultHandler<Resource> handler); void updateInstance(ServerContext serverContext, String tokenId, UpdateRequest updateRequest, ResultHandler<Resource> handler); void queryCollection(ServerContext serverContext, QueryRequest queryRequest, QueryResultHandler queryResultHandler); void patchInstance(ServerContext serverContext, String s, PatchRequest patchRequest, ResultHandler<Resource> handler); void actionInstance(ServerContext serverContext, String s, ActionRequest actionRequest, ResultHandler<JsonValue> jsonValueResultHandler); void actionCollection(ServerContext serverContext, ActionRequest actionRequest, ResultHandler<JsonValue> jsonValueResultHandler); }
CoreTokenResource implements CollectionResourceProvider { public void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler) { try { store.delete(tokenId); Map<String, String> result = new HashMap<String, String>(); result.put(TOKEN_ID, tokenId); Resource resource = new Resource(tokenId, "0", new JsonValue(result)); handler.handleResult(resource); } catch (CoreTokenException e) { handler.handleError(generateException(e)); } } CoreTokenResource(JSONSerialisation serialisation, CTSPersistentStore store); void createInstance(ServerContext serverContext, CreateRequest createRequest, ResultHandler<Resource> handler); void deleteInstance(ServerContext serverContext, String tokenId, DeleteRequest deleteRequest, ResultHandler<Resource> handler); void readInstance(ServerContext serverContext, String tokenId, ReadRequest readRequest, ResultHandler<Resource> handler); void updateInstance(ServerContext serverContext, String tokenId, UpdateRequest updateRequest, ResultHandler<Resource> handler); void queryCollection(ServerContext serverContext, QueryRequest queryRequest, QueryResultHandler queryResultHandler); void patchInstance(ServerContext serverContext, String s, PatchRequest patchRequest, ResultHandler<Resource> handler); void actionInstance(ServerContext serverContext, String s, ActionRequest actionRequest, ResultHandler<JsonValue> jsonValueResultHandler); void actionCollection(ServerContext serverContext, ActionRequest actionRequest, ResultHandler<JsonValue> jsonValueResultHandler);  }