@Test
  public void publishReceivedCountsIncomingMessages() {
    assumeThat(metricRegistry.getMeters().get("test.incomingMessages").getCount(), is(0l));
    listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE));

    assertThat(metricRegistry.getMeters().get("test.incomingMessages").getCount(), is(1l));
  }
  @Test
  public void publishReceivedCountsEmptyMessages() {
    assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l));
    listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE, (byte[]) null));
    listener.publishReceived(client, new PublishMessage("test", QoS.AT_LEAST_ONCE, new byte[0]));

    assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(2l));
  }
  @Test
  public void publishReceivedCountsDiscardedMessages()
      throws BufferOutOfCapacityException, ProcessingDisabledException {
    final PublishMessage message = new PublishMessage("test", QoS.AT_LEAST_ONCE, "");

    assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l));
    listener.publishReceived(client, message);

    assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(1l));
  }
 @Test
 public void test() throws Exception {
   Map<String, JobParameter> parameters = new HashMap<String, JobParameter>();
   JobExecution jobExecution = jobLauncherTestUtils.launchJob(new JobParameters(parameters));
   Assert.assertEquals(
       jobExecution.getExitStatus().getExitDescription(),
       BatchStatus.COMPLETED,
       jobExecution.getStatus());
   Map<String, Meter> meters = metricRegistry.getMeters();
   assertThat(meters).hasSize(2);
   assertThat(meters)
       .containsKey("batch.sampleJob.job.metered")
       .containsKey("batch.sampleJob.step.chunkStep.step.metered");
   assertThat(extractProperty("count", Number.class).from(meters.values()))
       .contains(1L)
       .doesNotContain(0L);
   Map<String, Timer> timers = metricRegistry.getTimers();
   assertThat(timers).hasSize(6);
   assertThat(timers)
       .containsKey("batch.sampleJob.job.timed")
       .containsKey("batch.sampleJob.step.chunkStep.chunk.timed")
       .containsKey("batch.sampleJob.step.chunkStep.step.timed")
       .containsKey("batch.sampleJob.step.chunkStep.read.timed")
       .containsKey("batch.sampleJob.step.chunkStep.process.timed")
       .containsKey("batch.sampleJob.step.chunkStep.write.timed");
   assertThat(extractProperty("count", Number.class).from(timers.values()))
       .contains(1L, 3L, 4L)
       .doesNotContain(0L);
   Map<String, Gauge> gauges = metricRegistry.getGauges();
   assertThat(gauges).hasSize(0);
 }
  @Test
  public void publishReceivedCountsDuplicateMessages() {
    final PublishMessage message = new PublishMessage("test", QoS.EXACTLY_ONCE, "test");

    assumeThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(0l));
    listener.publishReceived(client, message);

    // assertThat(metricRegistry.getMeters().get("test.incompleteMessages").getCount(), is(1l));
  }