- Improved unit test code.
git-svn-id: https://svn.apache.org/repos/asf/maven/enforcer/trunk@1612401 13f79535-47bb-0310-9956-ffa450edef68
diff --git a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java
index ab8bbd8..f6713c8 100644
--- a/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java
+++ b/enforcer-rules/src/test/java/org/apache/maven/plugins/enforcer/RequireActiveProfileTest.java
@@ -19,6 +19,14 @@
* under the License.
*/
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.when;
+
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
import org.apache.maven.enforcer.rule.api.EnforcerRuleException;
import org.apache.maven.enforcer.rule.api.EnforcerRuleHelper;
import org.apache.maven.model.Profile;
@@ -26,12 +34,6 @@
import org.codehaus.plexus.component.configurator.expression.ExpressionEvaluationException;
import org.junit.Before;
import org.junit.Test;
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.List;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
/**
* Check the profile rule.
@@ -110,9 +112,7 @@
public void testTwoActiveProfilesWithOneRequiredProfile()
throws EnforcerRuleException
{
- List<Profile> profiles = new ArrayList<Profile>();
- profiles.add( createProfile( "profile-1" ) );
- profiles.add( createProfile( "profile-2" ) );
+ List<Profile> profiles = Arrays.asList( createProfile( "profile-1" ), createProfile( "profile-2" ) );
when( project.getActiveProfiles() ).thenReturn( profiles );
@@ -126,9 +126,7 @@
public void testTwoActiveProfilesWhereOneProfileIsRequiredToBeActivated()
throws EnforcerRuleException
{
- List<Profile> profiles = new ArrayList<Profile>();
- profiles.add( createProfile( "profile-1" ) );
- profiles.add( createProfile( "profile-2" ) );
+ List<Profile> profiles = Arrays.asList( createProfile( "profile-1" ), createProfile( "profile-2" ) );
when( project.getActiveProfiles() ).thenReturn( profiles );
@@ -143,9 +141,8 @@
public void testTwoActiveProfilesWithTwoRequiredProfilesWhereOneOfThemIsNotPartOfTheActiveProfiles()
throws EnforcerRuleException, ExpressionEvaluationException
{
- List<Profile> profiles = new ArrayList<Profile>();
- profiles.add( createProfile( "profile-X" ) );
- profiles.add( createProfile( "profile-Y" ) );
+
+ List<Profile> profiles = Arrays.asList( createProfile( "profile-X" ), createProfile( "profile-Y" ) );
when( project.getActiveProfiles() ).thenReturn( profiles );
@@ -160,8 +157,7 @@
public void testOneActiveProfilesWithTwoRequiredProfiles()
throws EnforcerRuleException, ExpressionEvaluationException
{
- List<Profile> profiles = new ArrayList<Profile>();
- profiles.add( createProfile( "profile-X" ) );
+ List<Profile> profiles = Collections.singletonList( createProfile( "profile-X" ) );
when( project.getActiveProfiles() ).thenReturn( profiles );
@@ -176,8 +172,7 @@
public void testOneActiveProfileWithTwoProfilesButNotAll()
throws EnforcerRuleException, ExpressionEvaluationException
{
- List<Profile> profiles = new ArrayList<Profile>();
- profiles.add( createProfile( "profile-X" ) );
+ List<Profile> profiles = Collections.singletonList( createProfile( "profile-X" ) );
when( project.getActiveProfiles() ).thenReturn( profiles );