Package org.springframework.xd.analytics.metrics.core

Examples of org.springframework.xd.analytics.metrics.core.GaugeRepository


  @Autowired
  RedisGaugeRepository repo;

  @Test
  public void testConvertToDouble() {
    GaugeRepository gaugeRepo = mock(GaugeRepository.class);
    GaugeHandler handler = new GaugeHandler(gaugeRepo, "test");
    int i = 4;
    long val = handler.convertToLong(i);
    assertEquals(4, val, 0.001);
    double d = 4.0;
View Full Code Here


    assertThat(gaugeRepository.findOne(gaugeName).getValue(), equalTo(0L));
  }

  @Test
  public void testCrud() {
    GaugeRepository repo = gaugeRepository;
    String myGaugeName = "myGauge";
    String yourGaugeName = "yourGauge";

    // Create and save a Gauge named 'myGauge'
    Gauge g1 = new Gauge(myGaugeName);
    Gauge myGauge = repo.save(g1);
    assertThat(myGauge.getName(), is(notNullValue()));
    // Create and save a Gauge named 'yourGauge'
    Gauge g2 = new Gauge(yourGaugeName);
    Gauge yourGauge = repo.save(g2);
    assertThat(yourGauge.getName(), is(notNullValue()));
    assertTrue(repo.exists(yourGauge.getName()));

    // Retrieve by name and compare for equality to previously saved instance.
    Gauge result = repo.findOne(myGaugeName);
    assertThat(result, equalTo(myGauge));

    result = repo.findOne(yourGauge.getName());
    assertThat(result, equalTo(yourGauge));

    List<Gauge> gauges = (List<Gauge>) repo.findAll();
    assertThat(gauges.size(), equalTo(2));

    repo.delete(myGauge);
    assertThat(repo.findOne(myGaugeName), is(nullValue()));

    repo.deleteAll();
    assertThat(repo.findOne(yourGaugeName), is(nullValue()));
    assertEquals(0, repo.count());

    repo.save(Arrays.asList(g1, g2));
    assertThat(repo.count(), equalTo(2L));

    repo.delete(Arrays.asList(g1, g2));
    assertEquals(0, repo.count());
  }
View Full Code Here

TOP

Related Classes of org.springframework.xd.analytics.metrics.core.GaugeRepository

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.