- 
                Notifications
    You must be signed in to change notification settings 
- Fork 65
Add ChangeUnitConstructor annotation to allow mongock to pick constructors for dependency injection #549
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
          
     Merged
      
      
    
  
     Merged
                    Add ChangeUnitConstructor annotation to allow mongock to pick constructors for dependency injection #549
Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      e4d1e1d
              
                add ChangeUnitConstructor
              
              
                thekaleidoscope 38d12f1
              
                enhance exception when no valid constructor exist
              
              
                thekaleidoscope 7bf139e
              
                add findChangeUnitConstructor in ChangeLogRuntimeImpl
              
              
                thekaleidoscope 3513614
              
                add warning when all valid constructors are not annotated with Change…
              
              
                thekaleidoscope da0a426
              
                minor refactoring
              
              
                thekaleidoscope 7ee61d5
              
                add tests to validate valid constructor behaviour
              
              
                thekaleidoscope df2519b
              
                fix annotation doc in ChangeUnit
              
              
                thekaleidoscope 7dadea8
              
                replace use of stream supplier to array
              
              
                thekaleidoscope File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            11 changes: 11 additions & 0 deletions
          
          11 
        
  mongock-core/mongock-api/src/main/java/io/mongock/api/annotations/ChangeUnitConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package io.mongock.api.annotations; | ||
|  | ||
| import java.lang.annotation.ElementType; | ||
| import java.lang.annotation.Retention; | ||
| import java.lang.annotation.RetentionPolicy; | ||
| import java.lang.annotation.Target; | ||
|  | ||
| @Target(ElementType.CONSTRUCTOR) | ||
| @Retention(RetentionPolicy.RUNTIME) | ||
| public @interface ChangeUnitConstructor { | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
        
          
          
            17 changes: 17 additions & 0 deletions
          
          17 
        
  ...a/io/mongock/runner/core/changelogs/withConstructor/ChangeUnitWithDefaultConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,17 @@ | ||
| package io.mongock.runner.core.changelogs.withConstructor; | ||
|  | ||
| import io.mongock.api.annotations.ChangeUnit; | ||
| import io.mongock.api.annotations.Execution; | ||
| import io.mongock.api.annotations.RollbackExecution; | ||
|  | ||
| @ChangeUnit(id = "ChangeUnitWithDefaultConstructor", order = "1") | ||
| public class ChangeUnitWithDefaultConstructor { | ||
|  | ||
| @Execution | ||
| public void execution() { | ||
| } | ||
|  | ||
| @RollbackExecution | ||
| public void rollbackExecution() { | ||
| } | ||
| } | 
        
          
          
            26 changes: 26 additions & 0 deletions
          
          26 
        
  ...unner/core/changelogs/withConstructor/ChangeUnitWithMoreThanOneChangeUnitConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| package io.mongock.runner.core.changelogs.withConstructor; | ||
|  | ||
| import io.mongock.api.annotations.ChangeUnit; | ||
| import io.mongock.api.annotations.ChangeUnitConstructor; | ||
| import io.mongock.api.annotations.Execution; | ||
| import io.mongock.api.annotations.RollbackExecution; | ||
|  | ||
| @ChangeUnit(id = "ChangeUnitWithMoreThanOneChangeUnitConstructor", order = "1") | ||
| public class ChangeUnitWithMoreThanOneChangeUnitConstructor { | ||
|  | ||
| @ChangeUnitConstructor | ||
| public ChangeUnitWithMoreThanOneChangeUnitConstructor() { | ||
| } | ||
|  | ||
| @ChangeUnitConstructor | ||
| public ChangeUnitWithMoreThanOneChangeUnitConstructor(String dummy) { | ||
| } | ||
|  | ||
| @Execution | ||
| public void execution() { | ||
| } | ||
|  | ||
| @RollbackExecution | ||
| public void rollbackExecution() { | ||
| } | ||
| } | 
        
          
          
            20 changes: 20 additions & 0 deletions
          
          20 
        
  ...ava/io/mongock/runner/core/changelogs/withConstructor/ChangeUnitWithValidConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package io.mongock.runner.core.changelogs.withConstructor; | ||
|  | ||
| import io.mongock.api.annotations.ChangeUnit; | ||
| import io.mongock.api.annotations.Execution; | ||
| import io.mongock.api.annotations.RollbackExecution; | ||
|  | ||
| @ChangeUnit(id = "ChangeUnitWithValidConstructor", order = "1") | ||
| public class ChangeUnitWithValidConstructor { | ||
|  | ||
| public ChangeUnitWithValidConstructor() { | ||
| } | ||
|  | ||
| @Execution | ||
| public void execution() { | ||
| } | ||
|  | ||
| @RollbackExecution | ||
| public void rollbackExecution() { | ||
| } | ||
| } | 
        
          
          
            35 changes: 35 additions & 0 deletions
          
          35 
        
  ...hangelogs/withConstructor/ChangeUnitWithValidConstructorsHavingChangeUnitConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| package io.mongock.runner.core.changelogs.withConstructor; | ||
|  | ||
| import io.mongock.api.annotations.ChangeUnit; | ||
| import io.mongock.api.annotations.ChangeUnitConstructor; | ||
| import io.mongock.api.annotations.Execution; | ||
| import io.mongock.api.annotations.RollbackExecution; | ||
|  | ||
| @ChangeUnit(id = "ChangeUnitWithValidConstructorsHavingChangeUnitConstructor", order = "1") | ||
| public class ChangeUnitWithValidConstructorsHavingChangeUnitConstructor { | ||
|  | ||
| public static final String DUMMY_VALUE = "dummyValue"; | ||
| private final String dummy; | ||
|  | ||
| public ChangeUnitWithValidConstructorsHavingChangeUnitConstructor(String dummy) { | ||
| this.dummy = dummy; | ||
| } | ||
|  | ||
|  | ||
| @ChangeUnitConstructor | ||
| public ChangeUnitWithValidConstructorsHavingChangeUnitConstructor() { | ||
| this.dummy = DUMMY_VALUE; | ||
| } | ||
|  | ||
| @Execution | ||
| public void execution() { | ||
| } | ||
|  | ||
| @RollbackExecution | ||
| public void rollbackExecution() { | ||
| } | ||
|  | ||
| public String getDummy() { | ||
| return dummy; | ||
| } | ||
| } | 
        
          
          
            20 changes: 20 additions & 0 deletions
          
          20 
        
  .../io/mongock/runner/core/changelogs/withConstructor/ChangeUnitWithoutValidConstructor.java
  
  
      
      
   
        
      
      
    
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| package io.mongock.runner.core.changelogs.withConstructor; | ||
|  | ||
| import io.mongock.api.annotations.ChangeUnit; | ||
| import io.mongock.api.annotations.Execution; | ||
| import io.mongock.api.annotations.RollbackExecution; | ||
|  | ||
| @ChangeUnit(id = "ChangeUnitWithoutValidConstructor", order = "1") | ||
| public class ChangeUnitWithoutValidConstructor { | ||
|  | ||
| private ChangeUnitWithoutValidConstructor() { | ||
| } | ||
|  | ||
| @Execution | ||
| public void execution() { | ||
| } | ||
|  | ||
| @RollbackExecution | ||
| public void rollbackExecution() { | ||
| } | ||
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.