From 7c23829b4fc02111e85dd019b36f937bbab2e8b2 Mon Sep 17 00:00:00 2001 From: Michael Seaton Date: Fri, 8 Nov 2024 15:37:28 -0500 Subject: [PATCH] SDK-344 - Add integration test --- .../plugins/AbstractSdkIntegrationTest.java | 4 ++-- .../maven/plugins/SetupIntegrationTest.java | 18 ++++++++++++++++++ .../openmrs-distro-spa-artifacts.properties | 13 +++++++++++++ 3 files changed, 33 insertions(+), 2 deletions(-) create mode 100644 integration-tests/src/test/resources/integration-test/openmrs-distro-spa-artifacts.properties diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java index e70d48374..3bf40e218 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/AbstractSdkIntegrationTest.java @@ -231,13 +231,13 @@ public void assertFilePresent(String... paths) { assertPathPresent(resolvedPath); } - public void assertFileContains(String regex, String... paths) throws IOException { + public void assertFileContains(String text, String... paths) throws IOException { Path resolvedPath = testDirectoryPath.toAbsolutePath(); for (String path : paths) { resolvedPath = resolvedPath.resolve(path); } String jsContents = new String(Files.readAllBytes(resolvedPath), StandardCharsets.UTF_8); - assertThat(jsContents, Matchers.containsString(regex)); + assertThat(jsContents, Matchers.containsString(text)); } public void assertPathPresent(Path path) { diff --git a/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java b/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java index aa187d880..cd1a1ae20 100644 --- a/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java +++ b/integration-tests/src/test/java/org/openmrs/maven/plugins/SetupIntegrationTest.java @@ -375,6 +375,24 @@ public void setup_shouldInstallWithParentDistroSpecifiedInDistroProperties() thr assertFileNotPresent(serverId, "modules", "htmlformentry-3.3.0.omod"); } + @Test + public void setup_shouldInstallWithSpaSpecifiedAsMavenArtifacts() throws Exception{ + addTaskParam("distro", testDirectory.toString() + File.separator + "openmrs-distro-spa-artifacts.properties"); + addMockDbSettings(); + + String serverId = UUID.randomUUID().toString(); + addAnswer(serverId); + addAnswer("1044"); + addAnswer("8080"); + + executeTask("setup"); + + assertFilePresent( serverId, "openmrs-2.6.9.war"); + assertModulesInstalled(serverId, "spa-2.0.0.omod"); + assertFilePresent(serverId, "frontend", "index.html"); + assertFileContains("@openmrs/esm-dispensing-app", serverId, "frontend", "importmap.json"); + } + private String readValueFromPropertyKey(File propertiesFile, String key) throws Exception { InputStream in = new FileInputStream(propertiesFile); diff --git a/integration-tests/src/test/resources/integration-test/openmrs-distro-spa-artifacts.properties b/integration-tests/src/test/resources/integration-test/openmrs-distro-spa-artifacts.properties new file mode 100644 index 000000000..5bf454faf --- /dev/null +++ b/integration-tests/src/test/resources/integration-test/openmrs-distro-spa-artifacts.properties @@ -0,0 +1,13 @@ +name=Spa Artifact Example +version=1.0.0-SNAPSHOT + +war.openmrs=2.6.9 + +omod.spa=2.0.0 + +spa.artifactId=openmrs-frontend-zl +spa.groupId=org.pih.openmrs +spa.version=1.3.0 +spa.include=openmrs-frontend-zl-1.3.0 + +db.h2.supported=false