diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml
index 1ff8580..47d8fa1 100644
--- a/.github/workflows/dev_build.yml
+++ b/.github/workflows/dev_build.yml
@@ -11,8 +11,6 @@ name: Taskit Development Build
on:
push:
branches: [ "dev" ]
- pull_request:
- branches-ignore: ["main"]
jobs:
dev-build:
diff --git a/.github/workflows/dev_pr_build.yml b/.github/workflows/dev_pr_build.yml
new file mode 100644
index 0000000..693f622
--- /dev/null
+++ b/.github/workflows/dev_pr_build.yml
@@ -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
diff --git a/.github/workflows/release_pr_build.yml b/.github/workflows/release_pr_build.yml
index 7637c30..8be3a63 100644
--- a/.github/workflows/release_pr_build.yml
+++ b/.github/workflows/release_pr_build.yml
@@ -34,7 +34,7 @@ jobs:
- name: Version Is Snapshot
if: ${{ endsWith(env.version, 'SNAPSHOT') }}
run: |
- echo "::error Version is a SNAPSHOT. Update version to proper version."
+ echo "Version is a SNAPSHOT version. Update version to proper version."
exit 1
- name: Build Taskit
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/CoreTranslationError.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/CoreTranslationError.java
index 965eb7c..4fd400f 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/CoreTranslationError.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/CoreTranslationError.java
@@ -19,7 +19,7 @@ public enum CoreTranslationError implements ContractError {
NO_TRANSLATION_ENGINES("There are no translation engines added to this controller."),
NULL_CLASS_REF("Null Class Ref"),
NULL_DEPENDENCY("Null dependency"),
- NULL_INIT_CONSUMER("Null Initilizer Consumer"),
+ NULL_INIT_CONSUMER("Null Initializer Consumer"),
NULL_OBJECT_FOR_TRANSLATION("The object to be translated was null"),
NULL_PATH("Null Path"),
NULL_TRANSLATION_ENGINE("Null Translation Engine"),
@@ -34,7 +34,7 @@ public enum CoreTranslationError implements ContractError {
"Translators were added to the builder but were not initialized. Make sure to call super.initTranslators() during your custom engine build method"),
UNKNOWN_CLASSREF("No object has been read in with the specified classRef"),
UNKNOWN_OBJECT("Object is not Translatable by this TranslationSpec"),
- UNKNWON_TRANSLATION_ENGINE_TYPE("Translation Engine Type was not set"),
+ UNKNOWN_TRANSLATION_ENGINE_TYPE("Translation Engine Type was not set"),
UNKNOWN_TRANSLATION_SPEC("No translation spec was provided for the given class"),
UNSUPPORTED_VERSION("The given version is not supported");
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationController.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationController.java
index 1dc7737..46a5e72 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationController.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationController.java
@@ -15,7 +15,7 @@
import gov.hhs.aspr.ms.util.errors.ContractException;
/**
- * The TranslatorController serves as the master of cerimonies for translating
+ * The TranslatorController serves as the master of ceremonies for translating
* between two types of objects. Additionally, it has the ability to distribute
* Input/Output files for reading and writing.
*/
@@ -137,7 +137,7 @@ public Builder addInputFilePath(Path filePath, Class> classRef, TranslationEng
}
/**
- * Adds the given classRef markerInterace mapping.
+ * Adds the given classRef markerInterface mapping.
*
* explicitly used when calling {@link TranslationController#writeOutput} with a
* class for which a classRef ScenarioId pair does not exist and/or the need to
@@ -196,7 +196,7 @@ public Builder addTranslationEngine(TranslationEngine translationEngine) {
this.data.parentChildClassRelationshipMap.put(childClassRef, parentClassRef);
}
-
+
return this;
}
}
@@ -404,7 +404,7 @@ void writeOutput(Path path, M object, Optional> superC
* Searches the list of read in objects and returns the first Object found of
* the given classRef
*
- * @param the type of the obect to get
+ * @param the type of the object to get
* @throws ContractException
*
* {@linkplain CoreTranslationError#UNKNOWN_CLASSREF}
@@ -412,10 +412,19 @@ void writeOutput(Path path, M object, Optional> superC
*
*/
public T getFirstObject(Class classRef) {
- for (Object object : this.objects) {
+ int index = -1;
+ for (int i = 0; i < this.objects.size(); i++) {
+ Object object = this.objects.get(i);
+
if (classRef.isAssignableFrom(object.getClass())) {
- return classRef.cast(object);
+ index = i;
+ break;
}
+
+ }
+
+ if (index > -1) {
+ return classRef.cast(this.objects.remove(index));
}
throw new ContractException(CoreTranslationError.UNKNOWN_CLASSREF);
@@ -425,16 +434,21 @@ public T getFirstObject(Class classRef) {
* Searches the list of read in objects and returns all Objects found with the
* given classRef
*
- * @param the type of the obect to get
+ * @param the type of the object to get
*/
public List getObjects(Class classRef) {
List objects = new ArrayList<>();
- for (Object object : this.objects) {
+ for (int i = 0; i < this.objects.size(); i++) {
+ Object object = this.objects.get(i);
+
if (classRef.isAssignableFrom(object.getClass())) {
objects.add(classRef.cast(object));
}
+
}
+ this.objects.removeAll(objects);
+
return objects;
}
@@ -442,7 +456,16 @@ public List getObjects(Class classRef) {
* Returns the entire list of read in objects
*/
public List getObjects() {
- return this.objects;
+ List objects = new ArrayList<>(this.objects);
+
+ this.objects.clear();
+
+ return objects;
+ }
+
+ // package access for testing
+ int getNumObjects() {
+ return this.objects.size();
}
}
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationEngine.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationEngine.java
index 26be4f3..6f81648 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationEngine.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationEngine.java
@@ -180,7 +180,7 @@ protected final void _addTranslationSpec(TranslationSpec translatio
* {@linkplain CoreTranslationError#NULL_TRANSLATOR}
* if translator is null
* {@linkplain CoreTranslationError#DUPLICATE_TRANSLATOR}
- * if translator has alaready been added
+ * if translator has already been added
*
*/
public abstract Builder addTranslator(Translator translator);
@@ -196,7 +196,7 @@ protected final void _addTranslator(Translator translator) {
}
/**
- * Adds the given classRef markerInterace mapping.
+ * Adds the given classRef markerInterface mapping.
*
* explicitly used when calling {@link TranslationController#writeOutput} with a
* class for which a classRef ScenarioId pair does not exist and/or the need to
@@ -380,7 +380,7 @@ void checkForCyclicGraph(MutableGraph mutableGraph) {
private void validateTranslationEngineType() {
if (this.data.translationEngineType == TranslationEngineType.UNKNOWN) {
- throw new ContractException(CoreTranslationError.UNKNWON_TRANSLATION_ENGINE_TYPE);
+ throw new ContractException(CoreTranslationError.UNKNOWN_TRANSLATION_ENGINE_TYPE);
}
}
@@ -401,7 +401,7 @@ Map, Class>> getChildParentClassMap() {
/**
* returns the {@link TranslationEngineType} of this TranslationEngine
*
- * guarenteed to NOT be {@link TranslationEngineType#UNKNOWN}
+ * guaranteed to NOT be {@link TranslationEngineType#UNKNOWN}
*/
public TranslationEngineType getTranslationEngineType() {
return this.data.translationEngineType;
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationSpec.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationSpec.java
index 40c0f46..f84c627 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationSpec.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslationSpec.java
@@ -37,14 +37,14 @@ public boolean isInitialized() {
* Input Class and if so, calls the related method
*
*
- * It then checks if the the object class is assinable from either the App or
+ * It then checks if the the object class is assignable from either the App or
* Input Class and if so, calls the related method
*
*
* If no match can be found, an exception is thrown
*
*
- * @param the expected return type after translation/coversion
+ * @param the expected return type after translation/conversion
* @throws ContractException {@linkplain CoreTranslationError#UNKNOWN_OBJECT} if
* no match can be found between the passed in object
* and the given appClass and InputClass
@@ -102,7 +102,7 @@ public boolean equals(Object obj) {
return false;
}
- // if different intput class, not equal
+ // if different input class, not equal
if (getInputObjectClass() != other.getInputObjectClass()) {
return false;
}
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/Translator.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/Translator.java
index 868d5f7..656925e 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/Translator.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/Translator.java
@@ -120,9 +120,9 @@ public Builder setInitializer(Consumer initConsumer) {
* @throws ContractException
*
* {@linkplain CoreTranslationError#NULL_DEPENDENCY}
- * if the dependecy is null
+ * if the dependency is null
* {@linkplain CoreTranslationError#DUPLICATE_DEPENDENCY}
- * if the dependecy has already been added
+ * if the dependency has already been added
*
*/
public Builder addDependency(TranslatorId dependency) {
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslatorId.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslatorId.java
index 8e0fc97..74a5538 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslatorId.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/TranslatorId.java
@@ -5,7 +5,7 @@
*/
public interface TranslatorId {
/**
- * Implementationn consistent with equals()
+ * Implementation consistent with equals()
*/
@Override
public int hashCode();
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TranslationSpecSupport.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TranslationSpecSupport.java
new file mode 100644
index 0000000..2217997
--- /dev/null
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TranslationSpecSupport.java
@@ -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 Set testGetTranslationSpecs(Class translatorClassRef,
+ List> translationSpecs) throws ClassNotFoundException {
+ Set missingTranslationSpecs = new LinkedHashSet<>();
+ List> 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;
+ }
+}
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/testobject/translationSpecs/testTextFileForTestCoverage.txt b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/testobject/translationSpecs/testTextFileForTestCoverage.txt
new file mode 100644
index 0000000..892394f
--- /dev/null
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/testobject/translationSpecs/testTextFileForTestCoverage.txt
@@ -0,0 +1 @@
+wombat
\ No newline at end of file
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationController.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationController.java
index 554f1db..45261e0 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationController.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationController.java
@@ -17,6 +17,7 @@
import gov.hhs.aspr.ms.taskit.core.testsupport.TestTranslationEngine;
import gov.hhs.aspr.ms.taskit.core.testsupport.testcomplexobject.TestComplexAppObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testcomplexobject.TestComplexObjectTranslator;
+import gov.hhs.aspr.ms.taskit.core.testsupport.testcomplexobject.input.TestComplexInputObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestAppChildObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestAppObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestObjectTranslator;
@@ -29,7 +30,7 @@
public class AT_TranslationController {
Path basePath = ResourceHelper.getResourceDir(this.getClass());
- Path filePath = ResourceHelper.makeOutputDir(basePath, "test-output");
+ Path filePath = ResourceHelper.createDirectory(basePath, "test-output");
@Test
@UnitTestForCoverage
@@ -100,7 +101,7 @@ public void testValidateTranslationEngine() {
@Test
@UnitTestForCoverage
/*
- * purpose of this test is to show that if there isnt a valid TranslationEngine
+ * purpose of this test is to show that if there isn't a valid TranslationEngine
* class -> Translation Engine Type -> Translation Engine mapping, an exception
* is thrown
*/
@@ -158,7 +159,7 @@ public void testValidateTranslationEngines() {
public void testReadInput() {
String fileName = "readInput-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -176,7 +177,7 @@ public void testReadInput() {
translationController.readInput();
- assertTrue(translationController.getObjects().size() == 1);
+ assertEquals(1, translationController.getNumObjects());
TestAppObject actualTestAppObject = translationController.getFirstObject(TestAppObject.class);
@@ -196,9 +197,9 @@ public void testReadInput() {
@Test
@UnitTestForCoverage
public void testWriteOutput_Engine() {
- String fileName = "badFilePath-testoutput.json";
+ String fileName = "badFilePath-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
TestTranslationEngine engine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
.addTranslator(TestComplexObjectTranslator.getTranslator()).build();
@@ -224,7 +225,7 @@ public void testWriteOutput_Engine() {
public void testWriteOutput() {
String fileName = "writeOutput-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -259,7 +260,7 @@ public void testWriteOutput() {
public void testWriteOutput_ParentClass() {
String fileName = "writeOutput_ParentClass-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -298,7 +299,7 @@ public void testWriteOutput_ParentClass() {
public void testWriteOutput_Base() {
String fileName = "writeOutput_Base-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -350,8 +351,10 @@ public void testWriteOutput_Base() {
@UnitTestMethod(target = TranslationController.class, name = "getFirstObject", args = { Class.class })
public void testGetFirstObject() throws IOException {
String fileName = "getFirstObject-testOutput.json";
+ String fileName2 = "getFirstObject-testOutput2.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -360,18 +363,24 @@ public void testGetFirstObject() throws IOException {
TranslationController translationController = TranslationController.builder()
.addInputFilePath(filePath.resolve(fileName), TestInputObject.class,
TranslationEngineType.CUSTOM)
+ .addInputFilePath(filePath.resolve(fileName2), TestComplexInputObject.class,
+ TranslationEngineType.CUSTOM)
.addTranslationEngine(testTranslationEngine).build();
TestAppObject expectedAppObject = TestObjectUtil.generateTestAppObject();
+ TestComplexAppObject expectedComplexAppObject = TestObjectUtil.generateTestComplexAppObject();
translationController.writeOutput(expectedAppObject, filePath.resolve(fileName),
TranslationEngineType.CUSTOM);
- translationController.readInput();
+ translationController.writeOutput(expectedComplexAppObject, filePath.resolve(fileName2),
+ TranslationEngineType.CUSTOM);
- assertTrue(translationController.getObjects().size() == 1);
+ translationController.readInput();
+ assertEquals(2, translationController.getNumObjects());
TestAppObject actualTestAppObject = translationController.getFirstObject(TestAppObject.class);
+ assertEquals(1, translationController.getNumObjects());
assertNotNull(actualTestAppObject);
@@ -389,9 +398,11 @@ public void testGetFirstObject() throws IOException {
public void testGetObjects_OfClass() throws IOException {
String fileName = "GetObjects_OfClass_1-testOutput.json";
String fileName2 = "GetObjects_OfClass_2-testOutput.json";
+ String fileName3 = "GetObjects_OfClass_3-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName3);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -402,27 +413,33 @@ public void testGetObjects_OfClass() throws IOException {
TranslationEngineType.CUSTOM)
.addInputFilePath(filePath.resolve(fileName2), TestInputObject.class,
TranslationEngineType.CUSTOM)
+ .addInputFilePath(filePath.resolve(fileName3), TestComplexInputObject.class,
+ TranslationEngineType.CUSTOM)
.addTranslationEngine(testTranslationEngine).build();
List expectedObjects = TestObjectUtil.getListOfAppObjects(2);
+ TestComplexAppObject expectedComplexAppObject = TestObjectUtil.generateTestComplexAppObject();
translationController.writeOutput(expectedObjects.get(0), filePath.resolve(fileName),
TranslationEngineType.CUSTOM);
translationController.writeOutput(expectedObjects.get(1), filePath.resolve(fileName2),
TranslationEngineType.CUSTOM);
+ translationController.writeOutput(expectedComplexAppObject, filePath.resolve(fileName3),
+ TranslationEngineType.CUSTOM);
translationController.readInput();
- assertEquals(2, translationController.getObjects().size());
+ assertEquals(3, translationController.getNumObjects());
List actualObjects = translationController.getObjects(TestAppObject.class);
+ assertEquals(1, translationController.getNumObjects());
assertEquals(2, actualObjects.size());
assertTrue(actualObjects.containsAll(expectedObjects));
- List actualObjects2 = translationController
- .getObjects(TestComplexAppObject.class);
+ List actualObjects2 = translationController
+ .getObjects(TestAppObject.class);
assertTrue(actualObjects2.isEmpty());
}
@@ -432,8 +449,8 @@ public void testGetObjects() throws IOException {
String fileName = "GetObjects_1-testOutput.json";
String fileName2 = "GetObjects_2-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
@@ -455,10 +472,10 @@ public void testGetObjects() throws IOException {
translationController.readInput();
- assertEquals(2, translationController.getObjects().size());
+ assertEquals(2, translationController.getNumObjects());
List actualObjects = translationController.getObjects();
-
+ assertEquals(0, translationController.getNumObjects());
assertEquals(2, actualObjects.size());
assertTrue(actualObjects.containsAll(expectedObjects));
@@ -492,7 +509,7 @@ public void testBuild() {
public void testAddInputFilePath() {
String fileName = "addInputFilePath-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
assertDoesNotThrow(() -> TranslationController.builder()
.addInputFilePath(filePath.resolve(fileName), TestInputObject.class,
@@ -565,7 +582,7 @@ public void testAddParentChildClassRelationship() {
@Test
@UnitTestMethod(target = TranslationController.Builder.class, name = "addTranslationEngine", args = {
TranslationEngine.class })
- public void testAddTransationEngine() {
+ public void testAddTranslationEngine() {
TestTranslationEngine translationEngine = TestTranslationEngine.builder()
.addTranslator(TestObjectTranslator.getTranslator())
.addTranslator(TestComplexObjectTranslator.getTranslator())
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationEngine.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationEngine.java
index f29b08d..f7a48e1 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationEngine.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationEngine.java
@@ -63,7 +63,7 @@ public void testValidateTranslationEngineType() {
engine.validateInit();
});
- assertEquals(CoreTranslationError.UNKNWON_TRANSLATION_ENGINE_TYPE, contractException.getErrorType());
+ assertEquals(CoreTranslationError.UNKNOWN_TRANSLATION_ENGINE_TYPE, contractException.getErrorType());
}
@Test
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationSpec.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationSpec.java
index 3c55fad..d208c68 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationSpec.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_TranslationSpec.java
@@ -111,7 +111,7 @@ public void testConvert() {
assertEquals(expectedAppChildObject, TestObjectUtil.getChildAppFromApp(actualAppChildObject));
// precondition
- // TranslationSpec not intialized
+ // TranslationSpec not initialized
ContractException contractException = assertThrows(ContractException.class, () -> {
TestObjectTranslationSpec testObjectTranslationSpec2 = new TestObjectTranslationSpec();
testObjectTranslationSpec2.convert(new TestAppObject());
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_Translator.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_Translator.java
index aacb59f..ad0ca24 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_Translator.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/AT_Translator.java
@@ -21,7 +21,7 @@ public class AT_Translator {
@Test
@UnitTestMethod(target = Translator.class, name = "getInitializer", args = {})
public void testGetInitializer() {
- Consumer expectedInitializer = (translatorConext) -> {
+ Consumer expectedInitializer = (translatorContext) -> {
};
Translator testTranslator = Translator.builder().setInitializer(expectedInitializer)
.setTranslatorId(new TranslatorId() {
@@ -35,7 +35,7 @@ public void testGetInitializer() {
public void testGetTranslatorId() {
TranslatorId expectedTranslatorId = new TranslatorId() {
};
- Translator testTranslator = Translator.builder().setInitializer((translatorConext) -> {
+ Translator testTranslator = Translator.builder().setInitializer((translatorContext) -> {
}).setTranslatorId(expectedTranslatorId).build();
assertEquals(expectedTranslatorId, testTranslator.getTranslatorId());
@@ -46,7 +46,7 @@ public void testGetTranslatorId() {
public void testGetTranslatorDependencies() {
TranslatorId expectedTranslatorId = new TranslatorId() {
};
- Translator testTranslator = Translator.builder().setInitializer((translatorConext) -> {
+ Translator testTranslator = Translator.builder().setInitializer((translatorContext) -> {
}).setTranslatorId(expectedTranslatorId).addDependency(TestObjectTranslatorId.TRANSLATOR_ID)
.addDependency(TestComplexObjectTranslatorId.TRANSLATOR_ID).build();
@@ -66,7 +66,7 @@ public void testHashCode() {
};
TranslatorId translatorIdB = new TranslatorId() {
};
- Consumer consumerA = (translatorConext) -> {
+ Consumer consumerA = (translatorContext) -> {
};
Translator translatorA = Translator.builder().setInitializer(consumerA).setTranslatorId(translatorIdA).build();
@@ -91,7 +91,7 @@ public void testHashCode() {
// if same id, but different dependencies, not equal
assertNotEquals(translatorA.hashCode(), translatorC.hashCode());
- // if same id and dependecies, equal
+ // if same id and dependencies, equal
assertEquals(translatorC.hashCode(), translatorD.hashCode());
}
@@ -102,7 +102,7 @@ public void testEquals() {
};
TranslatorId translatorIdB = new TranslatorId() {
};
- Consumer consumerA = (translatorConext) -> {
+ Consumer consumerA = (translatorContext) -> {
};
Translator translatorA = Translator.builder().setInitializer(consumerA).setTranslatorId(translatorIdA).build();
@@ -129,7 +129,7 @@ public void testEquals() {
// if same id, but different dependencies, not equal
assertNotEquals(translatorA, translatorC);
- // if same id and dependecies, equal
+ // if same id and dependencies, equal
assertEquals(translatorC, translatorD);
Translator.Data data = new Translator.Data();
@@ -149,7 +149,7 @@ public void testBuilder() {
public void testBuild() {
TranslatorId translatorIdA = new TranslatorId() {
};
- Translator translatorA = Translator.builder().setInitializer((translatorConext) -> {
+ Translator translatorA = Translator.builder().setInitializer((translatorContext) -> {
}).setTranslatorId(translatorIdA).build();
assertNotNull(translatorA);
@@ -164,7 +164,7 @@ public void testBuild() {
// null translatorId
contractException = assertThrows(ContractException.class, () -> {
- Translator.builder().setInitializer((translatorConext) -> {
+ Translator.builder().setInitializer((translatorContext) -> {
}).build();
});
@@ -176,7 +176,7 @@ public void testBuild() {
public void testSetTranslatorId() {
TranslatorId translatorIdA = new TranslatorId() {
};
- Translator translatorA = Translator.builder().setInitializer((translatorConext) -> {
+ Translator translatorA = Translator.builder().setInitializer((translatorContext) -> {
}).setTranslatorId(translatorIdA).build();
assertEquals(translatorIdA, translatorA.getTranslatorId());
@@ -193,7 +193,7 @@ public void testSetTranslatorId() {
@Test
@UnitTestMethod(target = Translator.Builder.class, name = "setInitializer", args = { Consumer.class })
public void testSetInitializer() {
- Consumer expectedInitializer = (translatorConext) -> {
+ Consumer expectedInitializer = (translatorContext) -> {
};
Translator testTranslator = Translator.builder().setInitializer(expectedInitializer)
.setTranslatorId(new TranslatorId() {
@@ -215,7 +215,7 @@ public void testSetInitializer() {
public void testAddDependency() {
TranslatorId expectedTranslatorId = new TranslatorId() {
};
- Translator testTranslator = Translator.builder().setInitializer((translatorConext) -> {
+ Translator testTranslator = Translator.builder().setInitializer((translatorContext) -> {
}).setTranslatorId(expectedTranslatorId).addDependency(TestObjectTranslatorId.TRANSLATOR_ID)
.addDependency(TestComplexObjectTranslatorId.TRANSLATOR_ID).build();
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TestTranslationEngine.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TestTranslationEngine.java
index c04ba79..00a4a3d 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TestTranslationEngine.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TestTranslationEngine.java
@@ -22,7 +22,7 @@
public class AT_TestTranslationEngine {
Path basePath = ResourceHelper.getResourceDir(this.getClass());
- Path filePath = ResourceHelper.makeOutputDir(basePath, "test-output");
+ Path filePath = ResourceHelper.createDirectory(basePath, "test-output");
@Test
@UnitTestMethod(target = TestTranslationEngine.class, name = "writeOutput", args = { Path.class, Object.class,
@@ -31,8 +31,8 @@ public void testWriteOutput() throws IOException {
String fileName = "writeOutputFromEngine_1-testOutput.json";
String fileName2 = "writeOutputFromEngine_2-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
TestObjectTranslationSpec testObjectTranslationSpec = new TestObjectTranslationSpec();
TestComplexObjectTranslationSpec complexObjectTranslationSpec = new TestComplexObjectTranslationSpec();
@@ -57,8 +57,8 @@ public void testReadInput() throws IOException {
String fileName = "readInputFromEngine_1-testOutput.json";
String fileName2 = "readInputFromEngine_2-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
TestObjectTranslationSpec testObjectTranslationSpec = new TestObjectTranslationSpec();
TestComplexObjectTranslationSpec complexObjectTranslationSpec = new TestComplexObjectTranslationSpec();
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TranslationSpecSupport.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TranslationSpecSupport.java
new file mode 100644
index 0000000..372c084
--- /dev/null
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/AT_TranslationSpecSupport.java
@@ -0,0 +1,32 @@
+package gov.hhs.aspr.ms.taskit.core.testsupport;
+
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+
+import org.junit.jupiter.api.Test;
+
+import gov.hhs.aspr.ms.taskit.core.TranslationSpec;
+import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestObjectTranslator;
+import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.translationSpecs.TestObjectTranslationSpec;
+
+public class AT_TranslationSpecSupport {
+
+ @Test
+ public void testTestGetTranslationSpecs() throws ClassNotFoundException {
+ List> translationSpecs = new ArrayList<>();
+
+ translationSpecs.add(new TestObjectTranslationSpec());
+
+ Set missingSpecs = TranslationSpecSupport.testGetTranslationSpecs(TestObjectTranslator.class, translationSpecs);
+
+ assertTrue(missingSpecs.isEmpty());
+
+ missingSpecs = TranslationSpecSupport.testGetTranslationSpecs(TestObjectTranslator.class, new ArrayList<>());
+
+ assertTrue(missingSpecs.size() == 1);
+ assertTrue(missingSpecs.contains(TestObjectTranslationSpec.class.getSimpleName()));
+ }
+}
diff --git a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestObjectUtil.java b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestObjectUtil.java
index 2093c9a..9a66c93 100644
--- a/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestObjectUtil.java
+++ b/core/src/test/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestObjectUtil.java
@@ -81,9 +81,9 @@ public static List getListOfInputObjects(int num) {
public static TestAppObject getAppFromInput(TestInputObject inputObject) {
TestAppObject appObject = new TestAppObject();
- TestComplexAppObject complextAppObject = getComplexAppFromComplexInput(inputObject.getTestComplexInputObject());
+ TestComplexAppObject complexAppObject = getComplexAppFromComplexInput(inputObject.getTestComplexInputObject());
- appObject.setTestComplexAppObject(complextAppObject);
+ appObject.setTestComplexAppObject(complexAppObject);
appObject.setBool(inputObject.isBool());
appObject.setInteger(inputObject.getInteger());
appObject.setString(inputObject.getString());
@@ -93,9 +93,9 @@ public static TestAppObject getAppFromInput(TestInputObject inputObject) {
public static TestInputObject getInputFromApp(TestAppObject appObject) {
TestInputObject inputObject = new TestInputObject();
- TestComplexInputObject complextInputObject = getComplexInputFromComplexApp(appObject.getTestComplexAppObject());
+ TestComplexInputObject complexInputObject = getComplexInputFromComplexApp(appObject.getTestComplexAppObject());
- inputObject.setTestComplexInputObject(complextInputObject);
+ inputObject.setTestComplexInputObject(complexInputObject);
inputObject.setBool(appObject.isBool());
inputObject.setInteger(appObject.getInteger());
inputObject.setString(appObject.getString());
@@ -126,22 +126,22 @@ public static TestInputChildObject getChildInputFromInput(TestInputObject inputO
}
public static TestComplexAppObject getComplexAppFromComplexInput(TestComplexInputObject inputObject) {
- TestComplexAppObject complextAppObject = new TestComplexAppObject();
+ TestComplexAppObject complexAppObject = new TestComplexAppObject();
- complextAppObject.setNumEntities(inputObject.getNumEntities());
- complextAppObject.setStartTime(inputObject.getStartTime());
- complextAppObject.setTestString(inputObject.getTestString());
+ complexAppObject.setNumEntities(inputObject.getNumEntities());
+ complexAppObject.setStartTime(inputObject.getStartTime());
+ complexAppObject.setTestString(inputObject.getTestString());
- return complextAppObject;
+ return complexAppObject;
}
public static TestComplexInputObject getComplexInputFromComplexApp(TestComplexAppObject appObject) {
- TestComplexInputObject complextInputObject = new TestComplexInputObject();
+ TestComplexInputObject complexInputObject = new TestComplexInputObject();
- complextInputObject.setNumEntities(appObject.getNumEntities());
- complextInputObject.setStartTime(appObject.getStartTime());
- complextInputObject.setTestString(appObject.getTestString());
+ complexInputObject.setNumEntities(appObject.getNumEntities());
+ complexInputObject.setStartTime(appObject.getStartTime());
+ complexInputObject.setTestString(appObject.getTestString());
- return complextInputObject;
+ return complexInputObject;
}
}
diff --git a/pom.xml b/pom.xml
index 5e7c161..8a45e03 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
- 4.0.2
+ 4.1.0
UTF-8
@@ -62,15 +62,15 @@
1.6.0
3.2.5
3.3.1
- 3.1.1
- 3.1.1
- 3.6.3
- 3.2.2
+ 3.1.2
+ 3.1.2
+ 3.7.0
+ 3.2.4
0.4.0
- 2.10.1
- 4.1.2
+ 2.11.0
+ 4.2.0
5.10.2
0.8.12
diff --git a/protobuf/pom.xml b/protobuf/pom.xml
index a12e10c..b589cb9 100644
--- a/protobuf/pom.xml
+++ b/protobuf/pom.xml
@@ -31,7 +31,7 @@
1.7.1
0.6.1
- 3.5.0
+ 3.6.0
1.4.1
@@ -165,13 +165,13 @@
- org.jacoco
- jacoco-maven-plugin
+ org.sonatype.central
+ central-publishing-maven-plugin
+ true
-
- com/google/type/*.class
- **/input/**/*.class
-
+ central
+ true
+ ASPR MS Taskit Protobuf
@@ -184,4 +184,23 @@
+
+
+ jacoco
+
+
+
+ org.jacoco
+ jacoco-maven-plugin
+
+
+ com/google/type/*.class
+ **/input/**/*.class
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/PrimitiveTranslationSpecs.java b/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/PrimitiveTranslationSpecs.java
index 9717848..8eecc04 100644
--- a/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/PrimitiveTranslationSpecs.java
+++ b/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/PrimitiveTranslationSpecs.java
@@ -54,8 +54,8 @@ class PrimitiveTranslationSpecs {
* Returns a set of Protobuf Message {@link Descriptor}s for each of the
* Primitive TranslationSpecs. A Descriptor is to a Protobuf Message as Class is
* to a Java Object.
- * Note: as metioned in the Class javadoc, these Primitive TranslationSpecs
- * and their Descriptors are exclusively used to falicitate converting to/from a
+ * Note: as mentioned in the Class javadoc, these Primitive TranslationSpecs
+ * and their Descriptors are exclusively used to facilitate converting to/from a
* Protobuf {@link Any} type
*/
Set getPrimitiveDescriptors() {
@@ -78,8 +78,8 @@ Set getPrimitiveDescriptors() {
/**
* Returns a set of {@link ProtobufTranslationSpec}s that includes each of the
* Primitive TranslationSpecs.
- * Note: as metioned in the Class javadoc, these Primitive TranslationSpecs
- * are exclusively used to falicitate converting to/from a Protobuf {@link Any}
+ * Note: as mentioned in the Class javadoc, these Primitive TranslationSpecs
+ * are exclusively used to facilitate converting to/from a Protobuf {@link Any}
* type
*/
Set> getPrimitiveTranslatorSpecs() {
@@ -94,8 +94,8 @@ Set getPrimitiveDescriptors() {
/**
* Returns a map of typeUrl to Class that includes each of the Primitive
* TranslationSpecs.
- * Note: as metioned in the Class javadoc, these Primitive TranslationSpecs
- * and their typeUrls are exclusively used to falicitate converting to/from a
+ * Note: as mentioned in the Class javadoc, these Primitive TranslationSpecs
+ * and their typeUrls are exclusively used to facilitate converting to/from a
* Protobuf {@link Any} type
*/
Map> getPrimitiveTypeUrlToClassMap() {
@@ -129,8 +129,8 @@ Map> getPrimitiveTypeUrlToClassMap() {
* Returns a map of {@link Class} to {@link ProtobufTranslationSpec} that
* includes each of the Primitive TranslationSpecs. This map is exclusively a
* map of the inputObjectClass to the TranslationSpec.
- * Note: as metioned in the Class javadoc, these Primitive TranslationSpecs
- * and their inputObjectClasses are exclusively used to falicitate converting
+ * Note: as mentioned in the Class javadoc, these Primitive TranslationSpecs
+ * and their inputObjectClasses are exclusively used to facilitate converting
* to/from a Protobuf {@link Any} type
*/
Map, ProtobufTranslationSpec, ?>> getPrimitiveInputTranslatorSpecMap() {
@@ -155,8 +155,8 @@ Map> getPrimitiveTypeUrlToClassMap() {
* Returns a map of {@link Class} to {@link ProtobufTranslationSpec} that
* includes each of the Primitive TranslationSpecs. This map is exclusively a
* map of the appObjectClass to the TranslationSpec.
- * Note: as metioned in the Class javadoc, these Primitive TranslationSpecs
- * and their appObjectClasses are exclusively used to falicitate converting
+ * Note: as mentioned in the Class javadoc, these Primitive TranslationSpecs
+ * and their appObjectClasses are exclusively used to facilitate converting
* to/from a Protobuf {@link Any} type
*/
Map, ProtobufTranslationSpec, ?>> getPrimitiveObjectTranslatorSpecMap() {
diff --git a/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/ProtobufTranslationEngine.java b/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/ProtobufTranslationEngine.java
index db9f190..b71fa5d 100644
--- a/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/ProtobufTranslationEngine.java
+++ b/protobuf/src/main/java/gov/hhs/aspr/ms/taskit/protobuf/ProtobufTranslationEngine.java
@@ -1,11 +1,11 @@
package gov.hhs.aspr.ms.taskit.protobuf;
+import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
-import java.io.Writer;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.nio.file.Path;
@@ -159,7 +159,7 @@ public Builder addFieldToIncludeDefaultValue(FieldDescriptor fieldDescriptor) {
}
/**
- * Overriden implementation of
+ * Override implementation of
* {@link TranslationEngine.Builder#addTranslationSpec(TranslationSpec)} that
* also populates the type urls for all Protobuf Message types that exist within
* the translationSpec
@@ -167,7 +167,7 @@ public Builder addFieldToIncludeDefaultValue(FieldDescriptor fieldDescriptor) {
* @throws ContractException
*
* {@link ProtobufCoreTranslationError#INVALID_INPUT_CLASS}
- * if the given inputClassRef is not assingable from
+ * if the given inputClassRef is not assignable from
* {@linkplain Message} nor
* {@linkplain ProtocolMessageEnum}
* {@link ProtobufCoreTranslationError#INVALID_TRANSLATION_SPEC}
@@ -200,7 +200,7 @@ public Builder addParentChildClassRelationship(Class classRe
return this;
}
-
+
/**
* checks the class to determine if it is a ProtocolMessageEnum or a Message and
* if so, gets the Descriptor (which is akin to a class but for a Protobuf
@@ -208,7 +208,7 @@ public Builder addParentChildClassRelationship(Class classRe
* descriptorMap and typeUrlToClassMap
*
* @throws ContractException {@link ProtobufCoreTranslationError#INVALID_INPUT_CLASS}
- * if the given inputClassRef is not assingable from
+ * if the given inputClassRef is not assignable from
* {@linkplain Message} nor
* {@linkplain ProtocolMessageEnum}
*/
@@ -294,7 +294,8 @@ void setDebug(boolean debug) {
* @param the type of the appObject
* @throws RuntimeException if there is an IOException during writing
*/
- protected void writeOutput(Path path, M appObject, Optional> superClass) throws IOException {
+ protected void writeOutput(Path path, M appObject, Optional> superClass)
+ throws IOException {
Message message;
if (Message.class.isAssignableFrom(appObject.getClass())) {
message = Message.class.cast(appObject);
@@ -319,7 +320,7 @@ protected void writeOutput(Path path, M appObject, Optional void writeOutput(Path path, U message) {
try {
- Writer writer = new FileWriter(path.toFile());
+ BufferedWriter writer = new BufferedWriter(new FileWriter(path.toFile()));
this.data.jsonPrinter.appendTo(message, writer);
if (debug) {
@@ -351,16 +352,20 @@ private void printJsonToConsole(String jsonString) {
* @param the return type
* @throws FileNotFoundException
* @throws RuntimeException
- *
- * if there is an issue getting the builder method
- * from the inputClassRef
- * if there is an issue merging the read in JSON
- * object into the resulting Protobuf Message builder
- *
- *
- * @throws ContractException {@linkplain ProtobufCoreTranslationError#INVALID_READ_INPUT_CLASS_REF}
- * if the given inputClassRef is not assingable from
- * {@linkplain Message}
+ *
+ * if there is an issue getting the builder
+ * method
+ * from the inputClassRef
+ * if there is an issue merging the read in
+ * JSON
+ * object into the resulting Protobuf Message
+ * builder
+ *
+ *
+ * @throws ContractException {@linkplain ProtobufCoreTranslationError#INVALID_READ_INPUT_CLASS_REF}
+ * if the given inputClassRef is not assignable
+ * from
+ * {@linkplain Message}
*/
protected T readInput(Path path, Class inputClassRef) throws IOException {
if (!Message.class.isAssignableFrom(inputClassRef)) {
@@ -433,7 +438,7 @@ Message.Builder getBuilderForMessage(Class messageClass) {
}
throw new RuntimeException(
- "\"newBuilder\" method exists, but it requires arugments, when it is expected to require 0 arugments");
+ "\"newBuilder\" method exists, but it requires arguments, when it is expected to require 0 arguments");
}
/**
@@ -495,7 +500,7 @@ public Class> getClassFromTypeUrl(String typeUrl) {
}
throw new ContractException(ProtobufCoreTranslationError.UNKNOWN_TYPE_URL,
- "Unable to find corrsponding class for: " + typeUrl);
+ "Unable to find corresponding class for: " + typeUrl);
}
}
diff --git a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/AT_ProtobufTranslationEngine.java b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/AT_ProtobufTranslationEngine.java
index 3758c0c..fd3b957 100644
--- a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/AT_ProtobufTranslationEngine.java
+++ b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/AT_ProtobufTranslationEngine.java
@@ -31,7 +31,7 @@
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestAppObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.translationSpecs.TestObjectTranslationSpec;
import gov.hhs.aspr.ms.taskit.protobuf.testsupport.TestObjectUtil;
-import gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses.BadMessageBadArguements;
+import gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses.BadMessageBadArguments;
import gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses.BadMessageIllegalAccess;
import gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses.BadMessageNoMethod;
import gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses.BadMessageNonStaticMethod;
@@ -47,7 +47,7 @@
public class AT_ProtobufTranslationEngine {
Path basePath = ResourceHelper.getResourceDir(this.getClass());
- Path filePath = ResourceHelper.makeOutputDir(basePath, "test-output");
+ Path filePath = ResourceHelper.createDirectory(basePath, "test-output");
@Test
@UnitTestMethod(target = ProtobufTranslationEngine.class, name = "getAnyFromObject", args = { Object.class })
@@ -83,7 +83,7 @@ public void testGetAnyFromObjectAsSafeClass() {
// preconditions
- // no translationSpec was prodived for the parent class
+ // no translationSpec was provided for the parent class
ContractException contractException = assertThrows(ContractException.class, () -> {
ProtobufTranslationEngine protobufTranslationEngine2 = ProtobufTranslationEngine.builder()
.addTranslationSpec(new TestProtobufComplexObjectTranslationSpec()).build();
@@ -149,7 +149,7 @@ public void testGetClassFromTypeUrl() {
public void testDebugPrint() throws IOException {
String fileName = "debugPrintFromEngine_1-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName);
ProtobufTranslationEngine protobufTranslationEngine = ProtobufTranslationEngine.builder()
.addTranslationSpec(new TestProtobufObjectTranslationSpec())
@@ -212,9 +212,9 @@ public void testGetBuilderForMessage() {
protobufTranslationEngine.getBuilderForMessage(BadMessageNonStaticMethod.class);
});
- // class has a static newBuilder method but it takes arguements
+ // class has a static newBuilder method but it takes arguments
assertThrows(RuntimeException.class, () -> {
- protobufTranslationEngine.getBuilderForMessage(BadMessageBadArguements.class);
+ protobufTranslationEngine.getBuilderForMessage(BadMessageBadArguments.class);
});
// class has a newBuilder method but it is not accessible
@@ -230,8 +230,8 @@ public void testReadInput() throws IOException {
String fileName = "readInputFromEngine_1-testOutput.json";
String fileName2 = "readInputFromEngine_2-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
ProtobufTranslationEngine protobufTranslationEngine = ProtobufTranslationEngine.builder()
.addTranslationSpec(new TestProtobufObjectTranslationSpec())
@@ -259,7 +259,7 @@ public void testReadInput() throws IOException {
assertEquals(ProtobufCoreTranslationError.INVALID_READ_INPUT_CLASS_REF, contractException.getErrorType());
- // precondition for the Runtime exceptions are convered by the tests:
+ // precondition for the Runtime exceptions are covered by the tests:
// testGetBuilderForMessage() and testParseJson()
}
@@ -269,8 +269,8 @@ public void testWriteOutput() throws IOException {
String fileName = "writeOutputFromEngine_1-testOutput.json";
String fileName2 = "writeOutputFromEngine_2-testOutput.json";
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
+ ResourceHelper.createFile(filePath, fileName);
+ ResourceHelper.createFile(filePath, fileName2);
ProtobufTranslationEngine protobufTranslationEngine = ProtobufTranslationEngine.builder()
.addTranslationSpec(new TestProtobufObjectTranslationSpec())
diff --git a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/TestObjectUtil.java b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/TestObjectUtil.java
index bf16751..ca84f69 100644
--- a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/TestObjectUtil.java
+++ b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/TestObjectUtil.java
@@ -79,10 +79,10 @@ public static List getListOfInputObjects(int num) {
public static TestAppObject getAppFromInput(TestInputObject inputObject) {
TestAppObject appObject = new TestAppObject();
- TestComplexAppObject complextAppObject = getComplexAppFromComplexInput(inputObject.getTestComplexInputObject());
+ TestComplexAppObject complexAppObject = getComplexAppFromComplexInput(inputObject.getTestComplexInputObject());
TestAppEnum testAppEnum = getTestAppEnumFromTestInputEnum(inputObject.getEnum());
- appObject.setTestComplexAppObject(complextAppObject);
+ appObject.setTestComplexAppObject(complexAppObject);
appObject.setBool(inputObject.getBool());
appObject.setInteger(inputObject.getInteger());
appObject.setString(inputObject.getString());
@@ -92,10 +92,10 @@ public static TestAppObject getAppFromInput(TestInputObject inputObject) {
}
public static TestInputObject getInputFromApp(TestAppObject appObject) {
- TestComplexInputObject complextInputObject = getComplexInputFromComplexApp(appObject.getTestComplexAppObject());
+ TestComplexInputObject complexInputObject = getComplexInputFromComplexApp(appObject.getTestComplexAppObject());
TestInputEnum testInputEnum = getTestInputEnumFromTestAppEnum(appObject.getTestAppEnum());
- TestInputObject inputObject = TestInputObject.newBuilder().setTestComplexInputObject(complextInputObject)
+ TestInputObject inputObject = TestInputObject.newBuilder().setTestComplexInputObject(complexInputObject)
.setBool(appObject.isBool()).setInteger(appObject.getInteger()).setString(appObject.getString())
.setEnum(testInputEnum).build();
@@ -115,21 +115,21 @@ public static TestAppChildObject getChildAppFromApp(TestAppObject appObject) {
}
public static TestComplexAppObject getComplexAppFromComplexInput(TestComplexInputObject inputObject) {
- TestComplexAppObject complextAppObject = new TestComplexAppObject();
+ TestComplexAppObject complexAppObject = new TestComplexAppObject();
- complextAppObject.setNumEntities(inputObject.getNumEntities());
- complextAppObject.setStartTime(inputObject.getStartTime());
- complextAppObject.setTestString(inputObject.getTestString());
+ complexAppObject.setNumEntities(inputObject.getNumEntities());
+ complexAppObject.setStartTime(inputObject.getStartTime());
+ complexAppObject.setTestString(inputObject.getTestString());
- return complextAppObject;
+ return complexAppObject;
}
public static TestComplexInputObject getComplexInputFromComplexApp(TestComplexAppObject appObject) {
- TestComplexInputObject complextInputObject = TestComplexInputObject.newBuilder()
+ TestComplexInputObject complexInputObject = TestComplexInputObject.newBuilder()
.setNumEntities(appObject.getNumEntities()).setStartTime(appObject.getStartTime())
.setTestString(appObject.getTestString()).build();
- return complextInputObject;
+ return complexInputObject;
}
public static TestAppEnum getTestAppEnumFromTestInputEnum(TestInputEnum testInputEnum) {
diff --git a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguements.java b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguments.java
similarity index 72%
rename from protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguements.java
rename to protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguments.java
index b649b74..6e71835 100644
--- a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguements.java
+++ b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/testsupport/testClasses/BadMessageBadArguments.java
@@ -1,8 +1,8 @@
package gov.hhs.aspr.ms.taskit.protobuf.testsupport.testClasses;
-public class BadMessageBadArguements {
+public class BadMessageBadArguments {
- private BadMessageBadArguements() {
+ private BadMessageBadArguments() {
}
diff --git a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/translationSpecs/AT_AnyTranslationSpec.java b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/translationSpecs/AT_AnyTranslationSpec.java
index f000f68..9caf26b 100644
--- a/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/translationSpecs/AT_AnyTranslationSpec.java
+++ b/protobuf/src/test/java/gov/hhs/aspr/ms/taskit/protobuf/translationSpecs/AT_AnyTranslationSpec.java
@@ -55,7 +55,7 @@ public void testConvertInputObject() {
assertEquals(expectedValue, obj);
// preconditions
- // the typeurl of the any is malformed
+ // the type url of the any is malformed
RuntimeException runtimeException = assertThrows(RuntimeException.class, () -> {
Any badAny = Any.newBuilder().setTypeUrl("badTypeUrl").build();
anyTranslationSpec.convertInputObject(badAny);
@@ -72,7 +72,7 @@ public void testConvertInputObject() {
assertEquals("Message is not assignable from " + TestInputEnum.class.getName(), runtimeException.getMessage());
- // the typeurl doesn't match the class of the packed message
+ // the type url doesn't match the class of the packed message
// this is tested in the test: testUnpackMessage
}
@@ -109,7 +109,7 @@ public void testConvertAppObject() {
AnyTranslationSpec anyTranslationSpec = new AnyTranslationSpec();
anyTranslationSpec.init(protobufTranslationEngine);
- // app object coverted into any
+ // app object converted into any
Integer value = 100;
Int32Value expectedValue = Int32Value.of(value);
@@ -121,10 +121,10 @@ public void testConvertAppObject() {
// app enum converted into any by wrapping it in a WrapperEnumValue
TestAppEnum appValue = TestAppEnum.TEST1;
- TestInputEnum expecetedValue = TestInputEnum.TEST1;
+ TestInputEnum expectedValueEnum = TestInputEnum.TEST1;
WrapperEnumValue wrapperEnumValue = WrapperEnumValue.newBuilder()
- .setEnumTypeUrl(TestInputEnum.getDescriptor().getFullName()).setValue(expecetedValue.name()).build();
+ .setEnumTypeUrl(TestInputEnum.getDescriptor().getFullName()).setValue(expectedValueEnum.name()).build();
expectedAny = Any.pack(wrapperEnumValue);
@@ -133,7 +133,7 @@ public void testConvertAppObject() {
assertEquals(expectedAny, actualAny);
// by calling covert on an object that was already converted
- // this case is specifcally used for
+ // this case is specifically used for
// ProtobufTranslationEngine.testGetAnyFromObjectAsSafeClass
actualAny = anyTranslationSpec.convertAppObject(wrapperEnumValue);