@Test public void writeToMmvShouldSetThePositionOfTheBufferBeforeWriting() { ByteBuffer byteBuffer = mock(ByteBuffer.class); TypeHandler<Object> typeHandler = mock(TypeHandler.class); when(typeHandler.getMetricType()).thenReturn(mock(MmvMetricType.class)); pcpMetricInfoV2.setOffset(THIS_PCP_METRIC_INFO_OFFSET); pcpMetricInfoV2.setTypeHandler(typeHandler); pcpMetricInfoV2.writeToMmv(byteBuffer); InOrder inOrder = Mockito.inOrder(byteBuffer); inOrder.verify(byteBuffer).position(THIS_PCP_METRIC_INFO_OFFSET); inOrder.verify(byteBuffer).putLong(anyLong()); }
@Override public void writeToMmv(ByteBuffer byteBuffer) { byteBuffer.position(offset); byteBuffer.putLong(getStringOffset(nameAsPcpString)); byteBuffer.putInt(getId()); byteBuffer.putInt(typeHandler.getMetricType().getIdentifier()); byteBuffer.putInt(getSemantics().getPcpValue()); byteBuffer.putInt(UnitMapping.getDimensions(getUnit(), metricName)); if (domain != null) { byteBuffer.putInt(domain.getId()); } else { byteBuffer.putInt(DEFAULT_INSTANCE_DOMAIN_ID); } byteBuffer.putInt(0); byteBuffer.putLong(getStringOffset(shortHelpText)); byteBuffer.putLong(getStringOffset(longHelpText)); }
PcpMetricInfoV2 extends PcpMetricInfo { @Override public void writeToMmv(ByteBuffer byteBuffer) { byteBuffer.position(offset); byteBuffer.putLong(getStringOffset(nameAsPcpString)); byteBuffer.putInt(getId()); byteBuffer.putInt(typeHandler.getMetricType().getIdentifier()); byteBuffer.putInt(getSemantics().getPcpValue()); byteBuffer.putInt(UnitMapping.getDimensions(getUnit(), metricName)); if (domain != null) { byteBuffer.putInt(domain.getId()); } else { byteBuffer.putInt(DEFAULT_INSTANCE_DOMAIN_ID); } byteBuffer.putInt(0); byteBuffer.putLong(getStringOffset(shortHelpText)); byteBuffer.putLong(getStringOffset(longHelpText)); } }
PcpMetricInfoV2 extends PcpMetricInfo { @Override public void writeToMmv(ByteBuffer byteBuffer) { byteBuffer.position(offset); byteBuffer.putLong(getStringOffset(nameAsPcpString)); byteBuffer.putInt(getId()); byteBuffer.putInt(typeHandler.getMetricType().getIdentifier()); byteBuffer.putInt(getSemantics().getPcpValue()); byteBuffer.putInt(UnitMapping.getDimensions(getUnit(), metricName)); if (domain != null) { byteBuffer.putInt(domain.getId()); } else { byteBuffer.putInt(DEFAULT_INSTANCE_DOMAIN_ID); } byteBuffer.putInt(0); byteBuffer.putLong(getStringOffset(shortHelpText)); byteBuffer.putLong(getStringOffset(longHelpText)); } PcpMetricInfoV2(String metricName, int id, PcpString nameAsPcpString); }
PcpMetricInfoV2 extends PcpMetricInfo { @Override public void writeToMmv(ByteBuffer byteBuffer) { byteBuffer.position(offset); byteBuffer.putLong(getStringOffset(nameAsPcpString)); byteBuffer.putInt(getId()); byteBuffer.putInt(typeHandler.getMetricType().getIdentifier()); byteBuffer.putInt(getSemantics().getPcpValue()); byteBuffer.putInt(UnitMapping.getDimensions(getUnit(), metricName)); if (domain != null) { byteBuffer.putInt(domain.getId()); } else { byteBuffer.putInt(DEFAULT_INSTANCE_DOMAIN_ID); } byteBuffer.putInt(0); byteBuffer.putLong(getStringOffset(shortHelpText)); byteBuffer.putLong(getStringOffset(longHelpText)); } PcpMetricInfoV2(String metricName, int id, PcpString nameAsPcpString); @Override void writeToMmv(ByteBuffer byteBuffer); @Override int byteSize(); }
PcpMetricInfoV2 extends PcpMetricInfo { @Override public void writeToMmv(ByteBuffer byteBuffer) { byteBuffer.position(offset); byteBuffer.putLong(getStringOffset(nameAsPcpString)); byteBuffer.putInt(getId()); byteBuffer.putInt(typeHandler.getMetricType().getIdentifier()); byteBuffer.putInt(getSemantics().getPcpValue()); byteBuffer.putInt(UnitMapping.getDimensions(getUnit(), metricName)); if (domain != null) { byteBuffer.putInt(domain.getId()); } else { byteBuffer.putInt(DEFAULT_INSTANCE_DOMAIN_ID); } byteBuffer.putInt(0); byteBuffer.putLong(getStringOffset(shortHelpText)); byteBuffer.putLong(getStringOffset(longHelpText)); } PcpMetricInfoV2(String metricName, int id, PcpString nameAsPcpString); @Override void writeToMmv(ByteBuffer byteBuffer); @Override int byteSize();  }