package io.leonard.maven.plugins.jspc;

import org.apache.maven.plugin.testing.MojoRule;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Test {@link JspcMojo}
 */
public class TestIncludesExcludesMojo {

  @Rule
  public MojoRule rule = new MojoRule();

  @Test
  public void shouldRespectIncludesAndExcludes() throws Exception {
    // Given
    File oneJspProject = new File("target/test-classes/unit/project_include_exclude");

    // When
    rule.executeMojo(oneJspProject, "compile");

    // Then
    Path jspPath = Paths.get("target/test-classes/unit/project_include_exclude/target/classes/jsp/jsp/_01_jsp.class");
    assertThat(jspPath).exists();

    Path jspfPath = Paths.get("target/test-classes/unit/project_include_exclude/target/classes/jsp/jsp/_02_jspf.class");
    assertThat(jspfPath).doesNotExist();
  }

}

package io.leonard.maven.plugins.jspc;

import org.apache.maven.plugin.testing.MojoRule;
import org.junit.Rule;
import org.junit.Test;

import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;

import static org.assertj.core.api.Assertions.assertThat;

/**
 * Test {@link JspcMojo}
 */
public class TestIncludesExcludesMojo {

  @Rule
  public MojoRule rule = new MojoRule();

  private String PROJECT_PATH = "target/test-classes/unit/project_include_exclude";
  private String TARGET_PATH = PROJECT_PATH + "/target/classes/jsp/jsp/";

  @Test
  public void shouldRespectIncludesAndExcludes() throws Exception {
    // Given
    File includeExcludeProject = new File(PROJECT_PATH);

    // When
    rule.executeMojo(includeExcludeProject, "compile");

    // Then
    Path jspPath = Paths.get(TARGET_PATH + "_01_jsp.class");
    assertThat(jspPath).exists();

    Path jspfPath = Paths.get(TARGET_PATH + "_02_jspf.class");
    assertThat(jspfPath).doesNotExist();
  }

}

Refactor test