Package com.google.sitebricks.stat.testservices

Examples of com.google.sitebricks.stat.testservices.ChildDummyService


  /**
   * This test illustrates how stats are published from parent classes when
   * a child class is published.
   */
  @Test public void testPublishingStatsInChildService() {
    ChildDummyService service = injector.getInstance(ChildDummyService.class);

    service.call();
    service.call();

    Stats stats = injector.getInstance(Stats.class);
    ImmutableMap<StatDescriptor, Object> snapshot = stats.snapshot();

    // We expect 1 stat from the child class and 2 from its parent
    assertEquals(snapshot.size(), 3);
    StatDescriptor numberOfChildCallsDescriptor =
        getByName(ChildDummyService.NUMBER_OF_CHILD_CALLS, snapshot);
    String numberOfChildCallsValue =
        (String) snapshot.get(numberOfChildCallsDescriptor);
    assertEquals(
        String.valueOf(service.getChildCalls()), numberOfChildCallsValue);

    // Below we check the value of the stats on the parent class
    StatDescriptor numberOfCallsDescriptor =
        getByName(DummyService.NUMBER_OF_CALLS, snapshot);
    String numberOfCallsValue = (String) snapshot.get(numberOfCallsDescriptor);
    assertEquals(String.valueOf(service.getCalls()), numberOfCallsValue);

    StatDescriptor callLatencyNsDescriptor =
        getByName(DummyService.CALL_LATENCY_NS, snapshot);
    String callLatencyValue = (String) snapshot.get(callLatencyNsDescriptor);
    assertEquals(service.getCallLatencyMs().toString(), callLatencyValue);
  }
View Full Code Here


   * Adding such behavior is a TODO, as it most likely would be the expected
   * behavior.
   */
  @Test
  public void testPublishingStatsInChildService() {
    ChildDummyService service = injector.getInstance(ChildDummyService.class);

    service.call();
    service.call();

    Stats stats = injector.getInstance(Stats.class);
    ImmutableMap<StatDescriptor, Object> snapshot = stats.snapshot();

    assertEquals(snapshot.size(), 1);
    StatDescriptor numberOfChildCallsDescriptor =
        getByName(ChildDummyService.NUMBER_OF_CHILD_CALLS, snapshot);
    String numberOfChildCallsValue =
        (String) snapshot.get(numberOfChildCallsDescriptor);
    assertEquals(
        String.valueOf(service.getChildCalls()), numberOfChildCallsValue);
  }
View Full Code Here

TOP

Related Classes of com.google.sitebricks.stat.testservices.ChildDummyService

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.