CursorStore { public void delete(final String username, final String cursorName) throws NotificationStoreException { Objects.requireNonNull(username, "username == null"); Preconditions.checkArgument(!username.isEmpty(), "username cannot be empty"); Objects.requireNonNull(cursorName, "cursorName == null"); Preconditions.checkArgument(!cursorName.isEmpty(), "cursorName cannot be empty"); final String key = getCursorKey(username, cursorName); final Location location = new Location(NAMESPACE, key); final DeleteValue deleteValue = new DeleteValue.Builder(location).withTimeout(timeout).build(); LOGGER.debug("Deleting key (async): {}", location); try (Timer.Context context = deleteTimer.time()) { final RiakFuture<Void, Location> future = client.executeAsync(deleteValue); future.await(requestTimeout.getQuantity(), requestTimeout.getUnit()); if (future.isSuccess()) { LOGGER.debug("Successfully deleted key: {}", location); } } catch (InterruptedException e) { LOGGER.warn("Delete request was interrupted", e); Thread.currentThread().interrupt(); throw new NotificationStoreException(e); } } CursorStore(
      final RiakClient client, final Duration timeout, final Duration requestTimeout); void initialize(); Optional<String> fetch(final String username, final String cursorName); void store(final String username, final String cursorName, final String value); void delete(final String username, final String cursorName); String getCursorKey(final String username, final String cursorName);  }
@Test @Ignore public void testDelete() throws Exception { store.delete(TEST_USER, CURSOR_NAME); verify(client).executeAsync(any(DeleteValue.class)); }
@Test public void testDeleteEmptyUsername() throws Exception { try { store.delete("", CURSOR_NAME); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { } verify(client, never()).execute(any(DeleteValue.class)); }
@Test public void testDeleteEmptyCursorName() throws Exception { try { store.delete(TEST_USER, ""); failBecauseExceptionWasNotThrown(IllegalArgumentException.class); } catch (IllegalArgumentException e) { } verify(client, never()).execute(any(DeleteValue.class)); }