### Question:
InstanceMonitor extends DynamicMBeanProvider { public InstanceMonitor(String clusterName, String participantName, ObjectName objectName) { _clusterName = clusterName; _participantName = participantName; _tags = ImmutableList.of(ClusterStatusMonitor.DEFAULT_TAG); _initObjectName = objectName; _dynamicCapacityMetricsMap = new ConcurrentHashMap<>(); createMetrics(); } InstanceMonitor(String clusterName, String participantName, ObjectName objectName); @Override String getSensorName(); synchronized void updateInstance(Set<String> tags,
      Map<String, List<String>> disabledPartitions, List<String> oldDisabledPartitions,
      boolean isLive, boolean isEnabled); synchronized void increaseMessageCount(long messageReceived); synchronized void updateMaxCapacityUsage(double maxUsage); synchronized void updateMessageQueueSize(long queueSize); synchronized void updatePastDueMessageGauge(long msgCount); void updateCapacity(Map<String, Integer> capacity); @Override DynamicMBeanProvider register();  }### Answer:
@Test public void testInstanceMonitor() throws JMException { String testCluster = "testCluster"; String testInstance = "testInstance"; String testDomain = "testDomain:key=value"; Set<String> tags = ImmutableSet.of("test", "DEFAULT"); Map<String, List<String>> disabledPartitions = ImmutableMap.of("instance1", ImmutableList.of("partition1", "partition2")); InstanceMonitor monitor = new InstanceMonitor(testCluster, testInstance, new ObjectName(testDomain)); Assert.assertEquals(monitor.getSensorName(), "ParticipantStatus.testCluster.DEFAULT.testInstance"); Assert.assertEquals(monitor.getInstanceName(), testInstance); Assert.assertEquals(monitor.getOnline(), 0L); Assert.assertEquals(monitor.getEnabled(), 0L); Assert.assertEquals(monitor.getTotalMessageReceived(), 0L); Assert.assertEquals(monitor.getDisabledPartitions(), 0L); Assert.assertEquals(monitor.getMaxCapacityUsageGauge(), 0.0d); monitor.updateMaxCapacityUsage(0.5d); monitor.increaseMessageCount(10L); monitor.updateInstance(tags, disabledPartitions, Collections.emptyList(), true, true); monitor.updateMessageQueueSize(100L); monitor.updatePastDueMessageGauge(50L); Assert.assertEquals(monitor.getTotalMessageReceived(), 10L); Assert.assertEquals(monitor.getSensorName(), "ParticipantStatus.testCluster.DEFAULT|test.testInstance"); Assert.assertEquals(monitor.getInstanceName(), testInstance); Assert.assertEquals(monitor.getOnline(), 1L); Assert.assertEquals(monitor.getEnabled(), 1L); Assert.assertEquals(monitor.getDisabledPartitions(), 2L); Assert.assertEquals(monitor.getMaxCapacityUsageGauge(), 0.5d); Assert.assertEquals(monitor.getMessageQueueSizeGauge(), 100L); Assert.assertEquals(monitor.getPastDueMessageGauge(), 50L); monitor.unregister(); }