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

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


    counterRepository.findOne(null);
  }

  @Test
  public void testCrud() {
    CounterRepository repo = counterRepository;
    String myCounterName = "myCounter";
    String yourCounterName = "yourCounter";

    // Create and save a Counter named 'myCounter'
    Counter c1 = new Counter(myCounterName);
    Counter myCounter = repo.save(c1);
    assertThat(myCounter.getName(), is(notNullValue()));
    // Create and save a Counter named 'yourCounter'
    Counter c2 = new Counter(yourCounterName);
    Counter yourCounter = repo.save(c2);
    assertThat(yourCounter.getName(), is(notNullValue()));
    assertTrue(repo.exists(yourCounterName));

    // Retrieve by name and compare for equality to previously saved instance.
    Counter result = repo.findOne(myCounterName);
    assertThat(result, equalTo(myCounter));

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

    List<Counter> counters = (List<Counter>) repo.findAll();
    assertThat(counters.size(), equalTo(2));
    counters = (List<Counter>) repo.findAll(Arrays.asList(yourCounterName, myCounterName));
    assertEquals(2, counters.size());

    repo.delete(myCounter);
    assertThat(repo.findOne(myCounterName), is(nullValue()));

    repo.delete(yourCounter.getName());
    assertThat(repo.findOne(yourCounterName), is(nullValue()));
    assertThat(repo.count(), equalTo(0L));

    repo.save(Arrays.asList(c1, c2));
    assertThat(repo.count(), equalTo(2L));

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

TOP

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

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.