diff --git a/pom.xml b/pom.xml index d1e669c..6d9645c 100644 --- a/pom.xml +++ b/pom.xml @@ -7,8 +7,8 @@ gov.hhs.aspr.ms util - 4.0.0 - jar + 4.1.0 + jar Modeling Utils A suite of utility methods that are useful for simulation frameworks. @@ -53,15 +53,15 @@ 17 - 3.0.0-M5 - 3.2.1 - 3.5.0 + 3.2.5 + 3.3.0 + 3.6.3 3.6.1 1.0 - 5.8.2 - 0.8.9 + 5.10.2 + 0.8.11 @@ -215,4 +215,4 @@ - \ No newline at end of file + diff --git a/src/main/java/util/annotations/UnitTag.java b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTag.java similarity index 91% rename from src/main/java/util/annotations/UnitTag.java rename to src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTag.java index 07e78a8..4732418 100644 --- a/src/main/java/util/annotations/UnitTag.java +++ b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTag.java @@ -1,4 +1,4 @@ -package util.annotations; +package gov.hhs.aspr.ms.util.annotations; public enum UnitTag { /* diff --git a/src/main/java/util/annotations/UnitTestConstructor.java b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestConstructor.java similarity index 92% rename from src/main/java/util/annotations/UnitTestConstructor.java rename to src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestConstructor.java index 78d0910..6cffa1c 100644 --- a/src/main/java/util/annotations/UnitTestConstructor.java +++ b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestConstructor.java @@ -1,4 +1,4 @@ -package util.annotations; +package gov.hhs.aspr.ms.util.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/util/annotations/UnitTestField.java b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestField.java similarity index 91% rename from src/main/java/util/annotations/UnitTestField.java rename to src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestField.java index 4b18a3d..58fc169 100644 --- a/src/main/java/util/annotations/UnitTestField.java +++ b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestField.java @@ -1,4 +1,4 @@ -package util.annotations; +package gov.hhs.aspr.ms.util.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/util/annotations/UnitTestForCoverage.java b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestForCoverage.java similarity index 90% rename from src/main/java/util/annotations/UnitTestForCoverage.java rename to src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestForCoverage.java index 0121199..513b54d 100644 --- a/src/main/java/util/annotations/UnitTestForCoverage.java +++ b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestForCoverage.java @@ -1,4 +1,4 @@ -package util.annotations; +package gov.hhs.aspr.ms.util.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/util/annotations/UnitTestMethod.java b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestMethod.java similarity index 92% rename from src/main/java/util/annotations/UnitTestMethod.java rename to src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestMethod.java index da73e29..10f335c 100644 --- a/src/main/java/util/annotations/UnitTestMethod.java +++ b/src/main/java/gov/hhs/aspr/ms/util/annotations/UnitTestMethod.java @@ -1,4 +1,4 @@ -package util.annotations; +package gov.hhs.aspr.ms.util.annotations; import java.lang.annotation.Documented; import java.lang.annotation.ElementType; diff --git a/src/main/java/gov/hhs/aspr/ms/util/combinatorics/TupleGenerator.java b/src/main/java/gov/hhs/aspr/ms/util/combinatorics/TupleGenerator.java new file mode 100644 index 0000000..8e9b38a --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/combinatorics/TupleGenerator.java @@ -0,0 +1,98 @@ +package gov.hhs.aspr.ms.util.combinatorics; + +import java.util.ArrayList; +import java.util.List; + +/** + * Utility class for generating tuples from a fixed set of finite ranges of the + * form [0,n). Uses a standard builder pattern for construction. + */ +public final class TupleGenerator { + private final int[] moduli; + private final int[] dimensions; + private final int size; + + private TupleGenerator(List dimensionSizes) { + dimensions = new int[dimensionSizes.size()]; + moduli = new int[dimensionSizes.size()]; + + int count = 1; + for (int i = 0; i < dimensionSizes.size(); i++) { + int dimSize = dimensionSizes.get(i); + dimensions[i] = dimSize; + moduli[i] = count; + count *= dimSize; + } + size = count; + } + + /** + * Returns the number of dimensions in this {@link TupleGenerator}. + */ + public int dimensions() { + return dimensions.length; + } + + /** + * Returns the number of tuples that can be generated by this {@link TupleGenerator} + */ + public int size() { + return size; + } + + /** + * Fills the given tuple with the values that correspond to the given index. + * + * @throws IndexOutOfBoundsException + * + * @throws IllegalArgumentException + * + */ + public void fillTuple(int index, int[] tuple) { + if ((index < 0) || (index >= size)) { + throw new IndexOutOfBoundsException("index out of bounds"); + } + + if (tuple == null) { + throw new IllegalArgumentException("null array"); + } + + if (tuple.length != dimensions.length) { + throw new IllegalArgumentException("wrong number of dimensions"); + } + + for (int i = 0; i < dimensions.length; i++) { + tuple[i] = (index / moduli[i]) % dimensions[i]; + } + } + + public static Builder builder() { + return new Builder(); + } + + public static class Builder { + private List dimensionSizes = new ArrayList<>(); + + private Builder() { + } + + public TupleGenerator build() { + return new TupleGenerator(dimensionSizes); + } + + public Builder addDimension(int dimensionSize) { + if (dimensionSize <= 0) { + throw new IllegalArgumentException("Non positive dimension size"); + } + dimensionSizes.add(dimensionSize); + return this; + } + } +} diff --git a/src/main/java/util/delaunay/GeoDelaunaySolver.java b/src/main/java/gov/hhs/aspr/ms/util/delaunay/GeoDelaunaySolver.java similarity index 98% rename from src/main/java/util/delaunay/GeoDelaunaySolver.java rename to src/main/java/gov/hhs/aspr/ms/util/delaunay/GeoDelaunaySolver.java index 89645f3..2906ace 100644 --- a/src/main/java/util/delaunay/GeoDelaunaySolver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/delaunay/GeoDelaunaySolver.java @@ -1,4 +1,4 @@ -package util.delaunay; +package gov.hhs.aspr.ms.util.delaunay; import java.util.ArrayList; import java.util.Arrays; @@ -10,10 +10,10 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.dimensiontree.VolumetricDimensionTree; -import util.earth.LatLon; -import util.vector.MutableVector3D; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.dimensiontree.VolumetricDimensionTree; +import gov.hhs.aspr.ms.util.earth.LatLon; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class GeoDelaunaySolver { diff --git a/src/main/java/util/delaunay/PlanarDelaunaySolver.java b/src/main/java/gov/hhs/aspr/ms/util/delaunay/PlanarDelaunaySolver.java similarity index 97% rename from src/main/java/util/delaunay/PlanarDelaunaySolver.java rename to src/main/java/gov/hhs/aspr/ms/util/delaunay/PlanarDelaunaySolver.java index 980b936..1f8181d 100644 --- a/src/main/java/util/delaunay/PlanarDelaunaySolver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/delaunay/PlanarDelaunaySolver.java @@ -1,4 +1,4 @@ -package util.delaunay; +package gov.hhs.aspr.ms.util.delaunay; import java.util.ArrayList; import java.util.Arrays; @@ -10,10 +10,10 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.dimensiontree.VolumetricDimensionTree; -import util.spherical.Chirality; -import util.vector.MutableVector2D; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.dimensiontree.VolumetricDimensionTree; +import gov.hhs.aspr.ms.util.spherical.Chirality; +import gov.hhs.aspr.ms.util.vector.MutableVector2D; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class PlanarDelaunaySolver { diff --git a/src/main/java/util/dimensiontree/DimensionTree.java b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTree.java similarity index 99% rename from src/main/java/util/dimensiontree/DimensionTree.java rename to src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTree.java index b31203c..b6b3c22 100644 --- a/src/main/java/util/dimensiontree/DimensionTree.java +++ b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTree.java @@ -1,4 +1,4 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; import java.util.ArrayList; import java.util.Arrays; @@ -9,7 +9,7 @@ import org.apache.commons.math3.util.FastMath; -import util.errors.ContractException; +import gov.hhs.aspr.ms.util.errors.ContractException; /** *

diff --git a/src/main/java/util/dimensiontree/DimensionTreeError.java b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTreeError.java similarity index 81% rename from src/main/java/util/dimensiontree/DimensionTreeError.java rename to src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTreeError.java index 0563f00..1827780 100644 --- a/src/main/java/util/dimensiontree/DimensionTreeError.java +++ b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/DimensionTreeError.java @@ -1,7 +1,7 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; -import util.errors.ContractError; -import util.errors.ContractException; +import gov.hhs.aspr.ms.util.errors.ContractError; +import gov.hhs.aspr.ms.util.errors.ContractException; /** * An enumeration supporting {@link ContractException} that acts as a general diff --git a/src/main/java/util/dimensiontree/VolumetricDimensionTree.java b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/VolumetricDimensionTree.java similarity index 99% rename from src/main/java/util/dimensiontree/VolumetricDimensionTree.java rename to src/main/java/gov/hhs/aspr/ms/util/dimensiontree/VolumetricDimensionTree.java index 9b23706..333b8e6 100644 --- a/src/main/java/util/dimensiontree/VolumetricDimensionTree.java +++ b/src/main/java/gov/hhs/aspr/ms/util/dimensiontree/VolumetricDimensionTree.java @@ -1,4 +1,4 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/util/earth/Earth.java b/src/main/java/gov/hhs/aspr/ms/util/earth/Earth.java similarity index 98% rename from src/main/java/util/earth/Earth.java rename to src/main/java/gov/hhs/aspr/ms/util/earth/Earth.java index 5f5fc43..72ed877 100644 --- a/src/main/java/util/earth/Earth.java +++ b/src/main/java/gov/hhs/aspr/ms/util/earth/Earth.java @@ -1,8 +1,8 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import org.apache.commons.math3.util.FastMath; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; /** * A spherical geo-model for converting various coordinate representations and diff --git a/src/main/java/util/earth/EarthGrid.java b/src/main/java/gov/hhs/aspr/ms/util/earth/EarthGrid.java similarity index 93% rename from src/main/java/util/earth/EarthGrid.java rename to src/main/java/gov/hhs/aspr/ms/util/earth/EarthGrid.java index d6b60c5..16fdef7 100644 --- a/src/main/java/util/earth/EarthGrid.java +++ b/src/main/java/gov/hhs/aspr/ms/util/earth/EarthGrid.java @@ -1,10 +1,10 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import org.apache.commons.math3.util.FastMath; -import util.vector.MutableVector3D; -import util.vector.Vector2D; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector2D; +import gov.hhs.aspr.ms.util.vector.Vector3D; /** * A utility class for converting (x,y) two dimensional grid coordinates to and diff --git a/src/main/java/util/earth/LatLon.java b/src/main/java/gov/hhs/aspr/ms/util/earth/LatLon.java similarity index 98% rename from src/main/java/util/earth/LatLon.java rename to src/main/java/gov/hhs/aspr/ms/util/earth/LatLon.java index f010123..8a921f1 100644 --- a/src/main/java/util/earth/LatLon.java +++ b/src/main/java/gov/hhs/aspr/ms/util/earth/LatLon.java @@ -1,4 +1,4 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import net.jcip.annotations.Immutable; diff --git a/src/main/java/util/earth/LatLonAlt.java b/src/main/java/gov/hhs/aspr/ms/util/earth/LatLonAlt.java similarity index 98% rename from src/main/java/util/earth/LatLonAlt.java rename to src/main/java/gov/hhs/aspr/ms/util/earth/LatLonAlt.java index 13243ce..8b30cc5 100644 --- a/src/main/java/util/earth/LatLonAlt.java +++ b/src/main/java/gov/hhs/aspr/ms/util/earth/LatLonAlt.java @@ -1,6 +1,6 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class LatLonAlt { diff --git a/src/main/java/util/errors/ContractError.java b/src/main/java/gov/hhs/aspr/ms/util/errors/ContractError.java similarity index 86% rename from src/main/java/util/errors/ContractError.java rename to src/main/java/gov/hhs/aspr/ms/util/errors/ContractError.java index 9a3f81d..e9a773e 100644 --- a/src/main/java/util/errors/ContractError.java +++ b/src/main/java/gov/hhs/aspr/ms/util/errors/ContractError.java @@ -1,5 +1,5 @@ -package util.errors; +package gov.hhs.aspr.ms.util.errors; /** * Marker interface for the descriptions of runtime exceptions where the source diff --git a/src/main/java/util/errors/ContractException.java b/src/main/java/gov/hhs/aspr/ms/util/errors/ContractException.java similarity index 97% rename from src/main/java/util/errors/ContractException.java rename to src/main/java/gov/hhs/aspr/ms/util/errors/ContractException.java index fa98fd3..f93a3e9 100644 --- a/src/main/java/util/errors/ContractException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/errors/ContractException.java @@ -1,4 +1,4 @@ -package util.errors; +package gov.hhs.aspr.ms.util.errors; /** * A {@link RuntimeException} that indicates that the cause of the error as a diff --git a/src/main/java/util/geolocator/GeoLocator.java b/src/main/java/gov/hhs/aspr/ms/util/geolocator/GeoLocator.java similarity index 96% rename from src/main/java/util/geolocator/GeoLocator.java rename to src/main/java/gov/hhs/aspr/ms/util/geolocator/GeoLocator.java index 5768131..8f74c72 100644 --- a/src/main/java/util/geolocator/GeoLocator.java +++ b/src/main/java/gov/hhs/aspr/ms/util/geolocator/GeoLocator.java @@ -1,4 +1,4 @@ -package util.geolocator; +package gov.hhs.aspr.ms.util.geolocator; import java.util.ArrayList; import java.util.Comparator; @@ -9,11 +9,11 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.dimensiontree.DimensionTree; -import util.earth.Earth; -import util.earth.LatLonAlt; -import util.vector.Vector2D; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.dimensiontree.DimensionTree; +import gov.hhs.aspr.ms.util.earth.Earth; +import gov.hhs.aspr.ms.util.earth.LatLonAlt; +import gov.hhs.aspr.ms.util.vector.Vector2D; +import gov.hhs.aspr.ms.util.vector.Vector3D; /** * A generics-based utility class for managing point locations on a spherical diff --git a/src/main/java/util/graph/Graph.java b/src/main/java/gov/hhs/aspr/ms/util/graph/Graph.java similarity index 99% rename from src/main/java/util/graph/Graph.java rename to src/main/java/gov/hhs/aspr/ms/util/graph/Graph.java index d05daa7..edc59d9 100644 --- a/src/main/java/util/graph/Graph.java +++ b/src/main/java/gov/hhs/aspr/ms/util/graph/Graph.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import java.util.List; diff --git a/src/main/java/util/graph/GraphDepthEvaluator.java b/src/main/java/gov/hhs/aspr/ms/util/graph/GraphDepthEvaluator.java similarity index 98% rename from src/main/java/util/graph/GraphDepthEvaluator.java rename to src/main/java/gov/hhs/aspr/ms/util/graph/GraphDepthEvaluator.java index 58cd4fd..292e56c 100644 --- a/src/main/java/util/graph/GraphDepthEvaluator.java +++ b/src/main/java/gov/hhs/aspr/ms/util/graph/GraphDepthEvaluator.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/src/main/java/util/graph/Graphs.java b/src/main/java/gov/hhs/aspr/ms/util/graph/Graphs.java similarity index 98% rename from src/main/java/util/graph/Graphs.java rename to src/main/java/gov/hhs/aspr/ms/util/graph/Graphs.java index fa98005..f495e59 100644 --- a/src/main/java/util/graph/Graphs.java +++ b/src/main/java/gov/hhs/aspr/ms/util/graph/Graphs.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -9,8 +9,8 @@ import java.util.Optional; import java.util.Set; -import util.path.Path; -import util.path.Paths; +import gov.hhs.aspr.ms.util.path.Path; +import gov.hhs.aspr.ms.util.path.Paths; public final class Graphs { diff --git a/src/main/java/util/graph/MutableGraph.java b/src/main/java/gov/hhs/aspr/ms/util/graph/MutableGraph.java similarity index 99% rename from src/main/java/util/graph/MutableGraph.java rename to src/main/java/gov/hhs/aspr/ms/util/graph/MutableGraph.java index 2210d0e..62d9090 100644 --- a/src/main/java/util/graph/MutableGraph.java +++ b/src/main/java/gov/hhs/aspr/ms/util/graph/MutableGraph.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import java.util.ArrayList; import java.util.LinkedHashMap; diff --git a/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer2.java b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer2.java new file mode 100644 index 0000000..f286f07 --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer2.java @@ -0,0 +1,63 @@ +package gov.hhs.aspr.ms.util.indexer; + +import gov.hhs.aspr.ms.util.errors.ContractException; +import net.jcip.annotations.ThreadSafe; + +/** + * A thread safe, immutable index converter that supports treating a 2D array as + * a 1D array. + */ + +@ThreadSafe +public final class Indexer2 { + + private final int size; + + private final int p1; + + /** + * Constructs an 2D indexer from the given dimension sizes + * + * @throws ContractException + *

    + *
  • {@linkplain IndexerError#NEGATIVE_DIMENSION_SIZE} + * if any dimension has a negative size
  • + *
  • {@linkplain IndexerError#EXCEEDS_MAX_ARRAY_SIZE} + * if the product of the dimensions exceeds max + * int
  • + *
+ * + * + */ + public Indexer2(final int dim1, final int dim2) { + if (dim1 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim2 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + try { + p1 = dim2; + size = Math.multiplyExact(p1, dim1); + } catch (ArithmeticException e) { + throw new ContractException(IndexerError.EXCEEDS_MAX_ARRAY_SIZE); + } + } + + /** + * Returns the combined index = index1*dim2+index2 from the given index values. + * No validation of the indexes or the result is provided. + */ + public int index(final int index1, final int index2) { + return index1 * p1 + index2; + } + + /** + * Returns the size (product of the dimensions) of the array supported by this + * index. + */ + public int size() { + return size; + } + +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer3.java b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer3.java new file mode 100644 index 0000000..e78a16a --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer3.java @@ -0,0 +1,63 @@ +package gov.hhs.aspr.ms.util.indexer; + +import gov.hhs.aspr.ms.util.errors.ContractException; + +/** + * A thread safe, immutable index converter that supports treating a 3D array as + * a 1D array. + */ +public final class Indexer3 { + private final int size; + private final int p1; + private final int p2; + + /** + * Constructs an 3D indexer from the given dimension sizes + * + * @throws ContractException + *
    + *
  • {@linkplain IndexerError#NEGATIVE_DIMENSION_SIZE} + * if any dimension has a negative size
  • + *
  • {@linkplain IndexerError#EXCEEDS_MAX_ARRAY_SIZE} + * if the product of the dimensions exceeds max + * int
  • + *
+ * + * + */ + public Indexer3(final int dim1, final int dim2, final int dim3) { + if (dim1 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim2 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim3 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + + try { + p2 = dim3; + p1 = Math.multiplyExact(p2, dim2); + size = Math.multiplyExact(p1, dim1); + } catch (ArithmeticException e) { + throw new ContractException(IndexerError.EXCEEDS_MAX_ARRAY_SIZE); + } + } + + /** + * Returns the combined index = (index1*dim2 +index2)*dim3+index3 from the given + * index values. No validation of the indexes or the result is provided. + */ + public int index(final int index1, final int index2, final int index3) { + return index1 * p1 + index2 * p2 + index3; + } + + /** + * Returns the size (product of the dimensions) of the array supported by this + * index. + */ + public int size() { + return size; + } +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer4.java b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer4.java new file mode 100644 index 0000000..fa76a89 --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer4.java @@ -0,0 +1,70 @@ +package gov.hhs.aspr.ms.util.indexer; + +import gov.hhs.aspr.ms.util.errors.ContractException; + +/** + * A thread safe, immutable index converter that supports treating a 4D array as + * a 1D array. + */ +public final class Indexer4 { + private final int size; + private final int p1; + private final int p2; + private final int p3; + + /** + * Constructs an 4D indexer from the given dimension sizes + * + * @throws ContractException + *
    + *
  • {@linkplain IndexerError#NEGATIVE_DIMENSION_SIZE} + * if any dimension has a negative size
  • + *
  • {@linkplain IndexerError#EXCEEDS_MAX_ARRAY_SIZE} + * if the product of the dimensions exceeds max + * int
  • + *
+ * + * + */ + public Indexer4(final int dim1, final int dim2, final int dim3, final int dim4) { + if (dim1 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim2 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim3 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim4 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + + try { + p3 = dim4; + p2 = Math.multiplyExact(p3, dim3); + p1 = Math.multiplyExact(p2, dim2); + size = Math.multiplyExact(p1, dim1); + } catch (ArithmeticException e) { + throw new ContractException(IndexerError.EXCEEDS_MAX_ARRAY_SIZE); + } + } + + /** + * Returns the combined index = ((index1*dim2 +index2)*dim3+index3)*dim4+index4 + * from the given index values. No validation of the indexes or the result is + * provided. + */ + public int index(final int index1, final int index2, final int index3, final int index4) { + return index1 * p1 + index2 * p2 + index3 * p3 + index4; + } + + /** + * Returns the size (product of the dimensions) of the array supported by this + * index. + */ + public int size() { + return size; + } + +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer5.java b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer5.java new file mode 100644 index 0000000..b66736a --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/indexer/Indexer5.java @@ -0,0 +1,76 @@ +package gov.hhs.aspr.ms.util.indexer; + +import gov.hhs.aspr.ms.util.errors.ContractException; + +/** + * A thread safe, immutable index converter that supports treating a 5D array as + * a 1D array. + */ +public final class Indexer5 { + private final int size; + private final int p1; + private final int p2; + private final int p3; + private final int p4; + + /** + * Constructs an 5D indexer from the given dimension sizes + * + * @throws ContractException + *
    + *
  • {@linkplain IndexerError#NEGATIVE_DIMENSION_SIZE} + * if any dimension has a negative size
  • + *
  • {@linkplain IndexerError#EXCEEDS_MAX_ARRAY_SIZE} + * if the product of the dimensions exceeds max + * int
  • + *
+ * + * + */ + public Indexer5(final int dim1, final int dim2, final int dim3, final int dim4, final int dim5) { + if (dim1 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim2 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim3 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim4 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + if (dim5 < 0) { + throw new ContractException(IndexerError.NEGATIVE_DIMENSION_SIZE); + } + + try { + p4 = dim5; + p3 = Math.multiplyExact(p4, dim4); + p2 = Math.multiplyExact(p3, dim3); + p1 = Math.multiplyExact(p2, dim2); + size = Math.multiplyExact(p1, dim1); + } catch (ArithmeticException e) { + throw new ContractException(IndexerError.EXCEEDS_MAX_ARRAY_SIZE); + } + + } + + /** + * Returns the combined index = (((index1*dim2 + * +index2)*dim3+index3)*dim4+index4)*dim5+index5 from the given index values. + * No validation of the indexes or the result is provided. + */ + public int index(final int index1, final int index2, final int index3, final int index4, final int index5) { + return index1 * p1 + index2 * p2 + index3 * p3 + index4 * p4 + index5; + } + + /** + * Returns the size (product of the dimensions) of the array supported by this + * index. + */ + public int size() { + return size; + } + +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/indexer/IndexerError.java b/src/main/java/gov/hhs/aspr/ms/util/indexer/IndexerError.java new file mode 100644 index 0000000..ba91b83 --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/indexer/IndexerError.java @@ -0,0 +1,27 @@ +package gov.hhs.aspr.ms.util.indexer; + +import gov.hhs.aspr.ms.util.errors.ContractError; +import gov.hhs.aspr.ms.util.errors.ContractException; + +/** + * An enumeration supporting {@link ContractException} that acts as a general + * description of the exception. + */ +public enum IndexerError implements ContractError { + NEGATIVE_DIMENSION_SIZE("Negative dimension size"), + EXCEEDS_MAX_ARRAY_SIZE("The size exceeds max int"), + ; + + + + private final String description; + + private IndexerError(final String description) { + this.description = description; + } + + @Override + public String getDescription() { + return description; + } +} diff --git a/src/main/java/util/maps/MapReindexer.java b/src/main/java/gov/hhs/aspr/ms/util/maps/MapReindexer.java similarity index 93% rename from src/main/java/util/maps/MapReindexer.java rename to src/main/java/gov/hhs/aspr/ms/util/maps/MapReindexer.java index 7332bee..1356eb5 100644 --- a/src/main/java/util/maps/MapReindexer.java +++ b/src/main/java/gov/hhs/aspr/ms/util/maps/MapReindexer.java @@ -1,4 +1,4 @@ -package util.maps; +package gov.hhs.aspr.ms.util.maps; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/ClassGraphDriver.java similarity index 51% rename from src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/ClassGraphDriver.java index b3d1d43..16899b2 100644 --- a/src/main/java/util/meta/classdependency/classgraph/ClassGraphDriver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/ClassGraphDriver.java @@ -1,14 +1,14 @@ -package util.meta.classdependency.classgraph; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; -import util.meta.classdependency.classgraph.reports.CircularClassDependencyReport; -import util.meta.classdependency.classgraph.reports.CircularPackageDependencyReport; -import util.meta.classdependency.classgraph.reports.WildCardReport; -import util.meta.classdependency.classgraph.support.ClassDependencyScan; -import util.meta.classdependency.classgraph.support.ClassDependencyScanner; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports.CircularClassDependencyReport; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports.CircularPackageDependencyReport; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports.WildCardReport; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.ClassDependencyScan; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.ClassDependencyScanner; public final class ClassGraphDriver { diff --git a/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java similarity index 85% rename from src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java index 8f8cbc1..4ee8ab1 100644 --- a/src/main/java/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularClassDependencyReport.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.reports; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports; import java.util.LinkedHashSet; import java.util.List; @@ -6,12 +6,12 @@ import java.util.Set; import java.util.stream.Collectors; -import util.graph.Graph; -import util.graph.GraphDepthEvaluator; -import util.graph.Graphs; -import util.graph.MutableGraph; -import util.meta.classdependency.classgraph.support.ClassDependencyScan; -import util.meta.classdependency.classgraph.support.JavaDependency; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.graph.GraphDepthEvaluator; +import gov.hhs.aspr.ms.util.graph.Graphs; +import gov.hhs.aspr.ms.util.graph.MutableGraph; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.ClassDependencyScan; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.JavaDependency; public final class CircularClassDependencyReport { private CircularClassDependencyReport() { diff --git a/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java similarity index 85% rename from src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java index 7db2b93..b82598a 100644 --- a/src/main/java/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/CircularPackageDependencyReport.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.reports; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports; import java.util.LinkedHashSet; import java.util.List; @@ -6,12 +6,12 @@ import java.util.Set; import java.util.stream.Collectors; -import util.graph.Graph; -import util.graph.GraphDepthEvaluator; -import util.graph.Graphs; -import util.graph.MutableGraph; -import util.meta.classdependency.classgraph.support.ClassDependencyScan; -import util.meta.classdependency.classgraph.support.JavaDependency; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.graph.GraphDepthEvaluator; +import gov.hhs.aspr.ms.util.graph.Graphs; +import gov.hhs.aspr.ms.util.graph.MutableGraph; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.ClassDependencyScan; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.JavaDependency; public final class CircularPackageDependencyReport { private CircularPackageDependencyReport() { diff --git a/src/main/java/util/meta/classdependency/classgraph/reports/WildCardReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/WildCardReport.java similarity index 77% rename from src/main/java/util/meta/classdependency/classgraph/reports/WildCardReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/WildCardReport.java index 449df01..2780d3b 100644 --- a/src/main/java/util/meta/classdependency/classgraph/reports/WildCardReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/reports/WildCardReport.java @@ -1,13 +1,13 @@ -package util.meta.classdependency.classgraph.reports; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.reports; import java.util.ArrayList; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; -import util.meta.classdependency.classgraph.support.ClassDependencyScan; -import util.meta.classdependency.classgraph.support.JavaDependency; -import util.meta.classdependency.classgraph.support.JavaRef; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.ClassDependencyScan; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.JavaDependency; +import gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support.JavaRef; public final class WildCardReport { private WildCardReport() { diff --git a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScan.java similarity index 94% rename from src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScan.java index bf9ed3a..ed41f66 100644 --- a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScan.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScan.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.support; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support; import java.util.LinkedHashSet; import java.util.Set; diff --git a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java similarity index 97% rename from src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java index 0d5b89c..cb13c17 100644 --- a/src/main/java/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/ClassDependencyScanner.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.support; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support; import java.io.IOException; import java.nio.file.FileVisitResult; diff --git a/src/main/java/util/meta/classdependency/classgraph/support/JavaDependency.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaDependency.java similarity index 95% rename from src/main/java/util/meta/classdependency/classgraph/support/JavaDependency.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaDependency.java index 4f47d85..0fee9ab 100644 --- a/src/main/java/util/meta/classdependency/classgraph/support/JavaDependency.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaDependency.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.support; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support; import net.jcip.annotations.Immutable; diff --git a/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaRef.java similarity index 95% rename from src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaRef.java index f13fa32..0c59ec3 100644 --- a/src/main/java/util/meta/classdependency/classgraph/support/JavaRef.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/classgraph/support/JavaRef.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.classgraph.support; +package gov.hhs.aspr.ms.util.meta.classdependency.classgraph.support; import net.jcip.annotations.Immutable; diff --git a/src/main/java/util/meta/classdependency/dependency/DependencyGraph.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyGraph.java similarity index 89% rename from src/main/java/util/meta/classdependency/dependency/DependencyGraph.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyGraph.java index c2b4558..709b262 100644 --- a/src/main/java/util/meta/classdependency/dependency/DependencyGraph.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyGraph.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.dependency; +package gov.hhs.aspr.ms.util.meta.classdependency.dependency; import java.io.IOException; import java.nio.file.Files; @@ -7,8 +7,8 @@ import java.util.List; import java.util.Optional; -import util.graph.Graph; -import util.graph.GraphDepthEvaluator; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.graph.GraphDepthEvaluator; public class DependencyGraph { private final Path file; diff --git a/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyTracer.java similarity index 98% rename from src/main/java/util/meta/classdependency/dependency/DependencyTracer.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyTracer.java index b175c34..06ec711 100644 --- a/src/main/java/util/meta/classdependency/dependency/DependencyTracer.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/classdependency/dependency/DependencyTracer.java @@ -1,4 +1,4 @@ -package util.meta.classdependency.dependency; +package gov.hhs.aspr.ms.util.meta.classdependency.dependency; import java.io.IOException; import java.nio.file.FileVisitResult; diff --git a/src/main/java/util/meta/codecount/CodeCountReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/codecount/CodeCountReport.java similarity index 98% rename from src/main/java/util/meta/codecount/CodeCountReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/codecount/CodeCountReport.java index a5b8a66..ab209ad 100644 --- a/src/main/java/util/meta/codecount/CodeCountReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/codecount/CodeCountReport.java @@ -1,4 +1,4 @@ -package util.meta.codecount; +package gov.hhs.aspr.ms.util.meta.codecount; import java.io.IOException; import java.nio.file.FileVisitResult; @@ -17,7 +17,7 @@ import java.util.Objects; import java.util.Set; -import util.wrappers.MutableInteger; +import gov.hhs.aspr.ms.util.wrappers.MutableInteger; public class CodeCountReport { diff --git a/src/main/java/util/meta/packagedependency/PackageDependencyData.java b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyData.java similarity index 96% rename from src/main/java/util/meta/packagedependency/PackageDependencyData.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyData.java index f05d131..456c706 100644 --- a/src/main/java/util/meta/packagedependency/PackageDependencyData.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyData.java @@ -1,12 +1,12 @@ -package util.meta.packagedependency; +package gov.hhs.aspr.ms.util.meta.packagedependency; import java.nio.file.Path; import java.util.LinkedHashSet; import java.util.Set; -import util.graph.Graph; -import util.graph.MutableGraph; -import util.meta.packagedependency.reports.PackageDependencyReport; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.graph.MutableGraph; +import gov.hhs.aspr.ms.util.meta.packagedependency.reports.PackageDependencyReport; /** * An immutable container for holding the primary level of package dependency diff --git a/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyDataGenerator.java similarity index 96% rename from src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyDataGenerator.java index 0cb4251..032d656 100644 --- a/src/main/java/util/meta/packagedependency/PackageDependencyDataGenerator.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/PackageDependencyDataGenerator.java @@ -1,4 +1,4 @@ -package util.meta.packagedependency; +package gov.hhs.aspr.ms.util.meta.packagedependency; import java.io.File; import java.io.IOException; @@ -15,9 +15,9 @@ import java.util.Map; import java.util.Set; -import util.graph.MutableGraph; -import util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails; -import util.meta.packagedependency.PackageDependencyData.PackageRef; +import gov.hhs.aspr.ms.util.graph.MutableGraph; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyData.PackageRef; /** * An utility class for generating a {@linkplain PackageDependencyData} that diff --git a/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/reports/PackageDependencyReport.java similarity index 95% rename from src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/reports/PackageDependencyReport.java index f7bcf70..8aed347 100644 --- a/src/main/java/util/meta/packagedependency/reports/PackageDependencyReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/packagedependency/reports/PackageDependencyReport.java @@ -1,4 +1,4 @@ -package util.meta.packagedependency.reports; +package gov.hhs.aspr.ms.util.meta.packagedependency.reports; import java.nio.file.Path; import java.nio.file.Paths; @@ -7,13 +7,13 @@ import java.util.Optional; import java.util.Set; -import util.graph.Graph; -import util.graph.GraphDepthEvaluator; -import util.graph.Graphs; -import util.meta.packagedependency.PackageDependencyData; -import util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails; -import util.meta.packagedependency.PackageDependencyData.PackageRef; -import util.meta.packagedependency.PackageDependencyDataGenerator; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.graph.GraphDepthEvaluator; +import gov.hhs.aspr.ms.util.graph.Graphs; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyData; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyDataGenerator; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyData.PackageDependencyDetails; +import gov.hhs.aspr.ms.util.meta.packagedependency.PackageDependencyData.PackageRef; /** * A console report detailing java package level dependencies across multiple diff --git a/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoContainer.java similarity index 90% rename from src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoContainer.java index 33e608e..a4f6a14 100644 --- a/src/main/java/util/meta/unittestcoverage/MetaInfoContainer.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoContainer.java @@ -1,14 +1,14 @@ -package util.meta.unittestcoverage; +package gov.hhs.aspr.ms.util.meta.unittestcoverage; import java.util.ArrayList; import java.util.List; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; public final class MetaInfoContainer { private static class Data { diff --git a/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java similarity index 95% rename from src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java index 48dc803..0ee2292 100644 --- a/src/main/java/util/meta/unittestcoverage/MetaInfoGenerator.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/MetaInfoGenerator.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage; +package gov.hhs.aspr.ms.util.meta.unittestcoverage; import java.io.File; import java.io.IOException; @@ -17,14 +17,14 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestForCoverage; -import util.annotations.UnitTestMethod; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; -import util.meta.unittestcoverage.warnings.WarningType; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestForCoverage; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.WarningType; /** * A utility class for generating various warnings on the coverage deficiencies diff --git a/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/IncompleteClassReport.java similarity index 76% rename from src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/IncompleteClassReport.java index 586c5a1..08e40a8 100644 --- a/src/main/java/util/meta/unittestcoverage/reports/IncompleteClassReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/IncompleteClassReport.java @@ -1,16 +1,16 @@ -package util.meta.unittestcoverage.reports; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.reports; import java.nio.file.Path; import java.nio.file.Paths; import java.util.LinkedHashSet; import java.util.Set; -import util.meta.unittestcoverage.MetaInfoContainer; -import util.meta.unittestcoverage.MetaInfoGenerator; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; -import util.meta.unittestcoverage.warnings.WarningType; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoContainer; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoGenerator; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.WarningType; public final class IncompleteClassReport { diff --git a/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MetaInfoReport.java similarity index 89% rename from src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MetaInfoReport.java index f30b9c4..21b6454 100644 --- a/src/main/java/util/meta/unittestcoverage/reports/MetaInfoReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MetaInfoReport.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.reports; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.reports; import java.nio.file.Path; import java.nio.file.Paths; @@ -8,16 +8,16 @@ import java.util.List; import java.util.Map; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.meta.unittestcoverage.MetaInfoContainer; -import util.meta.unittestcoverage.MetaInfoGenerator; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; -import util.meta.unittestcoverage.warnings.WarningType; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoContainer; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoGenerator; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.WarningType; /** * A script covering the details of the GCM Test Plan. It produces a console diff --git a/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MissingTestsReport.java similarity index 86% rename from src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MissingTestsReport.java index 7b4a942..8f5523d 100644 --- a/src/main/java/util/meta/unittestcoverage/reports/MissingTestsReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/MissingTestsReport.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.reports; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.reports; import java.nio.file.Path; import java.nio.file.Paths; @@ -7,12 +7,12 @@ import java.util.Map; import java.util.TreeMap; -import util.meta.unittestcoverage.MetaInfoContainer; -import util.meta.unittestcoverage.MetaInfoGenerator; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; -import util.meta.unittestcoverage.warnings.WarningType; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoContainer; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoGenerator; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.WarningType; /** * A script that produces a console report shows missing unit tests. diff --git a/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/StatusReport.java similarity index 75% rename from src/main/java/util/meta/unittestcoverage/reports/StatusReport.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/StatusReport.java index 2329cca..fa2f776 100644 --- a/src/main/java/util/meta/unittestcoverage/reports/StatusReport.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/reports/StatusReport.java @@ -1,13 +1,13 @@ -package util.meta.unittestcoverage.reports; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.reports; import java.nio.file.Path; import java.nio.file.Paths; -import util.meta.unittestcoverage.MetaInfoContainer; -import util.meta.unittestcoverage.MetaInfoGenerator; -import util.meta.unittestcoverage.warnings.ConstructorWarning; -import util.meta.unittestcoverage.warnings.FieldWarning; -import util.meta.unittestcoverage.warnings.MethodWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoContainer; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.MetaInfoGenerator; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.ConstructorWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.FieldWarning; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings.MethodWarning; public final class StatusReport { diff --git a/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/ConstructorWarning.java similarity index 96% rename from src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/ConstructorWarning.java index 8de1e9a..28a7043 100644 --- a/src/main/java/util/meta/unittestcoverage/warnings/ConstructorWarning.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/ConstructorWarning.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.warnings; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings; import java.lang.reflect.Constructor; diff --git a/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/FieldWarning.java similarity index 96% rename from src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/FieldWarning.java index b4b69c1..3b78e82 100644 --- a/src/main/java/util/meta/unittestcoverage/warnings/FieldWarning.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/FieldWarning.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.warnings; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings; import java.lang.reflect.Field; diff --git a/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/MethodWarning.java similarity index 96% rename from src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/MethodWarning.java index a2e4d62..42356d6 100644 --- a/src/main/java/util/meta/unittestcoverage/warnings/MethodWarning.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/MethodWarning.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.warnings; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings; import java.lang.reflect.Method; diff --git a/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/WarningType.java similarity index 97% rename from src/main/java/util/meta/unittestcoverage/warnings/WarningType.java rename to src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/WarningType.java index 3f538da..162d020 100644 --- a/src/main/java/util/meta/unittestcoverage/warnings/WarningType.java +++ b/src/main/java/gov/hhs/aspr/ms/util/meta/unittestcoverage/warnings/WarningType.java @@ -1,4 +1,4 @@ -package util.meta.unittestcoverage.warnings; +package gov.hhs.aspr.ms.util.meta.unittestcoverage.warnings; public enum WarningType { diff --git a/src/main/java/util/path/ArrayPathSolver.java b/src/main/java/gov/hhs/aspr/ms/util/path/ArrayPathSolver.java similarity index 93% rename from src/main/java/util/path/ArrayPathSolver.java rename to src/main/java/gov/hhs/aspr/ms/util/path/ArrayPathSolver.java index 6f9440b..f92f40a 100644 --- a/src/main/java/util/path/ArrayPathSolver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/path/ArrayPathSolver.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import java.lang.reflect.Array; import java.util.ArrayList; @@ -7,9 +7,9 @@ import java.util.Map; import java.util.Optional; -import util.graph.Graph; -import util.path.Paths.EdgeCostEvaluator; -import util.path.Paths.TravelCostEvaluator; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Paths.EdgeCostEvaluator; +import gov.hhs.aspr.ms.util.path.Paths.TravelCostEvaluator; /** * Manages shortest path solutions for a given graph with reasonable efficiency diff --git a/src/main/java/util/path/MapPathSolver.java b/src/main/java/gov/hhs/aspr/ms/util/path/MapPathSolver.java similarity index 92% rename from src/main/java/util/path/MapPathSolver.java rename to src/main/java/gov/hhs/aspr/ms/util/path/MapPathSolver.java index 6b944e1..511d719 100644 --- a/src/main/java/util/path/MapPathSolver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/path/MapPathSolver.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import java.util.ArrayList; import java.util.LinkedHashMap; @@ -6,10 +6,10 @@ import java.util.Map; import java.util.Optional; -import util.graph.Graph; -import util.path.Paths.EdgeCostEvaluator; -import util.path.Paths.TravelCostEvaluator; -import util.wrappers.MultiKey; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Paths.EdgeCostEvaluator; +import gov.hhs.aspr.ms.util.path.Paths.TravelCostEvaluator; +import gov.hhs.aspr.ms.util.wrappers.MultiKey; /** * Manages shortest path solutions for a given graph with reasonable efficiency diff --git a/src/main/java/util/path/Path.java b/src/main/java/gov/hhs/aspr/ms/util/path/Path.java similarity index 98% rename from src/main/java/util/path/Path.java rename to src/main/java/gov/hhs/aspr/ms/util/path/Path.java index 3688c24..5bd6b71 100644 --- a/src/main/java/util/path/Path.java +++ b/src/main/java/gov/hhs/aspr/ms/util/path/Path.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/util/path/PathSolver.java b/src/main/java/gov/hhs/aspr/ms/util/path/PathSolver.java similarity index 85% rename from src/main/java/util/path/PathSolver.java rename to src/main/java/gov/hhs/aspr/ms/util/path/PathSolver.java index bab218d..d38f03c 100644 --- a/src/main/java/util/path/PathSolver.java +++ b/src/main/java/gov/hhs/aspr/ms/util/path/PathSolver.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import java.util.Optional; diff --git a/src/main/java/util/path/Paths.java b/src/main/java/gov/hhs/aspr/ms/util/path/Paths.java similarity index 98% rename from src/main/java/util/path/Paths.java rename to src/main/java/gov/hhs/aspr/ms/util/path/Paths.java index 3044dcd..d951437 100644 --- a/src/main/java/util/path/Paths.java +++ b/src/main/java/gov/hhs/aspr/ms/util/path/Paths.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import java.util.ArrayList; import java.util.Collections; @@ -8,8 +8,8 @@ import java.util.Optional; import java.util.PriorityQueue; -import util.graph.Graph; -import util.path.Path.Builder; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Path.Builder; /** * Solves a shortest path through a graph from an origin node to a destination diff --git a/src/main/java/util/random/RandomGeneratorProvider.java b/src/main/java/gov/hhs/aspr/ms/util/random/RandomGeneratorProvider.java similarity index 88% rename from src/main/java/util/random/RandomGeneratorProvider.java rename to src/main/java/gov/hhs/aspr/ms/util/random/RandomGeneratorProvider.java index c1662d4..b4a0066 100644 --- a/src/main/java/util/random/RandomGeneratorProvider.java +++ b/src/main/java/gov/hhs/aspr/ms/util/random/RandomGeneratorProvider.java @@ -1,4 +1,4 @@ -package util.random; +package gov.hhs.aspr.ms.util.random; import org.apache.commons.math3.random.RandomGenerator; import org.apache.commons.math3.random.Well44497b; diff --git a/src/main/java/gov/hhs/aspr/ms/util/readers/TextTableReader.java b/src/main/java/gov/hhs/aspr/ms/util/readers/TextTableReader.java new file mode 100644 index 0000000..d454593 --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/readers/TextTableReader.java @@ -0,0 +1,244 @@ +package gov.hhs.aspr.ms.util.readers; + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.nio.file.Path; +import java.util.Arrays; +import java.util.Collections; +import java.util.HashMap; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.function.Consumer; + +public class TextTableReader { + + private TextTableReader() { + } + + public static void readToMap(String delimeter, String expectedHeader, Path filePath, + Consumer> consumer) { + BufferedReader reader = getReader(filePath); + + // assume headers are correct + String[] expectedHeaders = expectedHeader.split(delimeter); + String[] headers = expectedHeaders; + int expectedHeaderLength = expectedHeaders.length; + int headerLength = expectedHeaderLength; + + String headerLine = expectedHeader; + + boolean headerLineRead = false; + + Map valueMap = new LinkedHashMap<>(); + + for (int i = 0; i < expectedHeaders.length; i++) { + valueMap.put(expectedHeaders[i], ""); + } + + try { + String line; + + long lineNumber = 1; + while ((line = reader.readLine()) != null) { + String[] lineValues = line.split(delimeter); + + if (lineIsCommentLine(lineValues[0], delimeter)) { + lineNumber++; + continue; + } + + if (!headerLineRead) { + if (!expectedHeader.equals(line)) { + // ensure that the actual headers and expected headers contain a union + checkHeadersContainExpectedHeaders(lineValues, expectedHeaders, filePath, reader); + + headerLine = line; + headers = lineValues; + headerLength = lineValues.length; + } + + headerLineRead = true; + lineNumber++; + continue; + } + + // do not allow duplicate header lines + checkDuplicateHeaderLine(line, headerLine, filePath, lineNumber, reader); + + // validate that number of values is equal to the number of headers + validateLineLength(lineValues, headerLength, line, headerLine, filePath, lineNumber, reader); + + for (int i = 0; i < lineValues.length; i++) { + String header = headers[i]; + if (valueMap.containsKey(header)) { + valueMap.put(header, lineValues[i]); + } + } + + consumer.accept(Collections.unmodifiableMap(valueMap)); + lineNumber++; + } + reader.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + public static void read(String delimeter, String expectedHeader, Path filePath, Consumer consumer) { + BufferedReader reader = getReader(filePath); + + String[] expectedHeaders = expectedHeader.split(delimeter); + int expectedHeaderLength = expectedHeaders.length; + int headerLength = expectedHeaderLength; + + String headerLine = expectedHeader; + + boolean headerLineRead = false; + boolean headerMatchesExpected = false; + + try { + String line; + // this lookup is only used if the actual header line doesn't match the expected + // header line. So this is safe to do. + int[] headerIndexLookup = new int[0]; + + long lineNumber = 1; + while ((line = reader.readLine()) != null) { + String[] lineValues = line.split(delimeter); + + if (lineIsCommentLine(lineValues[0], delimeter)) { + lineNumber++; + continue; + } + + if (!headerLineRead) { + headerMatchesExpected = expectedHeader.equals(line); + if (!headerMatchesExpected) { + // ensure that the actual headers and expected headers contain a union + checkHeadersContainExpectedHeaders(lineValues, expectedHeaders, filePath, reader); + + headerIndexLookup = processHeaderLine(expectedHeaders, lineValues, delimeter); + headerLine = line; + headerLength = lineValues.length; + } + + headerLineRead = true; + lineNumber++; + continue; + } + + // do not allow duplicate header lines + checkDuplicateHeaderLine(line, headerLine, filePath, lineNumber, reader); + + // validate that number of values is equal to the number of headers + validateLineLength(lineValues, headerLength, line, headerLine, filePath, lineNumber, reader); + + String[] retValues = lineValues; + + if (!headerMatchesExpected) { + retValues = new String[expectedHeaderLength]; + + for (int i = 0; i < lineValues.length; i++) { + int index = headerIndexLookup[i]; + if (index != -1) { + retValues[i] = lineValues[index]; + } + } + } + + consumer.accept(retValues); + lineNumber++; + } + reader.close(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + + private static void checkHeadersContainExpectedHeaders(String[] headers, String[] expectedHeaders, Path filePath, + BufferedReader reader) throws IOException { + List expectedHeadersList = Arrays.asList(expectedHeaders); + List headersList = Arrays.asList(headers); + + if (!headersList.containsAll(expectedHeadersList)) { + reader.close(); + throw new RuntimeException( + "The actual headers do not contain the set of expected headers. Did you forget to put a header line? File: " + + filePath + " Expected Headers: " + expectedHeadersList.toString() + " Headers: " + + headersList.toString()); + } + } + + private static void checkDuplicateHeaderLine(String line, String headerLine, Path filePath, long lineNumber, + BufferedReader reader) throws IOException { + if (line.equals(headerLine)) { + reader.close(); + throw new RuntimeException("Duplicate header line. File: " + filePath + " Line: " + lineNumber); + } + } + + private static void validateLineLength(String[] lineValues, int headerLength, String line, String headerLine, + Path filePath, long lineNumber, BufferedReader reader) throws IOException { + if (lineValues.length != headerLength) { + reader.close(); + throw new RuntimeException( + "mismatch between values on line and number of headers. Please ensure data integrity. File: " + + filePath + " Line Number: " + lineNumber + " Line contents: " + line + " headers: " + + headerLine + " "); + } + } + + private static BufferedReader getReader(Path filePath) { + try { + return new BufferedReader(new FileReader(filePath.toFile())); + } catch (FileNotFoundException e) { + throw new RuntimeException(e); + } + } + + private static boolean lineIsCommentLine(String value, String delimeter) { + if (value.strip().startsWith("//")) { + return true; + } + + return false; + } + + private static int[] processHeaderLine(String[] expectedHeaders, String[] actualHeaders, String delimeter) { + + int[] headerIndexLookup = new int[actualHeaders.length]; + + for (int i = 0; i < actualHeaders.length; i++) { + headerIndexLookup[i] = -1; + } + + Map headerMapStrToInt = new HashMap<>(); + Map headerMapIntToStr = new HashMap<>(); + + for (int i = 0; i < expectedHeaders.length; i++) { + headerMapStrToInt.put(expectedHeaders[i], i); + headerMapIntToStr.put(i, expectedHeaders[i]); + } + + for (int i = 0; i < actualHeaders.length; i++) { + String expectedColHeader = headerMapIntToStr.get(i); + String actualColHeader = actualHeaders[i]; + + int newIndex = i; + + if (expectedColHeader == null || !expectedColHeader.equals(actualColHeader)) { + if (!headerMapStrToInt.containsKey(actualColHeader)) { + continue; + } + newIndex = headerMapStrToInt.get(actualColHeader); + } + + headerIndexLookup[i] = newIndex; + } + + return headerIndexLookup; + } +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceError.java b/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceError.java new file mode 100644 index 0000000..686d170 --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceError.java @@ -0,0 +1,18 @@ +package gov.hhs.aspr.ms.util.resourcehelper; + +import gov.hhs.aspr.ms.util.errors.ContractError; + +public enum ResourceError implements ContractError { + UNKNOWN_FILE("Provided file does not exist"); + + private final String description; + + private ResourceError(final String description) { + this.description = description; + } + + @Override + public String getDescription() { + return description; + } +} diff --git a/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceHelper.java b/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceHelper.java new file mode 100644 index 0000000..1757f7b --- /dev/null +++ b/src/main/java/gov/hhs/aspr/ms/util/resourcehelper/ResourceHelper.java @@ -0,0 +1,87 @@ +package gov.hhs.aspr.ms.util.resourcehelper; + +import java.io.File; +import java.io.IOException; +import java.net.URI; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; + +import gov.hhs.aspr.ms.util.errors.ContractException; + +public class ResourceHelper { + + private ResourceHelper() { + } + + public static Path getResourceDir(Class classRef) { + return Path.of(getURI(classRef.getClassLoader().getResource(""))); + } + + protected static URI getURI(URL url) { + try { + return url.toURI(); + } catch (URISyntaxException e) { + throw new RuntimeException(e); + } + } + + public static Path makeOutputDir(Path dirPath) { + dirPath.toFile().mkdirs(); + + return dirPath; + } + + public static Path makeOutputDir(Path basepath, String subDir) { + Path dirPath = basepath.resolve(subDir); + + return makeOutputDir(dirPath); + } + + public static void createOutputFile(Path filePath, String fileName) { + + File isAfile = filePath.resolve(fileName).toFile(); + + if (isAfile.exists()) { + isAfile.delete(); + } + + createFile(isAfile); + } + + public static Path validatePath(String path, boolean isOutput) { + Path maybePath = Path.of(path); + File maybeFile = maybePath.toFile(); + + boolean isDirectory = maybeFile.isDirectory(); + boolean isFile = maybeFile.isFile(); + + // if the given string corresponds to a file that exists, return path + if (isFile) { + return maybePath; + } + + // if file does not exist, ensure the path is not a directory and that the + // parent directory of the outputFile exists. + if (isOutput && !isDirectory) { + Path parentPath = maybePath.getParent(); + + if (Files.exists(parentPath)) { + return maybePath; + } + } + + // otherwise throw an exception + throw new ContractException(ResourceError.UNKNOWN_FILE, path); + } + + protected static void createFile(File file) { + try { + file.createNewFile(); + } catch (IOException e) { + throw new RuntimeException(e); + } + } + +} diff --git a/src/main/java/util/spherical/Chirality.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/Chirality.java similarity index 83% rename from src/main/java/util/spherical/Chirality.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/Chirality.java index 7e54bbb..86fef25 100644 --- a/src/main/java/util/spherical/Chirality.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/Chirality.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; /** * Enumeration representing the chirality of triangle vertex ordering on the diff --git a/src/main/java/util/spherical/MalformedSphericalArcException.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalArcException.java similarity index 91% rename from src/main/java/util/spherical/MalformedSphericalArcException.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalArcException.java index a709cd9..ac5af8c 100644 --- a/src/main/java/util/spherical/MalformedSphericalArcException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalArcException.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; /** * A RuntimeException thrown when a {@link SphericalArc} cannot be formed due to diff --git a/src/main/java/util/spherical/MalformedSphericalPointException.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPointException.java similarity index 90% rename from src/main/java/util/spherical/MalformedSphericalPointException.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPointException.java index 4ce164e..6bcd4a4 100644 --- a/src/main/java/util/spherical/MalformedSphericalPointException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPointException.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; /** * A RuntimeException thrown when a {@link SphericalPoint} cannot be formed due diff --git a/src/main/java/util/spherical/MalformedSphericalPolygonException.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPolygonException.java similarity index 90% rename from src/main/java/util/spherical/MalformedSphericalPolygonException.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPolygonException.java index 5ce40ff..5b62a8c 100644 --- a/src/main/java/util/spherical/MalformedSphericalPolygonException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalPolygonException.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; /** * A RuntimeException thrown when a {@link SphericalPolygon} cannot be formed diff --git a/src/main/java/util/spherical/MalformedSphericalTriangleException.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalTriangleException.java similarity index 90% rename from src/main/java/util/spherical/MalformedSphericalTriangleException.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalTriangleException.java index 9ccca3d..6dfb66c 100644 --- a/src/main/java/util/spherical/MalformedSphericalTriangleException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/MalformedSphericalTriangleException.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; /** * A RuntimeException thrown when a {@link SphericalTriangle} cannot be formed. diff --git a/src/main/java/util/spherical/SphericalArc.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalArc.java similarity index 97% rename from src/main/java/util/spherical/SphericalArc.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalArc.java index 8818e00..22929a2 100644 --- a/src/main/java/util/spherical/SphericalArc.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalArc.java @@ -1,12 +1,12 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import java.util.Arrays; import org.apache.commons.math3.util.FastMath; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; import net.jcip.annotations.Immutable; -import util.vector.MutableVector3D; -import util.vector.Vector3D; /** * Represents an immutable great arc segment on the unit sphere defined by two diff --git a/src/main/java/util/spherical/SphericalPoint.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPoint.java similarity index 92% rename from src/main/java/util/spherical/SphericalPoint.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPoint.java index 2fb6b30..1370d03 100644 --- a/src/main/java/util/spherical/SphericalPoint.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPoint.java @@ -1,8 +1,8 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; import net.jcip.annotations.Immutable; -import util.vector.MutableVector3D; -import util.vector.Vector3D; /** * Represents an immutable point on the unit sphere. Instances are created via diff --git a/src/main/java/util/spherical/SphericalPolygon.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPolygon.java similarity index 98% rename from src/main/java/util/spherical/SphericalPolygon.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPolygon.java index d2810df..bf95d9f 100644 --- a/src/main/java/util/spherical/SphericalPolygon.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalPolygon.java @@ -1,13 +1,13 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import java.util.ArrayList; import java.util.List; import org.apache.commons.math3.util.FastMath; +import gov.hhs.aspr.ms.util.dimensiontree.VolumetricDimensionTree; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; import net.jcip.annotations.Immutable; -import util.dimensiontree.VolumetricDimensionTree; -import util.vector.MutableVector3D; /** * Represents an immutable, non-crossing polygon on the surface of a unit diff --git a/src/main/java/util/spherical/SphericalTriangle.java b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalTriangle.java similarity index 97% rename from src/main/java/util/spherical/SphericalTriangle.java rename to src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalTriangle.java index a0ff5aa..f9e4e4a 100644 --- a/src/main/java/util/spherical/SphericalTriangle.java +++ b/src/main/java/gov/hhs/aspr/ms/util/spherical/SphericalTriangle.java @@ -1,10 +1,10 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import org.apache.commons.math3.util.FastMath; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; import net.jcip.annotations.Immutable; -import util.vector.MutableVector3D; -import util.vector.Vector3D; /** * Represents an immutable triangle on the unit sphere. diff --git a/src/main/java/util/stats/BinContainer.java b/src/main/java/gov/hhs/aspr/ms/util/stats/BinContainer.java similarity index 99% rename from src/main/java/util/stats/BinContainer.java rename to src/main/java/gov/hhs/aspr/ms/util/stats/BinContainer.java index acff2bc..e3983ce 100644 --- a/src/main/java/util/stats/BinContainer.java +++ b/src/main/java/gov/hhs/aspr/ms/util/stats/BinContainer.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import java.util.LinkedHashMap; import java.util.Map; diff --git a/src/main/java/util/stats/ImmutableStat.java b/src/main/java/gov/hhs/aspr/ms/util/stats/ImmutableStat.java similarity index 99% rename from src/main/java/util/stats/ImmutableStat.java rename to src/main/java/gov/hhs/aspr/ms/util/stats/ImmutableStat.java index c4aa25a..2a5cf64 100644 --- a/src/main/java/util/stats/ImmutableStat.java +++ b/src/main/java/gov/hhs/aspr/ms/util/stats/ImmutableStat.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import java.util.Optional; diff --git a/src/main/java/util/stats/KahanSum.java b/src/main/java/gov/hhs/aspr/ms/util/stats/KahanSum.java similarity index 93% rename from src/main/java/util/stats/KahanSum.java rename to src/main/java/gov/hhs/aspr/ms/util/stats/KahanSum.java index bb1cbcc..9749f0e 100644 --- a/src/main/java/util/stats/KahanSum.java +++ b/src/main/java/gov/hhs/aspr/ms/util/stats/KahanSum.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; /** * Implements the error reducing methodology for sums of floating point numbers diff --git a/src/main/java/util/stats/MutableStat.java b/src/main/java/gov/hhs/aspr/ms/util/stats/MutableStat.java similarity index 99% rename from src/main/java/util/stats/MutableStat.java rename to src/main/java/gov/hhs/aspr/ms/util/stats/MutableStat.java index 09b0997..336766f 100644 --- a/src/main/java/util/stats/MutableStat.java +++ b/src/main/java/gov/hhs/aspr/ms/util/stats/MutableStat.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import java.util.Collection; import java.util.Optional; diff --git a/src/main/java/util/stats/Stat.java b/src/main/java/gov/hhs/aspr/ms/util/stats/Stat.java similarity index 97% rename from src/main/java/util/stats/Stat.java rename to src/main/java/gov/hhs/aspr/ms/util/stats/Stat.java index 5286c94..d500bd1 100644 --- a/src/main/java/util/stats/Stat.java +++ b/src/main/java/gov/hhs/aspr/ms/util/stats/Stat.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import java.util.Optional; diff --git a/src/main/java/util/time/Stopwatch.java b/src/main/java/gov/hhs/aspr/ms/util/time/Stopwatch.java similarity index 97% rename from src/main/java/util/time/Stopwatch.java rename to src/main/java/gov/hhs/aspr/ms/util/time/Stopwatch.java index fbbdd12..34000c3 100644 --- a/src/main/java/util/time/Stopwatch.java +++ b/src/main/java/gov/hhs/aspr/ms/util/time/Stopwatch.java @@ -1,4 +1,4 @@ -package util.time; +package gov.hhs.aspr.ms.util.time; /** * A nano-time based accumulator of elapsed time that allows the client to start diff --git a/src/main/java/util/time/TimeElapser.java b/src/main/java/gov/hhs/aspr/ms/util/time/TimeElapser.java similarity index 96% rename from src/main/java/util/time/TimeElapser.java rename to src/main/java/gov/hhs/aspr/ms/util/time/TimeElapser.java index b16ef9a..e03cc66 100644 --- a/src/main/java/util/time/TimeElapser.java +++ b/src/main/java/gov/hhs/aspr/ms/util/time/TimeElapser.java @@ -1,4 +1,4 @@ -package util.time; +package gov.hhs.aspr.ms.util.time; /** * A debug-convenience class for measuring elapsed time via System.nanoTime() diff --git a/src/main/java/util/vector/Circle2D.java b/src/main/java/gov/hhs/aspr/ms/util/vector/Circle2D.java similarity index 99% rename from src/main/java/util/vector/Circle2D.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/Circle2D.java index 8d73314..894e876 100644 --- a/src/main/java/util/vector/Circle2D.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/Circle2D.java @@ -1,11 +1,11 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import java.util.List; import org.apache.commons.math3.util.FastMath; +import gov.hhs.aspr.ms.util.spherical.Chirality; import net.jcip.annotations.Immutable; -import util.spherical.Chirality; /** * A utility for calculating the smallest circle that encompasses a set of 2D diff --git a/src/main/java/util/vector/MutableVector2D.java b/src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector2D.java similarity index 99% rename from src/main/java/util/vector/MutableVector2D.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector2D.java index 9d9736e..5669d5e 100644 --- a/src/main/java/util/vector/MutableVector2D.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector2D.java @@ -1,8 +1,8 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import org.apache.commons.math3.util.FastMath; -import util.spherical.Chirality; +import gov.hhs.aspr.ms.util.spherical.Chirality; /** * A mutable 2-dimensional vector class supporting common 2D transforms. diff --git a/src/main/java/util/vector/MutableVector3D.java b/src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector3D.java similarity index 99% rename from src/main/java/util/vector/MutableVector3D.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector3D.java index d0ba00e..6d1ea81 100644 --- a/src/main/java/util/vector/MutableVector3D.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/MutableVector3D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import org.apache.commons.math3.util.FastMath; diff --git a/src/main/java/util/vector/NonNormalVectorException.java b/src/main/java/gov/hhs/aspr/ms/util/vector/NonNormalVectorException.java similarity index 90% rename from src/main/java/util/vector/NonNormalVectorException.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/NonNormalVectorException.java index 241c0c4..e58feb0 100644 --- a/src/main/java/util/vector/NonNormalVectorException.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/NonNormalVectorException.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; /** * A RuntimeException thrown when a vector is not normal(length = 1); diff --git a/src/main/java/util/vector/Vector2D.java b/src/main/java/gov/hhs/aspr/ms/util/vector/Vector2D.java similarity index 99% rename from src/main/java/util/vector/Vector2D.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/Vector2D.java index c4ed4f7..2de7598 100644 --- a/src/main/java/util/vector/Vector2D.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/Vector2D.java @@ -1,9 +1,9 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import org.apache.commons.math3.util.FastMath; +import gov.hhs.aspr.ms.util.spherical.Chirality; import net.jcip.annotations.Immutable; -import util.spherical.Chirality; /** * A immutable 2-dimensional vector class supporting common 2D transforms. diff --git a/src/main/java/util/vector/Vector3D.java b/src/main/java/gov/hhs/aspr/ms/util/vector/Vector3D.java similarity index 99% rename from src/main/java/util/vector/Vector3D.java rename to src/main/java/gov/hhs/aspr/ms/util/vector/Vector3D.java index 0b4dbf4..f3496a1 100644 --- a/src/main/java/util/vector/Vector3D.java +++ b/src/main/java/gov/hhs/aspr/ms/util/vector/Vector3D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import org.apache.commons.math3.util.FastMath; diff --git a/src/main/java/util/wrappers/MultiKey.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MultiKey.java similarity index 98% rename from src/main/java/util/wrappers/MultiKey.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MultiKey.java index 47c082d..b299b47 100644 --- a/src/main/java/util/wrappers/MultiKey.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MultiKey.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import java.util.ArrayList; import java.util.Arrays; diff --git a/src/main/java/util/wrappers/MutableBoolean.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableBoolean.java similarity index 97% rename from src/main/java/util/wrappers/MutableBoolean.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableBoolean.java index 22360fe..e737652 100644 --- a/src/main/java/util/wrappers/MutableBoolean.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableBoolean.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; public final class MutableBoolean { private boolean value; diff --git a/src/main/java/util/wrappers/MutableDouble.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableDouble.java similarity index 98% rename from src/main/java/util/wrappers/MutableDouble.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableDouble.java index a130aeb..d461b8a 100644 --- a/src/main/java/util/wrappers/MutableDouble.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableDouble.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; public final class MutableDouble { private double value; diff --git a/src/main/java/util/wrappers/MutableInteger.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableInteger.java similarity index 97% rename from src/main/java/util/wrappers/MutableInteger.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableInteger.java index 3b9e342..c1a9b30 100644 --- a/src/main/java/util/wrappers/MutableInteger.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableInteger.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; public final class MutableInteger { private int value; diff --git a/src/main/java/util/wrappers/MutableLong.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableLong.java similarity index 97% rename from src/main/java/util/wrappers/MutableLong.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableLong.java index 3a02c92..2d9e18d 100644 --- a/src/main/java/util/wrappers/MutableLong.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableLong.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; public final class MutableLong { private long value; diff --git a/src/main/java/util/wrappers/MutableObject.java b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableObject.java similarity index 97% rename from src/main/java/util/wrappers/MutableObject.java rename to src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableObject.java index b490463..eac2e3b 100644 --- a/src/main/java/util/wrappers/MutableObject.java +++ b/src/main/java/gov/hhs/aspr/ms/util/wrappers/MutableObject.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; public final class MutableObject { private T value; diff --git a/src/test/java/tools/MetaInfoReportRunner.java b/src/test/java/gov/hhs/aspr/ms/tools/MetaInfoReportRunner.java similarity index 51% rename from src/test/java/tools/MetaInfoReportRunner.java rename to src/test/java/gov/hhs/aspr/ms/tools/MetaInfoReportRunner.java index b627ca8..7b6c8bb 100644 --- a/src/test/java/tools/MetaInfoReportRunner.java +++ b/src/test/java/gov/hhs/aspr/ms/tools/MetaInfoReportRunner.java @@ -1,6 +1,6 @@ -package tools; +package gov.hhs.aspr.ms.tools; -import util.meta.unittestcoverage.reports.MetaInfoReport; +import gov.hhs.aspr.ms.util.meta.unittestcoverage.reports.MetaInfoReport; public class MetaInfoReportRunner { public static void main(String[] args) { diff --git a/src/test/java/gov/hhs/aspr/ms/util/combinatorics/AT_TupleGenerator.java b/src/test/java/gov/hhs/aspr/ms/util/combinatorics/AT_TupleGenerator.java new file mode 100644 index 0000000..e3d8af6 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/combinatorics/AT_TupleGenerator.java @@ -0,0 +1,156 @@ +package gov.hhs.aspr.ms.util.combinatorics; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.apache.commons.math3.random.RandomGenerator; +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; + +public class AT_TupleGenerator { + + /** + * Tests {@link TupleGenerator#size()} + */ + @Test + @UnitTestMethod(target = TupleGenerator.class, name = "size", args = {}) + public void testSize() { + + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(7820715406750309229L); + for (int i = 0; i < 100; i++) { + TupleGenerator.Builder builder = TupleGenerator.builder(); + int dimensionCount = randomGenerator.nextInt(4) + 1; + int expectedSize = 1; + for (int j = 0; j < dimensionCount; j++) { + int dimSize = randomGenerator.nextInt(10) + 1; + expectedSize *= dimSize; + builder.addDimension(dimSize); + } + int actualSize = builder.build().size(); + assertEquals(expectedSize, actualSize); + } + } + + /** + * Tests {@link TupleGenerator#builder()} + */ + @Test + @UnitTestMethod(target = TupleGenerator.class, name = "builder", args = {}) + public void testBuilder() { + // covered by other tests + } + + /** + * Tests {@link TupleGenerator#dimensions()} + */ + @Test + @UnitTestMethod(target = TupleGenerator.class, name = "dimensions", args = {}) + public void testDimensions() { + + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(7661626069466374878L); + for (int i = 0; i < 100; i++) { + TupleGenerator.Builder builder = TupleGenerator.builder(); + int dimensionCount = randomGenerator.nextInt(4) + 1; + for (int j = 0; j < dimensionCount; j++) { + int dimSize = randomGenerator.nextInt(10) + 1; + builder.addDimension(dimSize); + } + int actualDimensionCount = builder.build().dimensions(); + assertEquals(dimensionCount, actualDimensionCount); + } + } + + /** + * Tests {@link TupleGenerator#fillTuple(int, int[])} + */ + @Test + @UnitTestMethod(target = TupleGenerator.class, name = "fillTuple", args = { int.class, int[].class }) + public void testFillTuple() { + + TupleGenerator tupleGenerator = TupleGenerator.builder().addDimension(2).addDimension(3).addDimension(5).build(); + + int[] tuple = new int[tupleGenerator.dimensions()]; + + List expectedArrays = new ArrayList<>(); + + expectedArrays.add(new int[] { 0, 0, 0 }); + expectedArrays.add(new int[] { 1, 0, 0 }); + expectedArrays.add(new int[] { 0, 1, 0 }); + expectedArrays.add(new int[] { 1, 1, 0 }); + expectedArrays.add(new int[] { 0, 2, 0 }); + expectedArrays.add(new int[] { 1, 2, 0 }); + expectedArrays.add(new int[] { 0, 0, 1 }); + expectedArrays.add(new int[] { 1, 0, 1 }); + expectedArrays.add(new int[] { 0, 1, 1 }); + expectedArrays.add(new int[] { 1, 1, 1 }); + expectedArrays.add(new int[] { 0, 2, 1 }); + expectedArrays.add(new int[] { 1, 2, 1 }); + expectedArrays.add(new int[] { 0, 0, 2 }); + expectedArrays.add(new int[] { 1, 0, 2 }); + expectedArrays.add(new int[] { 0, 1, 2 }); + expectedArrays.add(new int[] { 1, 1, 2 }); + expectedArrays.add(new int[] { 0, 2, 2 }); + expectedArrays.add(new int[] { 1, 2, 2 }); + expectedArrays.add(new int[] { 0, 0, 3 }); + expectedArrays.add(new int[] { 1, 0, 3 }); + expectedArrays.add(new int[] { 0, 1, 3 }); + expectedArrays.add(new int[] { 1, 1, 3 }); + expectedArrays.add(new int[] { 0, 2, 3 }); + expectedArrays.add(new int[] { 1, 2, 3 }); + expectedArrays.add(new int[] { 0, 0, 4 }); + expectedArrays.add(new int[] { 1, 0, 4 }); + expectedArrays.add(new int[] { 0, 1, 4 }); + expectedArrays.add(new int[] { 1, 1, 4 }); + expectedArrays.add(new int[] { 0, 2, 4 }); + expectedArrays.add(new int[] { 1, 2, 4 }); + + for (int i = 0; i < tupleGenerator.size(); i++) { + tupleGenerator.fillTuple(i, tuple); + assertTrue(Arrays.equals(expectedArrays.get(i), tuple)); + } + /** + * precondition tests + */ + assertThrows(IndexOutOfBoundsException.class, () -> tupleGenerator.fillTuple(-2, tuple)); + assertThrows(IndexOutOfBoundsException.class, () -> tupleGenerator.fillTuple(-1, tuple)); + assertThrows(IndexOutOfBoundsException.class, () -> tupleGenerator.fillTuple(tupleGenerator.size(), tuple)); + assertThrows(IndexOutOfBoundsException.class, () -> tupleGenerator.fillTuple(tupleGenerator.size() + 1, tuple)); + assertThrows(IllegalArgumentException.class, () -> tupleGenerator.fillTuple(0, null)); + assertThrows(IllegalArgumentException.class, () -> tupleGenerator.fillTuple(0, new int[tupleGenerator.dimensions() - 1])); + assertThrows(IllegalArgumentException.class, () -> tupleGenerator.fillTuple(0, new int[tupleGenerator.dimensions() + 1])); + + } + + @Test + @UnitTestMethod(target = TupleGenerator.Builder.class, name = "build", args = {}) + public void testBuild() { + TupleGenerator.Builder builder = TupleGenerator.builder(); + TupleGenerator tupleGenerator = builder.build(); + + assertNotNull(tupleGenerator); + } + + @Test + @UnitTestMethod(target = TupleGenerator.Builder.class, name = "addDimension", args = { int.class }) + public void testAddDimension() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1967914502607382607L); + for (int i = 0; i < 100; i++) { + TupleGenerator.Builder builder = TupleGenerator.builder(); + int dimensionCount = randomGenerator.nextInt(4) + 1; + for (int j = 0; j < dimensionCount; j++) { + int dimSize = randomGenerator.nextInt(10) + 1; + builder.addDimension(dimSize); + } + int actualDimensionCount = builder.build().dimensions(); + assertEquals(dimensionCount, actualDimensionCount); + } + } +} diff --git a/src/test/java/util/delaunay/AT_GeoDelaunaySolver.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_GeoDelaunaySolver.java similarity index 72% rename from src/test/java/util/delaunay/AT_GeoDelaunaySolver.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_GeoDelaunaySolver.java index 3ed7b0a..3447246 100644 --- a/src/test/java/util/delaunay/AT_GeoDelaunaySolver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_GeoDelaunaySolver.java @@ -1,11 +1,11 @@ -package util.delaunay; +package gov.hhs.aspr.ms.util.delaunay; import java.util.Map; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_GeoDelaunaySolver { diff --git a/src/test/java/util/delaunay/AT_PlanarDelaunaySolver.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_PlanarDelaunaySolver.java similarity index 72% rename from src/test/java/util/delaunay/AT_PlanarDelaunaySolver.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_PlanarDelaunaySolver.java index ad56b96..7596fea 100644 --- a/src/test/java/util/delaunay/AT_PlanarDelaunaySolver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/AT_PlanarDelaunaySolver.java @@ -1,11 +1,11 @@ -package util.delaunay; +package gov.hhs.aspr.ms.util.delaunay; import java.util.Map; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_PlanarDelaunaySolver { diff --git a/src/test/java/util/delaunay/geovisualizer/GeoVisualizerDriver.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerDriver.java similarity index 90% rename from src/test/java/util/delaunay/geovisualizer/GeoVisualizerDriver.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerDriver.java index a984a94..5a2ef58 100644 --- a/src/test/java/util/delaunay/geovisualizer/GeoVisualizerDriver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerDriver.java @@ -1,4 +1,4 @@ -package util.delaunay.geovisualizer; +package gov.hhs.aspr.ms.util.delaunay.geovisualizer; import java.io.IOException; import java.nio.file.Files; @@ -10,9 +10,9 @@ import org.apache.commons.math3.util.Pair; -import util.delaunay.GeoDelaunaySolver; -import util.earth.LatLon; -import util.time.TimeElapser; +import gov.hhs.aspr.ms.util.delaunay.GeoDelaunaySolver; +import gov.hhs.aspr.ms.util.time.TimeElapser; +import gov.hhs.aspr.ms.util.earth.LatLon; /** * A demonstration application driver that displays population data consisting diff --git a/src/test/java/util/delaunay/geovisualizer/GeoVisualizerPanel.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerPanel.java similarity index 97% rename from src/test/java/util/delaunay/geovisualizer/GeoVisualizerPanel.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerPanel.java index 65beae4..c308169 100644 --- a/src/test/java/util/delaunay/geovisualizer/GeoVisualizerPanel.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualizerPanel.java @@ -1,4 +1,4 @@ -package util.delaunay.geovisualizer; +package gov.hhs.aspr.ms.util.delaunay.geovisualizer; import java.awt.BasicStroke; import java.awt.Color; @@ -30,16 +30,16 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.dimensiontree.DimensionTree; -import util.earth.Earth; -import util.earth.LatLon; -import util.earth.LatLonAlt; -import util.graph.Graph; -import util.path.Path; -import util.path.Paths; -import util.time.TimeElapser; -import util.vector.MutableVector3D; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.dimensiontree.DimensionTree; +import gov.hhs.aspr.ms.util.earth.Earth; +import gov.hhs.aspr.ms.util.earth.LatLonAlt; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Path; +import gov.hhs.aspr.ms.util.path.Paths; +import gov.hhs.aspr.ms.util.time.TimeElapser; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; +import gov.hhs.aspr.ms.util.earth.LatLon; public class GeoVisualizerPanel extends JPanel { diff --git a/src/test/java/util/delaunay/geovisualizer/GeoVisualzerFrame.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualzerFrame.java similarity index 88% rename from src/test/java/util/delaunay/geovisualizer/GeoVisualzerFrame.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualzerFrame.java index 1d917a3..7485efb 100644 --- a/src/test/java/util/delaunay/geovisualizer/GeoVisualzerFrame.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/geovisualizer/GeoVisualzerFrame.java @@ -1,4 +1,4 @@ -package util.delaunay.geovisualizer; +package gov.hhs.aspr.ms.util.delaunay.geovisualizer; import java.awt.Frame; import java.util.List; @@ -8,7 +8,7 @@ import org.apache.commons.math3.util.Pair; -import util.earth.LatLon; +import gov.hhs.aspr.ms.util.earth.LatLon; public class GeoVisualzerFrame extends JFrame { private static final long serialVersionUID = -5106781364986923139L; diff --git a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java similarity index 81% rename from src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java index 1384e49..40095ab 100644 --- a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerDriver.java @@ -1,4 +1,4 @@ -package util.delaunay.planarvisualizer; +package gov.hhs.aspr.ms.util.delaunay.planarvisualizer; import java.util.LinkedHashMap; import java.util.List; @@ -7,10 +7,10 @@ import org.apache.commons.math3.random.RandomGenerator; import org.apache.commons.math3.util.Pair; -import util.delaunay.PlanarDelaunaySolver; -import util.random.RandomGeneratorProvider; -import util.time.TimeElapser; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.delaunay.PlanarDelaunaySolver; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.time.TimeElapser; +import gov.hhs.aspr.ms.util.vector.Vector2D; /** * A demonstration application driver that displays a randomized set of 5000 diff --git a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java similarity index 98% rename from src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java index 8a4bc41..749fe24 100644 --- a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualizerPanel.java @@ -1,4 +1,4 @@ -package util.delaunay.planarvisualizer; +package gov.hhs.aspr.ms.util.delaunay.planarvisualizer; import java.awt.BasicStroke; import java.awt.Color; @@ -22,8 +22,8 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.vector.MutableVector2D; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.vector.MutableVector2D; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class PlanarVisualizerPanel extends JPanel { private static final long serialVersionUID = -8746718644903555611L; diff --git a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java similarity index 88% rename from src/test/java/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java rename to src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java index ecc552b..150f3ab 100644 --- a/src/test/java/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java +++ b/src/test/java/gov/hhs/aspr/ms/util/delaunay/planarvisualizer/PlanarVisualzerFrame.java @@ -1,4 +1,4 @@ -package util.delaunay.planarvisualizer; +package gov.hhs.aspr.ms.util.delaunay.planarvisualizer; import java.awt.Frame; import java.util.List; @@ -8,7 +8,7 @@ import org.apache.commons.math3.util.Pair; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class PlanarVisualzerFrame extends JFrame { private static final long serialVersionUID = -5106781364986923139L; diff --git a/src/test/java/util/dimensiontree/AT_DimensionTree.java b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTree.java similarity index 98% rename from src/test/java/util/dimensiontree/AT_DimensionTree.java rename to src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTree.java index f2bd197..b9885c0 100644 --- a/src/test/java/util/dimensiontree/AT_DimensionTree.java +++ b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTree.java @@ -1,4 +1,4 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -18,10 +18,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.time.TimeElapser; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.time.TimeElapser; diff --git a/src/test/java/util/dimensiontree/AT_DimensionTreeError.java b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTreeError.java similarity index 90% rename from src/test/java/util/dimensiontree/AT_DimensionTreeError.java rename to src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTreeError.java index 9c02da7..bd935d7 100644 --- a/src/test/java/util/dimensiontree/AT_DimensionTreeError.java +++ b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_DimensionTreeError.java @@ -1,4 +1,4 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -8,7 +8,7 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_DimensionTreeError { diff --git a/src/test/java/util/dimensiontree/AT_VolumetricDimensionTree.java b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_VolumetricDimensionTree.java similarity index 98% rename from src/test/java/util/dimensiontree/AT_VolumetricDimensionTree.java rename to src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_VolumetricDimensionTree.java index 672986b..1212a76 100644 --- a/src/test/java/util/dimensiontree/AT_VolumetricDimensionTree.java +++ b/src/test/java/gov/hhs/aspr/ms/util/dimensiontree/AT_VolumetricDimensionTree.java @@ -1,4 +1,4 @@ -package util.dimensiontree; +package gov.hhs.aspr.ms.util.dimensiontree; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -13,10 +13,10 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class AT_VolumetricDimensionTree { diff --git a/src/test/java/util/earth/AT_Earth.java b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_Earth.java similarity index 98% rename from src/test/java/util/earth/AT_Earth.java rename to src/test/java/gov/hhs/aspr/ms/util/earth/AT_Earth.java index e7eae08..2f783f0 100644 --- a/src/test/java/util/earth/AT_Earth.java +++ b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_Earth.java @@ -1,4 +1,4 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -9,10 +9,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class AT_Earth { diff --git a/src/test/java/util/earth/AT_EarthGrid.java b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_EarthGrid.java similarity index 79% rename from src/test/java/util/earth/AT_EarthGrid.java rename to src/test/java/gov/hhs/aspr/ms/util/earth/AT_EarthGrid.java index 0b33e75..2c8e326 100644 --- a/src/test/java/util/earth/AT_EarthGrid.java +++ b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_EarthGrid.java @@ -1,15 +1,15 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class AT_EarthGrid { diff --git a/src/test/java/util/earth/AT_LatLon.java b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLon.java similarity index 96% rename from src/test/java/util/earth/AT_LatLon.java rename to src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLon.java index 6258f56..dc45562 100644 --- a/src/test/java/util/earth/AT_LatLon.java +++ b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLon.java @@ -1,4 +1,4 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -6,9 +6,9 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_LatLon { diff --git a/src/test/java/util/earth/AT_LatLonAlt.java b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLonAlt.java similarity index 97% rename from src/test/java/util/earth/AT_LatLonAlt.java rename to src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLonAlt.java index 987a6ae..7a96ed9 100644 --- a/src/test/java/util/earth/AT_LatLonAlt.java +++ b/src/test/java/gov/hhs/aspr/ms/util/earth/AT_LatLonAlt.java @@ -1,4 +1,4 @@ -package util.earth; +package gov.hhs.aspr.ms.util.earth; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -6,10 +6,10 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class AT_LatLonAlt { diff --git a/src/test/java/util/errors/AT_ContractException.java b/src/test/java/gov/hhs/aspr/ms/util/errors/AT_ContractException.java similarity index 90% rename from src/test/java/util/errors/AT_ContractException.java rename to src/test/java/gov/hhs/aspr/ms/util/errors/AT_ContractException.java index 65eb188..14829cf 100644 --- a/src/test/java/util/errors/AT_ContractException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/errors/AT_ContractException.java @@ -1,13 +1,13 @@ -package util.errors; +package gov.hhs.aspr.ms.util.errors; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_ContractException { diff --git a/src/test/java/util/geolocator/AT_GeoLocator.java b/src/test/java/gov/hhs/aspr/ms/util/geolocator/AT_GeoLocator.java similarity index 94% rename from src/test/java/util/geolocator/AT_GeoLocator.java rename to src/test/java/gov/hhs/aspr/ms/util/geolocator/AT_GeoLocator.java index 73f4813..fd4ae16 100644 --- a/src/test/java/util/geolocator/AT_GeoLocator.java +++ b/src/test/java/gov/hhs/aspr/ms/util/geolocator/AT_GeoLocator.java @@ -1,4 +1,4 @@ -package util.geolocator; +package gov.hhs.aspr.ms.util.geolocator; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -17,14 +17,14 @@ import org.apache.commons.math3.util.Pair; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; -import util.earth.Earth; -import util.earth.LatLon; -import util.earth.LatLonAlt; -import util.geolocator.GeoLocator.Builder; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.earth.Earth; +import gov.hhs.aspr.ms.util.earth.LatLonAlt; +import gov.hhs.aspr.ms.util.geolocator.GeoLocator.Builder; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; +import gov.hhs.aspr.ms.util.earth.LatLon; public class AT_GeoLocator { diff --git a/src/test/java/util/graph/AT_Graph.java b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graph.java similarity index 99% rename from src/test/java/util/graph/AT_Graph.java rename to src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graph.java index 494991c..fa5cd71 100644 --- a/src/test/java/util/graph/AT_Graph.java +++ b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graph.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,8 +11,8 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_Graph { diff --git a/src/test/java/util/graph/AT_GraphDepthEvaluator.java b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_GraphDepthEvaluator.java similarity index 98% rename from src/test/java/util/graph/AT_GraphDepthEvaluator.java rename to src/test/java/gov/hhs/aspr/ms/util/graph/AT_GraphDepthEvaluator.java index 3591d0a..691b926 100644 --- a/src/test/java/util/graph/AT_GraphDepthEvaluator.java +++ b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_GraphDepthEvaluator.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -12,7 +12,7 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_GraphDepthEvaluator { diff --git a/src/test/java/util/graph/AT_Graphs.java b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graphs.java similarity index 98% rename from src/test/java/util/graph/AT_Graphs.java rename to src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graphs.java index 0badce0..5e931ca 100644 --- a/src/test/java/util/graph/AT_Graphs.java +++ b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_Graphs.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -9,9 +9,9 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; -import util.graph.Graphs.GraphConnectedness; -import util.graph.Graphs.GraphCyclisity; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.graph.Graphs.GraphConnectedness; +import gov.hhs.aspr.ms.util.graph.Graphs.GraphCyclisity; public class AT_Graphs { diff --git a/src/test/java/util/graph/AT_MutableGraph.java b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_MutableGraph.java similarity index 99% rename from src/test/java/util/graph/AT_MutableGraph.java rename to src/test/java/gov/hhs/aspr/ms/util/graph/AT_MutableGraph.java index b8d2ba0..877837c 100644 --- a/src/test/java/util/graph/AT_MutableGraph.java +++ b/src/test/java/gov/hhs/aspr/ms/util/graph/AT_MutableGraph.java @@ -1,4 +1,4 @@ -package util.graph; +package gov.hhs.aspr.ms.util.graph; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -14,8 +14,8 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_MutableGraph { diff --git a/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer2.java b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer2.java new file mode 100644 index 0000000..b759a90 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer2.java @@ -0,0 +1,73 @@ +package gov.hhs.aspr.ms.util.indexer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.FastMath; +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.errors.ContractException; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; + +public class AT_Indexer2 { + @Test + @UnitTestConstructor(target = Indexer2.class, args = { int.class, int.class }) + public void testIndexer2() { + + // precondition test: if any dimension has a negative size + + ContractException contractException = assertThrows(ContractException.class, () -> new Indexer2(-1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer2(1, -1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + // precondition test: if the product of the dimensions exceeds max int + int n = (int) FastMath.pow(Integer.MAX_VALUE, 1.0 / 2) + 1; + + contractException = assertThrows(ContractException.class, () -> new Indexer2(n, n)); + assertEquals(IndexerError.EXCEEDS_MAX_ARRAY_SIZE, contractException.getErrorType()); + + } + + @Test + @UnitTestMethod(target = Indexer2.class, name = "index", args = { int.class, int.class }) + public void testIndex() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6937151566492160140L); + + //show that index = index1*dim2+index2 + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + + Indexer2 indexer2 = new Indexer2(dim1, dim2); + + for (int j = 0; j < 100; j++) { + + int index1 = randomGenerator.nextInt(dim1); + int index2 = randomGenerator.nextInt(dim2); + + assertEquals(index1 * dim2 + index2, indexer2.index(index1, index2)); + } + } + } + + @Test + @UnitTestMethod(target = Indexer2.class, name = "size", args = {}) + public void testSize() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1286993379829775736L); + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + + Indexer2 indexer2 = new Indexer2(dim1, dim2); + + assertEquals(dim1*dim2, indexer2.size()); + } + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer3.java b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer3.java new file mode 100644 index 0000000..4b45ce1 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer3.java @@ -0,0 +1,80 @@ +package gov.hhs.aspr.ms.util.indexer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.FastMath; +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.errors.ContractException; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; + +public class AT_Indexer3 { + @Test + @UnitTestConstructor(target = Indexer3.class, args = { int.class, int.class, int.class }) + public void testIndexer3() { + + // precondition test: if any dimension has a negative size + + ContractException contractException = assertThrows(ContractException.class, () -> new Indexer3(-1, 1,1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer3(1, -1,1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer3(1, 1,-1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + + // precondition test: if the product of the dimensions exceeds max int + int n = (int) FastMath.pow(Integer.MAX_VALUE, 1.0 / 3) + 1; + + contractException = assertThrows(ContractException.class, () -> new Indexer3(n, n, n)); + assertEquals(IndexerError.EXCEEDS_MAX_ARRAY_SIZE, contractException.getErrorType()); + + } + + @Test + @UnitTestMethod(target = Indexer3.class, name = "index", args = { int.class, int.class, int.class }) + public void testIndex() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6937151566492160140L); + + //show that index = (index1*dim2 +index2)*dim3+index3 + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + int dim3 = randomGenerator.nextInt(30) + 1; + + Indexer3 indexer3 = new Indexer3(dim1, dim2,dim3); + + for (int j = 0; j < 100; j++) { + + int index1 = randomGenerator.nextInt(dim1); + int index2 = randomGenerator.nextInt(dim2); + int index3 = randomGenerator.nextInt(dim3); + + assertEquals((index1*dim2 +index2)*dim3+index3, indexer3.index(index1, index2,index3)); + } + } + } + + @Test + @UnitTestMethod(target = Indexer3.class, name = "size", args = {}) + public void testSize() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1286993379829775736L); + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + int dim3 = randomGenerator.nextInt(30) + 1; + + Indexer3 indexer3 = new Indexer3(dim1, dim2,dim3); + + assertEquals(dim1*dim2*dim3, indexer3.size()); + } + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer4.java b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer4.java new file mode 100644 index 0000000..5b6a666 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer4.java @@ -0,0 +1,86 @@ +package gov.hhs.aspr.ms.util.indexer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.FastMath; +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.errors.ContractException; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; + +public class AT_Indexer4 { + @Test + @UnitTestConstructor(target = Indexer4.class, args = { int.class, int.class, int.class, int.class }) + public void testIndexer4() { + + // precondition test: if any dimension has a negative size + + ContractException contractException = assertThrows(ContractException.class, () -> new Indexer4(-1, 1, 1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer4(1, -1, 1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer4(1, 1, -1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer4(1, 1, 1, -1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + // precondition test: if the product of the dimensions exceeds max int + int n = (int) FastMath.pow(Integer.MAX_VALUE, 1.0 / 4) + 1; + + contractException = assertThrows(ContractException.class, () -> new Indexer4(n, n, n, n)); + assertEquals(IndexerError.EXCEEDS_MAX_ARRAY_SIZE, contractException.getErrorType()); + + } + + @Test + @UnitTestMethod(target = Indexer4.class, name = "index", args = { int.class, int.class, int.class, int.class }) + public void testIndex() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6937151566492160140L); + + // show that index = ((index1 * dim2 + index2) * dim3 + index3) * dim4 + index4 + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + int dim3 = randomGenerator.nextInt(30) + 1; + int dim4 = randomGenerator.nextInt(30) + 1; + + Indexer4 indexer4 = new Indexer4(dim1, dim2, dim3, dim4); + + for (int j = 0; j < 100; j++) { + + int index1 = randomGenerator.nextInt(dim1); + int index2 = randomGenerator.nextInt(dim2); + int index3 = randomGenerator.nextInt(dim3); + int index4 = randomGenerator.nextInt(dim4); + + assertEquals(((index1 * dim2 + index2) * dim3 + index3) * dim4 + index4, + indexer4.index(index1, index2, index3, index4)); + } + } + } + + @Test + @UnitTestMethod(target = Indexer4.class, name = "size", args = { }) + public void testSize() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1286993379829775736L); + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + int dim3 = randomGenerator.nextInt(30) + 1; + int dim4 = randomGenerator.nextInt(30) + 1; + + Indexer4 Indexer4 = new Indexer4(dim1, dim2, dim3, dim4); + + assertEquals(dim1 * dim2 * dim3 * dim4, Indexer4.size()); + } + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer5.java b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer5.java new file mode 100644 index 0000000..bc632b5 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_Indexer5.java @@ -0,0 +1,98 @@ +package gov.hhs.aspr.ms.util.indexer; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import org.apache.commons.math3.random.RandomGenerator; +import org.apache.commons.math3.util.FastMath; +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.errors.ContractException; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; + +public class AT_Indexer5 { + @Test + @UnitTestConstructor(target = Indexer5.class, args = { int.class, int.class, int.class, int.class, int.class }) + public void testIndexer5() { + + // precondition test: if any dimension has a negative size + + ContractException contractException = assertThrows(ContractException.class, () -> new Indexer5(-1, 1, 1, 1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer5(1, -1, 1, 1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer5(1, 1, -1, 1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer5(1, 1, 1, -1, 1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + contractException = assertThrows(ContractException.class, () -> new Indexer5(1, 1, 1, 1, -1)); + assertEquals(IndexerError.NEGATIVE_DIMENSION_SIZE, contractException.getErrorType()); + + // precondition test: if the product of the dimensions exceeds max int + int n = (int) FastMath.pow(Integer.MAX_VALUE, 1.0 / 5) + 1; + + contractException = assertThrows(ContractException.class, () -> new Indexer5(n, n, n, n, n)); + assertEquals(IndexerError.EXCEEDS_MAX_ARRAY_SIZE, contractException.getErrorType()); + + } + + @Test + @UnitTestMethod(target = Indexer5.class, name = "index", args = { int.class, int.class, int.class, int.class, + int.class }) + public void testIndex() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(6937151566492160140L); + + // show that index = (((index1*dim2 + // +index2)*dim3+index3)*dim4+index4)*dim5+index5 + + int n = 30; + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(n) + 1; + int dim2 = randomGenerator.nextInt(n) + 1; + int dim3 = randomGenerator.nextInt(n) + 1; + int dim4 = randomGenerator.nextInt(n) + 1; + int dim5 = randomGenerator.nextInt(n) + 1; + + Indexer5 indexer5 = new Indexer5(dim1, dim2, dim3, dim4, dim5); + + for (int j = 0; j < 100; j++) { + + int index1 = randomGenerator.nextInt(dim1); + int index2 = randomGenerator.nextInt(dim2); + int index3 = randomGenerator.nextInt(dim3); + int index4 = randomGenerator.nextInt(dim4); + int index5 = randomGenerator.nextInt(dim5); + + int expectedIndex = (((index1 * dim2 + index2) * dim3 + index3) * dim4 + index4) * dim5 + index5; + int actualIndex = indexer5.index(index1, index2, index3, index4, index5); + + assertEquals(expectedIndex, actualIndex); + } + } + } + + @Test + @UnitTestMethod(target = Indexer5.class, name = "size", args = {}) + public void testSize() { + RandomGenerator randomGenerator = RandomGeneratorProvider.getRandomGenerator(1286993379829775736L); + + for (int i = 0; i < 30; i++) { + int dim1 = randomGenerator.nextInt(30) + 1; + int dim2 = randomGenerator.nextInt(30) + 1; + int dim3 = randomGenerator.nextInt(30) + 1; + int dim4 = randomGenerator.nextInt(30) + 1; + int dim5 = randomGenerator.nextInt(30) + 1; + + Indexer5 Indexer5 = new Indexer5(dim1, dim2, dim3, dim4, dim5); + + assertEquals(dim1 * dim2 * dim3 * dim4 * dim5, Indexer5.size()); + } + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_IndexerError.java b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_IndexerError.java new file mode 100644 index 0000000..5630005 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/indexer/AT_IndexerError.java @@ -0,0 +1,36 @@ +package gov.hhs.aspr.ms.util.indexer; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; + + +public class AT_IndexerError { + + /** + * Tests {@link NucleusError#getDescription()} + */ + @Test + @UnitTestMethod(target = IndexerError.class, name = "getDescription", args = {}) + public void testGetDescription() { + // show that each ErrorType has a non-null, non-empty description + for (IndexerError nucleusError : IndexerError.values()) { + assertNotNull(nucleusError.getDescription()); + assertTrue(nucleusError.getDescription().length() > 0); + } + + // show that each description is unique (ignoring case as well) + Set descriptions = new LinkedHashSet<>(); + for (IndexerError nucleusError : IndexerError.values()) { + boolean isUnique = descriptions.add(nucleusError.getDescription().toLowerCase()); + assertTrue(isUnique, nucleusError + " duplicates the description of another member"); + } + } + +} diff --git a/src/test/java/util/path/AT_ArrayPathSolver.java b/src/test/java/gov/hhs/aspr/ms/util/path/AT_ArrayPathSolver.java similarity index 93% rename from src/test/java/util/path/AT_ArrayPathSolver.java rename to src/test/java/gov/hhs/aspr/ms/util/path/AT_ArrayPathSolver.java index d7a160f..18d0bac 100644 --- a/src/test/java/util/path/AT_ArrayPathSolver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/path/AT_ArrayPathSolver.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,12 +11,12 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.graph.Graph; -import util.path.Paths.EdgeCostEvaluator; -import util.path.Paths.TravelCostEvaluator; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Paths.EdgeCostEvaluator; +import gov.hhs.aspr.ms.util.path.Paths.TravelCostEvaluator; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class AT_ArrayPathSolver { /* diff --git a/src/test/java/util/path/AT_MapPathSolver.java b/src/test/java/gov/hhs/aspr/ms/util/path/AT_MapPathSolver.java similarity index 93% rename from src/test/java/util/path/AT_MapPathSolver.java rename to src/test/java/gov/hhs/aspr/ms/util/path/AT_MapPathSolver.java index bffc54f..e3dea82 100644 --- a/src/test/java/util/path/AT_MapPathSolver.java +++ b/src/test/java/gov/hhs/aspr/ms/util/path/AT_MapPathSolver.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,12 +11,12 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.graph.Graph; -import util.path.Paths.EdgeCostEvaluator; -import util.path.Paths.TravelCostEvaluator; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Paths.EdgeCostEvaluator; +import gov.hhs.aspr.ms.util.path.Paths.TravelCostEvaluator; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class AT_MapPathSolver { /* diff --git a/src/test/java/util/path/AT_Path.java b/src/test/java/gov/hhs/aspr/ms/util/path/AT_Path.java similarity index 97% rename from src/test/java/util/path/AT_Path.java rename to src/test/java/gov/hhs/aspr/ms/util/path/AT_Path.java index 6fbc45d..3f56c78 100644 --- a/src/test/java/util/path/AT_Path.java +++ b/src/test/java/gov/hhs/aspr/ms/util/path/AT_Path.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -11,7 +11,7 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_Path { diff --git a/src/test/java/util/path/AT_Paths.java b/src/test/java/gov/hhs/aspr/ms/util/path/AT_Paths.java similarity index 94% rename from src/test/java/util/path/AT_Paths.java rename to src/test/java/gov/hhs/aspr/ms/util/path/AT_Paths.java index 4b89bba..9c09b2a 100644 --- a/src/test/java/util/path/AT_Paths.java +++ b/src/test/java/gov/hhs/aspr/ms/util/path/AT_Paths.java @@ -1,4 +1,4 @@ -package util.path; +package gov.hhs.aspr.ms.util.path; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -10,11 +10,11 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; -import util.graph.Graph; -import util.path.Paths.EdgeCostEvaluator; -import util.path.Paths.TravelCostEvaluator; -import util.vector.Vector2D; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.graph.Graph; +import gov.hhs.aspr.ms.util.path.Paths.EdgeCostEvaluator; +import gov.hhs.aspr.ms.util.path.Paths.TravelCostEvaluator; +import gov.hhs.aspr.ms.util.vector.Vector2D; public class AT_Paths { diff --git a/src/test/java/util/random/AT_RandomGeneratorProvider.java b/src/test/java/gov/hhs/aspr/ms/util/random/AT_RandomGeneratorProvider.java similarity index 92% rename from src/test/java/util/random/AT_RandomGeneratorProvider.java rename to src/test/java/gov/hhs/aspr/ms/util/random/AT_RandomGeneratorProvider.java index e0b01eb..ebd345d 100644 --- a/src/test/java/util/random/AT_RandomGeneratorProvider.java +++ b/src/test/java/gov/hhs/aspr/ms/util/random/AT_RandomGeneratorProvider.java @@ -1,4 +1,4 @@ -package util.random; +package gov.hhs.aspr.ms.util.random; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -10,7 +10,7 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_RandomGeneratorProvider { diff --git a/src/test/java/gov/hhs/aspr/ms/util/readers/AT_TextTableReader.java b/src/test/java/gov/hhs/aspr/ms/util/readers/AT_TextTableReader.java new file mode 100644 index 0000000..5bbece4 --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/readers/AT_TextTableReader.java @@ -0,0 +1,26 @@ +package gov.hhs.aspr.ms.util.readers; + +import java.nio.file.Path; +import java.util.function.Consumer; + +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; + +public class AT_TextTableReader { + + @Test + @UnitTestMethod(target = TextTableReader.class, name = "readToMap", args = { String.class, String.class, Path.class, + Consumer.class }, tags = {UnitTag.INCOMPLETE}) + public void testRead_Map() { + + } + + @Test + @UnitTestMethod(target = TextTableReader.class, name = "read", args = { String.class, String.class, Path.class, + Consumer.class }, tags = {UnitTag.INCOMPLETE}) + public void testRead() { + + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceError.java b/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceError.java new file mode 100644 index 0000000..170cbee --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceError.java @@ -0,0 +1,27 @@ +package gov.hhs.aspr.ms.util.resourcehelper; + +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.util.LinkedHashSet; +import java.util.Set; + +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; + +public class AT_ResourceError { + @Test + @UnitTestMethod(target = ResourceError.class, name = "getDescription", args = {}) + public void testGetDescription() { + // show that each description is a unique, non-null and non-empty string + Set descriptions = new LinkedHashSet<>(); + for (ResourceError personBlockError : ResourceError.values()) { + String description = personBlockError.getDescription(); + assertNotNull(description, "null description for " + personBlockError); + assertTrue(description.length() > 0, "empty string for " + personBlockError); + boolean unique = descriptions.add(description); + assertTrue(unique, "description for " + personBlockError + " is not unique"); + } + } +} diff --git a/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceHelper.java b/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceHelper.java new file mode 100644 index 0000000..5354b7f --- /dev/null +++ b/src/test/java/gov/hhs/aspr/ms/util/resourcehelper/AT_ResourceHelper.java @@ -0,0 +1,144 @@ +package gov.hhs.aspr.ms.util.resourcehelper; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.assertTrue; + +import java.io.File; +import java.io.IOException; +import java.net.MalformedURLException; +import java.net.URISyntaxException; +import java.net.URL; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; + +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.errors.ContractException; + +public class AT_ResourceHelper { + + @Test + @UnitTestMethod(target = ResourceHelper.class, name = "getResourceDir", args = { Class.class }) + public void testGetResourceDir() throws MalformedURLException { + Path path = ResourceHelper.getResourceDir(this.getClass()); + + assertNotNull(path); + assertTrue(path.toFile().exists()); + assertTrue(path.resolve("resourceHelper.json").toFile().exists()); + + // preconditions + // bad url syntax + URL url = new URL("file:${my.properties}"); + + RuntimeException runtimeException = assertThrows(RuntimeException.class, () -> { + ResourceHelper.getURI(url); + }); + + assertTrue(runtimeException.getCause() instanceof URISyntaxException); + } + + @Test + @UnitTestMethod(target = ResourceHelper.class, name = "makeOutputDir", args = { Path.class }) + public void testMakeTestOutputDir() { + Path path = ResourceHelper.getResourceDir(this.getClass()).resolve("additional-folder"); + + Path newPath = ResourceHelper.makeOutputDir(path); + + assertNotNull(newPath); + assertTrue(newPath.toFile().exists()); + } + + @Test + @UnitTestMethod(target = ResourceHelper.class, name = "makeOutputDir", args = { Path.class, String.class }) + public void testMakeTestOutputDir_SubDir() { + Path path = ResourceHelper.getResourceDir(this.getClass()).resolve("additional-folder"); + + Path newPath = ResourceHelper.makeOutputDir(path, "subFolder"); + + assertNotNull(newPath); + assertTrue(newPath.toFile().exists()); + } + + private class IOExceptionFile extends File { + + /** + * + */ + private static final long serialVersionUID = 1L; + + public IOExceptionFile(String pathname) { + super(pathname); + } + + public IOExceptionFile(File file) { + super(file, pathSeparator); + } + + @Override + public boolean createNewFile() throws IOException { + + throw new IOException(); + } + + } + + @Test + @UnitTestMethod(target = ResourceHelper.class, name = "createOutputFile", args = { Path.class, + String.class }) + public void testCreateTestOutputFile() throws IOException { + Path path = ResourceHelper.getResourceDir(this.getClass()); + + Path newPath = ResourceHelper.makeOutputDir(path); + + String fileName = "foo.txt"; + ResourceHelper.createOutputFile(newPath, fileName); + + assertTrue(newPath.resolve(fileName).toFile().exists()); + + // test for delete/recreat file if it exists + ResourceHelper.createOutputFile(newPath, fileName); + + // preconditions + // force an IOException + RuntimeException runtimeException = assertThrows(RuntimeException.class, () -> { + IOExceptionFile testFile = new IOExceptionFile(newPath.resolve(fileName).toFile()); + ResourceHelper.createFile(testFile); + }); + + assertTrue(runtimeException.getCause() instanceof IOException); + } + + @Test + @UnitTestMethod(target = ResourceHelper.class, name = "validatePath", args = { String.class, boolean.class }) + public void testValidatePath() { + Path resourceDir = ResourceHelper.getResourceDir(getClass()); + // path is a file that is not output and exists + String path = resourceDir.resolve("resourceHelper.json").toAbsolutePath().toString(); + Path expectedPath = resourceDir.resolve("resourceHelper.json").toAbsolutePath(); + assertEquals(expectedPath, ResourceHelper.validatePath(path, false)); + + // file is an output file that does not exist, but the directory the file + // resides in exists + ResourceHelper.makeOutputDir(resourceDir, "testOutput"); + path = resourceDir.resolve("testOutput").resolve("resourceHelper.json").toAbsolutePath().toString(); + expectedPath = resourceDir.resolve("testOutput").resolve("resourceHelper.json").toAbsolutePath(); + assertEquals(expectedPath, ResourceHelper.validatePath(path, true)); + + // preconditions + // File does not exist and it is not an outputFile + ContractException contractException = assertThrows(ContractException.class, () -> { + ResourceHelper.validatePath("testOutput", false); + }); + + assertEquals(ResourceError.UNKNOWN_FILE, contractException.getErrorType()); + + // is output but parent directory does not exist + contractException = assertThrows(ContractException.class, () -> { + ResourceHelper.validatePath(resourceDir.resolve("nonExistantDir").resolve("file.json").toString(), true); + }); + + assertEquals(ResourceError.UNKNOWN_FILE, contractException.getErrorType()); + } +} diff --git a/src/test/java/util/spherical/AT_MalformedSphericalArcException.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalArcException.java similarity index 90% rename from src/test/java/util/spherical/AT_MalformedSphericalArcException.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalArcException.java index 2adbe49..0c40d4b 100644 --- a/src/test/java/util/spherical/AT_MalformedSphericalArcException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalArcException.java @@ -1,11 +1,11 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; public class AT_MalformedSphericalArcException { @Test diff --git a/src/test/java/util/spherical/AT_MalformedSphericalPointException.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPointException.java similarity index 91% rename from src/test/java/util/spherical/AT_MalformedSphericalPointException.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPointException.java index 4f05e4a..eba3c08 100644 --- a/src/test/java/util/spherical/AT_MalformedSphericalPointException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPointException.java @@ -1,11 +1,11 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; public class AT_MalformedSphericalPointException { @Test diff --git a/src/test/java/util/spherical/AT_MalformedSphericalPolygonException.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPolygonException.java similarity index 91% rename from src/test/java/util/spherical/AT_MalformedSphericalPolygonException.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPolygonException.java index 92e027c..584ee3f 100644 --- a/src/test/java/util/spherical/AT_MalformedSphericalPolygonException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalPolygonException.java @@ -1,11 +1,11 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; public class AT_MalformedSphericalPolygonException { @Test diff --git a/src/test/java/util/spherical/AT_MalformedSphericalTriangleException.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalTriangleException.java similarity index 91% rename from src/test/java/util/spherical/AT_MalformedSphericalTriangleException.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalTriangleException.java index a671b45..909721c 100644 --- a/src/test/java/util/spherical/AT_MalformedSphericalTriangleException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_MalformedSphericalTriangleException.java @@ -1,11 +1,11 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; public class AT_MalformedSphericalTriangleException { @Test diff --git a/src/test/java/util/spherical/AT_SphericalArc.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalArc.java similarity index 98% rename from src/test/java/util/spherical/AT_SphericalArc.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalArc.java index 8cd1178..1ad70b3 100644 --- a/src/test/java/util/spherical/AT_SphericalArc.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalArc.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -9,10 +9,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class AT_SphericalArc { diff --git a/src/test/java/util/spherical/AT_SphericalPoint.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPoint.java similarity index 92% rename from src/test/java/util/spherical/AT_SphericalPoint.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPoint.java index 3c04378..ea9e9e7 100644 --- a/src/test/java/util/spherical/AT_SphericalPoint.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPoint.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -8,11 +8,11 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.MutableVector3D; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.MutableVector3D; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class AT_SphericalPoint { diff --git a/src/test/java/util/spherical/AT_SphericalPolygon.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPolygon.java similarity index 98% rename from src/test/java/util/spherical/AT_SphericalPolygon.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPolygon.java index 20be977..fd61bed 100644 --- a/src/test/java/util/spherical/AT_SphericalPolygon.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalPolygon.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -14,12 +14,12 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestMethod; -import util.earth.Earth; -import util.earth.LatLon; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.earth.Earth; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; +import gov.hhs.aspr.ms.util.earth.LatLon; public class AT_SphericalPolygon { diff --git a/src/test/java/util/spherical/AT_SphericalTriangle.java b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalTriangle.java similarity index 98% rename from src/test/java/util/spherical/AT_SphericalTriangle.java rename to src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalTriangle.java index 9c17926..33afe15 100644 --- a/src/test/java/util/spherical/AT_SphericalTriangle.java +++ b/src/test/java/gov/hhs/aspr/ms/util/spherical/AT_SphericalTriangle.java @@ -1,4 +1,4 @@ -package util.spherical; +package gov.hhs.aspr.ms.util.spherical; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; @@ -8,10 +8,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.vector.Vector3D; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Vector3D; public class AT_SphericalTriangle { diff --git a/src/test/java/util/stats/AT_BinContainer.java b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_BinContainer.java similarity index 96% rename from src/test/java/util/stats/AT_BinContainer.java rename to src/test/java/gov/hhs/aspr/ms/util/stats/AT_BinContainer.java index f395786..092e76f 100644 --- a/src/test/java/util/stats/AT_BinContainer.java +++ b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_BinContainer.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; @@ -9,11 +9,11 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.stats.BinContainer.Bin; -import util.stats.BinContainer.Builder; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.stats.BinContainer.Bin; +import gov.hhs.aspr.ms.util.stats.BinContainer.Builder; public class AT_BinContainer { /** diff --git a/src/test/java/util/stats/AT_ImmutableStat.java b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_ImmutableStat.java similarity index 98% rename from src/test/java/util/stats/AT_ImmutableStat.java rename to src/test/java/gov/hhs/aspr/ms/util/stats/AT_ImmutableStat.java index 198c3dc..61d82b7 100644 --- a/src/test/java/util/stats/AT_ImmutableStat.java +++ b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_ImmutableStat.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -7,8 +7,8 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_ImmutableStat { diff --git a/src/test/java/util/stats/AT_KahanSum.java b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_KahanSum.java similarity index 91% rename from src/test/java/util/stats/AT_KahanSum.java rename to src/test/java/gov/hhs/aspr/ms/util/stats/AT_KahanSum.java index be2d98f..56c2726 100644 --- a/src/test/java/util/stats/AT_KahanSum.java +++ b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_KahanSum.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -6,9 +6,9 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_KahanSum { diff --git a/src/test/java/util/stats/AT_MutableStat.java b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_MutableStat.java similarity index 97% rename from src/test/java/util/stats/AT_MutableStat.java rename to src/test/java/gov/hhs/aspr/ms/util/stats/AT_MutableStat.java index dd8de93..19378cd 100644 --- a/src/test/java/util/stats/AT_MutableStat.java +++ b/src/test/java/gov/hhs/aspr/ms/util/stats/AT_MutableStat.java @@ -1,4 +1,4 @@ -package util.stats; +package gov.hhs.aspr.ms.util.stats; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -13,9 +13,9 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableStat { diff --git a/src/test/java/util/time/AT_Stopwatch.java b/src/test/java/gov/hhs/aspr/ms/util/time/AT_Stopwatch.java similarity index 89% rename from src/test/java/util/time/AT_Stopwatch.java rename to src/test/java/gov/hhs/aspr/ms/util/time/AT_Stopwatch.java index 6f4d5a9..43bf870 100644 --- a/src/test/java/util/time/AT_Stopwatch.java +++ b/src/test/java/gov/hhs/aspr/ms/util/time/AT_Stopwatch.java @@ -1,10 +1,10 @@ -package util.time; +package gov.hhs.aspr.ms.util.time; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_Stopwatch { diff --git a/src/test/java/util/time/AT_TimeElapser.java b/src/test/java/gov/hhs/aspr/ms/util/time/AT_TimeElapser.java similarity index 86% rename from src/test/java/util/time/AT_TimeElapser.java rename to src/test/java/gov/hhs/aspr/ms/util/time/AT_TimeElapser.java index 069b0ae..1c51e59 100644 --- a/src/test/java/util/time/AT_TimeElapser.java +++ b/src/test/java/gov/hhs/aspr/ms/util/time/AT_TimeElapser.java @@ -1,9 +1,9 @@ -package util.time; +package gov.hhs.aspr.ms.util.time; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_TimeElapser { diff --git a/src/test/java/util/vector/AT_Circle2D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Circle2D.java similarity index 85% rename from src/test/java/util/vector/AT_Circle2D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_Circle2D.java index 9ac317f..0707e34 100644 --- a/src/test/java/util/vector/AT_Circle2D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Circle2D.java @@ -1,13 +1,13 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import java.util.List; import org.junit.jupiter.api.Test; -import util.annotations.UnitTag; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.vector.Circle2D.SolutionAlgorithm; +import gov.hhs.aspr.ms.util.annotations.UnitTag; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.vector.Circle2D.SolutionAlgorithm; public class AT_Circle2D { diff --git a/src/test/java/util/vector/AT_MutableVector2D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector2D.java similarity index 99% rename from src/test/java/util/vector/AT_MutableVector2D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector2D.java index c7a1028..2edfb7c 100644 --- a/src/test/java/util/vector/AT_MutableVector2D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector2D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -8,11 +8,11 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.spherical.Chirality; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.spherical.Chirality; public class AT_MutableVector2D { diff --git a/src/test/java/util/vector/AT_MutableVector3D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector3D.java similarity index 99% rename from src/test/java/util/vector/AT_MutableVector3D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector3D.java index 9fc77b8..301e1c1 100644 --- a/src/test/java/util/vector/AT_MutableVector3D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_MutableVector3D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -8,10 +8,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableVector3D { diff --git a/src/test/java/util/vector/AT_NonNormalVectorException.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_NonNormalVectorException.java similarity index 90% rename from src/test/java/util/vector/AT_NonNormalVectorException.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_NonNormalVectorException.java index 264a146..cd617f5 100644 --- a/src/test/java/util/vector/AT_NonNormalVectorException.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_NonNormalVectorException.java @@ -1,11 +1,11 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; public class AT_NonNormalVectorException { @Test diff --git a/src/test/java/util/vector/AT_Vector2D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector2D.java similarity index 98% rename from src/test/java/util/vector/AT_Vector2D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector2D.java index b44a5e2..33cb2d2 100644 --- a/src/test/java/util/vector/AT_Vector2D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector2D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -8,11 +8,11 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; -import util.spherical.Chirality; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.spherical.Chirality; public class AT_Vector2D { diff --git a/src/test/java/util/vector/AT_Vector3D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector3D.java similarity index 99% rename from src/test/java/util/vector/AT_Vector3D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector3D.java index 9e7c790..8034fa7 100644 --- a/src/test/java/util/vector/AT_Vector3D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/AT_Vector3D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -8,10 +8,10 @@ import org.apache.commons.math3.util.FastMath; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestField; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestField; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_Vector3D { diff --git a/src/test/java/util/vector/MT_Circle2D.java b/src/test/java/gov/hhs/aspr/ms/util/vector/MT_Circle2D.java similarity index 93% rename from src/test/java/util/vector/MT_Circle2D.java rename to src/test/java/gov/hhs/aspr/ms/util/vector/MT_Circle2D.java index 2691959..d6d2e5a 100644 --- a/src/test/java/util/vector/MT_Circle2D.java +++ b/src/test/java/gov/hhs/aspr/ms/util/vector/MT_Circle2D.java @@ -1,4 +1,4 @@ -package util.vector; +package gov.hhs.aspr.ms.util.vector; import static org.junit.jupiter.api.Assertions.assertTrue; @@ -11,9 +11,9 @@ import org.apache.commons.math3.util.FastMath; import org.apache.commons.math3.util.Pair; -import util.delaunay.planarvisualizer.PlanarVisualzerFrame; -import util.random.RandomGeneratorProvider; -import util.vector.Circle2D.SolutionAlgorithm; +import gov.hhs.aspr.ms.util.delaunay.planarvisualizer.PlanarVisualzerFrame; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.vector.Circle2D.SolutionAlgorithm; /** * A manual test class for {@linkplain Circle2D} comparing the performance of diff --git a/src/test/java/util/wrappers/AT_MultiKey.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MultiKey.java similarity index 98% rename from src/test/java/util/wrappers/AT_MultiKey.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MultiKey.java index 6d3b326..8b5d18f 100644 --- a/src/test/java/util/wrappers/AT_MultiKey.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MultiKey.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertArrayEquals; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -9,8 +9,8 @@ import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; public class AT_MultiKey { diff --git a/src/test/java/util/wrappers/AT_MutableBoolean.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableBoolean.java similarity index 93% rename from src/test/java/util/wrappers/AT_MutableBoolean.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableBoolean.java index 6ff97e8..10dbf8d 100644 --- a/src/test/java/util/wrappers/AT_MutableBoolean.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableBoolean.java @@ -1,13 +1,13 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableBoolean { diff --git a/src/test/java/util/wrappers/AT_MutableDouble.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableDouble.java similarity index 96% rename from src/test/java/util/wrappers/AT_MutableDouble.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableDouble.java index d33ceb6..11974fb 100644 --- a/src/test/java/util/wrappers/AT_MutableDouble.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableDouble.java @@ -1,13 +1,13 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableDouble { diff --git a/src/test/java/util/wrappers/AT_MutableInteger.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableInteger.java similarity index 96% rename from src/test/java/util/wrappers/AT_MutableInteger.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableInteger.java index e101066..7947119 100644 --- a/src/test/java/util/wrappers/AT_MutableInteger.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableInteger.java @@ -1,13 +1,13 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableInteger { @Test diff --git a/src/test/java/util/wrappers/AT_MutableLong.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableLong.java similarity index 95% rename from src/test/java/util/wrappers/AT_MutableLong.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableLong.java index f4f6e83..bdf4088 100644 --- a/src/test/java/util/wrappers/AT_MutableLong.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/AT_MutableLong.java @@ -1,13 +1,13 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertEquals; import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class AT_MutableLong { diff --git a/src/test/java/util/wrappers/MT_MutableObject.java b/src/test/java/gov/hhs/aspr/ms/util/wrappers/MT_MutableObject.java similarity index 94% rename from src/test/java/util/wrappers/MT_MutableObject.java rename to src/test/java/gov/hhs/aspr/ms/util/wrappers/MT_MutableObject.java index 2334985..9a56bde 100644 --- a/src/test/java/util/wrappers/MT_MutableObject.java +++ b/src/test/java/gov/hhs/aspr/ms/util/wrappers/MT_MutableObject.java @@ -1,4 +1,4 @@ -package util.wrappers; +package gov.hhs.aspr.ms.util.wrappers; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNull; @@ -6,9 +6,9 @@ import org.apache.commons.math3.random.RandomGenerator; import org.junit.jupiter.api.Test; -import util.annotations.UnitTestConstructor; -import util.annotations.UnitTestMethod; -import util.random.RandomGeneratorProvider; +import gov.hhs.aspr.ms.util.annotations.UnitTestConstructor; +import gov.hhs.aspr.ms.util.annotations.UnitTestMethod; +import gov.hhs.aspr.ms.util.random.RandomGeneratorProvider; public class MT_MutableObject { diff --git a/src/test/resources/resourceHelper.json b/src/test/resources/resourceHelper.json new file mode 100644 index 0000000..9e26dfe --- /dev/null +++ b/src/test/resources/resourceHelper.json @@ -0,0 +1 @@ +{} \ No newline at end of file