From e17e744b209d8c1d622c628469375c28b3c80d6f Mon Sep 17 00:00:00 2001 From: Filip Hrisafov Date: Sun, 20 Sep 2020 11:06:33 +0200 Subject: [PATCH] Dependency upgrades Upgrades: * Maven Enforcer Plugin to 3.0.0-M3 * Maven Surefire Plugin to 3.0.0-M5 * Maven Checkstyle Plugin to 3.1.1 * Maven Bundle Plugin to 5.1.1 * Jacoco Maven Plugin to 0.8.6 * Checkstyle to 8.36.1 * JUnit Jipiter to 5.7.0 * AssertJ to 3.17.2 * Guava to 29.0-jre Fix AssertJ breaking changes Use Java 8 or Apache Commons IO instead of Guava where possible Update GitHub Actions to use JDK 14 and JDK 15-ea --- .github/workflows/java-ea.yml | 2 +- .github/workflows/main.yml | 2 +- parent/pom.xml | 19 +++++++++---------- .../ap/test/bugs/_1338/Issue1338Test.java | 6 ++---- .../ap/test/bugs/_1359/Issue1359Test.java | 6 +++--- .../ap/test/bugs/_895/Issue895Test.java | 2 +- .../nestedprop/expanding/FlattenedStock.java | 6 +++--- .../mapstruct/ap/test/collection/Target.java | 9 ++++----- .../StringListMapper.java | 4 +--- .../testutil/assertions/JavaFileAssert.java | 6 ++---- .../testutil/runner/CompilingStatement.java | 8 ++++---- 11 files changed, 31 insertions(+), 39 deletions(-) diff --git a/.github/workflows/java-ea.yml b/.github/workflows/java-ea.yml index c20151ecc..a5afa065c 100644 --- a/.github/workflows/java-ea.yml +++ b/.github/workflows/java-ea.yml @@ -7,7 +7,7 @@ jobs: strategy: fail-fast: false matrix: - java: [15-ea] + java: [16-ea] name: 'Linux JDK ${{ matrix.java }}' runs-on: ubuntu-latest steps: diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d1f65d18f..08278a1ad 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -11,7 +11,7 @@ jobs: strategy: fail-fast: false matrix: - java: [11, 13, 14] + java: [11, 13, 15] name: 'Linux JDK ${{ matrix.java }}' runs-on: ubuntu-latest steps: diff --git a/parent/pom.xml b/parent/pom.xml index b26cf8683..e28caa20b 100644 --- a/parent/pom.xml +++ b/parent/pom.xml @@ -22,17 +22,16 @@ UTF-8 1.0.0.Alpha2 - - 3.0.0-M1 - 3.0.0-M3 + 3.0.0-M3 + 3.0.0-M5 3.1.0 4.0.3.RELEASE 1.6.0 - 8.29 - 5.6.0 + 8.36.1 + 5.7.0 1 - 3.11.1 + 3.17.2 jdt_apt @@ -112,7 +111,7 @@ com.google.guava guava - 19.0 + 29.0-jre org.mapstruct.tools.gem @@ -307,7 +306,7 @@ org.apache.maven.plugins maven-checkstyle-plugin - 3.1.0 + 3.1.1 build-config/checkstyle.xml true @@ -383,7 +382,7 @@ org.apache.felix maven-bundle-plugin - 4.0.0 + 5.1.1 bundle-manifest @@ -529,7 +528,7 @@ org.jacoco jacoco-maven-plugin - 0.8.5 + 0.8.6 org.jvnet.jaxb2.maven2 diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1338/Issue1338Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1338/Issue1338Test.java index 8274b748a..83c5212d2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1338/Issue1338Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1338/Issue1338Test.java @@ -14,7 +14,6 @@ import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.atIndex; /** * @author Filip Hrisafov @@ -34,9 +33,8 @@ public class Issue1338Test { source.setProperties( Arrays.asList( "first", "second" ) ); Target target = Issue1338Mapper.INSTANCE.map( source ); - assertThat( target ) - .extracting( "properties" ) - .contains( Arrays.asList( "first", "second" ), atIndex( 0 ) ); + assertThat( target.getProperties() ) + .containsExactly( "first", "second" ); Source mapped = Issue1338Mapper.INSTANCE.map( target ); diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1359/Issue1359Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1359/Issue1359Test.java index 7434afa9f..aa49cc59f 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_1359/Issue1359Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_1359/Issue1359Test.java @@ -15,7 +15,7 @@ import org.mapstruct.ap.testutil.WithClasses; import org.mapstruct.ap.testutil.runner.AnnotationProcessorTestRunner; import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.atIndex; +import static org.assertj.core.api.InstanceOfAssertFactories.ITERABLE; /** * @author Filip Hrisafov @@ -33,14 +33,14 @@ public class Issue1359Test { public void shouldCompile() { Target target = new Target(); - assertThat( target ).extracting( "properties" ).contains( null, atIndex( 0 ) ); + assertThat( target ).extracting( "properties" ).isNull(); Set properties = new HashSet<>(); properties.add( "first" ); Source source = new Source( properties ); Issue1359Mapper.INSTANCE.map( target, source ); - assertThat( target ).extracting( "properties" ).contains( properties, atIndex( 0 ) ); + assertThat( target ).extracting( "properties", ITERABLE ).containsExactly( "first" ); } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/bugs/_895/Issue895Test.java b/processor/src/test/java/org/mapstruct/ap/test/bugs/_895/Issue895Test.java index 9de76b43d..d9f25f5fe 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/bugs/_895/Issue895Test.java +++ b/processor/src/test/java/org/mapstruct/ap/test/bugs/_895/Issue895Test.java @@ -32,6 +32,6 @@ public class Issue895Test { assertThat( listOfByteArray.getBytes() ).containsExactly( new byte[] { 0, 1 }, new byte[] { 1, 2 } ); arrayOfByteArray = Mappers.getMapper( MultiArrayMapper.class ).convert( listOfByteArray ); - assertThat( arrayOfByteArray.getBytes() ).containsExactly( new byte[] { 0, 1 }, new byte[] { 1, 2 } ); + assertThat( arrayOfByteArray.getBytes() ).isDeepEqualTo( new byte[][] { { 0, 1 }, { 1, 2 } } ); } } diff --git a/processor/src/test/java/org/mapstruct/ap/test/builder/nestedprop/expanding/FlattenedStock.java b/processor/src/test/java/org/mapstruct/ap/test/builder/nestedprop/expanding/FlattenedStock.java index 70cbbb7f8..f7cce1a03 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/builder/nestedprop/expanding/FlattenedStock.java +++ b/processor/src/test/java/org/mapstruct/ap/test/builder/nestedprop/expanding/FlattenedStock.java @@ -5,7 +5,7 @@ */ package org.mapstruct.ap.test.builder.nestedprop.expanding; -import static com.google.common.base.Preconditions.checkNotNull; +import static java.util.Objects.requireNonNull; public class FlattenedStock { private String article1; @@ -16,8 +16,8 @@ public class FlattenedStock { } public FlattenedStock(String article1, String article2, int count) { - this.article1 = checkNotNull( article1 ); - this.article2 = checkNotNull( article2 ); + this.article1 = requireNonNull( article1 ); + this.article2 = requireNonNull( article2 ); this.count = count; } diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java b/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java index 51a1eddda..2ff6cbfb2 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/Target.java @@ -8,14 +8,12 @@ package org.mapstruct.ap.test.collection; import java.util.ArrayList; import java.util.Collection; import java.util.EnumSet; +import java.util.HashMap; import java.util.HashSet; import java.util.List; import java.util.Map; import java.util.Set; -import com.google.common.collect.Lists; -import com.google.common.collect.Maps; - public class Target { //CHECKSTYLE:OFF @@ -54,10 +52,11 @@ public class Target { private StringHolderToLongMap nonGenericMapStringtoLong; public Target() { - otherStringLongMap = Maps.newHashMap(); + otherStringLongMap = new HashMap<>(); otherStringLongMap.put( "not-present-after-mapping", 42L ); - otherStringList = Lists.newArrayList( "not-present-after-mapping" ); + otherStringList = new ArrayList<>(); + otherStringList.add( "not-present-after-mapping" ); } public List getStringList() { diff --git a/processor/src/test/java/org/mapstruct/ap/test/collection/iterabletononiterable/StringListMapper.java b/processor/src/test/java/org/mapstruct/ap/test/collection/iterabletononiterable/StringListMapper.java index 1cbe6e128..93983acf5 100644 --- a/processor/src/test/java/org/mapstruct/ap/test/collection/iterabletononiterable/StringListMapper.java +++ b/processor/src/test/java/org/mapstruct/ap/test/collection/iterabletononiterable/StringListMapper.java @@ -8,12 +8,10 @@ package org.mapstruct.ap.test.collection.iterabletononiterable; import java.util.Arrays; import java.util.List; -import com.google.common.base.Joiner; - public class StringListMapper { public String stringListToString(List strings) { - return strings == null ? null : Joiner.on( "-" ).join( strings ); + return strings == null ? null : String.join( "-", strings ); } public List stringToStringList(String string) { diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/assertions/JavaFileAssert.java b/processor/src/test/java/org/mapstruct/ap/testutil/assertions/JavaFileAssert.java index 7a14619b0..2bcfbd94d 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/assertions/JavaFileAssert.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/assertions/JavaFileAssert.java @@ -15,6 +15,7 @@ import java.nio.charset.StandardCharsets; import java.util.ArrayList; import java.util.List; +import org.apache.commons.io.FileUtils; import org.assertj.core.api.AbstractCharSequenceAssert; import org.assertj.core.api.Assertions; import org.assertj.core.api.FileAssert; @@ -23,9 +24,6 @@ import org.assertj.core.internal.Diff; import org.assertj.core.internal.Failures; import org.assertj.core.util.diff.Delta; -import com.google.common.base.Charsets; -import com.google.common.io.Files; - /** * Allows to perform assertions on .java source files. * @@ -58,7 +56,7 @@ public class JavaFileAssert extends FileAssert { isFile(); try { - return Assertions.assertThat( Files.toString( actual, Charsets.UTF_8 ) ); + return Assertions.assertThat( FileUtils.readFileToString( actual, StandardCharsets.UTF_8 ) ); } catch ( IOException e ) { failWithMessage( "Unable to read" + actual.toString() + ". Exception: " + e.getMessage() ); diff --git a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java index 59916e981..3e61d8bd9 100644 --- a/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java +++ b/processor/src/test/java/org/mapstruct/ap/testutil/runner/CompilingStatement.java @@ -19,6 +19,7 @@ import java.util.Comparator; import java.util.HashMap; import java.util.HashSet; import java.util.Iterator; +import java.util.LinkedList; import java.util.List; import java.util.Map; import java.util.Properties; @@ -26,6 +27,7 @@ import java.util.Set; import java.util.stream.Stream; import com.puppycrawl.tools.checkstyle.api.AutomaticBean; +import org.apache.commons.io.output.NullOutputStream; import org.junit.runners.model.FrameworkMethod; import org.junit.runners.model.Statement; import org.mapstruct.ap.testutil.WithClasses; @@ -41,8 +43,6 @@ import org.mapstruct.ap.testutil.compilation.model.CompilationOutcomeDescriptor; import org.mapstruct.ap.testutil.compilation.model.DiagnosticDescriptor; import org.xml.sax.InputSource; -import com.google.common.collect.Lists; -import com.google.common.io.ByteStreams; import com.puppycrawl.tools.checkstyle.Checker; import com.puppycrawl.tools.checkstyle.ConfigurationLoader; import com.puppycrawl.tools.checkstyle.DefaultLogger; @@ -217,7 +217,7 @@ abstract class CompilingStatement extends Statement { ByteArrayOutputStream errorStream = new ByteArrayOutputStream(); checker.addListener( new DefaultLogger( - ByteStreams.nullOutputStream(), + NullOutputStream.NULL_OUTPUT_STREAM, AutomaticBean.OutputStreamOptions.CLOSE, errorStream, AutomaticBean.OutputStreamOptions.CLOSE @@ -234,7 +234,7 @@ abstract class CompilingStatement extends Statement { } private static List findGeneratedFiles(File file) { - final List files = Lists.newLinkedList(); + final List files = new LinkedList<>(); if ( file.canRead() ) { if ( file.isDirectory() ) {