@Test public void setAndGet() { this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 12.3))); this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 15.3))); assertThat(Iterables.collection(this.repository.findAll("foo")).iterator().next() .getValue()).isEqualTo(15.3); }
@Test public void setAndGetMultiple() { this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.val", 12.3), new Metric<Number>("foo.bar", 11.3))); assertThat(Iterables.collection(this.repository.findAll("foo"))).hasSize(2); }
@Test public void prefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.exporter.setGroups(Collections.singleton("foo")); this.exporter.export(); assertThat(Iterables.collection(this.writer.groups())).hasSize(1); }
@Test public void unprefixedMetricsNotCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.exporter.setGroups(Collections.singleton("bar")); this.exporter.export(); assertThat(Iterables.collection(this.writer.groups())).isEmpty(); }
@Test public void multiMetricGroupsCopiedAsDefault() { this.reader.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("bar", 2.3), new Metric<Number>("spam", 1.3))); this.exporter.export(); assertThat(this.writer.countGroups()).isEqualTo(1); assertThat(Iterables.collection(this.writer.findAll("foo"))).hasSize(2); }
@Test public void onlyPrefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.reader.set(new Metric<Number>("foobar.spam", 1.3)); this.exporter.setGroups(Collections.singleton("foo")); this.exporter.export(); assertThat(Iterables.collection(this.writer.groups())).hasSize(1); }
@Test public void setAndGet() { this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 12.3))); this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.bar", 15.3))); assertEquals(15.3, Iterables.collection(this.repository.findAll("foo")).iterator() .next().getValue()); }
@Test public void setAndGetMultiple() { this.repository.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("foo.val", 12.3), new Metric<Number>("foo.bar", 11.3))); assertEquals(2, Iterables.collection(this.repository.findAll("foo")).size()); }
@Test public void prefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.exporter.setGroups(Collections.singleton("foo")); this.exporter.export(); assertEquals(1, Iterables.collection(this.writer.groups()).size()); }
@Test public void unprefixedMetricsNotCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.exporter.setGroups(Collections.singleton("bar")); this.exporter.export(); assertEquals(0, Iterables.collection(this.writer.groups()).size()); }
@Test public void multiMetricGroupsCopiedAsDefault() { this.reader.set("foo", Arrays.<Metric<?>>asList(new Metric<Number>("bar", 2.3), new Metric<Number>("spam", 1.3))); this.exporter.export(); assertEquals(1, this.writer.countGroups()); assertEquals(2, Iterables.collection(this.writer.findAll("foo")).size()); }
@Test public void onlyPrefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo.bar", 2.3)); this.reader.set(new Metric<Number>("foo.spam", 1.3)); this.reader.set(new Metric<Number>("foobar.spam", 1.3)); this.exporter.setGroups(Collections.singleton("foo")); this.exporter.export(); assertEquals(1, Iterables.collection(this.writer.groups()).size()); }
@Test public void findAll() { this.repository.increment(new Delta<Long>("foo", 3L)); this.repository.set(new Metric<Number>("bar", 12.3)); assertThat(Iterables.collection(this.repository.findAll())).hasSize(2); }
@Test public void prefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo", 2.3)); this.exporter.export(); assertThat(Iterables.collection(this.writer.groups())).hasSize(1); }
@Test public void findAll() { this.repository.increment(new Delta<Long>("foo", 3L)); this.repository.set(new Metric<Number>("bar", 12.3)); assertEquals(2, Iterables.collection(this.repository.findAll()).size()); }
@Test public void prefixedMetricsCopied() { this.reader.set(new Metric<Number>("foo", 2.3)); this.exporter.export(); assertEquals(1, Iterables.collection(this.writer.groups()).size()); }