|
24 | 24 | import org.junit.jupiter.api.BeforeEach;
|
25 | 25 | import org.junit.jupiter.api.Test;
|
26 | 26 | import org.springframework.test.annotation.DirtiesContext;
|
| 27 | +import org.springframework.data.domain.Sort; |
| 28 | +import org.springframework.data.mongodb.core.index.Index; |
27 | 29 | import org.springframework.test.context.DynamicPropertyRegistry;
|
28 | 30 | import org.springframework.test.context.DynamicPropertySource;
|
29 | 31 | import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
@@ -64,16 +66,35 @@ static void setMongoDbConnectionString(DynamicPropertyRegistry registry) {
|
64 | 66 |
|
65 | 67 | @BeforeEach
|
66 | 68 | public void setUp() {
|
| 69 | + // collections |
67 | 70 | mongoTemplate.createCollection("BATCH_JOB_INSTANCE");
|
68 | 71 | mongoTemplate.createCollection("BATCH_JOB_EXECUTION");
|
69 | 72 | mongoTemplate.createCollection("BATCH_STEP_EXECUTION");
|
| 73 | + // sequences |
70 | 74 | mongoTemplate.createCollection("BATCH_SEQUENCES");
|
71 | 75 | mongoTemplate.getCollection("BATCH_SEQUENCES")
|
72 | 76 | .insertOne(new Document(Map.of("_id", "BATCH_JOB_INSTANCE_SEQ", "count", 0L)));
|
73 | 77 | mongoTemplate.getCollection("BATCH_SEQUENCES")
|
74 | 78 | .insertOne(new Document(Map.of("_id", "BATCH_JOB_EXECUTION_SEQ", "count", 0L)));
|
75 | 79 | mongoTemplate.getCollection("BATCH_SEQUENCES")
|
76 | 80 | .insertOne(new Document(Map.of("_id", "BATCH_STEP_EXECUTION_SEQ", "count", 0L)));
|
| 81 | + // indices |
| 82 | + mongoTemplate.indexOps("BATCH_JOB_INSTANCE") |
| 83 | + .ensureIndex(new Index().on("jobName", Sort.Direction.ASC).named("job_name_idx")); |
| 84 | + mongoTemplate.indexOps("BATCH_JOB_INSTANCE") |
| 85 | + .ensureIndex(new Index().on("jobName", Sort.Direction.ASC) |
| 86 | + .on("jobKey", Sort.Direction.ASC) |
| 87 | + .named("job_name_key_idx")); |
| 88 | + mongoTemplate.indexOps("BATCH_JOB_INSTANCE") |
| 89 | + .ensureIndex(new Index().on("jobInstanceId", Sort.Direction.DESC).named("job_instance_idx")); |
| 90 | + mongoTemplate.indexOps("BATCH_JOB_EXECUTION") |
| 91 | + .ensureIndex(new Index().on("jobInstanceId", Sort.Direction.ASC).named("job_instance_idx")); |
| 92 | + mongoTemplate.indexOps("BATCH_JOB_EXECUTION") |
| 93 | + .ensureIndex(new Index().on("jobInstanceId", Sort.Direction.ASC) |
| 94 | + .on("status", Sort.Direction.ASC) |
| 95 | + .named("job_instance_status_idx")); |
| 96 | + mongoTemplate.indexOps("BATCH_STEP_EXECUTION") |
| 97 | + .ensureIndex(new Index().on("stepExecutionId", Sort.Direction.ASC).named("step_execution_idx")); |
77 | 98 | }
|
78 | 99 |
|
79 | 100 | @Test
|
|
0 commit comments