-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
#495 Add functionality for extending foundation-mda
- Loading branch information
1 parent
6dc75d8
commit 97bc5e5
Showing
62 changed files
with
687 additions
and
220 deletions.
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
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
83 changes: 83 additions & 0 deletions
83
...lugins/mda-maven-plugin/src/test/java/com/boozallen/mda/maven/MetamodelExtensionTest.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,83 @@ | ||
package com.boozallen.mda.maven; | ||
|
||
import static org.junit.Assert.assertNull; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Maven Plugins::MDA Maven Plugin | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import java.io.File; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
import java.nio.file.Paths; | ||
|
||
import org.apache.commons.io.FileUtils; | ||
|
||
import com.boozallen.mda.maven.mojo.PipelineArtifactsMojo; | ||
|
||
import io.cucumber.java.After; | ||
import io.cucumber.java.Before; | ||
import io.cucumber.java.en.Given; | ||
import io.cucumber.java.en.Then; | ||
import io.cucumber.java.en.When; | ||
|
||
public class MetamodelExtensionTest { | ||
private MojoTestCaseWrapper mojoTestCase = new MojoTestCaseWrapper(); | ||
private Exception exception; | ||
private File modelSource; | ||
private String modelRepositoryImpl; | ||
private String testProject; | ||
|
||
@Before("@MetamodelExtension") | ||
public void setup() throws Exception { | ||
mojoTestCase.configurePluginTestHarness(); | ||
Path testPom = Paths.get("src", "test", "resources", "test-pom", "pom.xml").toAbsolutePath(); | ||
Path testProject = Paths.get("target", "test-project").toAbsolutePath(); | ||
Files.createDirectories(testProject); | ||
Files.copy(testPom, testProject.resolve("pom.xml")); | ||
this.testProject = testProject.toString(); | ||
} | ||
|
||
@After("@MetamodelExtension") | ||
public void teardown() throws Exception { | ||
mojoTestCase.tearDownPluginTestHarness(); | ||
FileUtils.deleteDirectory(Paths.get(this.testProject).toFile()); | ||
} | ||
|
||
@Given("a model instance repository extending foundation-mda") | ||
public void a_model_instance_repository_extending_foundation_mda() { | ||
this.modelRepositoryImpl = "com.boozallen.mda.maven.metadata.repository.ExtensionModelInstanceRepository"; | ||
} | ||
|
||
@Given("a pipeline with metamodel extensions") | ||
public void a_pipeline_with_metamodel_extensions() { | ||
this.modelSource = new File("src/test/resources/models/model-extension.jar"); | ||
} | ||
|
||
@When("the copy-pipeline-artifacts goal is executed") | ||
public void the_copy_pipeline_artifacts_goal_is_executed() { | ||
//Read in the test pom for the correct pipeline type and configure the mojo with the parameters | ||
File testPom = new File(testProject + "/pom.xml"); | ||
|
||
try { | ||
PipelineArtifactsMojo mojo = (PipelineArtifactsMojo) mojoTestCase.lookupConfiguredMojo(testPom, "copy-pipeline-artifacts"); | ||
mojo.setModelsSource(this.modelSource); | ||
mojo.setPipelinesDirectory(new File("src/test/resources/pipelines/data-flow").getAbsolutePath() + "/"); | ||
mojo.setMetadataRepositoryImpl(this.modelRepositoryImpl); | ||
mojo.execute(); | ||
} catch (Exception exception) { | ||
this.exception = exception; | ||
} | ||
} | ||
|
||
@Then("the extended metamodel is read successfully") | ||
public void the_extended_metamodel_is_read_successfully() { | ||
assertNull("An exception occurred when executing the mojo with a metamodel repository extension", this.exception); | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
...st/java/com/boozallen/mda/maven/metadata/repository/ExtensionModelInstanceRepository.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,46 @@ | ||
package com.boozallen.mda.maven.metadata.repository; | ||
|
||
/*- | ||
* #%L | ||
* aiSSEMBLE::Foundation::Maven Plugins::MDA Maven Plugin | ||
* %% | ||
* Copyright (C) 2021 Booz Allen | ||
* %% | ||
* This software package is licensed under the Booz Allen Public License. All Rights Reserved. | ||
* #L% | ||
*/ | ||
|
||
import org.technologybrewery.fermenter.mda.metamodel.ModelRepositoryConfiguration; | ||
import org.technologybrewery.fermenter.mda.util.JsonUtils; | ||
|
||
import com.boozallen.aiops.mda.metamodel.AissembleModelInstanceRepository; | ||
import com.boozallen.aiops.mda.metamodel.element.PipelineType; | ||
import com.boozallen.aiops.mda.metamodel.element.PipelineTypeElement; | ||
|
||
import com.fasterxml.jackson.databind.ObjectMapper; | ||
import com.fasterxml.jackson.databind.module.SimpleModule; | ||
|
||
/* | ||
* Class extending the aissemble metamodel repository with our custom classes | ||
*/ | ||
public class ExtensionModelInstanceRepository extends AissembleModelInstanceRepository { | ||
public static class PipelineTypeElementExtension extends PipelineTypeElement { | ||
public String simpleField; | ||
} | ||
|
||
public ExtensionModelInstanceRepository(ModelRepositoryConfiguration config) { | ||
super(config); | ||
this.configureCustomObjectMapper(); | ||
} | ||
|
||
public void configureCustomObjectMapper() { | ||
SimpleModule module = new SimpleModule(); | ||
|
||
// Add custom Pipeline extension | ||
module.addAbstractTypeMapping(PipelineType.class, PipelineTypeElementExtension.class); | ||
|
||
ObjectMapper localMapper = new ObjectMapper(); | ||
localMapper.registerModule(module); | ||
JsonUtils.setObjectMapper(localMapper); | ||
} | ||
} |
Binary file added
BIN
+1.4 KB
...n/foundation-maven-plugins/mda-maven-plugin/src/test/resources/models/model-extension.jar
Binary file not shown.
8 changes: 8 additions & 0 deletions
8
...ven-plugins/mda-maven-plugin/src/test/resources/specifications/MetamodelExtension.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 @@ | ||
@MetamodelExtension | ||
Feature: As an aiSSEMBLE user, I want pipeline artifacts derived from MDA models with extended metamodel schemas | ||
|
||
Scenario: Use model instance repository with metamodel extensions | ||
Given a model instance repository extending foundation-mda | ||
And a pipeline with metamodel extensions | ||
When the copy-pipeline-artifacts goal is executed | ||
Then the extended metamodel is read successfully |
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
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
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
Oops, something went wrong.