I have created a Micrometer class where counters are created and incremented. How to write unit test cases for the public method and avoid registering or sending the events to micrometer.
public class MicroMeter {
private static final MeterRegistry registry = Metrics.globalRegistry;
private Counter createCounter(final String meterName, Map<String, String> mp) {
List<Tag> tags = new ArrayList<>();
for (Map.Entry<String, String> entry : mp.entrySet()) {
tags.add(Tag.of(entry.getKey(), entry.getValue()));
}
return Counter
.builder(meterName)
.tags(tags)
.register(registry);
}
private void incrementCounter(Counter counter) {
counter.increment();
}
public static void createCounterAndIncrement(final String meterName, Map<String, String> mp){
MicroMeter microMeter = new MicroMeter();
Counter counter = microMeter.createCounter(meterName, dimensions);
microMeter.incrementCounter(counter);
}
}
then
coming from? – Cavuoto