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

mockito v3.3.3 #382

Closed
wants to merge 10 commits 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 12 additions & 5 deletions pom.xml
Expand Up @@ -258,20 +258,27 @@
<version>3.10</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter-engine</artifactId>
<version>5.6.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>1.9.5</version>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-junit-jupiter</artifactId>
<version>3.3.3</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-library</artifactId>
<version>1.3</version>
<artifactId>hamcrest</artifactId>
<version>2.2</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand Down
Expand Up @@ -21,10 +21,10 @@

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.codehaus.mojo.versions.ordering.NumericVersionComparator;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

/**
* Basic tests for {@linkplain org.codehaus.mojo.versions.AbstractVersionsUpdaterMojo}.
Expand Down
Expand Up @@ -6,22 +6,23 @@
import org.apache.maven.model.Prerequisites;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.xml.Xpp3Dom;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
import org.mockito.runners.MockitoJUnitRunner;
import org.mockito.junit.jupiter.MockitoExtension;

import java.util.ArrayList;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.mockito.Mockito.lenient;
import static org.mockito.Mockito.when;

/**
* Unit tests for RequiredMavenVersionFinder.
*/
@RunWith(MockitoJUnitRunner.class)
@ExtendWith(MockitoExtension.class)
public class RequiredMavenVersionFinderTest {

@Mock
Expand Down Expand Up @@ -53,20 +54,20 @@ public class RequiredMavenVersionFinderTest {
@Mock
private Prerequisites parentPrerequisites;

@Before
@BeforeEach
public void setup() {
when(mavenProject.getPrerequisites()).thenReturn(null);
when(mavenProject.getBuildPlugins()).thenReturn(null);
when(mavenProject.hasParent()).thenReturn(false);
when(prerequisites.getMaven()).thenReturn(null);
when(nonEnforcerPlugin.getArtifactId()).thenReturn(null);
when(enforcerPlugin.getArtifactId()).thenReturn("maven-enforcer-plugin");
when(enforcerPlugin.getExecutions()).thenReturn(null);
when(pluginExecution.getGoals()).thenReturn(null);
when(parentMavenProject.getPrerequisites()).thenReturn(null);
when(parentMavenProject.getBuildPlugins()).thenReturn(null);
when(parentMavenProject.hasParent()).thenReturn(false);
when(parentPrerequisites.getMaven()).thenReturn(null);
lenient().when(mavenProject.getPrerequisites()).thenReturn(null);
lenient().when(mavenProject.getBuildPlugins()).thenReturn(null);
lenient().when(mavenProject.hasParent()).thenReturn(false);
lenient().when(prerequisites.getMaven()).thenReturn(null);
lenient().when(nonEnforcerPlugin.getArtifactId()).thenReturn(null);
lenient().when(enforcerPlugin.getArtifactId()).thenReturn("maven-enforcer-plugin");
lenient().when(enforcerPlugin.getExecutions()).thenReturn(null);
lenient().when(pluginExecution.getGoals()).thenReturn(null);
lenient().when(parentMavenProject.getPrerequisites()).thenReturn(null);
lenient().when(parentMavenProject.getBuildPlugins()).thenReturn(null);
lenient().when(parentMavenProject.hasParent()).thenReturn(false);
lenient().when(parentPrerequisites.getMaven()).thenReturn(null);
}

@Test
Expand Down
Expand Up @@ -21,7 +21,7 @@

import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.stax2.XMLInputFactory2;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import javax.xml.stream.XMLEventReader;
import javax.xml.stream.XMLEventWriter;
Expand All @@ -34,8 +34,8 @@
import java.io.ByteArrayOutputStream;
import java.util.Stack;

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

/**
* Basic tests for rewriting XML with a StAX (JSR-173) implementation.
Expand Down Expand Up @@ -68,7 +68,7 @@ public void testBasic()

String output = new String( dest.toByteArray(), "utf-8" );

assertFalse( "StAX implementation is not good enough", input.equals( output ) );
assertFalse( input.equals( output ), "StAX implementation is not good enough" );
}

@Test
Expand Down
Expand Up @@ -8,17 +8,17 @@
import org.apache.maven.plugin.MojoFailureException;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;

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

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class SeparatePatternsForIncludesAnExcludesTest
{

AbstractVersionsDependencyUpdaterMojo mojo;

@Before
@BeforeEach
public void setUp()
throws Exception
{
Expand Down
Expand Up @@ -29,14 +29,14 @@
import org.codehaus.mojo.versions.ordering.NumericVersionComparator;
import org.hamcrest.CoreMatchers;
import org.hamcrest.Matchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.Arrays;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertThat;
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.hamcrest.MatcherAssert.assertThat;

public class ArtifactVersionsTest
{
Expand Down
Expand Up @@ -44,18 +44,18 @@
import org.codehaus.mojo.versions.Property;
import org.codehaus.mojo.versions.ordering.VersionComparators;
import org.hamcrest.CoreMatchers;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import static java.util.Arrays.asList;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.junit.matchers.JUnitMatchers.hasItems;
import static org.hamcrest.core.IsIterableContaining.hasItems;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.anyList;
import static org.mockito.Mockito.mock;
Expand Down Expand Up @@ -151,15 +151,18 @@ public void testRuleSets()
{
VersionsHelper helper = createHelper();

assertEquals( "no match gives default", VersionComparators.getVersionComparator( "maven" ),
helper.getVersionComparator( "net.foo", "bar" ) );
assertEquals( "matches wildcard", VersionComparators.getVersionComparator( "mercury" ),
helper.getVersionComparator( "org.apache.maven", "plugins" ) );
assertEquals( "exact match wins over initial match", VersionComparators.getVersionComparator( "mercury" ),
helper.getVersionComparator( "com.mycompany.custom.maven", "plugins" ) );
assertEquals( "non-wildcard prefix wins over wildcard prefix match",
VersionComparators.getVersionComparator( "maven" ),
helper.getVersionComparator( "com.mycompany.maven.plugins", "plugins" ) );
assertEquals( VersionComparators.getVersionComparator( "maven" ),
helper.getVersionComparator( "net.foo", "bar" ),
"no match gives default" );
assertEquals( VersionComparators.getVersionComparator( "mercury" ),
helper.getVersionComparator( "org.apache.maven", "plugins" ),
"matches wildcard" );
assertEquals( VersionComparators.getVersionComparator( "mercury" ),
helper.getVersionComparator( "com.mycompany.custom.maven", "plugins" ),
"exact match wins over initial match" );
assertEquals( VersionComparators.getVersionComparator( "maven" ),
helper.getVersionComparator( "com.mycompany.maven.plugins", "plugins" ),
"non-wildcard prefix wins over wildcard prefix match" );
assertEquals( VersionComparators.getVersionComparator( "maven" ),
helper.getVersionComparator( "com.mycompany.maven", "new-maven-plugin" ) );
assertEquals( VersionComparators.getVersionComparator( "mercury" ),
Expand Down
14 changes: 7 additions & 7 deletions src/test/java/org/codehaus/mojo/versions/api/PomHelperTest.java
Expand Up @@ -5,19 +5,19 @@
import org.apache.maven.model.io.xpp3.MavenXpp3Reader;
import org.codehaus.mojo.versions.rewriting.ModifiedPomXMLEventReader;
import org.codehaus.stax2.XMLInputFactory2;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import javax.xml.stream.XMLInputFactory;
import java.io.File;
import java.io.StringReader;
import java.net.URL;
import java.util.List;

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

/**
* Tests the methods of {@link PomHelper}.
Expand Down Expand Up @@ -76,7 +76,7 @@ public void testLongProperties()

String newVersion = "1";

assertTrue( "The pom has been modified", PomHelper.setProjectVersion( pom, newVersion ) );
assertTrue( PomHelper.setProjectVersion( pom, newVersion ), "The pom has been modified" );

assertEquals( newVersion, PomHelper.getProjectVersion( pom ) );

Expand Down
Expand Up @@ -2,10 +2,10 @@

import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.hamcrest.collection.IsArrayContainingInOrder.arrayContaining;
import static org.junit.Assert.assertThat;
import static org.hamcrest.MatcherAssert.assertThat;

public class MajorMinorIncrementalFilterTest {

Expand Down
Expand Up @@ -20,9 +20,9 @@
*/

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class MavenVersionComparatorTest
{
Expand Down
Expand Up @@ -20,9 +20,9 @@
*/

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertEquals;
import static org.junit.jupiter.api.Assertions.assertEquals;

public class MercuryVersionComparatorTest
{
Expand Down
Expand Up @@ -20,10 +20,10 @@
*/

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.junit.Test;
import org.junit.jupiter.api.Test;

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

public class NumericVersionComparatorTest
{
Expand Down
Expand Up @@ -21,9 +21,9 @@

import org.apache.maven.artifact.versioning.DefaultArtifactVersion;
import org.apache.maven.artifact.versioning.ArtifactVersion;
import org.junit.Test;
import org.junit.jupiter.api.Test;

import static org.junit.Assert.assertTrue;
import static org.junit.jupiter.api.Assertions.assertTrue;

public class VersionComparatorsTest
{
Expand Down Expand Up @@ -64,7 +64,7 @@ public void assertLater(String version, VersionComparator instance) {
int count = instance.getSegmentCount( v1 );
for (int i = 0; i < count; i++) {
ArtifactVersion v2 = instance.incrementSegment( v1, i );
assertTrue(v1.toString() + " < " + v2.toString(), instance.compare( v1, v2 ) < 0);
assertTrue( instance.compare( v1, v2 ) < 0, v1.toString() + " < " + v2.toString() );
}
}
}