Skip to content

Commit

Permalink
Remove Mockito and logback-classic dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
ak-git committed Sep 29, 2024
1 parent 9c5b05e commit 4fd2eaa
Show file tree
Hide file tree
Showing 5 changed files with 2 additions and 87 deletions.
39 changes: 1 addition & 38 deletions .idea/compiler.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 1 addition & 5 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ nebula-lint = '20.0.0'
jspecify = '1.0.0'
junit = '5.11.1'
assertj = '3.26.3'
mockito = '5.14.0'

micronaut = '4.6.2'

Expand All @@ -30,11 +29,8 @@ junit-jupiter-api = { module = 'org.junit.jupiter:junit-jupiter-api' }
junit-jupiter-engine = { module = 'org.junit.jupiter:junit-jupiter-engine' }
junit-platform-launcher = { module = 'org.junit.platform:junit-platform-launcher' }
assertj = { module = 'org.assertj:assertj-core', version.ref = 'assertj' }
mockito-core = { module = "org.mockito:mockito-core", version.ref = "mockito" }
mockito-junit = { module = "org.mockito:mockito-junit-jupiter", version.ref = "mockito" }

[bundles]
test-implementation = ['junit-jupiter-api', 'assertj']
test-compile = ['junit-jupiter', 'junit-jupiter-engine']
test-runtime = ['junit-jupiter-engine', 'junit-platform-launcher']
test-mockito = ['mockito-core', 'mockito-junit']
test-runtime = ['junit-jupiter-engine', 'junit-platform-launcher']
4 changes: 0 additions & 4 deletions mnt/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,14 @@ plugins {
}

dependencies {
annotationProcessor("io.micronaut:micronaut-http-validation")
annotationProcessor("io.micronaut.serde:micronaut-serde-processor")
implementation libs.jspecify
implementation("org.yaml:snakeyaml")
implementation("ch.qos.logback:logback-classic")
compileOnly("io.micronaut:micronaut-http-client")
runtimeOnly("io.micronaut.serde:micronaut-serde-jackson")
runtimeOnly("ch.qos.logback:logback-classic")

testImplementation(platform(libs.junit))
testImplementation libs.bundles.test.implementation
testImplementation libs.bundles.test.mockito
testCompileOnly libs.bundles.test.compile
testRuntimeOnly libs.bundles.test.runtime
}
Expand Down
2 changes: 0 additions & 2 deletions mnt/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,6 @@
requires org.jspecify;
requires org.slf4j;
requires org.yaml.snakeyaml;
requires ch.qos.logback.core;
requires ch.qos.logback.classic;
requires jakarta.inject;
requires jakarta.annotation;
requires io.micronaut.context;
Expand Down
38 changes: 0 additions & 38 deletions mnt/src/test/java/com/ak/micronaut/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -1,46 +1,15 @@
package com.ak.micronaut;

import ch.qos.logback.classic.Level;
import ch.qos.logback.classic.Logger;
import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.classic.spi.LoggingEvent;
import ch.qos.logback.core.Appender;
import io.micronaut.context.ApplicationContext;
import io.micronaut.runtime.EmbeddedApplication;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.ArgumentCaptor;
import org.mockito.Captor;
import org.mockito.Mock;
import org.mockito.Mockito;
import org.mockito.junit.jupiter.MockitoExtension;
import org.slf4j.LoggerFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;

@ExtendWith(MockitoExtension.class)
class ApplicationTest {
private static final EmbeddedApplication<?> APPLICATION = ApplicationContext.run(EmbeddedApplication.class);
private static final Logger LOGGER = (Logger) LoggerFactory.getLogger(ApplicationTest.class.getPackageName());

@Mock
private Appender<ILoggingEvent> appender;
@Captor
private ArgumentCaptor<LoggingEvent> loggingEventCaptor;

@BeforeEach
void setUp() {
LOGGER.addAppender(appender);
}

@AfterEach
void cleanUp() {
LOGGER.detachAppender(appender);
}

@AfterAll
static void tearDown() {
Expand All @@ -51,12 +20,5 @@ static void tearDown() {
void testItWorks() {
assertThat(APPLICATION.isRunning()).isTrue();
assertThatNoException().isThrownBy(() -> Application.main(new String[] {}));

Mockito.verify(appender).doAppend(loggingEventCaptor.capture());

assertThat(loggingEventCaptor.getAllValues()).hasSize(1);
LoggingEvent loggingEvent = loggingEventCaptor.getAllValues().getFirst();
assertThat(loggingEvent.getFormattedMessage()).isEqualTo("mnt running = true");
assertThat(loggingEvent.getLevel()).isEqualTo(Level.INFO);
}
}

0 comments on commit 4fd2eaa

Please sign in to comment.