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

Add test case for dependency exclusions in DependencyTest #1538

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
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 @@ -23,6 +23,7 @@

import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
Expand Down Expand Up @@ -222,7 +223,12 @@ private void reportSessionCollectedValidationIssues(MavenSession mavenSession) {
logger.warn("");
logger.warn("Plugin {} validation issues were detected in following plugin(s)", issueLocalitiesToReport);
logger.warn("");
for (Map.Entry<String, PluginValidationIssues> entry : issuesMap.entrySet()) {

// Sorting the plugins
List<Map.Entry<String, PluginValidationIssues>> sortedEntries = new ArrayList<>(issuesMap.entrySet());
sortedEntries.sort(Map.Entry.comparingByKey(String.CASE_INSENSITIVE_ORDER));

for (Map.Entry<String, PluginValidationIssues> entry : sortedEntries) {
PluginValidationIssues issues = entry.getValue();
if (!hasAnythingToReport(issues, issueLocalitiesToReport)) {
continue;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,30 @@
*/
package org.apache.maven.model;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

/**
* Tests {@code Dependency}.
*
*/
class DependencyTest {

private Dependency dependency;

@BeforeEach
public void setUp() {
dependency = new Dependency();
dependency.setGroupId("groupId");
dependency.setArtifactId("artifactId");
dependency.setVersion("1.0");
}

@Test
void testHashCodeNullSafe() {
new Dependency().hashCode();
Expand All @@ -52,4 +64,18 @@ void testEqualsIdentity() {
void testToStringNullSafe() {
assertNotNull(new Dependency().toString());
}

@Test
public void testDependencyExclusions() {
Exclusion exclusion = new Exclusion();
exclusion.setGroupId("excludedGroupId");
exclusion.setArtifactId("excludedArtifactId");

dependency.addExclusion(exclusion);

assertEquals(1, dependency.getExclusions().size());
Exclusion addedExclusion = dependency.getExclusions().get(0);
assertEquals("excludedGroupId", addedExclusion.getGroupId());
assertEquals("excludedArtifactId", addedExclusion.getArtifactId());
}
}