Skip to content
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

WIP: #226: specific migration #597

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,28 @@ public static MigrationImpl devon4j() {
.next().build();
}

public static MigrationImpl junit() {
return new MigrationBuilder().to(null)
.pom()
.replaceString("com.devonfw.module.test.common.api.category.CategorySystemTest", "system")
.replaceString(
"com.devonfw.module.test.common.api.category.CategoryComponentTest,com.devonfw.module.test.common.api.category.CategorySubsystemTest,com.devonfw.module.test.common.api.category.CategorySystemTest",
"component,subsystem,system")
.replaceString(
"com.devonfw.module.test.common.api.category.CategorySubsystemTest,com.devonfw.module.test.common.api.category.CategorySystemTest",
"subsystem,system")
.replaceDependency(new VersionIdentifier("junit", "junit", null),
new VersionIdentifier("org.junit.jupiter", "junit-jupiter-engine", null, VersionIdentifier.SCOPE_TEST))
.addDependency(new VersionIdentifier("*-core", null),
new VersionIdentifier("org.junit.platform", "junit-platform-runner", null, VersionIdentifier.SCOPE_TEST))
.and().java()
.replace("import org.junit.Test;",
"import org.junit.jupiter.api.extension.ExtendWith;\n import org.junit.jupiter.api.Test;\n import org.springframework.test.context.junit.jupiter.SpringExtension;")
.replace("@RunWith(SpringRunner.class)", "@ExtendWith(SpringExtension.class)")
.replace("com.devonfw.module.jpa.dataaccess.api.RevisionMetadata",
"com.devonfw.module.basic.common.api.RevisionMetadata")
.replace("com.devonfw.module.jpa.dataaccess.api.RevisionMetadataType",
"com.devonfw.module.basic.common.api.RevisionMetadataType")
.and().next().build();
Comment on lines +201 to +222
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice starting point. However a migration from junit 4 to 5 should not be strictly limited to devon4j spring projects.
However, we can merge this and later add PR for improvements. Actually this migration is rather tricky. We could find several projects at CG to test and improve this...

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,16 @@ private int run(String[] args) throws Exception {
}
} else if ("single".equals(arg)) {
singleStep = true;
} else if ("step".equals(arg)) {
if (!arguments.hasNext()) {
throw new IllegalArgumentException("Commandline option 'step' has to be followed by a identifier of a specific step");
}
arg = arguments.next();
switch(arg) {
case "junit":
migration = Migrations.junit();
Comment on lines +69 to +70
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should directly register migration steps with its ID in builder code that is then given via CLI avoiding a separate mapping here.

break;
}
} else {
throw new IllegalArgumentException("Unknown argument '" + arg + "'");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ public MigrationBuilder(VersionIdentifier from) {
this.steps = new ArrayList<>();
}

public MigrationBuilder() {
this(null);
}

/**
* @param to the {@link VersionIdentifier} to migrate to.
* @return the builder to configure the {@link MigrationStep} to migrate to that given {@link VersionIdentifier}.
Expand Down