EtcdRepository implements ConfigurationRepository, RegistryRepository { @SneakyThrows({InterruptedException.class, ExecutionException.class}) @Override public String get(final String key) { List<KeyValue> keyValues = client.getKVClient().get(ByteSequence.from(key, Charsets.UTF_8)).get().getKvs(); return keyValues.isEmpty() ? null : keyValues.iterator().next().getValue().toString(Charsets.UTF_8); }  @Override void init(final String name, final GovernanceCenterConfiguration config); @SneakyThrows({InterruptedException.class, ExecutionException.class}) @Override String get(final String key); @SneakyThrows({InterruptedException.class, ExecutionException.class}) @Override List<String> getChildrenKeys(final String key); @SneakyThrows({InterruptedException.class, ExecutionException.class}) @Override void persist(final String key, final String value); @SneakyThrows({InterruptedException.class, ExecutionException.class}) @Override void persistEphemeral(final String key, final String value); @Override void delete(final String key); @Override void watch(final String key, final DataChangedEventListener dataChangedEventListener); @Override void close(); @Override String getType();  }
@Test public void assertGetKey() { repository.get("key"); verify(kv).get(ByteSequence.from("key", Charsets.UTF_8)); verify(getResponse).getKvs(); }
@Test public void assertGetKeyWhenThrowInterruptedException() throws ExecutionException, InterruptedException { doThrow(InterruptedException.class).when(getFuture).get(); try { repository.get("key"); } catch (final Exception ex) { assertThat(ex, instanceOf(InterruptedException.class)); } }
@Test public void assertGetKeyWhenThrowExecutionException() throws ExecutionException, InterruptedException { doThrow(ExecutionException.class).when(getFuture).get(); try { repository.get("key"); } catch (final Exception ex) { assertThat(ex, instanceOf(ExecutionException.class)); } }