public PcpMmvWriter(ByteBufferFactory byteBufferFactory, IdentifierSourceSet identifierSources, MmvVersion mmvVersion) { this.byteBufferFactory = byteBufferFactory; this.metricInfoStore = mmvVersion.createMetricInfoStore(identifierSources, stringStore); this.instanceDomainStore = mmvVersion.createInstanceDomainStore(identifierSources, stringStore); this.mmvVersion = mmvVersion; this.metricNameValidator = mmvVersion.createMetricNameValidator(); registerType(String.class, MMV_STRING_HANDLER); }
@Test public void shouldCreateAMetricInfoStoreWhenConstructed() { MmvVersion mmvVersion = mock(MmvVersion.class); IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); new PcpMmvWriter(mock(ByteBufferFactory.class), identifierSourceSet, mmvVersion); verify(mmvVersion).createMetricInfoStore(eq(identifierSourceSet), any(PcpStringStore.class)); }
@Before public void setUp() throws IOException { MockitoAnnotations.initMocks(this); when(mmvVersion.createMetricNameValidator()).thenReturn(metricNameValidator); when(mmvVersion.createInstanceDomainStore(eq(identifierSourceSet), any(PcpStringStore.class))).thenReturn(instanceDomainStore); when(mmvVersion.createMetricInfoStore(eq(identifierSourceSet), any(PcpStringStore.class))).thenReturn(metricInfoStore); when(byteBufferFactory.build(anyInt())).thenReturn(byteBuffer); pcpMmvWriter = new PcpMmvWriter(byteBufferFactory, identifierSourceSet, mmvVersion); }
@Test public void mmvVersion2_shouldCreateAVersion2MetricStore() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); PcpStringStore stringStore = mock(PcpStringStore.class); Store<PcpMetricInfo> actual = MMV_VERSION2.createMetricInfoStore(identifierSourceSet, stringStore); Store<PcpMetricInfo> expected = new MetricInfoStoreV2(identifierSourceSet, stringStore); assertReflectionEquals(expected, actual); }
@Test public void mmvVersion1_shouldCreateAVersion1MetricStore() { IdentifierSourceSet identifierSourceSet = mock(IdentifierSourceSet.class); Store<PcpMetricInfo> actual = MMV_VERSION1.createMetricInfoStore(identifierSourceSet, null); Store<PcpMetricInfo> expected = new MetricInfoStoreV1(identifierSourceSet); assertReflectionEquals(expected, actual); }