Skip to content

Commit

Permalink
Merge pull request #39 from ncats/awmisc_change_subst_version
Browse files Browse the repository at this point in the history
Change substance module version and add test
  • Loading branch information
blueSwordfish authored Sep 24, 2024
2 parents afa97a7 + 17cd504 commit 5f6e308
Show file tree
Hide file tree
Showing 4 changed files with 107 additions and 7 deletions.
5 changes: 0 additions & 5 deletions gsrs-module-clinical-trials-spring-boot-autoconfigure/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -91,11 +91,6 @@
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>gov.nih.ncats</groupId>
<artifactId>gsrs-spring-boot-starter</artifactId>
<version>${gsrs.version}</version>
</dependency>
<dependency>
<groupId>gov.nih.ncats</groupId>
<artifactId>gsrs-spring-starter-tests</artifactId>
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,102 @@
package gsrs.clinicaltrials.tests;


import java.io.File;
import java.io.IOException;
import java.util.List;
import java.util.Properties;
import gsrs.startertests.pomutilities.PomUtilities;
import org.apache.maven.model.Dependency;
import org.apache.maven.model.Model;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;


public class ClinicalTrialsPomsVersionTest {
// Check GSRS versions in all pom.xml, and select extraJars, installExtraJars.sh commands
// against the values in pom-version.properties. Helpful when making a version change
// for the whole GSRS project.
// Test effectively skipped unless CLI param -DdoPomCheck=true
// Run from command line:
// mvn test -Dtest=gsrs.clinicaltrials.tests.ClinicalTrialsPomsVersionTest -DdoPomCheck=true -pl gsrs-module-clinical-trials-spring-boot-starter-tests

// Set to true when testing in IDE
boolean turnOffPomParameterCheck = false;
String clinicalTrialsModuleVersion;
String starterModuleVersion;
String substancesModuleVersion;
String otherModuleVersion;
String rootDir;
String propertiesFile;
String installExtraJarsScriptText;
boolean doPomCheck = false;

@BeforeEach
public void setup() {
doPomCheck=Boolean.parseBoolean(System.getProperty("doPomCheck"));
if(!doPomCheck && !turnOffPomParameterCheck) { return; }
String scriptFile = "installExtraJars.sh";
propertiesFile = "pom-version.properties";
rootDir = "..";

try {
Properties properties = PomUtilities.readPomVersionProperties(rootDir + "/" + propertiesFile);


starterModuleVersion = properties.getProperty("ct.pomversiontest.starterModuleVersion");
substancesModuleVersion = properties.getProperty("ct.pomversiontest.substancesModuleVersion");
clinicalTrialsModuleVersion = properties.getProperty("ct.pomversiontest.clinicalTrialsModuleVersion");

assertNotNull(starterModuleVersion);
assertNotNull(substancesModuleVersion);
System.out.println("starterModuleVersion: " + starterModuleVersion);
System.out.println("substancesModuleVersion: " + substancesModuleVersion);
} catch (IOException e) {
throw new RuntimeException(e);
}
// try {
// installExtraJarsScriptText = PomUtilities.readTextFile(rootDir + "/" + scriptFile, StandardCharsets.UTF_8);
// } catch (IOException e) {
// throw new RuntimeException(e);
// }
}

@Test
public void testPomCheck() {
if(!doPomCheck && !turnOffPomParameterCheck) {
System.out.println("Effectively skipping testPomCheck because -DdoPomCheck is not true.");
return;
}
Model rootModel;
try {
rootModel = PomUtilities.readPomToModel(rootDir + "/pom.xml");
Properties properties = rootModel.getProperties();
System.out.println("> checking root");
assertEquals( clinicalTrialsModuleVersion, rootModel.getVersion(), "version");
assertEquals(starterModuleVersion, properties.getProperty("gsrs.version"), "gsrs.version:");
assertEquals( substancesModuleVersion, properties.getProperty("gsrs.substance.version"));
List<String> modules = rootModel.getModules();
for (String module : modules) {
System.out.println("> checking "+ module);
Model moduleModel;
try {
moduleModel = PomUtilities.readPomToModel(rootDir + "/" + module + "/pom.xml");
String checkVersion = moduleModel.getParent().getVersion();
assertEquals (clinicalTrialsModuleVersion, checkVersion, "parent/version");
} catch (Exception e) {
throw new RuntimeException(e);
}
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

public void checkDependencyExtraJarExistsAndFindPathInScript(Dependency dependency) {
String jarPath = "extraJars/" + PomUtilities.makeJarFilename(dependency);
File file = new File(rootDir + "/" + jarPath);
assertTrue(file.exists());
assertTrue(installExtraJarsScriptText.contains(jarPath));
}
}
3 changes: 3 additions & 0 deletions pom-version.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
ct.pomversiontest.starterModuleVersion=3.1.1
ct.pomversiontest.substancesModuleVersion=3.1.1.1
ct.pomversiontest.clinicalTrialsModuleVersion=3.1.1-SNAPSHOT
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Hoxton.SR1</spring-cloud.version>
<gsrs.version>3.1</gsrs.version>
<gsrs.substance.version>3.1.1</gsrs.substance.version>
<gsrs.version>3.1.1</gsrs.version>
<gsrs.substance.version>3.1.1.1</gsrs.substance.version>
<gsrs.clinical-trials.version>3.1.1-SNAPSHOT</gsrs.clinical-trials.version>
<log4j2.version>2.17.1</log4j2.version>
</properties>
Expand Down

0 comments on commit 5f6e308

Please sign in to comment.