SerializableZookeeperState implements SerializableState { public void delete(String key) throws IOException { try { Variable value = zkState.fetch(key).get(); if (value.value().length == 0) { throw new InvalidParameterException("Key does not exist:" + key); } zkState.expunge(value); } catch (InterruptedException | ExecutionException e) { throw new IOException("Unable to delete key:" + key, e); } } SerializableZookeeperState(org.apache.mesos.state.State zkState); @SuppressWarnings("unchecked") T get(String key); void set(String key, T object); void delete(String key);  }
@Test public void shouldDeleteKey() throws IOException { serializableState.delete("test"); }
@Test(expected = InvalidParameterException.class) public void shouldExceptionIfKeyDoesntExist() throws IOException { when(variable.value()).thenReturn("".getBytes(Charset.forName("UTF-8"))); future = CompletableFuture.completedFuture(variable); when(state.fetch(anyString())).thenReturn(future); serializableState.delete("test"); }