1313import java .util .Properties ;
1414
1515import static org .hamcrest .MatcherAssert .assertThat ;
16+ import static org .hamcrest .Matchers .equalTo ;
1617import static org .hamcrest .Matchers .hasItemInArray ;
1718import static org .junit .Assert .assertFalse ;
19+ import static org .junit .Assert .assertNotNull ;
1820import static org .openmrs .maven .plugins .SdkMatchers .hasNameStartingWith ;
1921import static org .openmrs .maven .plugins .SdkMatchers .hasUserOwa ;
2022import static org .openmrs .maven .plugins .SdkMatchers .serverHasVersion ;
@@ -148,8 +150,8 @@ public void deploy_shouldUpgradeDistroTo3_0_0() throws Exception {
148150 Server server = Server .loadServer (testServerId );
149151 assertThat (server , serverHasVersion ("3.0.0" ));
150152
151- assertLogContains ("+ Adds frontend spa" );
152- assertLogContains ("+ Adds frontend configuration" );
153+ assertLogContains ("+ Assembles and builds new frontend spa" );
154+ assertLogContains ("+ Adds config package distro-emr- configuration 3.0.0 " );
153155 }
154156
155157 @ Test
@@ -165,7 +167,7 @@ public void deploy_shouldUpgradeDistroWithConfigPackage() throws Exception {
165167 assertFilePresent (testServerId , "configuration" , "addresshierarchy" , "addresshierarchy-core_demo.csv" );
166168 assertFilePresent (testServerId , "configuration" , "conceptclasses" , "conceptclasses-core_data.csv" );
167169 assertFilePresent (testServerId , "configuration" , "encountertypes" , "encountertypes_core-demo.csv" );
168- assertLogContains ("+ Adds frontend configuration" );
170+ assertLogContains ("+ Adds config package distro-emr- configuration 3.0.0 " );
169171 }
170172
171173 @ Test
@@ -180,7 +182,7 @@ public void deploy_shouldUpgradeDistroWithContentPackage() throws Exception {
180182 assertFilePresent (testServerId , "configuration" , "conceptclasses" , "hiv" , "conceptclasses.csv" );
181183 assertFilePresent (testServerId , "configuration" , "conceptsources" , "hiv" , "conceptsources.csv" );
182184 assertFilePresent (testServerId , "configuration" , "encountertypes" , "hiv" , "encountertypes.csv" );
183- assertLogContains ("+ Adds frontend configuration " );
185+ assertLogContains ("+ Adds content package hiv 1.0.0 " );
184186 }
185187
186188 @ Test
@@ -197,7 +199,13 @@ public void deploy_shouldReplaceConfigurationAndContentIfChanged() throws Except
197199 assertFilePresent (testServerId , "configuration" , "addresshierarchy" , "addresshierarchy-core_demo.csv" );
198200 assertFilePresent (testServerId , "configuration" , "conceptclasses" , "conceptclasses-core_data.csv" );
199201 assertFilePresent (testServerId , "configuration" , "encountertypes" , "encountertypes_core-demo.csv" );
200- assertLogContains ("+ Adds frontend configuration" );
202+ assertLogContains ("+ Adds config package distro-emr-configuration 3.0.0" );
203+
204+ Server server = Server .loadServer (testDirectoryPath .resolve (testServerId ));
205+ assertNotNull (server );
206+ assertThat (server .getConfigArtifacts ().size (), equalTo (1 ));
207+ assertThat (server .getConfigArtifacts ().get (0 ).getArtifactId (), equalTo ("distro-emr-configuration" ));
208+ assertThat (server .getContentArtifacts ().size (), equalTo (0 ));
201209
202210 includeDistroPropertiesFile ("openmrs-distro-content-package.properties" );
203211 addAnswer (testServerId );
@@ -212,7 +220,14 @@ public void deploy_shouldReplaceConfigurationAndContentIfChanged() throws Except
212220 assertFilePresent (testServerId , "configuration" , "conceptclasses" , "hiv" , "conceptclasses.csv" );
213221 assertFilePresent (testServerId , "configuration" , "conceptsources" , "hiv" , "conceptsources.csv" );
214222 assertFilePresent (testServerId , "configuration" , "encountertypes" , "hiv" , "encountertypes.csv" );
215- assertLogContains ("^ Updates frontend configuration" );
223+ assertLogContains ("- Removes existing configuration" );
224+ assertLogContains ("+ Adds content package hiv 1.0.0" );
225+
226+ server = Server .loadServer (testDirectoryPath .resolve (testServerId ));
227+ assertNotNull (server );
228+ assertThat (server .getConfigArtifacts ().size (), equalTo (0 ));
229+ assertThat (server .getContentArtifacts ().size (), equalTo (1 ));
230+ assertThat (server .getContentArtifacts ().get (0 ).getArtifactId (), equalTo ("hiv" ));
216231 }
217232
218233 @ Test
@@ -279,4 +294,43 @@ public void deploy_shouldInstallOwaAndOwaModule() throws Exception {
279294 Server server = Server .loadServer (testServerId );
280295 assertThat (server , hasUserOwa (new OwaId ("conceptdictionary" ,"1.0.0" )));
281296 }
297+
298+ @ Test
299+ public void deploy_shouldDeployOwas () throws Exception {
300+ testServerId = setupTestServer ("referenceapplication:2.2" );
301+ includeDistroPropertiesFile ("openmrs-distro-owa1.properties" );
302+ addAnswer (testServerId );
303+ addAnswer ("y" );
304+ addAnswer ("y" );
305+ executeTask ("deploy" );
306+ assertSuccess ();
307+ assertFilePresent (testServerId , "owa" );
308+ assertFilePresent (testServerId , "owa" , "addonmanager.owa" );
309+ assertFilePresent (testServerId , "owa" , "SystemAdministration.owa" );
310+ assertFilePresent (testServerId , "owa" , "orderentry.owa" );
311+ assertLogContains ("+ Adds owa addonmanager 1.0.0" );
312+ assertLogContains ("+ Adds owa sysadmin 1.2.0" );
313+ assertLogContains ("+ Adds owa orderentry 1.2.4" );
314+
315+ Server server = Server .loadServer (testDirectoryPath .resolve (testServerId ));
316+ assertNotNull (server );
317+ assertThat (server .getOwaArtifacts ().size (), equalTo (3 ));
318+
319+ // Re-deploy with a distro properties that includes additions, upgrades, downgrades, and removals
320+ includeDistroPropertiesFile ("openmrs-distro-owa2.properties" );
321+ executeTask ("deploy" );
322+ assertSuccess ();
323+ assertFilePresent (testServerId , "owa" );
324+ assertFilePresent (testServerId , "owa" , "addonmanager.owa" );
325+ assertFilePresent (testServerId , "owa" , "SystemAdministration.owa" );
326+ assertFileNotPresent (testServerId , "owa" , "orderentry.owa" );
327+ assertFilePresent (testServerId , "owa" , "conceptdictionary.owa" );
328+ assertLogContains ("^ Updates owa addonmanager 1.0.0 to 1.1.0" );
329+ assertLogContains ("v Downgrades owa sysadmin 1.2.0 to 1.1.0" );
330+ assertLogContains ("+ Adds owa conceptdictionary 1.0.0" );
331+ assertLogContains ("- Deletes owa orderentry 1.2.4" );
332+
333+ server = Server .loadServer (testDirectoryPath .resolve (testServerId ));
334+ assertThat (server .getOwaArtifacts ().size (), equalTo (3 ));
335+ }
282336}
0 commit comments