@Test public void convertShouldReturnNonEmptyListOfGaugesOnNonEmptyDurationReportEntries() { ReportEntry durationReportEntry = mock(ReportEntry.class); when(durationReportEntry.getType()).thenReturn(ReportEntryType.DURATION); List<ReportEntry> reportEntries = Collections.singletonList(durationReportEntry); Map<String, LabeledMetricConf> labeledMetricConfByPattern = Collections.singletonMap("key", mock(LabeledMetricConf.class)); ExtractedMetric extractedMetric = mock(ExtractedMetric.class); when(extractedMetric.getMetricName()).thenReturn("metric_name"); when(extractedMetric.getValue()).thenReturn(1d); DurationReportEntryMetricExtraction.Extractor durationMetricExtractor = mock(DurationReportEntryMetricExtraction.Extractor.class); when(durationMetricExtractor.extract(durationReportEntry)).thenReturn(extractedMetric); Gauge gauge = mock(Gauge.class); GaugesCreation.BuilderWithoutLabels builderWithoutLabels = mock(GaugesCreation.BuilderWithoutLabels.class); when(builderWithoutLabels.build("metric_name", "location:path", 1d)).thenReturn(gauge); List<Gauge> gauges = ReportEntryToMetricConverter.convert(reportEntries, "path", labeledMetricConfByPattern, mock(CounterReportEntryMetricExtraction.Extractor.class), durationMetricExtractor, builderWithoutLabels, mock(GaugesCreation.BuilderWithLabels.class) ); assertEquals(Collections.singletonList(gauge), gauges); }
public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); } }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern); static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern,
                                      CounterReportEntryMetricExtraction.Extractor counterReportEntryMetricExtractor,
                                      DurationReportEntryMetricExtraction.Extractor durationReportEntryMetricExtractor,
                                      GaugesCreation.BuilderWithoutLabels gaugesBuilderWithoutLabels,
                                      GaugesCreation.BuilderWithLabels gaugesBuilderWithLabelsBuilder); static X uniqueElementOrThrow(List<E> list, Function<E, X> mapper); }
ReportEntryToMetricConverter { public static List<Gauge> convert(List<ReportEntry> reportEntries, String path, Map<String, LabeledMetricConf> labeledMetricConfByPattern) { return convert(reportEntries, path, labeledMetricConfByPattern, CounterReportEntryMetricExtraction::extractMetricFromReportEntry, DurationReportEntryMetricExtraction::extractMetricFromReportEntry, GaugesCreation::buildGaugeWithoutLabels, GaugesCreation::buildGaugeWithLabels); }  static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern); static List<Gauge> convert(List<ReportEntry> reportEntries,
                                      String path,
                                      Map<String, LabeledMetricConf> labeledMetricConfByPattern,
                                      CounterReportEntryMetricExtraction.Extractor counterReportEntryMetricExtractor,
                                      DurationReportEntryMetricExtraction.Extractor durationReportEntryMetricExtractor,
                                      GaugesCreation.BuilderWithoutLabels gaugesBuilderWithoutLabels,
                                      GaugesCreation.BuilderWithLabels gaugesBuilderWithLabelsBuilder); static X uniqueElementOrThrow(List<E> list, Function<E, X> mapper); static final String REPORT_ENTRY_KEY_SEP; static final String METRIC_NAME_SEP; static final String LABEL_PATTERN_VALUE_TOKEN; static final String DURATION_METRIC_NAME_SUFFIX; }