-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #19 from TechnologyBrewery/15-expose-root-project-…
…directory #15: update Fermenter to expose root project directory
- Loading branch information
Showing
5 changed files
with
76 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
fermenter-mda/src/test/java/org/technologybrewery/fermenter/mda/GenerationContextSteps.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.technologybrewery.fermenter.mda; | ||
|
||
import cucumber.api.java.After; | ||
import cucumber.api.java.Before; | ||
import cucumber.api.java.en.Given; | ||
import cucumber.api.java.en.Then; | ||
import cucumber.api.java.en.When; | ||
import org.junit.Assert; | ||
import org.technologybrewery.fermenter.mda.element.Target; | ||
import org.technologybrewery.fermenter.mda.generator.GenerationContext; | ||
|
||
import java.io.File; | ||
|
||
public class GenerationContextSteps { | ||
private MojoTestCaseWrapper mojoTestCase = new MojoTestCaseWrapper(); | ||
protected File mavenProjectBaseDir; | ||
protected GenerateSourcesMojo generateSourcesMojo; | ||
protected GenerationContext context; | ||
|
||
@Before("@generationContext") | ||
public void configureMavenPluginTestHarness() throws Exception { | ||
mojoTestCase.configurePluginTestHarness(); | ||
} | ||
|
||
@After("@generationContext") | ||
public void tearDownMavenPluginTestHarness() throws Exception { | ||
mojoTestCase.tearDownPluginTestHarness(); | ||
} | ||
|
||
/* | ||
This is an approximation of using a submodule whose base directory is different from the base directory set in test maven session. While not an exact replica, it highlights that we aren't giving a local base directory from the loaded pom. | ||
*/ | ||
@Given("^generation in a Maven submodule$") | ||
public void generation_in_a_Maven_submodule() throws Throwable { | ||
mavenProjectBaseDir = new File("src/test/resources/plugin-testing-harness-pom-files/java-default-config"); | ||
generateSourcesMojo = (GenerateSourcesMojo) mojoTestCase.lookupConfiguredMojo(new File(mavenProjectBaseDir, "pom.xml"), "generate-sources"); | ||
generateSourcesMojo.updateMojoConfigsBasedOnLanguage(); | ||
generateSourcesMojo.validateMojoConfigs(); | ||
} | ||
|
||
@When("^the generation context is created$") | ||
public void the_generation_context_is_created() throws Throwable { | ||
Target target = new Target(); | ||
context = generateSourcesMojo.createGenerationContext(target); | ||
} | ||
|
||
@Then("^access to the root module's base directory is available$") | ||
public void access_to_the_root_module_s_base_directory_is_available() throws Throwable { | ||
Assert.assertNotNull(context.getExecutionRootDirectory()); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
8 changes: 8 additions & 0 deletions
8
fermenter-mda/src/test/resources/specifications/generation-context.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
@generationContext | ||
Feature: Expose project data to generation context | ||
|
||
Scenario: The execution root is available to generators | ||
Given generation in a Maven submodule | ||
When the generation context is created | ||
Then access to the root module's base directory is available | ||
|