From d0397b5a55103c0261dbc5e4c5dbd9b130b33a31 Mon Sep 17 00:00:00 2001
From: Zachary Bischoff <116595361+bischoffz@users.noreply.github.com>
Date: Fri, 1 Mar 2024 13:28:27 -0500
Subject: [PATCH 01/15] Update pom.xml
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 59de761..d751996 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,7 +41,7 @@
- 3.2.0
+ 4.0.0-SNAPSHOTUTF-8
From bbb2d66dabd9b0f07f3e9e2aa3f45ec868f43829 Mon Sep 17 00:00:00 2001
From: Zachary Bischoff <116595361+bischoffz@users.noreply.github.com>
Date: Mon, 4 Mar 2024 17:17:34 -0500
Subject: [PATCH 02/15] remove output files from controller builder (#38)
---
.../ms/taskit/core/TranslationController.java | 415 ++++--------------
.../ms/taskit/core/TranslationEngine.java | 49 ---
.../testsupport/TestTranslationEngine.java | 7 -
.../taskit/core/AT_TranslationController.java | 391 +++--------------
.../core/TranslationEngineTestHelper.java | 25 --
.../testsupport/AT_TestTranslationEngine.java | 7 -
.../protobuf/ProtobufTranslationEngine.java | 7 -
.../ProtobufTranslationEngineTestHelper.java | 24 -
.../AT_ProtobufTranslationEngine.java | 28 +-
9 files changed, 158 insertions(+), 795 deletions(-)
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 b3a899b..27dce53 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
@@ -12,8 +12,6 @@
import java.util.Optional;
import java.util.Set;
-import org.apache.commons.math3.util.Pair;
-
import gov.hhs.aspr.ms.util.errors.ContractException;
/**
@@ -36,9 +34,6 @@ final static class Data {
protected final List translators = new ArrayList<>();
protected final Map> inputFilePathMap = new LinkedHashMap<>();
protected final Map inputFilePathEngine = new LinkedHashMap<>();
- protected final Map outputFilePathMap = new LinkedHashMap<>();
- protected final Map outputFilePathEngine = new LinkedHashMap<>();
- protected final Map, Class>> parentChildClassRelationshipMap = new LinkedHashMap<>();
Data() {
}
@@ -63,14 +58,10 @@ private void validateFilePathNotNull(Path filePath) {
}
}
- private void validatePathNotDuplicate(Path filePath, boolean in, boolean out) {
- if (in && this.data.inputFilePathMap.containsKey(filePath)) {
+ private void validatePathNotDuplicate(Path filePath) {
+ if (this.data.inputFilePathMap.containsKey(filePath)) {
throw new ContractException(CoreTranslationError.DUPLICATE_INPUT_PATH);
}
-
- if (out && this.data.outputFilePathMap.values().contains(filePath)) {
- throw new ContractException(CoreTranslationError.DUPLICATE_OUTPUT_PATH);
- }
}
private void validateTranslationEngineNotNull(TranslationEngine translationEngine) {
@@ -133,7 +124,7 @@ TranslationController buildWithoutInitAndChecks() {
public Builder addInputFilePath(Path filePath, Class> classRef, TranslationEngineType translationEngineType) {
validateFilePathNotNull(filePath);
validateClassRefNotNull(classRef);
- validatePathNotDuplicate(filePath, true, false);
+ validatePathNotDuplicate(filePath);
if (!filePath.toFile().exists()) {
throw new ContractException(CoreTranslationError.INVALID_INPUT_PATH);
@@ -144,129 +135,6 @@ public Builder addInputFilePath(Path filePath, Class> classRef, TranslationEng
return this;
}
- /**
- * Adds the path and class ref to be written to after building via
- * {@link TranslationController#writeOutput} with the given classRef and
- * scenario id of 0 as the key
- *
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#NULL_PATH} if
- * filePath is null
- *
{@linkplain CoreTranslationError#NULL_CLASS_REF}
- * if classRef is null
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH}
- * if filePath has already been added
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH_KEY}
- * if the classRef and scenarioId pair has already
- * been added
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_PATH}
- * if filePath does not exist on the system. Note this
- * check is for the folder, not the file. The file
- * will be created if necessary by the writer
- *
- */
- public Builder addOutputFilePath(Path filePath, Class> classRef,
- TranslationEngineType translationEngineType) {
- return this.addOutputFilePath(filePath, classRef, 0, translationEngineType);
- }
-
- /**
- * Adds the path and class ref to be written to after building via
- * {@link TranslationController#writeOutput} with the given classRef and
- * scenarioId as the key
- *
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#NULL_PATH} if
- * filePath is null
- *
{@linkplain CoreTranslationError#NULL_CLASS_REF}
- * if classRef is null
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH}
- * if filePath has already been added
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH_KEY}
- * if the classRef and scenarioId pair has already
- * been added
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_PATH}
- * if filePath does not exist on the system. Note this
- * check is for the folder, not the file. The file
- * will be created if necessary by the writer
- *
- */
- public Builder addOutputFilePath(Path filePath, Class> classRef, Integer scenarioId,
- TranslationEngineType translationEngineType) {
- validateClassRefNotNull(classRef);
-
- return this.addOutputFilePath(filePath, classRef.getName() + ":" + scenarioId, translationEngineType);
- }
-
- /**
- * Adds the path and class ref to be written to after building via
- * {@link TranslationController#writeOutput} with the given key
- *
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#NULL_PATH} if
- * filePath is null
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH}
- * if filePath has already been added
- *
{@linkplain CoreTranslationError#DUPLICATE_OUTPUT_PATH_KEY}
- * if the classRef and scenarioId pair has already
- * been added
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_PATH}
- * if filePath does not exist on the system. Note this
- * check is for the folder, not the file. The file
- * will be created if necessary by the writer
- *
- */
- public Builder addOutputFilePath(Path filePath, String key, TranslationEngineType translationEngineType) {
- validateFilePathNotNull(filePath);
- validatePathNotDuplicate(filePath, false, true);
-
- if (this.data.outputFilePathMap.containsKey(key)) {
- throw new ContractException(CoreTranslationError.DUPLICATE_OUTPUT_PATH_KEY);
- }
-
- if (!filePath.getParent().toFile().exists()) {
- throw new ContractException(CoreTranslationError.INVALID_OUTPUT_PATH);
- }
-
- this.data.outputFilePathMap.put(key, filePath);
- this.data.outputFilePathEngine.put(filePath, translationEngineType);
- return this;
- }
-
- /**
- * Adds the given classRef markerInterace 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
- * output the given class as the markerInterface instead of the concrete class
- *
- * @param the childClass
- * @param the parentClass/MarkerInterfaceClass
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#NULL_CLASS_REF}
- * if classRef is null or if markerInterface is
- * null
- *
{@linkplain CoreTranslationError#DUPLICATE_CLASSREF}
- * if child parent relationship has already been
- * added
- *
- */
- public Builder addParentChildClassRelationship(Class classRef, Class parentClassRef) {
- validateClassRefNotNull(classRef);
- validateClassRefNotNull(parentClassRef);
-
- if (this.data.parentChildClassRelationshipMap.containsKey(classRef)) {
- throw new ContractException(CoreTranslationError.DUPLICATE_CLASSREF);
- }
-
- this.data.parentChildClassRelationshipMap.put(classRef, parentClassRef);
- return this;
- }
-
/**
* Adds a {@link TranslationEngine.Builder}
*
@@ -281,22 +149,6 @@ public Builder addTranslationEngine(TranslationEngine translationEngine) {
this.data.translationEngines.add(translationEngine);
- Map, Class>> childToParentClassMap = translationEngine.getChildParentClassMap();
-
- for (Class> childClassRef : childToParentClassMap.keySet()) {
- // Need to duplicate code here because the map doesn't provide the type safety
- // that is required by the addParentChildClassRelationship method
- Class> parentClassRef = childToParentClassMap.get(childClassRef);
-
- // Note: no 'class is not null' validation here because it was validated prior
- // to being put into the engine
- if (this.data.parentChildClassRelationshipMap.containsKey(childClassRef)) {
- throw new ContractException(CoreTranslationError.DUPLICATE_CLASSREF);
- }
-
- this.data.parentChildClassRelationshipMap.put(childClassRef, parentClassRef);
- }
-
return this;
}
@@ -309,38 +161,6 @@ public static Builder builder() {
return new Builder(new Data());
}
- /**
- * Passes the given reader and inputClassRef to the built
- * {@link TranslationEngine} to read, parse and translate the inputData.
- *
- * @param the classType associated with the reader
- */
- void readInput(Path path, Class inputClassRef, TranslationEngine translationEngine) {
- Object appObject;
- try {
- appObject = translationEngine.readInput(path, inputClassRef);
- this.objects.add(appObject);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
- /**
- * Passes the given writer object and optional superClass to the built
- * {@link TranslationEngine} to translate and write to the outputFile
- *
- * @param the class of the object to write to the outputFile
- * @param the optional parent class of the object to write to the outputFile
- */
- void writeOutput(Path path, M object, Optional> superClass,
- TranslationEngine translationEngine) {
- try {
- translationEngine.writeOutput(path, object, superClass);
- } catch (IOException e) {
- throw new RuntimeException(e);
- }
- }
-
void initTranslationEngines() {
for (TranslationEngine translationEngine : this.data.translationEngines) {
translationEngine.translationSpecsAreInitialized();
@@ -412,200 +232,117 @@ public TranslationController readInput() {
}
/**
- * Given the classRef and scenarioId, find the given outputFilePath. If the
- * classRef Scenario pair has been added, that is returned. Otherwise, checks to
- * see if the classRef exists in the parentChildClassRelationshipMap and if so,
- * returns
- * the resulting classRef scenarioId pair
- *
- * @param the childClass
- * @param the optional parentClass/MarkerInterfaceClass
- */
- Pair>> getOutputPathKey(Class classRef, Integer scenarioId) {
- String key = classRef.getName() + ":" + scenarioId;
-
- if (this.data.outputFilePathMap.containsKey(key)) {
- return new Pair<>(key, Optional.empty());
- }
-
- if (this.data.parentChildClassRelationshipMap.containsKey(classRef)) {
- // can safely cast because of type checking when adding to the
- // parentChildClassRelationshipMap
- @SuppressWarnings("unchecked")
- Class parentClass = (Class) this.data.parentChildClassRelationshipMap.get(classRef);
-
- key = parentClass.getName() + ":" + scenarioId;
-
- if (this.data.outputFilePathMap.containsKey(key)) {
- return new Pair<>(key, Optional.of(parentClass));
- }
- }
-
- throw new ContractException(CoreTranslationError.INVALID_OUTPUT_CLASSREF,
- "No path was provided for " + classRef.getName());
- }
-
- /**
- * Given the classRef and scenarioId, find the given outputFilePath. If the
- * classRef Scenario pair has been added, that is returned. Otherwise, checks to
- * see if the classRef exists in the parentChildClassRelationshipMap and if so,
- * returns
- * the resulting classRef scenarioId pair
+ * Passes the given reader and inputClassRef to the built
+ * {@link TranslationEngine} to read, parse and translate the inputData.
*
- * @param the childClass
- * @param the optional parentClass/MarkerInterfaceClass
+ * @param the classType associated with the reader
*/
- Path getOutputPath(String key) {
- if (this.data.outputFilePathMap.containsKey(key)) {
- return this.data.outputFilePathMap.get(key);
+ void readInput(Path path, Class inputClassRef, TranslationEngine translationEngine) {
+ Object appObject;
+ try {
+ appObject = translationEngine.readInput(path, inputClassRef);
+ this.objects.add(appObject);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
}
-
- throw new ContractException(CoreTranslationError.INVALID_OUTPUT_CLASSREF,
- "No path was provided for " + key);
}
/**
- * takes the list of objects and writes each object out to it's corresponding
- * outputFilePath, if it exists
- *
- * internally calls {@link TranslationController#writeOutput(Object)}
+ * writes the given object to the given path using the given translation engine
+ * type
*
- * @param the type of the list of obects to write to output
+ * @param the classType of the object
* @throws ContractException
*
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the class of the object paired with the
- * scenarioId does not have a associated
- * outputFilePath
+ *
{@linkplain CoreTranslationError#NULL_OBJECT_FOR_TRANSLATION}
+ * if the object is null
+ *
{@linkplain CoreTranslationError#NULL_PATH}
+ * if the path is null
+ *
{@linkplain CoreTranslationError#INVALID_OUTPUT_PATH}
+ * if the path does not exist (specifically the parent
+ * directory of the path ie. a/b/c/foo.txt throws this
+ * if a/b/c doesn't exist
*
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
* if translationEngine is null
*
*/
- public void writeOutput(List objects) {
- for (T object : objects) {
- this.writeOutput(object);
- }
+ public void writeOutput(M object, Path path,
+ TranslationEngineType translationEngineType) {
+
+ this.writeOutput(object, Optional.empty(), path, translationEngineType);
}
/**
- * takes the list of objects and writes each object out to it's corresponding
- * outputFilePath using the supplied key, if it exists
- *
- * internally calls {@link TranslationController#writeOutput(Object)}
+ * writes the given object to the given path using the given translation engine
+ * type using the parent class as the actual output type
*
- * @param the type of the list of obects to write to output
+ * @param the classType of the object
* @throws ContractException
*
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the supplied key has no valid outputFilePath
- * mapping
+ *
{@linkplain CoreTranslationError#NULL_CLASS_REF}
+ * if the parent classref is null
+ *
{@linkplain CoreTranslationError#NULL_OBJECT_FOR_TRANSLATION}
+ * if the object is null
+ *
{@linkplain CoreTranslationError#NULL_PATH}
+ * if the path is null
+ *
{@linkplain CoreTranslationError#INVALID_OUTPUT_PATH}
+ * if the path does not exist (specifically the parent
+ * directory of the path ie. a/b/c/foo.txt throws this
+ * if a/b/c doesn't exist
*
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
* if translationEngine is null
*
*/
- public void writeOutput(Map objects) {
- for (String key : objects.keySet()) {
- this.writeOutput(objects.get(key), key);
+ public void writeOutput(M object, Class parentClassRef, Path path,
+ TranslationEngineType translationEngineType) {
+
+ if (parentClassRef == null) {
+ throw new ContractException(CoreTranslationError.NULL_CLASS_REF);
}
+
+ this.writeOutput(object, Optional.of(parentClassRef), path, translationEngineType);
}
- /**
- * takes the list of objects with the specified scenarioId and writes each
- * object out to it's corresponding outputFilePath, if it exists
- *
- * internally calls {@link TranslationController#writeOutput(Object, Integer)}
- *
- * @param the type of the list of obects to write to output
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the class of the object paired with the
- * scenarioId does not have a associated
- * outputFilePath
- *
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
- * if translationEngine is null
- *
- */
- public void writeOutput(List objects, Integer scenarioId) {
- for (T object : objects) {
- this.writeOutput(object, scenarioId);
+ void writeOutput(M object, Optional> parentClassRef, Path path,
+ TranslationEngineType translationEngineType) {
+
+ if (object == null) {
+ throw new ContractException(CoreTranslationError.NULL_OBJECT_FOR_TRANSLATION);
}
- }
- /**
- * takes the given object and writes it out to it's corresponding
- * outputFilePath, if it exists
- *
- * internally calls {@link TranslationController#writeOutput(Object, Integer)}
- * with a scenarioId of 0
- *
- * @param the type of the list of obects to write to output
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the class of the object paired with the
- * scenarioId does not have a associated
- * outputFilePath
- *
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
- * if translationEngine is null
- *
- */
- public void writeOutput(T object) {
- this.writeOutput(object, 0);
- }
+ if (path == null) {
+ throw new ContractException(CoreTranslationError.NULL_PATH);
+ }
- /**
- * takes the given object and scenarioId pair and writes it out to it's
- * corresponding outputFilePath, if it exists
- *
- * @param the classType of the object
- * @param the optional type of the parent class of the object
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the class of the object paired with the
- * scenarioId does not have a associated
- * outputFilePath
- *
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
- * if translationEngine is null
- *
- */
- @SuppressWarnings("unchecked")
- public void writeOutput(M object, Integer scenarioId) {
- // this gives an unchecked warning, surprisingly
- Class classRef = (Class) object.getClass();
+ if (!path.getParent().toFile().exists()) {
+ throw new ContractException(CoreTranslationError.INVALID_OUTPUT_PATH);
+ }
+
+ TranslationEngine translationEngine = this.translationEngines.get(translationEngineType);
- Pair>> keyPair = getOutputPathKey(classRef, scenarioId);
+ if (translationEngine == null) {
+ throw new ContractException(CoreTranslationError.NULL_TRANSLATION_ENGINE);
+ }
- this.writeOutput(object, keyPair.getFirst(), keyPair.getSecond());
+ this.writeOutput(path, object, parentClassRef, translationEngine);
}
/**
- * takes the given object and scenarioId pair and writes it out to it's
- * corresponding outputFilePath, if it exists
+ * Passes the given writer object and optional superClass to the built
+ * {@link TranslationEngine} to translate and write to the outputFile
*
- * @param the classType of the object
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#INVALID_OUTPUT_CLASSREF}
- * if the supplied key has no valid outputFilePath
- * mapping
- *
{@linkplain CoreTranslationError#NULL_TRANSLATION_ENGINE}
- * if translationEngine is null
- *
+ * @param the class of the object to write to the outputFile
+ * @param the optional parent class of the object to write to the outputFile
*/
- public void writeOutput(M object, String key) {
- this.writeOutput(object, key, Optional.empty());
+ void writeOutput(Path path, M object, Optional> superClass,
+ TranslationEngine translationEngine) {
+ try {
+ translationEngine.writeOutput(path, object, superClass);
+ } catch (IOException e) {
+ throw new RuntimeException(e);
+ }
}
- void writeOutput(M object, String key, Optional> parentClassRef) {
- Path path = getOutputPath(key);
-
- TranslationEngineType type = this.data.outputFilePathEngine.get(path);
- TranslationEngine translationEngine = this.translationEngines.get(type);
-
- this.writeOutput(path, object, parentClassRef, translationEngine);
- }
/**
* Searches the list of read in objects and returns the first Object found of
* the given classRef
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 327a1c5..2c4827d 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
@@ -37,7 +37,6 @@ protected TranslationEngine(Data data) {
protected static class Data {
protected final Map, BaseTranslationSpec> classToTranslationSpecMap = new LinkedHashMap<>();
protected final Set translationSpecs = new LinkedHashSet<>();
- protected Map, Class>> childToParentClassMap = new LinkedHashMap<>();
protected TranslationEngineType translationEngineType = TranslationEngineType.UNKNOWN;
protected boolean translatorsInitialized = false;
@@ -112,12 +111,6 @@ private void validateTranslatorNotNull(Translator translator) {
}
}
- private void validateClassRefNotNull(Class> classRef) {
- if (classRef == null) {
- throw new ContractException(CoreTranslationError.NULL_CLASS_REF);
- }
- }
-
void clearBuilder() {
this.data = new Data();
}
@@ -193,38 +186,6 @@ protected final void _addTranslator(Translator translator) {
this.translators.add(translator);
}
- /**
- * Adds the given classRef markerInterace 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
- * output the given class as the markerInterface instead of the concrete class
- *
- * @param the childClass
- * @param the parentClass/MarkerInterfaceClass
- * @throws ContractException
- *
- *
{@linkplain CoreTranslationError#NULL_CLASS_REF}
- * if classRef is null or if markerInterface is
- * null
- *
{@linkplain CoreTranslationError#DUPLICATE_CLASSREF}
- * if child parent relationship has already been
- * added
- *
- */
- public abstract Builder addParentChildClassRelationship(Class classRef, Class markerInterface);
-
- protected final void _addParentChildClassRelationship(Class classRef, Class markerInterface) {
- validateClassRefNotNull(classRef);
- validateClassRefNotNull(markerInterface);
-
- if (this.data.childToParentClassMap.containsKey(classRef)) {
- throw new ContractException(CoreTranslationError.DUPLICATE_CLASSREF);
- }
-
- this.data.childToParentClassMap.put(classRef, markerInterface);
- }
-
/*
* Goes through the list of translators and orders them based on their
* dependencies
@@ -386,16 +347,6 @@ private void validateTranslatorsInitialized() {
}
}
- // This is package access so the TranslationController can access it but nothing
- // else.
- Map, Class>> getChildParentClassMap() {
- Map, Class>> copyMap = new LinkedHashMap<>(this.data.childToParentClassMap);
-
- this.data.childToParentClassMap = null;
-
- return copyMap;
- }
-
/**
* returns the {@link TranslationEngineType} of this TranslationEngine
*
diff --git a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestTranslationEngine.java b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestTranslationEngine.java
index 8fd5373..e0863fa 100644
--- a/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestTranslationEngine.java
+++ b/core/src/main/java/gov/hhs/aspr/ms/taskit/core/testsupport/TestTranslationEngine.java
@@ -98,13 +98,6 @@ public Builder addTranslator(Translator translator) {
return this;
}
-
- @Override
- public Builder addParentChildClassRelationship(Class classRef, Class markerInterface) {
- _addParentChildClassRelationship(classRef, markerInterface);
-
- return this;
- }
}
public static Builder builder() {
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 8bae610..9713bce 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
@@ -8,19 +8,16 @@
import java.io.IOException;
import java.nio.file.Path;
-import java.util.ArrayList;
-import java.util.LinkedHashMap;
import java.util.List;
-import java.util.Map;
import java.util.Optional;
-import org.apache.commons.math3.util.Pair;
import org.junit.jupiter.api.Test;
import gov.hhs.aspr.ms.taskit.core.testsupport.TestObjectUtil;
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.testobject.TestAppChildObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestAppObject;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.TestObjectTranslator;
import gov.hhs.aspr.ms.taskit.core.testsupport.testobject.input.TestInputObject;
@@ -170,13 +167,12 @@ public void testReadInput() {
TranslationController translationController = TranslationController.builder()
.addInputFilePath(filePath.resolve(fileName), TestInputObject.class,
TranslationEngineType.CUSTOM)
- .addOutputFilePath(filePath.resolve(fileName), TestAppObject.class,
- TranslationEngineType.CUSTOM)
.addTranslationEngine(testTranslationEngine).build();
TestAppObject expectedAppObject = TestObjectUtil.generateTestAppObject();
- translationController.writeOutput(expectedAppObject);
+ translationController.writeOutput(expectedAppObject, filePath.resolve(fileName),
+ TranslationEngineType.CUSTOM);
translationController.readInput();
@@ -223,112 +219,23 @@ public void testWriteOutput_Engine() {
}
@Test
- @UnitTestForCoverage
- public void testGetOutputPathKey() {
- String fileName = "GetOutputPath_1-testOutput.json";
- String fileName2 = "GetOutputPath_2-testOutput.json";
-
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
-
- TranslationController translationController = TranslationController.builder()
- .addTranslationEngine(TestTranslationEngine.builder().build())
- .addOutputFilePath(filePath.resolve(fileName), TestAppObject.class,
- TranslationEngineType.CUSTOM)
- .addOutputFilePath(filePath.resolve(fileName2), Object.class, 1,
- TranslationEngineType.CUSTOM)
- .addParentChildClassRelationship(TestAppObject.class, Object.class).build();
-
- Pair>> expectedPair1 = new Pair<>(
- TestAppObject.class.getName() + ":" + 0,
- Optional.empty());
- Pair>> expectedPair2 = new Pair<>(Object.class.getName() + ":" + 1,
- Optional.of(Object.class));
-
- Pair>> actualPair1 = translationController
- .getOutputPathKey(TestAppObject.class, 0);
- Pair>> actualPair2 = translationController
- .getOutputPathKey(TestAppObject.class, 1);
-
- assertEquals(expectedPair1, actualPair1);
- assertEquals(expectedPair2, actualPair2);
- // preconditions
-
- // if the class scenarioId pair does not exist and there is no parent child
- // class relationship
- ContractException contractException = assertThrows(ContractException.class, () -> {
- translationController.getOutputPathKey(TestInputObject.class, 1);
- });
-
- assertEquals(CoreTranslationError.INVALID_OUTPUT_CLASSREF, contractException.getErrorType());
-
- // if the class and scenarioID pair does not exist AND there is a parent child
- // class relationship AND the parentClass scenarioId pair does not exists
- contractException = assertThrows(ContractException.class, () -> {
- translationController.getOutputPathKey(TestAppObject.class, 4);
- });
-
- assertEquals(CoreTranslationError.INVALID_OUTPUT_CLASSREF, contractException.getErrorType());
- }
-
- @Test
- @UnitTestMethod(target = TranslationController.class, name = "writeOutput", args = { List.class })
- public void testWriteOutput_List() {
- String fileName = "WriteOutput_List_1-testOutput.json";
- String fileName2 = "WriteOutput_List_2-testOutput.json";
-
- ResourceHelper.createOutputFile(filePath, fileName);
- ResourceHelper.createOutputFile(filePath, fileName2);
-
- TestTranslationEngine testTranslationEngine = TestTranslationEngine.builder()
- .addTranslator(TestObjectTranslator.getTranslator())
- .addTranslator(TestComplexObjectTranslator.getTranslator()).build();
-
- TranslationController translationController = TranslationController.builder()
- .addOutputFilePath(filePath.resolve(fileName), TestAppObject.class,
- TranslationEngineType.CUSTOM)
- .addOutputFilePath(filePath.resolve(fileName2), TestComplexAppObject.class,
- TranslationEngineType.CUSTOM)
- .addTranslationEngine(testTranslationEngine).build();
-
- List
From 306719d11371549006f1217980ecde7ab0ee4a89 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sat, 6 Apr 2024 00:24:01 -0400
Subject: [PATCH 08/15] Bump org.apache.maven.plugins:maven-source-plugin (#44)
Bumps the standard-plugins group with 1 update: [org.apache.maven.plugins:maven-source-plugin](https://github.com/apache/maven-source-plugin).
Updates `org.apache.maven.plugins:maven-source-plugin` from 3.3.0 to 3.3.1
- [Commits](https://github.com/apache/maven-source-plugin/compare/maven-source-plugin-3.3.0...maven-source-plugin-3.3.1)
---
updated-dependencies:
- dependency-name: org.apache.maven.plugins:maven-source-plugin
dependency-type: direct:production
update-type: version-update:semver-patch
dependency-group: standard-plugins
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index c7163e6..0174802 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
1.6.03.2.5
- 3.3.0
+ 3.3.13.1.13.1.13.6.3
From 05b362c05075e5f36632489ff9e25df7cad6bcf1 Mon Sep 17 00:00:00 2001
From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com>
Date: Sat, 6 Apr 2024 00:24:45 -0400
Subject: [PATCH 09/15] Bump org.jacoco:jacoco-maven-plugin in the
test-dependencies group (#45)
Bumps the test-dependencies group with 1 update: [org.jacoco:jacoco-maven-plugin](https://github.com/jacoco/jacoco).
Updates `org.jacoco:jacoco-maven-plugin` from 0.8.11 to 0.8.12
- [Release notes](https://github.com/jacoco/jacoco/releases)
- [Commits](https://github.com/jacoco/jacoco/compare/v0.8.11...v0.8.12)
---
updated-dependencies:
- dependency-name: org.jacoco:jacoco-maven-plugin
dependency-type: direct:development
update-type: version-update:semver-patch
dependency-group: test-dependencies
...
Signed-off-by: dependabot[bot]
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 0174802..519939c 100644
--- a/pom.xml
+++ b/pom.xml
@@ -60,7 +60,7 @@
2.10.14.1.15.10.2
- 0.8.11
+ 0.8.12
From 238cb80019c8f373ee6901de38859f4b89f91380 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Mon, 8 Apr 2024 16:47:26 -0400
Subject: [PATCH 10/15] update pom project url
---
core/pom.xml | 3 ++-
protobuf/pom.xml | 3 ++-
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/core/pom.xml b/core/pom.xml
index 4984da0..d94c3b2 100644
--- a/core/pom.xml
+++ b/core/pom.xml
@@ -17,7 +17,8 @@
Translation and Serialization Toolkit (Taskit): CoreThe core components of a toolkit that aids in the conversion between two Java objects, primiarly for use with coverting between an input Java object and a application Java object.
-
+ https://github.com/HHS/aspr-ms-taskit
+
scm:git:git://github.com/HHS/aspr-ms-taskit.git
diff --git a/protobuf/pom.xml b/protobuf/pom.xml
index b271fdb..97794bf 100644
--- a/protobuf/pom.xml
+++ b/protobuf/pom.xml
@@ -17,7 +17,8 @@
Translation and Serialization Toolkit (Taskit): ProtobufA toolkit that aids in the conversion between Protobuf Java objects and application Java objects.
-
+ https://github.com/HHS/aspr-ms-taskit
+
scm:git:git://github.com/HHS/aspr-ms-taskit.git
From 75704859de3ed9b4c7b20595a182bded8608a9a6 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Fri, 12 Apr 2024 00:09:08 -0400
Subject: [PATCH 11/15] add shawn to developer section in pom
---
pom.xml | 8 +++++++-
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index 18316c6..c845e23 100644
--- a/pom.xml
+++ b/pom.xml
@@ -20,7 +20,7 @@
https://www.gnu.org/licenses/gpl-3.0.en.html
- Vulnerability Disclosure Policy
+ HHS Vulnerability Disclosure Policyhttps://www.hhs.gov/vulnerability-disclosure-policy/index.html
@@ -33,6 +33,12 @@
zachary.bischoff@leidos.comhttps://www.leidos.com
+
+ Shawn Hatch
+ Leidos
+ shawn.hatch@leidos.com
+ https://www.leidos.com
+
From c8935af326fd2089fe828228cfcea648e9c3a364 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Sun, 14 Apr 2024 23:26:34 -0400
Subject: [PATCH 12/15] update README
---
README.md | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/README.md b/README.md
index e14f8ee..4969cbb 100644
--- a/README.md
+++ b/README.md
@@ -73,7 +73,7 @@ See [TestObject](protobuf/src/main/proto/gov/hhs/aspr/ms/taskit/protobuf/testobj
- Favorite IDE for Java development
- Modeling Util located [here](https://github.com/HHS/ASPR-ms-util)
-*Note that Modeling Util is in Maven Central, so there is no need to download and build it.
+*Note that Modeling Util is in Maven Central, so there is no need to clone and build it.
### Building
To build this project:
From ac694b7c4db1fa5c195c2c82e9d93cb461f145a4 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Sun, 14 Apr 2024 23:26:55 -0400
Subject: [PATCH 13/15] update README
---
README.md | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/README.md b/README.md
index 4969cbb..7120523 100644
--- a/README.md
+++ b/README.md
@@ -71,9 +71,9 @@ See [TestObject](protobuf/src/main/proto/gov/hhs/aspr/ms/taskit/protobuf/testobj
- Maven 3.8.x
- Java 17
- Favorite IDE for Java development
-- Modeling Util located [here](https://github.com/HHS/ASPR-ms-util)
+- Modeling Utilities located [here](https://github.com/HHS/ASPR-ms-util)
-*Note that Modeling Util is in Maven Central, so there is no need to clone and build it.
+*Note that Modeling Utilities is in Maven Central, so there is no need to clone and build it.
### Building
To build this project:
From ef4e86e2a9eaff2fed2f3fa18976673aeac013d3 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Sun, 14 Apr 2024 23:55:59 -0400
Subject: [PATCH 14/15] update workflows
---
.github/workflows/dev_build.yml | 2 +-
.github/workflows/release_build.yml | 2 +-
.github/workflows/release_pr_build.yml | 12 +++++++++++-
3 files changed, 13 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/dev_build.yml b/.github/workflows/dev_build.yml
index 547308a..1ff8580 100644
--- a/.github/workflows/dev_build.yml
+++ b/.github/workflows/dev_build.yml
@@ -15,7 +15,7 @@ on:
branches-ignore: ["main"]
jobs:
- build:
+ dev-build:
runs-on: ubuntu-latest
steps:
- name: Checkout Taskit
diff --git a/.github/workflows/release_build.yml b/.github/workflows/release_build.yml
index 6203c86..44b8aa6 100644
--- a/.github/workflows/release_build.yml
+++ b/.github/workflows/release_build.yml
@@ -16,7 +16,7 @@ on:
branches: ["main"]
jobs:
- create-release:
+ release:
runs-on: ubuntu-latest
permissions:
contents: write
diff --git a/.github/workflows/release_pr_build.yml b/.github/workflows/release_pr_build.yml
index 4fb97f0..7637c30 100644
--- a/.github/workflows/release_pr_build.yml
+++ b/.github/workflows/release_pr_build.yml
@@ -13,7 +13,7 @@ on:
branches: ["main"]
jobs:
- main-build:
+ release-pr-build:
runs-on: ubuntu-latest
permissions:
contents: write
@@ -26,6 +26,16 @@ jobs:
with:
java-version: '17'
distribution: 'temurin'
+
+ - name: Get Version
+ run: |
+ echo "version=$(mvn help:evaluate -Dexpression=project.version -q -DforceStdout --file pom.xml)" >> "$GITHUB_ENV"
+ - name: Version Is Snapshot
+ if: ${{ endsWith(env.version, 'SNAPSHOT') }}
+ run: |
+ echo "::error Version is a SNAPSHOT. Update version to proper version."
+ exit 1
+
- name: Build Taskit
run: mvn clean install -Pjavadoc,jacoco --file pom.xml
\ No newline at end of file
From 9cfa3c49be7c77263070e918c158539b7f6332a9 Mon Sep 17 00:00:00 2001
From: bischoffz
Date: Mon, 15 Apr 2024 01:15:19 -0400
Subject: [PATCH 15/15] update to 4.0.0 proper
---
pom.xml | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/pom.xml b/pom.xml
index c845e23..01390b8 100644
--- a/pom.xml
+++ b/pom.xml
@@ -51,7 +51,7 @@
- 4.0.0-SNAPSHOT
+ 4.0.0UTF-8