diff --git a/src/main/java/com/github/alexisjehan/mvncheck/core/Service.java b/src/main/java/com/github/alexisjehan/mvncheck/core/Service.java index f62c746..55f9e86 100644 --- a/src/main/java/com/github/alexisjehan/mvncheck/core/Service.java +++ b/src/main/java/com/github/alexisjehan/mvncheck/core/Service.java @@ -193,7 +193,11 @@ public List findBuildFiles(final Path path, final int maxDepth) throw public List filterBuildFiles(final List buildFiles) { Ensure.notNullAndNotNullElements("buildFiles", buildFiles); final var outputDirectories = buildFiles.stream() - .map(buildFile -> buildFile.getFile().resolveSibling(buildFile.getType().getOutputDirectoryName())) + .map( + buildFile -> buildFile.getFile().resolveSibling( + buildFile.getType().getOutputDirectoryName() + ) + ) .collect(Collectors.toUnmodifiableList()); return buildFiles.stream() .filter(buildFile -> outputDirectories.stream().noneMatch(buildFile.getFile()::startsWith)) @@ -287,7 +291,12 @@ public List findArtifactUpdateVersions( .filter(version -> !ignoreSnapshots || !VersionFilter.SNAPSHOT.accept(version)) .isPresent() ) - .map(artifact -> artifactAvailableVersionsResolver.resolve(artifact, build.getRepositories())) + .map( + artifact -> artifactAvailableVersionsResolver.resolve( + artifact, + build.getRepositories() + ) + ) .map(artifactAvailableVersions -> { final var artifact = artifactAvailableVersions.getArtifact(); final var artifactVersion = artifact.getOptionalVersion().orElseThrow(); diff --git a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java index d463aec..7ef0ace 100644 --- a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java +++ b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolver.java @@ -167,28 +167,40 @@ private Build resolve(final BuildFile file, final OutputStream outputStream) thr final var repositories = parseRepositories(reader); logger.debug("Parsed repositories:"); repositories.forEach( - repository -> logger.debug("- {}", () -> ToString.toString(repository)) + repository -> logger.debug( + "- {}", + () -> ToString.toString(repository) + ) ); logger.trace("Filtering repositories"); final var filteredRepositories = filterRepositories(repositories); logger.debug("Filtered repositories:"); filteredRepositories.forEach( - filteredRepository -> logger.debug("- {}", () -> ToString.toString(filteredRepository)) + filteredRepository -> logger.debug( + "- {}", + () -> ToString.toString(filteredRepository) + ) ); logger.trace("Parsing artifacts"); final var artifacts = parseArtifacts(reader); logger.debug("Parsed artifacts:"); artifacts.forEach( - artifact -> logger.debug("- {}", () -> ToString.toString(artifact)) + artifact -> logger.debug( + "- {}", + () -> ToString.toString(artifact) + ) ); logger.trace("Filtering artifacts"); final var filteredArtifacts = filterArtifacts(artifacts); logger.debug("Filtered artifacts:"); filteredArtifacts.forEach( - filteredArtifact -> logger.debug("- {}", () -> ToString.toString(filteredArtifact)) + filteredArtifact -> logger.debug( + "- {}", + () -> ToString.toString(filteredArtifact) + ) ); return new Build(file, filteredRepositories, filteredArtifacts); @@ -280,7 +292,10 @@ static List> parseArtifacts(final BufferedReader bu } final var artifactTypeString = Strings.substringBefore(line, " - "); final var optionalArtifactType = Arrays.stream(GradleArtifactType.values()) - .filter(artifactType -> artifactType.dependenciesTaskName().equals(artifactTypeString)) + .filter( + artifactType -> artifactType.dependenciesTaskName() + .equals(artifactTypeString) + ) .findAny(); if (optionalArtifactType.isEmpty()) { while (null != (line = bufferedReader.readLine())) { @@ -411,9 +426,16 @@ static List> filterArtifacts(final List GradleArtifactType.TEST_COMPILE_CLASSPATH == artifact.getType()) + .filter( + artifact -> + GradleArtifactType.TEST_COMPILE_CLASSPATH == artifact.getType() + ) .collect(Collectors.toUnmodifiableList()) - .forEach(artifact -> artifacts.remove(artifact.withType(GradleArtifactType.TEST_RUNTIME_CLASSPATH))); + .forEach( + artifact -> artifacts.remove( + artifact.withType(GradleArtifactType.TEST_RUNTIME_CLASSPATH) + ) + ); return artifacts.stream() .map(artifact -> { switch (artifact.getType()) { diff --git a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/MavenBuildResolver.java b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/MavenBuildResolver.java index f354f41..34233fe 100644 --- a/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/MavenBuildResolver.java +++ b/src/main/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/MavenBuildResolver.java @@ -132,28 +132,40 @@ public Build resolve(final BuildFile file) { final var effectiveRepositories = extractRepositories(effectiveModel); logger.debug("Extracted effective repositories:"); effectiveRepositories.forEach( - effectiveRepository -> logger.debug("- {}", () -> ToString.toString(effectiveRepository)) + effectiveRepository -> logger.debug( + "- {}", + () -> ToString.toString(effectiveRepository) + ) ); logger.trace("Extracting effective artifacts"); final var effectiveArtifacts = extractArtifacts(effectiveModel); logger.debug("Extracted effective artifacts:"); effectiveArtifacts.forEach( - effectiveArtifact -> logger.debug("- {}", () -> ToString.toString(effectiveArtifact)) + effectiveArtifact -> logger.debug( + "- {}", + () -> ToString.toString(effectiveArtifact) + ) ); logger.trace("Extracting raw artifacts"); final var rawArtifacts = extractArtifacts(rawModel); logger.debug("Extracted raw artifacts:"); rawArtifacts.forEach( - rawArtifact -> logger.debug("- {}", () -> ToString.toString(rawArtifact)) + rawArtifact -> logger.debug( + "- {}", + () -> ToString.toString(rawArtifact) + ) ); logger.trace("Inheriting artifacts"); final var inheritedArtifacts = inherit(rawArtifacts, effectiveArtifacts); logger.debug("Inherited artifacts:"); inheritedArtifacts.forEach( - inheritedArtifact -> logger.debug("- {}", () -> ToString.toString(inheritedArtifact)) + inheritedArtifact -> logger.debug( + "- {}", + () -> ToString.toString(inheritedArtifact) + ) ); return new Build(file, effectiveRepositories, inheritedArtifacts); @@ -299,21 +311,22 @@ private static List> inherit( final var rawArtifactOptionalVersion = rawArtifact.getOptionalVersion(); return effectiveArtifacts.stream() .filter( - effectiveArtifact -> rawArtifactType == effectiveArtifact.getType() - && rawArtifactIdentifier.equals(effectiveArtifact.getIdentifier()) + effectiveArtifact -> + rawArtifactType == effectiveArtifact.getType() + && rawArtifactIdentifier.equals(effectiveArtifact.getIdentifier()) ) .sorted( Comparator.comparing( - effectiveArtifact -> rawArtifactOptionalVersion.equals( - effectiveArtifact.getOptionalVersion() - ), + effectiveArtifact -> + rawArtifactOptionalVersion.equals( + effectiveArtifact.getOptionalVersion() + ), Comparator.reverseOrder() ) ) .map( - effectiveArtifact -> effectiveArtifact.withVersionInherited( - rawArtifactOptionalVersion.isEmpty() - ) + effectiveArtifact -> + effectiveArtifact.withVersionInherited(rawArtifactOptionalVersion.isEmpty()) ) .findAny() .orElse(rawArtifact); diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/ServiceTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/ServiceTest.java index 2a6dfce..40bba15 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/ServiceTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/ServiceTest.java @@ -367,7 +367,8 @@ void testFindArtifactUpdateVersionsDeprecated1() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && fooIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && fooIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) @@ -382,7 +383,8 @@ void testFindArtifactUpdateVersionsDeprecated1() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && barIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && barIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) @@ -432,7 +434,8 @@ void testFindArtifactUpdateVersionsDeprecated2() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && fooIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && fooIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) @@ -447,7 +450,8 @@ void testFindArtifactUpdateVersionsDeprecated2() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && barIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && barIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) @@ -517,7 +521,8 @@ void testFindArtifactUpdateVersions() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && fooIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && fooIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) @@ -532,7 +537,8 @@ void testFindArtifactUpdateVersions() throws IOException { .when( mockedArtifactAvailableVersionsResolver.resolve( Mockito.argThat( - artifact -> null != artifact && barIdentifier.equals(artifact.getIdentifier()) + artifact -> null != artifact + && barIdentifier.equals(artifact.getIdentifier()) ), Mockito.notNull() ) diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactIdentifierTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactIdentifierTest.java index da2b156..8a46c77 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactIdentifierTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactIdentifierTest.java @@ -54,24 +54,27 @@ void testConstructorInvalid() { void testEqualsAndHashCodeAndToString() { assertThat(artifactIdentifier.equals(artifactIdentifier)).isTrue(); assertThat(artifactIdentifier).isNotEqualTo(new Object()); - assertThat(new ArtifactIdentifier(GROUP_ID, ARTIFACT_ID)).satisfies(otherArtifactIdentifier -> { - assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).isEqualTo(artifactIdentifier); - assertThat(otherArtifactIdentifier).hasSameHashCodeAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).hasToString(artifactIdentifier.toString()); - }); - assertThat(new ArtifactIdentifier(OTHER_GROUP_ID, ARTIFACT_ID)).satisfies(otherArtifactIdentifier -> { - assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).isNotEqualTo(artifactIdentifier); - assertThat(otherArtifactIdentifier).doesNotHaveSameHashCodeAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).doesNotHaveToString(artifactIdentifier.toString()); - }); - assertThat(new ArtifactIdentifier(GROUP_ID, OTHER_ARTIFACT_ID)).satisfies(otherArtifactIdentifier -> { - assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).isNotEqualTo(artifactIdentifier); - assertThat(otherArtifactIdentifier).doesNotHaveSameHashCodeAs(artifactIdentifier); - assertThat(otherArtifactIdentifier).doesNotHaveToString(artifactIdentifier.toString()); - }); + assertThat(new ArtifactIdentifier(GROUP_ID, ARTIFACT_ID)) + .satisfies(otherArtifactIdentifier -> { + assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).isEqualTo(artifactIdentifier); + assertThat(otherArtifactIdentifier).hasSameHashCodeAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).hasToString(artifactIdentifier.toString()); + }); + assertThat(new ArtifactIdentifier(OTHER_GROUP_ID, ARTIFACT_ID)) + .satisfies(otherArtifactIdentifier -> { + assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).isNotEqualTo(artifactIdentifier); + assertThat(otherArtifactIdentifier).doesNotHaveSameHashCodeAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).doesNotHaveToString(artifactIdentifier.toString()); + }); + assertThat(new ArtifactIdentifier(GROUP_ID, OTHER_ARTIFACT_ID)) + .satisfies(otherArtifactIdentifier -> { + assertThat(otherArtifactIdentifier).isNotSameAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).isNotEqualTo(artifactIdentifier); + assertThat(otherArtifactIdentifier).doesNotHaveSameHashCodeAs(artifactIdentifier); + assertThat(otherArtifactIdentifier).doesNotHaveToString(artifactIdentifier.toString()); + }); } @Test diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactTest.java index e46c825..9d28471 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/ArtifactTest.java @@ -125,54 +125,61 @@ void testWithTypeInvalid() { @Test void testWithVersionInherited() { - assertThat(artifact.withVersionInherited(VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact.getType()).isEqualTo(artifact.getType()); - assertThat(otherArtifact.getIdentifier()).isEqualTo(artifact.getIdentifier()); - assertThat(otherArtifact.getOptionalVersion()).isEqualTo(artifact.getOptionalVersion()); - assertThat(otherArtifact.isVersionInherited()).isEqualTo(VERSION_INHERITED); - }); - assertThat(artifact.withVersionInherited(OTHER_VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact.getType()).isEqualTo(artifact.getType()); - assertThat(otherArtifact.getIdentifier()).isEqualTo(artifact.getIdentifier()); - assertThat(otherArtifact.getOptionalVersion()).isEqualTo(artifact.getOptionalVersion()); - assertThat(otherArtifact.isVersionInherited()).isEqualTo(OTHER_VERSION_INHERITED); - }); + assertThat(artifact.withVersionInherited(VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact.getType()).isEqualTo(artifact.getType()); + assertThat(otherArtifact.getIdentifier()).isEqualTo(artifact.getIdentifier()); + assertThat(otherArtifact.getOptionalVersion()).isEqualTo(artifact.getOptionalVersion()); + assertThat(otherArtifact.isVersionInherited()).isEqualTo(VERSION_INHERITED); + }); + assertThat(artifact.withVersionInherited(OTHER_VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact.getType()).isEqualTo(artifact.getType()); + assertThat(otherArtifact.getIdentifier()).isEqualTo(artifact.getIdentifier()); + assertThat(otherArtifact.getOptionalVersion()).isEqualTo(artifact.getOptionalVersion()); + assertThat(otherArtifact.isVersionInherited()).isEqualTo(OTHER_VERSION_INHERITED); + }); } @Test void testEqualsAndHashCodeAndToString() { assertThat(artifact.equals(artifact)).isTrue(); assertThat(artifact).isNotEqualTo(new Object()); - assertThat(new Artifact<>(TYPE, IDENTIFIER, VERSION, VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact).isNotSameAs(artifact); - assertThat(otherArtifact).isEqualTo(artifact); - assertThat(otherArtifact).hasSameHashCodeAs(artifact); - assertThat(otherArtifact).hasToString(artifact.toString()); - }); - assertThat(new Artifact<>(OTHER_TYPE, IDENTIFIER, VERSION, VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact).isNotSameAs(artifact); - assertThat(otherArtifact).isNotEqualTo(artifact); - assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); - assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); - }); - assertThat(new Artifact<>(TYPE, OTHER_IDENTIFIER, VERSION, VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact).isNotSameAs(artifact); - assertThat(otherArtifact).isNotEqualTo(artifact); - assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); - assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); - }); - assertThat(new Artifact<>(TYPE, IDENTIFIER, OTHER_VERSION, VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact).isNotSameAs(artifact); - assertThat(otherArtifact).isNotEqualTo(artifact); - assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); - assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); - }); - assertThat(new Artifact<>(TYPE, IDENTIFIER, VERSION, OTHER_VERSION_INHERITED)).satisfies(otherArtifact -> { - assertThat(otherArtifact).isNotSameAs(artifact); - assertThat(otherArtifact).isNotEqualTo(artifact); - assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); - assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); - }); + assertThat(new Artifact<>(TYPE, IDENTIFIER, VERSION, VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact).isNotSameAs(artifact); + assertThat(otherArtifact).isEqualTo(artifact); + assertThat(otherArtifact).hasSameHashCodeAs(artifact); + assertThat(otherArtifact).hasToString(artifact.toString()); + }); + assertThat(new Artifact<>(OTHER_TYPE, IDENTIFIER, VERSION, VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact).isNotSameAs(artifact); + assertThat(otherArtifact).isNotEqualTo(artifact); + assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); + assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); + }); + assertThat(new Artifact<>(TYPE, OTHER_IDENTIFIER, VERSION, VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact).isNotSameAs(artifact); + assertThat(otherArtifact).isNotEqualTo(artifact); + assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); + assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); + }); + assertThat(new Artifact<>(TYPE, IDENTIFIER, OTHER_VERSION, VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact).isNotSameAs(artifact); + assertThat(otherArtifact).isNotEqualTo(artifact); + assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); + assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); + }); + assertThat(new Artifact<>(TYPE, IDENTIFIER, VERSION, OTHER_VERSION_INHERITED)) + .satisfies(otherArtifact -> { + assertThat(otherArtifact).isNotSameAs(artifact); + assertThat(otherArtifact).isNotEqualTo(artifact); + assertThat(otherArtifact).doesNotHaveSameHashCodeAs(artifact); + assertThat(otherArtifact).doesNotHaveToString(artifact.toString()); + }); } @Test diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/ArtifactUpdateVersionTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/ArtifactUpdateVersionTest.java index 2399b1f..344ed14 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/ArtifactUpdateVersionTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/ArtifactUpdateVersionTest.java @@ -63,24 +63,27 @@ void testConstructorInvalid() { void testEqualsAndHashCodeAndToString() { assertThat(artifactUpdateVersion.equals(artifactUpdateVersion)).isTrue(); assertThat(artifactUpdateVersion).isNotEqualTo(new Object()); - assertThat(new ArtifactUpdateVersion(ARTIFACT, UPDATE_VERSION)).satisfies(otherArtifactUpdateVersion -> { - assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).isEqualTo(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).hasSameHashCodeAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).hasToString(artifactUpdateVersion.toString()); - }); - assertThat(new ArtifactUpdateVersion(OTHER_ARTIFACT, UPDATE_VERSION)).satisfies(otherArtifactUpdateVersion -> { - assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).isNotEqualTo(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).doesNotHaveSameHashCodeAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).doesNotHaveToString(artifactUpdateVersion.toString()); - }); - assertThat(new ArtifactUpdateVersion(ARTIFACT, OTHER_UPDATE_VERSION)).satisfies(otherArtifactUpdateVersion -> { - assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).isNotEqualTo(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).doesNotHaveSameHashCodeAs(artifactUpdateVersion); - assertThat(otherArtifactUpdateVersion).doesNotHaveToString(artifactUpdateVersion.toString()); - }); + assertThat(new ArtifactUpdateVersion(ARTIFACT, UPDATE_VERSION)) + .satisfies(otherArtifactUpdateVersion -> { + assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).isEqualTo(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).hasSameHashCodeAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).hasToString(artifactUpdateVersion.toString()); + }); + assertThat(new ArtifactUpdateVersion(OTHER_ARTIFACT, UPDATE_VERSION)) + .satisfies(otherArtifactUpdateVersion -> { + assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).isNotEqualTo(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).doesNotHaveSameHashCodeAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).doesNotHaveToString(artifactUpdateVersion.toString()); + }); + assertThat(new ArtifactUpdateVersion(ARTIFACT, OTHER_UPDATE_VERSION)) + .satisfies(otherArtifactUpdateVersion -> { + assertThat(otherArtifactUpdateVersion).isNotSameAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).isNotEqualTo(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).doesNotHaveSameHashCodeAs(artifactUpdateVersion); + assertThat(otherArtifactUpdateVersion).doesNotHaveToString(artifactUpdateVersion.toString()); + }); } @Test diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/ArtifactAvailableVersionsResolveExceptionTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/ArtifactAvailableVersionsResolveExceptionTest.java index be9a870..7229c9d 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/ArtifactAvailableVersionsResolveExceptionTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/ArtifactAvailableVersionsResolveExceptionTest.java @@ -35,8 +35,8 @@ final class ArtifactAvailableVersionsResolveExceptionTest { private static final String MESSAGE = "foo-message"; - private final ArtifactAvailableVersionsResolveException artifactAvailableVersionsResolveException - = new ArtifactAvailableVersionsResolveException(MESSAGE); + private final ArtifactAvailableVersionsResolveException artifactAvailableVersionsResolveException = + new ArtifactAvailableVersionsResolveException(MESSAGE); @Test void testConstructorInvalid() { diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverIT.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverIT.java index 24934e3..c9df8cc 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverIT.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverIT.java @@ -38,8 +38,8 @@ final class MavenArtifactAvailableVersionsResolverIT { - private final MavenArtifactAvailableVersionsResolver mavenArtifactAvailableVersionsResolver - = new MavenArtifactAvailableVersionsResolver(new MavenSession()); + private final MavenArtifactAvailableVersionsResolver mavenArtifactAvailableVersionsResolver = + new MavenArtifactAvailableVersionsResolver(new MavenSession()); @Test void testResolve() { diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverTest.java index beaadae..2233558 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/artifact/version/resolver/MavenArtifactAvailableVersionsResolverTest.java @@ -115,8 +115,9 @@ void testResolve() throws VersionRangeResolutionException { "foo-version" ) ).satisfies( - artifact -> assertThat(mavenArtifactAvailableVersionsResolver.resolve(artifact, repositories)) - .isEqualTo(new ArtifactAvailableVersions(artifact, List.of("foo-version1", "foo-version2"))) + artifact -> assertThat( + mavenArtifactAvailableVersionsResolver.resolve(artifact, repositories) + ).isEqualTo(new ArtifactAvailableVersions(artifact, List.of("foo-version1", "foo-version2"))) ); assertThat( new Artifact<>( @@ -125,8 +126,9 @@ void testResolve() throws VersionRangeResolutionException { "foo-plugin-version" ) ).satisfies( - artifact -> assertThat(mavenArtifactAvailableVersionsResolver.resolve(artifact, repositories)) - .isEqualTo(new ArtifactAvailableVersions(artifact, List.of("foo-version1", "foo-version2"))) + artifact -> assertThat( + mavenArtifactAvailableVersionsResolver.resolve(artifact, repositories) + ).isEqualTo(new ArtifactAvailableVersions(artifact, List.of("foo-version1", "foo-version2"))) ); } diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolverTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolverTest.java index 9c54df0..3f599f8 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolverTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/component/build/resolver/GradleBuildResolverTest.java @@ -282,60 +282,64 @@ void testResolveInvalid(@TempDir final Path tmpDirectory) { assertThat(BuildFileType.GRADLE_GROOVY).satisfies(buildFileType -> { final var tmpBuildDirectory = tmpDirectory.resolve("groovy"); Files.createDirectory(tmpBuildDirectory); - assertThat(tmpBuildDirectory.resolve("build_not-found.gradle")).satisfies(tmpBuildFile -> { - final var buildFile = new BuildFile(buildFileType, tmpBuildFile); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - }); - assertThat(tmpBuildDirectory.resolve("build.gradle")).satisfies(tmpBuildFile -> { - final var buildFile = new BuildFile(buildFileType, tmpBuildFile); - Files.copy( - Path.of("src", "test", "resources", "build_error.gradle"), - tmpBuildFile, - StandardCopyOption.REPLACE_EXISTING - ); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - Files.copy( - Path.of("src", "test", "resources", "build_foo.gradle"), - tmpBuildFile, - StandardCopyOption.REPLACE_EXISTING - ); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - }); + assertThat(tmpBuildDirectory.resolve("build_not-found.gradle")) + .satisfies(tmpBuildFile -> { + final var buildFile = new BuildFile(buildFileType, tmpBuildFile); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + }); + assertThat(tmpBuildDirectory.resolve("build.gradle")) + .satisfies(tmpBuildFile -> { + final var buildFile = new BuildFile(buildFileType, tmpBuildFile); + Files.copy( + Path.of("src", "test", "resources", "build_error.gradle"), + tmpBuildFile, + StandardCopyOption.REPLACE_EXISTING + ); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + Files.copy( + Path.of("src", "test", "resources", "build_foo.gradle"), + tmpBuildFile, + StandardCopyOption.REPLACE_EXISTING + ); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + }); }); assertThat(BuildFileType.GRADLE_KOTLIN).satisfies(buildFileType -> { final var tmpBuildDirectory = tmpDirectory.resolve("kotlin"); Files.createDirectory(tmpBuildDirectory); - assertThat(tmpBuildDirectory.resolve("build_not-found.gradle.kts")).satisfies(tmpBuildFile -> { - final var buildFile = new BuildFile(buildFileType, tmpBuildFile); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - }); - assertThat(tmpBuildDirectory.resolve("build.gradle.kts")).satisfies(tmpBuildFile -> { - final var buildFile = new BuildFile(buildFileType, tmpBuildFile); - Files.copy( - Path.of("src", "test", "resources", "build_error.gradle.kts"), - tmpBuildFile, - StandardCopyOption.REPLACE_EXISTING - ); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - Files.copy( - Path.of("src", "test", "resources", "build_foo.gradle.kts"), - tmpBuildFile, - StandardCopyOption.REPLACE_EXISTING - ); - assertThatExceptionOfType(BuildResolveException.class) - .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) - .withCauseInstanceOf(GradleConnectionException.class); - }); + assertThat(tmpBuildDirectory.resolve("build_not-found.gradle.kts")) + .satisfies(tmpBuildFile -> { + final var buildFile = new BuildFile(buildFileType, tmpBuildFile); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + }); + assertThat(tmpBuildDirectory.resolve("build.gradle.kts")) + .satisfies(tmpBuildFile -> { + final var buildFile = new BuildFile(buildFileType, tmpBuildFile); + Files.copy( + Path.of("src", "test", "resources", "build_error.gradle.kts"), + tmpBuildFile, + StandardCopyOption.REPLACE_EXISTING + ); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + Files.copy( + Path.of("src", "test", "resources", "build_foo.gradle.kts"), + tmpBuildFile, + StandardCopyOption.REPLACE_EXISTING + ); + assertThatExceptionOfType(BuildResolveException.class) + .isThrownBy(() -> gradleBuildResolver.resolve(buildFile)) + .withCauseInstanceOf(GradleConnectionException.class); + }); }); } } diff --git a/src/test/java/com/github/alexisjehan/mvncheck/core/util/MavenUtilsTest.java b/src/test/java/com/github/alexisjehan/mvncheck/core/util/MavenUtilsTest.java index 00ffac4..44c1a3a 100644 --- a/src/test/java/com/github/alexisjehan/mvncheck/core/util/MavenUtilsTest.java +++ b/src/test/java/com/github/alexisjehan/mvncheck/core/util/MavenUtilsTest.java @@ -411,12 +411,16 @@ void testMakeMirrorSelector() throws SettingsBuildingException { MavenUtils.makeSettings(null, null) ) ).satisfies(mirrorSelector -> { - assertThat(MavenUtils.createRemoteRepository("foo-id", "https://foo-host")).satisfies( - remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)).isNull() - ); - assertThat(MavenUtils.createRemoteRepository("bar-id", "https://bar-host")).satisfies( - remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)).isNull() - ); + assertThat(MavenUtils.createRemoteRepository("foo-id", "https://foo-host")) + .satisfies( + remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)) + .isNull() + ); + assertThat(MavenUtils.createRemoteRepository("bar-id", "https://bar-host")) + .satisfies( + remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)) + .isNull() + ); }); assertThat( MavenUtils.makeMirrorSelector( @@ -426,14 +430,19 @@ void testMakeMirrorSelector() throws SettingsBuildingException { ) ) ).satisfies(mirrorSelector -> { - assertThat(MavenUtils.createRemoteRepository("foo-id", "https://foo-host")).satisfies( - remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)).isEqualTo( - remoteRepositoryBuilder.setMirroredRepositories(List.of(remoteRepository)).build() - ) - ); - assertThat(MavenUtils.createRemoteRepository("bar-id", "https://bar-host")).satisfies( - remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)).isNull() - ); + assertThat(MavenUtils.createRemoteRepository("foo-id", "https://foo-host")) + .satisfies( + remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)) + .isEqualTo( + remoteRepositoryBuilder.setMirroredRepositories(List.of(remoteRepository)) + .build() + ) + ); + assertThat(MavenUtils.createRemoteRepository("bar-id", "https://bar-host")) + .satisfies( + remoteRepository -> assertThat(mirrorSelector.getMirror(remoteRepository)) + .isNull() + ); }); }