@Test
    public void terminalNodes() {
        // Given
        Range range = Range.between(0, 60 * 1000);
        TimeWindow timeWindow = new TimeWindow(range);

        NodeList.Builder nodeBuilder = NodeList.newBuilder();
        LinkList.Builder linkBuilder = LinkList.newBuilder();

        // fromNode : [testApp] test-app
        Node fromNode = createNode("testApp", ServiceTypeFactory.of(1000, "WAS"));
        String fromNodeAgent = "test-app";
        // databaseNode : [testDatabase] test-database
        Node databaseNode = createNode("testDatabase", ServiceTypeFactory.of(2000, "RDB", ServiceTypeProperty.TERMINAL));
        String databaseNodeAgent = "test-database";
        nodeBuilder.addNode(databaseNode);
        // cacheNode : [testCache] test-cache
        Node cacheNode = createNode("testCache", ServiceTypeFactory.of(8000, "Cache", ServiceTypeProperty.TERMINAL));
        String cacheNodeAgent = "test-cache";
        nodeBuilder.addNode(cacheNode);
        NodeList nodeList = nodeBuilder.build();

        Link databaseLink = new Link(LinkDirection.IN_LINK, fromNode, databaseNode, range);
        HistogramSlot databaseSlowSlot = databaseNode.getServiceType().getHistogramSchema().getSlowSlot();
        long databaseCallSlowCount = 50L;
        databaseLink.addInLink(createLinkCallDataMap(fromNodeAgent, fromNode.getServiceType(), databaseNodeAgent, databaseNode.getServiceType(), databaseSlowSlot, databaseCallSlowCount));
        linkBuilder.addLink(databaseLink);

        Link cacheLink = new Link(LinkDirection.IN_LINK, fromNode, cacheNode, range);
        HistogramSlot cacheFastSlot = cacheNode.getServiceType().getHistogramSchema().getFastSlot();
        HistogramSlot cacheSlowSlot = cacheNode.getServiceType().getHistogramSchema().getSlowSlot();
        long cacheCallFastCount = 199L;
        long cacheCallSlowCount = 99L;
        cacheLink.addInLink(createLinkCallDataMap(fromNodeAgent, fromNode.getServiceType(), cacheNodeAgent, cacheNode.getServiceType(), cacheFastSlot, cacheCallFastCount));
        cacheLink.addInLink(createLinkCallDataMap(fromNodeAgent, fromNode.getServiceType(), cacheNodeAgent, cacheNode.getServiceType(), cacheSlowSlot, cacheCallSlowCount));
        linkBuilder.addLink(cacheLink);
        LinkList linkList = linkBuilder.build();

        // When
        nodeHistogramAppender.appendNodeHistogram(timeWindow, nodeList, linkList, buildTimeoutMillis);

        // Then
        // Database node
        Node actualDatabaseNode = nodeList.findNode(databaseNode.getApplication());
        NodeHistogram databaseNodeHistogram = actualDatabaseNode.getNodeHistogram();
        // verify application-level histogram
        Histogram databaseApplicationHistogram = databaseNodeHistogram.getApplicationHistogram();
        assertEquals(databaseCallSlowCount, databaseApplicationHistogram.getSlowCount());
        assertEquals(databaseCallSlowCount, databaseApplicationHistogram.getTotalCount());
        // verify agent-level histogram
        Map<String, Histogram> databaseAgentHistogramMap = databaseNodeHistogram.getAgentHistogramMap();
        Histogram databaseAgentHistogram = databaseAgentHistogramMap.get(databaseNodeAgent);
        assertEquals(databaseCallSlowCount, databaseAgentHistogram.getSlowCount());
        assertEquals(databaseCallSlowCount, databaseAgentHistogram.getTotalCount());
        // Cache node
        Node actualCacheNode = nodeList.findNode(cacheNode.getApplication());
        NodeHistogram cacheNodeHistogram = actualCacheNode.getNodeHistogram();
        // verify application-level histogram
        Histogram cacheApplicationHistogram = cacheNodeHistogram.getApplicationHistogram();
        assertEquals(cacheCallFastCount, cacheApplicationHistogram.getFastCount());
        assertEquals(cacheCallSlowCount, cacheApplicationHistogram.getSlowCount());
        assertEquals(cacheCallFastCount + cacheCallSlowCount, cacheApplicationHistogram.getTotalCount());
        // verify agent-level histogram
        Map<String, Histogram> cacheAgentHistogramMap = cacheNodeHistogram.getAgentHistogramMap();
        Histogram cacheAgentHistogram = cacheAgentHistogramMap.get(cacheNodeAgent);
        assertEquals(cacheCallFastCount, cacheAgentHistogram.getFastCount());
        assertEquals(cacheCallSlowCount, cacheAgentHistogram.getSlowCount());
        assertEquals(cacheCallFastCount + cacheCallSlowCount, cacheAgentHistogram.getTotalCount());
    }
Checks histograms for multiple terminal nodes called from a single node.
<pre>
    fromNode ---> databaseNode
              |-> cacheNode
</pre>
web/src/test/java/com/navercorp/pinpoint/web/applicationmap/appender/histogram/NodeHistogramAppenderTest.java