package com.zaxxer.hikari.metrics.micrometer;

import com.zaxxer.hikari.metrics.PoolStats;
import io.micrometer.core.instrument.MeterRegistry;
import io.micrometer.core.instrument.simple.SimpleMeterRegistry;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;

public class MicrometerMetricsTrackerTest {

   private MeterRegistry mockMeterRegistry = new SimpleMeterRegistry();

   private MicrometerMetricsTracker testee;

   @Before
   public void setup(){
      testee = new MicrometerMetricsTracker("mypool", new PoolStats(1000L) {
         @Override
         protected void update() {
            // nothing
         }
      }, mockMeterRegistry);
   }

   @Test
   public void close() throws Exception {
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.acquire").tag("pool", "mypool").timer());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.usage").tag("pool", "mypool").timer());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.creation").tag("pool", "mypool").timer());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.timeout").tag("pool", "mypool").counter());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections").tag("pool", "mypool").gauge());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.idle").tag("pool", "mypool").gauge());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.active").tag("pool", "mypool").gauge());
      Assert.assertNotNull(mockMeterRegistry.find("hikaricp.connections.pending").tag("pool", "mypool").gauge());

      testee.close();
   }
}

@@ -1624,16 +1624,236 @@
 auge());
+%0A      Assert.assertNotNull(mockMeterRegistry.find(%22hikaricp.connections.max%22).tag(%22pool%22, %22mypool%22).gauge());%0A      Assert.assertNotNull(mockMeterRegistry.find(%22hikaricp.connections.min%22).tag(%22pool%22, %22mypool%22).gauge());
 %0A%0A      

add test case for new metrics (#1115)