-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #64 from HHS/update-util-to-4.2.0
Update util to 4.2.0
- Loading branch information
Showing
26 changed files
with
367 additions
and
153 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time | ||
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven | ||
|
||
# This workflow uses actions that are not certified by GitHub. | ||
# They are provided by a third-party and are governed by | ||
# separate terms of service, privacy policy, and support | ||
# documentation. | ||
|
||
name: Taskit Development PR Build | ||
|
||
on: | ||
pull_request: | ||
branches-ignore: ["main"] | ||
|
||
jobs: | ||
dev-build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout Taskit | ||
uses: actions/checkout@v4 | ||
|
||
- name: Set up JDK 17 | ||
uses: actions/setup-java@v4 | ||
with: | ||
java-version: '17' | ||
distribution: 'temurin' | ||
cache: maven | ||
|
||
- name: Get Util Version | ||
run: | | ||
echo "util_version=v$(mvn help:evaluate -Dexpression=util.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV" | ||
- name: Checkout Util | ||
if: ${{ endsWith(env.util_version, 'SNAPSHOT') }} | ||
uses: actions/checkout@v4 | ||
with: | ||
repository: HHS/ASPR-ms-util | ||
path: util | ||
ref: dev | ||
|
||
- name: Build Util | ||
if: ${{ endsWith(env.util_version, 'SNAPSHOT') }} | ||
run: mvn clean install -DskipTests --file util/pom.xml | ||
|
||
- name: Build Taskit | ||
run: mvn clean install --file pom.xml | ||
|
||
# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive | ||
# - name: Update dependency graph | ||
# uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6 |
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
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
69 changes: 69 additions & 0 deletions
69
core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TranslationSpecSupport.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,69 @@ | ||
package gov.hhs.aspr.ms.taskit.core.testsupport; | ||
|
||
import java.io.File; | ||
import java.nio.file.Path; | ||
import java.util.ArrayList; | ||
import java.util.LinkedHashSet; | ||
import java.util.List; | ||
import java.util.Set; | ||
|
||
import gov.hhs.aspr.ms.taskit.core.TranslationSpec; | ||
import gov.hhs.aspr.ms.util.resourcehelper.ResourceHelper; | ||
|
||
public class TranslationSpecSupport { | ||
|
||
private TranslationSpecSupport() {} | ||
/* | ||
* This method is to ensure that every translationSpec that is supposed to be | ||
* tied to a Translator is defined in its list of translationSpecs. If a | ||
* translationSpec is added and not subsequently added to the list in the | ||
* Translator, then this test will fail and provide the name of the missing | ||
* TranslationSpec | ||
*/ | ||
public static <T> Set<String> testGetTranslationSpecs(Class<T> translatorClassRef, | ||
List<TranslationSpec<?, ?>> translationSpecs) throws ClassNotFoundException { | ||
Set<String> missingTranslationSpecs = new LinkedHashSet<>(); | ||
List<Class<?>> translationSpecClasses = new ArrayList<>(); | ||
|
||
// create a list with the translation spec class names | ||
for (TranslationSpec<?, ?> translationSpec : translationSpecs) { | ||
translationSpecClasses.add(translationSpec.getClass()); | ||
} | ||
|
||
// get the package of the translator class to get its translationSpecs package | ||
// path | ||
String packageName = translatorClassRef.getPackageName() + ".translationSpecs"; | ||
String packagePath = packageName.replaceAll("[.]", "/"); | ||
|
||
ClassLoader classLoader = ClassLoader.getSystemClassLoader(); | ||
|
||
Path path = ResourceHelper.getResourceDir(translatorClassRef) | ||
.getParent() | ||
.resolve("classes") | ||
.resolve(packagePath); | ||
|
||
// the path from above will be referencing the test-classes compile folder. We | ||
// want the classes folder, else it will fail because the test classes for | ||
// translationSpecs are prefixed with AT_ | ||
File[] files = path.toFile().listFiles(); | ||
|
||
// loop over all the files in the directory, for every file that ends in .class, | ||
// construct the full qualified class name. use the classLoader to load the | ||
// class and assert that the provided list of translationSpecs contains that | ||
// class | ||
for (File file : files) { | ||
String className = file.getName(); | ||
if (className.endsWith(".class")) { | ||
// note the substring here is to eliminate the .class suffix of the filename | ||
className = packageName + "." + className.substring(0, className.length() - 6); | ||
Class<?> classRef = classLoader.loadClass(className); | ||
|
||
if(!translationSpecClasses.contains(classRef)) { | ||
missingTranslationSpecs.add(classRef.getSimpleName()); | ||
} | ||
} | ||
} | ||
|
||
return missingTranslationSpecs; | ||
} | ||
} |
1 change: 1 addition & 0 deletions
1
...pr/ms/taskit/core/testsupport/testobject/translationSpecs/testTextFileForTestCoverage.txt
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 @@ | ||
wombat |
Oops, something went wrong.