package e2e;

import scaffolding.TestProject;

import static org.hamcrest.CoreMatchers.containsString;
import static org.hamcrest.MatcherAssert.assertThat;
import static scaffolding.ExactCountMatcher.noneOf;
import static scaffolding.ExactCountMatcher.oneOf;

import java.io.File;
import java.util.List;

import org.junit.Rule;
import org.junit.Test;

import de.hilling.maven.release.TestUtils;

public class ExecutionTest {

    private static final String ECHO_PLUGIN_OUTPUT = "echo-maven-plugin running because profileActivatedByReleasePlugin" + " is " + "activated";

    @Rule
    public TestProject testProject = new TestProject(ProjectType.MODULE_PROFILES);

    @Test
    public void profilesNotPassedToTheReleaseExecutionAreNotPassedOnToTheDeploymentButConfiguredProfilesAre() throws
                                                                                                              Exception {
        List<String> consoleOutput = testProject.mvnRelease();
        assertThat(consoleOutput, noneOf(containsString("The module-with-profiles test has run")));
        assertThat(consoleOutput, oneOf(containsString(ECHO_PLUGIN_OUTPUT)));
    }

    @Test
    public void profilesPassedToTheReleaseExecutionArePassedOnToTheDeployment() throws Exception {
        List<String> consoleOutput = testProject.mvn("-DbuildNumber=1", TestUtils.RELEASE_GOAL, "-P runTestsProfile");
        assertThat(consoleOutput, oneOf(containsString("The module-with-profiles test has run")));
        assertThat(consoleOutput, oneOf(containsString(ECHO_PLUGIN_OUTPUT)));
    }

    @Test
    public void userAndGlobalSettingsCanBeOverwrittenWithStandardMavenCommandLineParameters() throws Exception {
        File globalSettings = new File("test-projects/module-with-profiles/custom-settings.xml");
        List<String> consoleOutput = testProject.mvn("-DbuildNumber=1", TestUtils.RELEASE_GOAL, "-gs",
                                                     globalSettings.getCanonicalPath());
        assertThat(consoleOutput, oneOf(containsString(ECHO_PLUGIN_OUTPUT)));
    }
}

@@ -542,22 +542,12 @@
 ugin
-%22 + %22 is %22 + %22
+ is 
 acti
@@ -1308,35 +1308,16 @@
 ect.mvn(
-%22-DbuildNumber=1%22, 
 TestUtil
@@ -1335,17 +1335,16 @@
 OAL, %22-P
- 
 runTests
@@ -1816,27 +1816,8 @@
 mvn(
-%22-DbuildNumber=1%22, 
 Test
@@ -1846,61 +1846,8 @@
 gs%22,
-%0A                                                    
  glo

check unit tests