При запуске модульного теста возникает ошибка ниже:
Код: Выделить всё
java.lang.NoClassDefFoundError: javax/servlet/DispatcherType
Класс модульного теста:
Код: Выделить всё
`@ExtendWith(MockitoExtension.class)
class ApiClientTest {
@RegisterExtension
static WireMockExtension mockServer = WireMockExtension.newInstance()
.options(wireMockConfig().dynamicPort().dynamicHttpsPort())
.build();
private final String transactionUUID = "uuid";
private ApiClient apiClient;
private HttpClient testClient;
@BeforeEach
void setUp() {
this.testClient = HttpClientBuilder.builder()
.baseUrl(mockServer.getRuntimeInfo().getHttpBaseUrl())
.build();
this.apiClient = new ApiClient(testClient);
}
@Test
@DisplayName("Successful transaction release")
void shouldSuccessfullyReleaseTransaction() {
mockServer.stubFor(patch(urlEqualTo("/xxxx/"))
.withHeader("xxxx", equalTo("xxx"))
.withRequestBody(matchingJsonPath("$.comment", equalTo("xxxx")))
.willReturn(ok("ok")));
assertThat(response).isEqualTo("ok");
}
}`
Сборка прошла успешно, поэтому я не думаю, что есть какие-либо проблемы с зависимостями
build.gradle
Код: Выделить всё
plugins {
id 'org.springframework.boot' version '3.1.6'
id 'io.spring.dependency-management' version '1.1.3'
id 'java'
id "io.freefair.lombok" version "8.4"
id "com.github.ben-manes.versions" version "0.49.0" // dependencyUpdates task
}
dependencies {
//spring
implementation 'org.springframework.boot:spring-boot-starter-actuator'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
Implementation 'org.bouncycastle:bcprov-jdk15on:1.70'
implementation 'com.amazonaws:aws-xray-recorder-sdk-core:2.14.0'
implementation 'com.amazonaws:aws-xray-recorder-sdk-slf4j:2.14.0'
developmentOnly 'org.springframework.boot:spring-boot-devtools'
implementation 'net.logstash.logback:logstash-logback-encoder:7.2'
implementation 'ch.qos.logback:logback-classic:1.4.12'
implementation 'ch.qos.logback:logback-core:1.4.12'
runtimeOnly 'org.codehaus.janino:janino'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testImplementation 'com.squareup.okhttp3:okhttp:4.10.0'
testImplementation 'com.squareup.okhttp3:mockwebserver:4.12.0'
testImplementation 'io.github.glytching:junit-extensions:2.6.0'
//testImplementation("org.mockito:mockito-core:5.7.0")
//lombok
compileOnly 'org.projectlombok:lombok:1.18.16'
annotationProcessor 'org.projectlombok:lombok:1.18.16'
testCompileOnly 'org.projectlombok:lombok:1.18.24'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.16'
//testing
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.0'
testImplementation 'org.junit.jupiter:junit-jupiter-params:5.9.0'
testRuntimeOnly 'org.junit.jupiter:junit-jupiter-engine'
testImplementation 'org.mockito:mockito-junit-jupiter:4.8.0'
testImplementation 'org.mockito:mockito-inline:4.8.0'
testImplementation 'org.hamcrest:hamcrest:2.2'
testImplementation 'org.mockito:mockito-core:4.8.0'
testImplementation 'org.assertj:assertj-core:3.23.1'
testImplementation 'com.github.tomakehurst:wiremock-jre8:2.34.0'
Подробнее здесь: https://stackoverflow.com/questions/788 ... ion-test-r