Skip to content

Commit 016cbc7

Browse files
committed
refactor: removed old importers
1 parent 301af7e commit 016cbc7

File tree

33 files changed

+42
-1610
lines changed

33 files changed

+42
-1610
lines changed

core/flamingock-core-api/src/main/java/io/flamingock/api/annotations/Stage.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,5 @@
5050
String name() default "";
5151

5252
String description() default "";
53-
54-
StageType type() default StageType.DEFAULT;
5553

5654
}

core/flamingock-core/src/main/java/io/flamingock/internal/core/task/navigation/navigator/ChangeProcessStrategyFactory.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ public ChangeProcessStrategy build() {
108108

109109
changeLogger.logStartChangeProcessStrategy(change.getId());
110110

111-
TargetSystemOps targetSystemOps = getTargetSystem(change.getId());
111+
TargetSystemOps targetSystemOps = getTargetSystem();
112112

113113
// Log target system resolution
114114
changeLogger.logTargetSystemResolved(change.getId(), change.getTargetSystem());
@@ -130,11 +130,11 @@ public ChangeProcessStrategy build() {
130130
);
131131
}
132132

133-
private TargetSystemOps getTargetSystem(String changeId) {
133+
private TargetSystemOps getTargetSystem() {
134134
try {
135135
return targetSystemManager.getTargetSystem(change.getTargetSystem());
136136
} catch (Exception e) {
137-
String message = String.format("Error in change [%s] : %s", changeId, e.getMessage());
137+
String message = String.format("Error in change [%s] : %s", change.getId(), e.getMessage());
138138
throw new FlamingockException(message);
139139
}
140140
}

core/flamingock-processor/src/main/java/io/flamingock/core/processor/FlamingockAnnotationProcessor.java

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -315,36 +315,6 @@ private int getStageTypePriority(StageType stageType) {
315315
}
316316
}
317317

318-
/**
319-
* Validates that stage types conform to the restrictions:
320-
* - Maximum 1 SYSTEM stage allowed
321-
* - Maximum 1 LEGACY stage allowed
322-
* - Unlimited DEFAULT stages allowed
323-
*
324-
* @param stages the stages to validate
325-
* @throws RuntimeException if validation fails
326-
*/
327-
private void validateStageTypes(Stage[] stages) {
328-
int systemStageCount = 0;
329-
int legacyStageCount = 0;
330-
331-
for (Stage stage : stages) {
332-
StageType stageType = stage.type();
333-
334-
if (stageType == StageType.SYSTEM) {
335-
systemStageCount++;
336-
if (systemStageCount > 1) {
337-
throw new RuntimeException("Multiple SYSTEM stages are not allowed. Only one stage with type StageType.SYSTEM is permitted.");
338-
}
339-
} else if (stageType == StageType.LEGACY) {
340-
legacyStageCount++;
341-
if (legacyStageCount > 1) {
342-
throw new RuntimeException("Multiple LEGACY stages are not allowed. Only one stage with type StageType.LEGACY is permitted.");
343-
}
344-
}
345-
}
346-
}
347-
348318
/**
349319
* Validates that stage types from YAML conform to the restrictions:
350320
* - Maximum 1 SYSTEM stage allowed
@@ -450,7 +420,7 @@ private PreviewStage mapAnnotationToStage(Map<String, List<CodePreviewChange>> c
450420
logger.verbose("Resources directory: " + resourcesDir);
451421
}
452422

453-
return PreviewStage.defaultBuilder(stageAnnotation.type())
423+
return PreviewStage.defaultBuilder(StageType.DEFAULT)
454424
.setName(name)
455425
.setDescription(stageAnnotation.description().isEmpty() ? null : stageAnnotation.description())
456426
.setSourcesRoots(sourceRoots)
@@ -704,10 +674,6 @@ private void validateConfiguration(EnableFlamingock pipelineAnnotation, boolean
704674
throw new RuntimeException("@EnableFlamingock annotation must specify either configFile OR stages configuration.");
705675
}
706676

707-
// Validate stage type restrictions when using annotation-based configuration
708-
if (hasStagesInAnnotation) {
709-
validateStageTypes(pipelineAnnotation.stages());
710-
}
711677
}
712678

713679
/**

core/flamingock-processor/src/test/java/io/flamingock/core/processor/PipelinePreProcessorTest.java

Lines changed: 5 additions & 109 deletions
Original file line numberDiff line numberDiff line change
@@ -178,68 +178,6 @@ void shouldCreatePipelineWithCorrectObjectStructure() throws Exception {
178178
assertEquals(StageType.DEFAULT, firstStage.getType());
179179
}
180180

181-
/**
182-
* Test validation that only one SYSTEM stage is allowed in annotation configuration.
183-
*/
184-
@Test
185-
@DisplayName("Should throw error for multiple SYSTEM stages in annotation configuration")
186-
void shouldThrowErrorForMultipleSystemStagesInAnnotation() throws Exception {
187-
// Given - create annotation with multiple system stages
188-
EnableFlamingock annotation = new MockFlamingockBuilder()
189-
.withStages(
190-
createMockStage("", StageType.SYSTEM, "com.example.system1"),
191-
createMockStage("", StageType.SYSTEM, "com.example.system2"),
192-
createMockStage("", StageType.DEFAULT, "com.example.migrations")
193-
)
194-
.build();
195-
Map<String, List<AbstractPreviewTask>> changes = createMockChangesMap();
196-
FlamingockAnnotationProcessor processor = new FlamingockAnnotationProcessor();
197-
198-
// When & Then - should throw RuntimeException
199-
Exception exception = assertThrows(Exception.class, () ->
200-
callGetPipelineFromProcessChanges(processor, changes, annotation));
201-
202-
Throwable cause = exception.getCause();
203-
if (cause instanceof RuntimeException) {
204-
assertTrue(cause.getMessage().contains("Multiple SYSTEM stages are not allowed"),
205-
"Should have error about multiple SYSTEM stages");
206-
} else {
207-
assertTrue(exception.getMessage().contains("Multiple SYSTEM stages are not allowed"),
208-
"Should have error about multiple SYSTEM stages");
209-
}
210-
}
211-
212-
/**
213-
* Test validation that only one LEGACY stage is allowed in annotation configuration.
214-
*/
215-
@Test
216-
@DisplayName("Should throw error for multiple LEGACY stages in annotation configuration")
217-
void shouldThrowErrorForMultipleLegacyStagesInAnnotation() throws Exception {
218-
// Given - create annotation with multiple legacy stages
219-
EnableFlamingock annotation = new MockFlamingockBuilder()
220-
.withStages(
221-
createMockStage("", StageType.LEGACY, "com.example.legacy1"),
222-
createMockStage("", StageType.LEGACY, "com.example.legacy2"),
223-
createMockStage("", StageType.DEFAULT, "com.example.migrations")
224-
)
225-
.build();
226-
Map<String, List<AbstractPreviewTask>> changes = createMockChangesMap();
227-
FlamingockAnnotationProcessor processor = new FlamingockAnnotationProcessor();
228-
229-
// When & Then - should throw RuntimeException
230-
Exception exception = assertThrows(Exception.class, () ->
231-
callGetPipelineFromProcessChanges(processor, changes, annotation));
232-
233-
Throwable cause = exception.getCause();
234-
if (cause instanceof RuntimeException) {
235-
assertTrue(cause.getMessage().contains("Multiple LEGACY stages are not allowed"),
236-
"Should have error about multiple LEGACY stages");
237-
} else {
238-
assertTrue(exception.getMessage().contains("Multiple LEGACY stages are not allowed"),
239-
"Should have error about multiple LEGACY stages");
240-
}
241-
}
242-
243181
/**
244182
* Test validation that multiple DEFAULT stages are allowed.
245183
*/
@@ -249,9 +187,9 @@ void shouldAllowMultipleDefaultStagesInAnnotation() throws Exception {
249187
// Given - create annotation with multiple default stages
250188
EnableFlamingock annotation = new MockFlamingockBuilder()
251189
.withStages(
252-
createMockStage("", StageType.DEFAULT, "com.example.migrations1"),
253-
createMockStage("", StageType.DEFAULT, "com.example.migrations2"),
254-
createMockStage("", StageType.DEFAULT, "com.example.migrations3")
190+
createMockStage("", "com.example.migrations1"),
191+
createMockStage("", "com.example.migrations2"),
192+
createMockStage("", "com.example.migrations3")
255193
)
256194
.build();
257195
Map<String, List<AbstractPreviewTask>> changes = createMockChangesMap();
@@ -266,47 +204,6 @@ void shouldAllowMultipleDefaultStagesInAnnotation() throws Exception {
266204
assertNull(pipeline.getSystemStage(), "Should not have system stage");
267205
}
268206

269-
/**
270-
* Test that stages are ordered correctly regardless of declaration order.
271-
*/
272-
@Test
273-
@DisplayName("Should order stages by type priority: LEGACY before DEFAULT")
274-
void shouldOrderStagesByTypePriorityLegacyBeforeDefault() throws Exception {
275-
// Given - create annotation with stages in reverse order (DEFAULT first, LEGACY second)
276-
EnableFlamingock annotation = new MockFlamingockBuilder()
277-
.withStages(
278-
createMockStage("", StageType.DEFAULT, "com.example.migrations"),
279-
createMockStage("", StageType.LEGACY, "com.example.init"),
280-
createMockStage("", StageType.DEFAULT, "com.example.cleanup")
281-
)
282-
.build();
283-
Map<String, List<AbstractPreviewTask>> changes = createMockChangesMap();
284-
FlamingockAnnotationProcessor processor = new FlamingockAnnotationProcessor();
285-
286-
// When - build pipeline from annotation
287-
PreviewPipeline pipeline = buildPipelineFromAnnotation(processor, annotation, changes);
288-
289-
// Then - verify stages are sorted by type priority
290-
assertNotNull(pipeline, "Pipeline should be created");
291-
assertEquals(3, pipeline.getStages().size(), "Should have 3 stages");
292-
293-
PreviewStage[] stages = pipeline.getStages().toArray(new PreviewStage[0]);
294-
295-
// First stage should be LEGACY (highest priority)
296-
assertEquals(StageType.LEGACY, stages[0].getType());
297-
assertEquals("init", stages[0].getName());
298-
assertEquals("com.example.init", stages[0].getSourcesPackage());
299-
300-
// Second and third stages should be DEFAULT (lower priority)
301-
assertEquals(StageType.DEFAULT, stages[1].getType());
302-
assertEquals("migrations", stages[1].getName());
303-
assertEquals("com.example.migrations", stages[1].getSourcesPackage());
304-
305-
assertEquals(StageType.DEFAULT, stages[2].getType());
306-
assertEquals("cleanup", stages[2].getName());
307-
assertEquals("com.example.cleanup", stages[2].getSourcesPackage());
308-
}
309-
310207
/**
311208
* Test that YAML stages are ordered correctly regardless of declaration order.
312209
*/
@@ -573,7 +470,7 @@ private Map<String, List<AbstractPreviewTask>> createMockChangesMap() {
573470
private EnableFlamingock createMockAnnotationWithStages() {
574471
return new MockFlamingockBuilder()
575472
.withStages(
576-
createMockStage("", StageType.DEFAULT, "com.example.migrations")
473+
createMockStage("", "com.example.migrations")
577474
)
578475
.build();
579476
}
@@ -588,11 +485,10 @@ private EnableFlamingock createMockAnnotationWithNeitherFileNorStages() {
588485
return new MockFlamingockBuilder().build();
589486
}
590487

591-
private Stage createMockStage(String name, StageType type, String location) {
488+
private Stage createMockStage(String name, String location) {
592489
return new Stage() {
593490
@Override public String name() { return name; }
594491
@Override public String description() { return ""; }
595-
@Override public StageType type() { return type; }
596492
@Override public String location() { return location; }
597493
@Override public Class<? extends java.lang.annotation.Annotation> annotationType() { return Stage.class; }
598494
};

core/importer/flamingock-importer-couchbase-tests/build.gradle.kts

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)