Skip to content

Commit

Permalink
fix: do not mock NeonBee logger in NeonBeeMockHelper
Browse files Browse the repository at this point in the history
Since, the logger was chenged to a constant in the NeonBee class, it is
no longer neccessary to create a logger in the `NeonBeeMockHelper`.

Resolves #130
  • Loading branch information
s4heid committed Jun 10, 2022
1 parent ae371b2 commit 8238ec8
Showing 1 changed file with 0 additions and 15 deletions.
15 changes: 0 additions & 15 deletions src/test/java/io/neonbee/NeonBeeMockHelper.java
Expand Up @@ -13,12 +13,9 @@
import java.util.function.Supplier;

import org.mockito.stubbing.Answer;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import io.micrometer.core.instrument.composite.CompositeMeterRegistry;
import io.neonbee.config.NeonBeeConfig;
import io.neonbee.test.helper.ReflectionHelper;
import io.vertx.core.AsyncResult;
import io.vertx.core.Context;
import io.vertx.core.DeploymentOptions;
Expand Down Expand Up @@ -243,18 +240,6 @@ public static NeonBee registerNeonBeeMock(Vertx vertx, NeonBeeConfig config) {
* @return the mocked NeonBee instance
*/
public static NeonBee registerNeonBeeMock(Vertx vertx, NeonBeeOptions options, NeonBeeConfig config) {
createLogger(); // the logger is only created internally, create one manually if required
return new NeonBee(vertx, options, config, new CompositeMeterRegistry(), new HazelcastClusterManager());
}

@SuppressWarnings({ "CatchAndPrintStackTrace", "PMD.AvoidPrintStackTrace" })
private static void createLogger() {
try {
Logger logger = (Logger) ReflectionHelper.getValueOfPrivateStaticField(NeonBee.class, "logger");
logger = logger == null ? LoggerFactory.getLogger(NeonBee.class) : logger;
ReflectionHelper.setValueOfPrivateStaticField(NeonBee.class, "logger", logger);
} catch (Exception e) {
e.printStackTrace();
}
}
}

0 comments on commit 8238ec8

Please sign in to comment.