Skip to content

Commit 0bc36b3

Browse files
committed
test: added test to flamingock-springboot-test-support
1 parent 2dec48b commit 0bc36b3

File tree

7 files changed

+234
-1
lines changed

7 files changed

+234
-1
lines changed

core/flamingock-test-support/build.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
dependencies {
2-
api(project(":core:flamingock-core"))
2+
implementation(project(":core:flamingock-core"))
33

44

55
testImplementation(platform("org.junit:junit-bom:5.10.0"))
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
val springBootVersion = "2.0.0.RELEASE"
2+
val springFrameworkVersion = "5.0.4.RELEASE"
3+
dependencies {
4+
implementation(project(":core:flamingock-test-support"))
5+
6+
implementation(project(":core:flamingock-core"))
7+
implementation(project(":core:flamingock-core-commons"))
8+
compileOnly("org.springframework:spring-context:${springFrameworkVersion}")
9+
compileOnly("org.springframework.boot:spring-boot:${springBootVersion}")
10+
compileOnly("org.springframework.boot:spring-boot-autoconfigure:${springBootVersion}")
11+
annotationProcessor("org.springframework.boot:spring-boot-configuration-processor:${springBootVersion}")
12+
13+
14+
testImplementation(platform("org.springframework.boot:spring-boot-dependencies:${springBootVersion}"))
15+
16+
testImplementation("org.springframework.boot:spring-boot-starter-test")
17+
18+
// Annotation processor for @EnableFlamingock in tests
19+
testAnnotationProcessor(project(":core:flamingock-processor"))
20+
21+
// Spring Boot integration module
22+
testImplementation(project(":platform-plugins:flamingock-springboot-integration"))
23+
24+
// InMemory test utilities
25+
testImplementation(project(":utils:test-util"))
26+
27+
// Non-transactional target system for tests
28+
testImplementation(project(":core:target-systems:nontransactional-target-system"))
29+
}
30+
31+
description = "Spring Boot testing integration module for Flamingock. Compatible with JDK 17 and above."
32+
33+
java {
34+
toolchain {
35+
languageVersion.set(JavaLanguageVersion.of(8))
36+
}
37+
}
38+
39+
configurations.testImplementation {
40+
extendsFrom(configurations.compileOnly.get())
41+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.springboot.testsupport;
17+
18+
import io.flamingock.api.targets.TargetSystem;
19+
import io.flamingock.core.kit.inmemory.InMemoryAuditStorage;
20+
import io.flamingock.core.kit.inmemory.InMemoryLockStorage;
21+
import io.flamingock.core.kit.inmemory.InMemoryTestAuditStore;
22+
import io.flamingock.internal.core.store.CommunityAuditStore;
23+
import io.flamingock.targetsystem.nontransactional.NonTransactionalTargetSystem;
24+
import org.springframework.context.annotation.Bean;
25+
import org.springframework.context.annotation.Configuration;
26+
27+
/**
28+
* Test configuration providing Flamingock infrastructure beans for Spring Boot tests.
29+
*/
30+
@Configuration
31+
public class FlamingockTestConfiguration {
32+
33+
@Bean
34+
public CommunityAuditStore auditStore() {
35+
InMemoryAuditStorage auditStorage = new InMemoryAuditStorage();
36+
InMemoryLockStorage lockStorage = new InMemoryLockStorage();
37+
return new InMemoryTestAuditStore(auditStorage, lockStorage);
38+
}
39+
40+
@Bean
41+
public TargetSystem testTargetSystem() {
42+
return new NonTransactionalTargetSystem("test-system");
43+
}
44+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.springboot.testsupport;
17+
18+
import io.flamingock.internal.common.core.audit.AuditEntry;
19+
import io.flamingock.internal.core.store.CommunityAuditStore;
20+
import org.junit.jupiter.api.Test;
21+
import org.junit.jupiter.api.extension.ExtendWith;
22+
import org.springframework.beans.factory.annotation.Autowired;
23+
import org.springframework.boot.test.context.SpringBootTest;
24+
import org.springframework.context.ApplicationContext;
25+
import org.springframework.test.context.junit.jupiter.SpringExtension;
26+
27+
import java.util.List;
28+
import java.util.stream.Collectors;
29+
30+
import static org.assertj.core.api.Assertions.assertThat;
31+
32+
/**
33+
* Integration test that verifies Flamingock Spring Boot integration works correctly.
34+
* This test runs a real Spring Boot application with @EnableFlamingock and verifies
35+
* that the change is executed and recorded in the audit store.
36+
*/
37+
@ExtendWith(SpringExtension.class)
38+
@SpringBootTest(classes = {TestApplication.class, FlamingockTestConfiguration.class})
39+
class SpringBootFlamingockIntegrationTest {
40+
41+
@Autowired
42+
private ApplicationContext context;
43+
44+
@Autowired
45+
private CommunityAuditStore auditStore;
46+
47+
@Test
48+
void contextLoads() {
49+
assertThat(context).isNotNull();
50+
}
51+
52+
@Test
53+
void flamingockRunnerBeanExists() {
54+
assertThat(context.containsBean("flamingock-runner")).isTrue();
55+
}
56+
57+
@Test
58+
void flamingockBuilderBeanExists() {
59+
assertThat(context.containsBean("flamingock-builder")).isTrue();
60+
}
61+
62+
@Test
63+
void changeWasApplied() {
64+
// Verify that the change was executed by checking the audit store
65+
List<AuditEntry> entries = auditStore.getPersistence()
66+
.getAuditHistory()
67+
.stream()
68+
.filter(e -> "simple-test-change".equals(e.getTaskId()))
69+
.filter(e -> AuditEntry.Status.APPLIED.equals(e.getState()))
70+
.collect(Collectors.toList());
71+
72+
assertThat(entries).hasSize(1);
73+
}
74+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.springboot.testsupport;
17+
18+
import io.flamingock.api.annotations.EnableFlamingock;
19+
import io.flamingock.api.annotations.Stage;
20+
import org.springframework.boot.SpringApplication;
21+
import org.springframework.boot.autoconfigure.SpringBootApplication;
22+
23+
/**
24+
* Test Spring Boot application with Flamingock enabled.
25+
* Used for integration testing of Flamingock Spring Boot support.
26+
*/
27+
@SpringBootApplication
28+
@EnableFlamingock(
29+
stages = @Stage(location = "io.flamingock.springboot.testsupport.changes")
30+
)
31+
public class TestApplication {
32+
33+
public static void main(String[] args) {
34+
SpringApplication.run(TestApplication.class, args);
35+
}
36+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/*
2+
* Copyright 2025 Flamingock (https://www.flamingock.io)
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package io.flamingock.springboot.testsupport.changes;
17+
18+
import io.flamingock.api.annotations.Apply;
19+
import io.flamingock.api.annotations.Change;
20+
import io.flamingock.api.annotations.TargetSystem;
21+
22+
/**
23+
* Simple non-transactional change for testing Spring Boot integration.
24+
*/
25+
@Change(id = "simple-test-change", transactional = false, author = "test")
26+
@TargetSystem(id = "test-system")
27+
public class _001__SimpleTestChange {
28+
29+
@Apply
30+
public void apply() {
31+
System.out.println("Executing simple test change");
32+
}
33+
}

settings.gradle.kts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,10 @@ project(":platform-plugins:flamingock-springboot-integration").name = "flamingoc
8080
project(":platform-plugins:flamingock-springboot-integration").projectDir =
8181
file("platform-plugins/flamingock-springboot-integration")
8282

83+
include("platform-plugins:flamingock-springboot-test-support")
84+
project(":platform-plugins:flamingock-springboot-test-support").name = "flamingock-springboot-test-support"
85+
project(":platform-plugins:flamingock-springboot-test-support").projectDir =
86+
file("platform-plugins/flamingock-springboot-test-support")
8387
//////////////////////////////////////
8488
// TARGET SYSTEMS
8589
//////////////////////////////////////
@@ -188,3 +192,4 @@ project(":cli:flamingock-cli").projectDir = file("cli/flamingock-cli")
188192
include("e2e:core-e2e")
189193
project(":e2e:core-e2e").name = "core-e2e"
190194
project(":e2e:core-e2e").projectDir = file("e2e/core-e2e")
195+

0 commit comments

Comments
 (0)