コード例 #1
0
 @Test
 public void testMetrics() throws Exception {
   InMemoryMetricRepository repository = new InMemoryMetricRepository();
   repository.set(new Metric<Double>("a", 0.5, new Date()));
   VanillaPublicMetrics publicMetrics = new VanillaPublicMetrics(repository);
   Map<String, Metric<?>> results = new HashMap<String, Metric<?>>();
   for (Metric<?> metric : publicMetrics.metrics()) {
     results.put(metric.getName(), metric);
   }
   assertThat(results.get("a").getValue().doubleValue(), equalTo(0.5));
 }
コード例 #2
0
  @Test
  public void testAdditionalMetrics() throws Exception {
    InMemoryMetricRepository repository = new InMemoryMetricRepository();
    Collection<PublicMetrics> allMetrics = new ArrayList<PublicMetrics>();
    allMetrics.add(new ImmutablePublicMetrics(new Metric<Number>("first", 2L)));
    allMetrics.add(new ImmutablePublicMetrics(new Metric<Number>("second", 4L)));

    VanillaPublicMetrics publicMetrics = new VanillaPublicMetrics(repository, allMetrics);
    Map<String, Metric<?>> results = new HashMap<String, Metric<?>>();
    for (Metric<?> metric : publicMetrics.metrics()) {
      results.put(metric.getName(), metric);
    }
    assertTrue(results.containsKey("first"));
    assertTrue(results.containsKey("second"));
    assertEquals(2, results.size());
  }