Skip to content

Commit

Permalink
O3-3776: Fix Content Package Template Creation (#287)
Browse files Browse the repository at this point in the history
  • Loading branch information
mherman22 authored Aug 26, 2024
1 parent 58f4b90 commit 517a440
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,5 @@

<properties>
<openmrsPlatformVersion>1.11.6</openmrsPlatformVersion>
<openmrsContentPackageVersion>1.0.0-SNAPSHOT</openmrsContentPackageVersion>
</properties>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,40 @@ public void createProject_shouldCreatePlatformModuleProject() throws Exception{
assertProjectCreated();
}

@Test
public void createProject_shouldCreateContentPackageModuleProject() throws Exception{
addTaskParam("type", "content-package");

addTaskParam("moduleId", "test");
addTaskParam("moduleName", "Test");
addTaskParam("moduleDescription", "none");
addTaskParam("groupId", "org.openmrs.content");
addTaskParam("version", "1.0.0-SNAPSHOT");

addAnswer("1.0.0");

addTaskParam(BATCH_ANSWERS, getAnswers()); //only to set interactive mode to false

executeTask("create-project");
assertSuccess();
assertContentPackageCreated();
}

@Test
public void createProject_shouldCreateContentPackageProjectUsingBatchAnswers() throws Exception{
addAnswer("Content Package");
addAnswer("test");
addAnswer("Test");
addAnswer("none");
addAnswer("org.openmrs.content");
addAnswer("1.0.0-SNAPSHOT");
addAnswer("1.0.0");

executeTask("create-project");
assertSuccess();
assertContentPackageCreated();
}

private void assertProjectCreated() {
//check only basic structure of module project and pom existence, not coupled with archetype itself
assertFilePresent("test");
Expand All @@ -82,4 +116,14 @@ private void assertProjectCreated() {
assertFilePresent("test", "omod");
assertFilePresent("test", "pom.xml");
}

private void assertContentPackageCreated() {
assertFilePresent("test");
assertFilePresent("test", ".github");
assertFilePresent("test", "configuration");
assertFilePresent("test", "README.md");
assertFilePresent("test", "assembly.xml");
assertFilePresent("test", "content.properties");
assertFilePresent("test", "pom.xml");
}
}
Original file line number Diff line number Diff line change
@@ -1,17 +1,5 @@
package org.openmrs.maven.plugins;

import static org.openmrs.maven.plugins.utility.PropertiesUtils.loadPropertiesFromResource;
import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
import static org.twdata.maven.mojoexecutor.MojoExecutor.element;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
import static org.twdata.maven.mojoexecutor.MojoExecutor.goal;
import static org.twdata.maven.mojoexecutor.MojoExecutor.groupId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.name;
import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin;
import static org.twdata.maven.mojoexecutor.MojoExecutor.version;

import org.apache.commons.lang.StringUtils;
import org.apache.maven.plugin.MojoExecutionException;
import org.apache.maven.plugin.MojoFailureException;
Expand All @@ -25,6 +13,18 @@
import java.util.Arrays;
import java.util.Properties;

import static org.openmrs.maven.plugins.utility.PropertiesUtils.loadPropertiesFromResource;
import static org.twdata.maven.mojoexecutor.MojoExecutor.artifactId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.configuration;
import static org.twdata.maven.mojoexecutor.MojoExecutor.element;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executeMojo;
import static org.twdata.maven.mojoexecutor.MojoExecutor.executionEnvironment;
import static org.twdata.maven.mojoexecutor.MojoExecutor.goal;
import static org.twdata.maven.mojoexecutor.MojoExecutor.groupId;
import static org.twdata.maven.mojoexecutor.MojoExecutor.name;
import static org.twdata.maven.mojoexecutor.MojoExecutor.plugin;
import static org.twdata.maven.mojoexecutor.MojoExecutor.version;

/**
* Creates a new OpenMRS project from an archetype
*/
Expand Down Expand Up @@ -281,6 +281,7 @@ private void createModule() throws MojoExecutionException {
"2.4");
archetypeArtifactId = SDKConstants.REFAPP_ARCH_ARTIFACT_ID;
} else if (TYPE_CONTENT_PACKAGE.equals(type)) {
contentpackage = wizard.promptForValueIfMissingWithDefault("What version of the content package (-D%s) do you want to support?", contentpackage, "contentpackage", "1.0.0");
archetypeArtifactId = SDKConstants.CONTENT_PACKAGE_ARCH_ARTIFACT_ID;
} else {
throw new MojoExecutionException("Invalid project type");
Expand Down

0 comments on commit 517a440

Please sign in to comment.