@Test public void testStore() throws Exception { final Notification expected = Notification.create("1"); final Optional<Notification> actual = client.store("test", expected); assertThat(actual.isPresent()).isTrue(); assertThat(actual.get()).isEqualTo(expected); }
public Optional<Notification> store(final String username, final Notification notification) { Objects.requireNonNull(notification, "notification == null"); final URI uri = getTarget(username); LOGGER.debug("POST {}", uri); try (Timer.Context context = storeTimer.time()) { return Optional.of( client .target(uri) .request(APPLICATION_JSON) .post(Entity.json(notification), Notification.class)); } catch (Exception e) { LOGGER.warn("Unable to store notification for {}", username, e); } return Optional.empty(); }
NotificationClient implements Closeable { public Optional<Notification> store(final String username, final Notification notification) { Objects.requireNonNull(notification, "notification == null"); final URI uri = getTarget(username); LOGGER.debug("POST {}", uri); try (Timer.Context context = storeTimer.time()) { return Optional.of( client .target(uri) .request(APPLICATION_JSON) .post(Entity.json(notification), Notification.class)); } catch (Exception e) { LOGGER.warn("Unable to store notification for {}", username, e); } return Optional.empty(); } }
NotificationClient implements Closeable { public Optional<Notification> store(final String username, final Notification notification) { Objects.requireNonNull(notification, "notification == null"); final URI uri = getTarget(username); LOGGER.debug("POST {}", uri); try (Timer.Context context = storeTimer.time()) { return Optional.of( client .target(uri) .request(APPLICATION_JSON) .post(Entity.json(notification), Notification.class)); } catch (Exception e) { LOGGER.warn("Unable to store notification for {}", username, e); } return Optional.empty(); } NotificationClient(final MetricRegistry registry, final Client client, final URI uri); }
NotificationClient implements Closeable { public Optional<Notification> store(final String username, final Notification notification) { Objects.requireNonNull(notification, "notification == null"); final URI uri = getTarget(username); LOGGER.debug("POST {}", uri); try (Timer.Context context = storeTimer.time()) { return Optional.of( client .target(uri) .request(APPLICATION_JSON) .post(Entity.json(notification), Notification.class)); } catch (Exception e) { LOGGER.warn("Unable to store notification for {}", username, e); } return Optional.empty(); } NotificationClient(final MetricRegistry registry, final Client client, final URI uri); Optional<SortedSet<Notification>> fetch(final String username); Optional<Notification> store(final String username, final Notification notification); void delete(final String username, final Collection<String> ids); void delete(final String username); boolean ping(); String version(); @Override void close(); }
NotificationClient implements Closeable { public Optional<Notification> store(final String username, final Notification notification) { Objects.requireNonNull(notification, "notification == null"); final URI uri = getTarget(username); LOGGER.debug("POST {}", uri); try (Timer.Context context = storeTimer.time()) { return Optional.of( client .target(uri) .request(APPLICATION_JSON) .post(Entity.json(notification), Notification.class)); } catch (Exception e) { LOGGER.warn("Unable to store notification for {}", username, e); } return Optional.empty(); } NotificationClient(final MetricRegistry registry, final Client client, final URI uri); Optional<SortedSet<Notification>> fetch(final String username); Optional<Notification> store(final String username, final Notification notification); void delete(final String username, final Collection<String> ids); void delete(final String username); boolean ping(); String version(); @Override void close();  }