MetricInfoStoreV2(IdentifierSourceSet identifierSources, PcpStringStore stringStore) { super(identifierSources.metricSource()); this.stringStore = stringStore; }
MetricInfoStoreV1(IdentifierSourceSet identifierSources) { super(identifierSources.metricSource()); }
private IdentifierSource parseMetrics(Iterable<String> metricData) { final BiMap<String, Integer> allocations = HashBiMap.<String, Integer>create(); int lineNumber = 0; for (String currentLine : metricData) { lineNumber++; if (!(currentLine.trim().isEmpty() || currentLine.trim().startsWith("#"))) { parseAllocation(allocations, lineNumber, currentLine); } } return new FixedValueIdentifierSource(allocations, fallbacks.metricSource()); }
private void assertMetricResultMatches(List<String> input) { IdentifierSourceSet sources = new StringParsingIdentifierSourceSet(Collections .<String> emptyList(), input, FALLBACK_SOURCES); assertEquals(METRIC_ID, sources.metricSource().calculateId(METRIC_NAME, Collections.<Integer> emptySet())); }
@Test public void metricInfoStoreShouldCreateANewPcpMetricInfoV2() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); PcpStringStore stringStore = mock(PcpStringStore.class); PcpString pcpString = mock(PcpString.class); IdentifierSource identifierSource = mock(IdentifierSource.class); when(identifierSourceSet.metricSource()).thenReturn(identifierSource); when(identifierSource.calculateId(eq("my.metric"), ArgumentMatchers.<Integer>anySet())).thenReturn(123); when(stringStore.createPcpString("my.metric")).thenReturn(pcpString); MetricInfoStoreV2 metricInfoStoreV2 = new MetricInfoStoreV2(identifierSourceSet, stringStore); PcpMetricInfo actual = metricInfoStoreV2.byName("my.metric"); PcpMetricInfoV2 expected = new PcpMetricInfoV2("my.metric", 123, pcpString); assertReflectionEquals(expected, actual); } }
@Test public void nullFileShouldUseDefaultMetricSource() { assertEquals(FIXED_FALLBACK, buildFileSet(null, null).metricSource().calculateId( METRIC_NAME, NO_IDS)); }
@Test public void metricValuesShouldBeParsedFromFile() { assertEquals(METRIC_ID, buildFileSet(null, tempFile(METRIC_FILE)).metricSource() .calculateId(METRIC_NAME, NO_IDS)); }
@Test public void metricValuesShouldBeParsedFromStream() { assertEquals(METRIC_ID, buildStreamSet(null, tempStream(METRIC_FILE)).metricSource() .calculateId(METRIC_NAME, NO_IDS)); }
@Test public void metricValuesShouldBeParsedFromReader() { assertEquals(METRIC_ID, buildReaderSet(null, tempReader(METRIC_FILE)).metricSource() .calculateId(METRIC_NAME, NO_IDS)); }