use of org.apache.tapestry5.versionmigrator.ClassRefactor in project tapestry-5 by apache.
the class PackageAndArtifactChangeRefactorCommitParser method apply.
@Override
public Optional<ClassRefactor> apply(String line) {
ClassRefactor move = null;
final Matcher matcher = PATTERN.matcher(line);
if (matcher.matches()) {
// System.out.printf("1(%s) 2(%s) 3(%s) 4(%s) 5(%s)\n", matcher.group(1), matcher.group(2), matcher.group(3), matcher.group(4), matcher.group(5));
String newPackageNameSuffix = FileRefactorCommitParser.extractPackageOrClassName(matcher.group(4));
String oldPackageNameSuffix = FileRefactorCommitParser.extractPackageOrClassName(matcher.group(2));
final String className = matcher.group(5);
final String newClassName = FileRefactorCommitParser.buildClassName("", newPackageNameSuffix, className);
final String oldClassName = FileRefactorCommitParser.buildClassName("", oldPackageNameSuffix, className);
final String sourceArtifactName = matcher.group(1);
final String destinationArtifactName = matcher.group(3);
move = new ClassRefactor(newClassName, oldClassName, sourceArtifactName, destinationArtifactName);
}
return Optional.ofNullable(move);
}
use of org.apache.tapestry5.versionmigrator.ClassRefactor in project tapestry-5 by apache.
the class PackageChangeRefactorCommitParser method apply.
@Override
public Optional<ClassRefactor> apply(String line) {
final Matcher matcher = PATTERN.matcher(line);
ClassRefactor move = null;
if (matcher.matches()) {
String newPackageNameSuffix = matcher.group(4);
String oldPackageNameSuffix = matcher.group(3);
// System.out.printf("1(%s) 2(%s) 3(%s) 4(%s) 5(%s)\n", matcher.group(1), matcher.group(2), oldPackageNameSuffix, newPackageNameSuffix, matcher.group(5));
final String rootPackageName = matcher.group(2).replace("src/main/java/", "").replace("/", ".");
final String className = matcher.group(5);
final String newClassName = FileRefactorCommitParser.buildClassName(rootPackageName, newPackageNameSuffix, className);
final String oldClassName = FileRefactorCommitParser.buildClassName(rootPackageName, oldPackageNameSuffix, className);
final String artifactName = matcher.group(1);
move = new ClassRefactor(newClassName, oldClassName, artifactName, artifactName);
}
return Optional.ofNullable(move);
}
use of org.apache.tapestry5.versionmigrator.ClassRefactor in project tapestry-5 by apache.
the class ArtifactChangeRefactorCommitParserTest method valid_line.
@Test
public void valid_line() {
// {tapestry-ioc => tapestry5-annotations}/src/main/java/org/apache/tapestry5/ioc/annotations/Advise.java
ArtifactChangeRefactorCommitParser parser = new ArtifactChangeRefactorCommitParser();
Optional<ClassRefactor> optionalRefactor = parser.apply(ArtifactChangeRefactorCommitParser.EXAMPLE);
Assert.assertTrue(optionalRefactor.isPresent(), "Line not detected as a change of artifact.");
ClassRefactor refactor = optionalRefactor.get();
final String expectedClassName = "org.apache.tapestry5.ioc.annotations.Advise";
Assert.assertEquals(refactor.getNewClassName(), expectedClassName);
Assert.assertEquals(refactor.getOldClassName(), expectedClassName);
Assert.assertEquals(refactor.getDestinationArtifact(), "tapestry5-annotations");
Assert.assertEquals(refactor.getSourceArtifact(), "tapestry-ioc");
}
use of org.apache.tapestry5.versionmigrator.ClassRefactor in project tapestry-5 by apache.
the class PackageAndArtifactChangeRefactorCommitParserTest method valid_line.
@Test
public void valid_line() {
// {tapestry-ioc/src/main/java/org/apache/tapestry5/ioc => commons/src/main/java/org/apache/tapestry5/commons}/ObjectProvider.java
PackageAndArtifactChangeRefactorCommitParser parser = new PackageAndArtifactChangeRefactorCommitParser();
Optional<ClassRefactor> optionalRefactor = parser.apply(PackageAndArtifactChangeRefactorCommitParser.EXAMPLE);
Assert.assertTrue(optionalRefactor.isPresent(), "Line not detected as a change of package and artifact.");
ClassRefactor refactor = optionalRefactor.get();
Assert.assertEquals(refactor.getNewClassName(), "org.apache.tapestry5.commons.ObjectProvider");
Assert.assertEquals(refactor.getOldClassName(), "org.apache.tapestry5.ioc.ObjectProvider");
Assert.assertEquals(refactor.getDestinationArtifact(), "commons");
Assert.assertEquals(refactor.getSourceArtifact(), "tapestry-ioc");
}
use of org.apache.tapestry5.versionmigrator.ClassRefactor in project tapestry-5 by apache.
the class PackageChangeRefactorCommitParserTest method valid_line.
@Test
public void valid_line() {
// commons/src/main/java/org/apache/tapestry5/{ioc => commons}/Messages.java (98%)
PackageChangeRefactorCommitParser parser = new PackageChangeRefactorCommitParser();
Optional<ClassRefactor> optionalRefactor = parser.apply(PackageChangeRefactorCommitParser.EXAMPLE);
Assert.assertTrue(optionalRefactor.isPresent(), "Line not detected as a change of package.");
ClassRefactor refactor = optionalRefactor.get();
Assert.assertEquals(refactor.getNewClassName(), "org.apache.tapestry5.commons.Messages");
Assert.assertEquals(refactor.getOldClassName(), "org.apache.tapestry5.ioc.Messages");
Assert.assertEquals(refactor.getDestinationArtifact(), "commons");
Assert.assertEquals(refactor.getSourceArtifact(), "commons");
}
Aggregations