test(wiki): drop unnecessary @DirtiesContext from new E2E tests

This commit is contained in:
matevip 2026-05-31 07:56:31 +08:00
parent 6e0e62556f
commit 5278568594
7 changed files with 23 additions and 36 deletions

View File

@ -2,14 +2,13 @@ package vip.mate.wiki.pipeline;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.context.TestConfiguration;
import org.springframework.context.annotation.Bean;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPipelineDefinitionEntity; import vip.mate.wiki.model.WikiPipelineDefinitionEntity;
import vip.mate.wiki.model.WikiPipelineStepRunEntity; import vip.mate.wiki.model.WikiPipelineStepRunEntity;
import vip.mate.wiki.repository.WikiPipelineRunMapper;
import vip.mate.wiki.repository.WikiPipelineStepRunMapper; import vip.mate.wiki.repository.WikiPipelineStepRunMapper;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -34,37 +33,37 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPipelineServiceE2ETest { class WikiPipelineServiceE2ETest {
/** Stub executors: 'echo' returns a marker; 'boom' always throws. */ // Stub executors: 'echo' returns a marker; 'boom' always throws. Built
@TestConfiguration // here (not via @TestConfiguration) so the test uses the shared default
static class StubExecutors { // context and does not fork a separate datasource that @DirtiesContext
@Bean // would close out from under sibling tests.
WikiStepExecutor echoExecutor() { private static final WikiStepExecutor ECHO = new WikiStepExecutor() {
return new WikiStepExecutor() { public String type() { return "echo"; }
public String type() { return "echo"; } public String execute(WikiStepContext c) {
public String execute(WikiStepContext c) { return "echo:" + c.stepId() + ":" + (c.previousOutput() == null ? "" : c.previousOutput());
return "echo:" + c.stepId() + ":" + (c.previousOutput() == null ? "" : c.previousOutput());
}
};
} }
@Bean };
WikiStepExecutor boomExecutor() { private static final WikiStepExecutor BOOM = new WikiStepExecutor() {
return new WikiStepExecutor() { public String type() { return "boom"; }
public String type() { return "boom"; } public String execute(WikiStepContext c) { throw new RuntimeException("kaboom"); }
public String execute(WikiStepContext c) throws Exception { throw new RuntimeException("kaboom"); } };
};
}
}
@Autowired @Autowired
private WikiPipelineService pipelineService; private WikiPipelineRunMapper runMapper;
@Autowired @Autowired
private WikiPipelineStepRunMapper stepRunMapper; private WikiPipelineStepRunMapper stepRunMapper;
@Autowired @Autowired
private ObjectMapper objectMapper; private ObjectMapper objectMapper;
private WikiPipelineService pipelineService;
@BeforeEach
void setUp() {
pipelineService = new WikiPipelineService(runMapper, stepRunMapper, objectMapper, List.of(ECHO, BOOM));
}
private static final java.util.concurrent.atomic.AtomicLong SEQ = private static final java.util.concurrent.atomic.AtomicLong SEQ =
new java.util.concurrent.atomic.AtomicLong(System.nanoTime()); new java.util.concurrent.atomic.AtomicLong(System.nanoTime());

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.profile;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPageTypeProfileEntity; import vip.mate.wiki.model.WikiPageTypeProfileEntity;
import java.util.List; import java.util.List;
@ -27,7 +26,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPageTypeProfileServiceE2ETest { class WikiPageTypeProfileServiceE2ETest {
@Autowired @Autowired

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.repository;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import vip.mate.wiki.model.WikiPageDependencyEntity; import vip.mate.wiki.model.WikiPageDependencyEntity;
@ -26,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPageDependencyMapperE2ETest { class WikiPageDependencyMapperE2ETest {
@Autowired @Autowired

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.repository;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPageTypeProfileEntity; import vip.mate.wiki.model.WikiPageTypeProfileEntity;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -26,7 +25,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPageTypeProfileMapperE2ETest { class WikiPageTypeProfileMapperE2ETest {
@Autowired @Autowired

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.repository;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPipelineRunEntity; import vip.mate.wiki.model.WikiPipelineRunEntity;
import java.time.LocalDateTime; import java.time.LocalDateTime;
@ -24,7 +23,6 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPipelineRunMapperE2ETest { class WikiPipelineRunMapperE2ETest {
@Autowired @Autowired

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.service;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPageEntity; import vip.mate.wiki.model.WikiPageEntity;
import java.util.List; import java.util.List;
@ -25,7 +24,6 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiDependencyServiceE2ETest { class WikiDependencyServiceE2ETest {
@Autowired @Autowired

View File

@ -3,7 +3,6 @@ package vip.mate.wiki.service;
import org.junit.jupiter.api.Test; import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.annotation.DirtiesContext;
import vip.mate.wiki.model.WikiPageEntity; import vip.mate.wiki.model.WikiPageEntity;
import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertEquals;
@ -22,7 +21,6 @@ import static org.junit.jupiter.api.Assertions.assertNotNull;
"mateclaw.feature-flag.refresh-ms=999999" "mateclaw.feature-flag.refresh-ms=999999"
} }
) )
@DirtiesContext(classMode = DirtiesContext.ClassMode.AFTER_CLASS)
class WikiPageMetadataE2ETest { class WikiPageMetadataE2ETest {
@Autowired @Autowired