@@ -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 };
0 commit comments