diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..4c07f35 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,25 @@ +name: CI + +on: + push: + branches: ["master"] + pull_request: + branches: ["**"] + +jobs: + test: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4.2.2 + + - name: Set up Java 11 + uses: actions/setup-java@v4.7.0 + with: + java-version: "11" + distribution: temurin + cache: maven + + - name: Run tests + working-directory: structSimV1 + run: mvn test diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..f398f94 --- /dev/null +++ b/.gitignore @@ -0,0 +1,4 @@ +*.class +ResultSim/ +all.log +structSimV1/target/ \ No newline at end of file diff --git a/README.md b/README.md index b54e40d..98b7818 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,113 @@ To use our framework to your project you have to add the "structSimV1.jar" to yo A tutorial (structSimTutorial.pdf) is available to help you to begin with our framework. Some example are also described in this tutorial. +## Citation + +If you use this framework in your research, please cite the following paper: + +> René Schumann, Caroline Taramarcaz. **Towards Systematic Testing of Complex Interacting Systems.** In *Proceedings of the Workshop on Testing Extra-Functional Properties and Quality Characteristics of Software Systems (ITEQS)*, CEUR Workshop Proceedings, Vol. 2397, pp. 55–, 2019. https://ceur-ws.org/Vol-2397/paper8.pdf + If you have some questions/remarks about this project, you can consult the official page of the project at this address : https://www.hevs.ch/fr/mini-sites/projets-produits/si-lab/projets/structured-simulation--a-framework-for-the-automated-analysis-of-adaptive-systems-8640 And in case, don't hesitate to contact us. + +## Running the simulation (mock mode) + +The framework ships with a mock simulator (`SimpleSimulationHandler`) that lets you run without a real external simulator. + +Ready-to-use example files are in [`examples/simple/`](examples/simple/). Copy them as described below. + +### 1. Copy `config.properties` into the classpath + +Copy [`examples/simple/config.properties`](examples/simple/config.properties) to `structSimV1/src/main/resources/config.properties`: + +```bash +cp examples/simple/config.properties structSimV1/src/main/resources/config.properties +``` + +```properties +pathOUT = /tmp/structsim-results +pathParameters = parameters.txt +pathSimulator = /tmp/structsim-simulator +pathToSimulatorResultFile = /tmp/structsim-simulator/results/results.txt +cuttOfPlanning = 10 +typeCuttOfPlanning = INT +``` + +| Key | Description | +|-----|-------------| +| `pathOUT` | Folder where results and `SummaryFile.txt` are written | +| `pathParameters` | Name of the parameters file — loaded from the classpath, so place it in `src/main/resources/` | +| `pathSimulator` | Folder where per-simulation sub-folders are created | +| `pathToSimulatorResultFile` | Result file the simulator creates after each run | +| `typeCuttOfPlanning` | When to stop generating simulations — `INT`, `CRITERIA`, `HOURS`, `MINUTES`, or `DAY` | +| `cuttOfPlanning` | Threshold value for the chosen stop type (see below) | + +**How `typeCuttOfPlanning` works:** + +The framework builds a tree of simulations by applying modifiers on top of each other. This setting controls when it stops growing the tree: + +- `INT` — stops after N outer loop iterations (e.g. `10` means 10 rounds of applying all modifiers). Good for a quick bounded run. +- `CRITERIA` — prunes any branch whose cumulative probability drops below the threshold (e.g. `0.15` = stop exploring paths less likely than 15%). Each modifier has a probability; they multiply as modifiers are combined. Good for skipping unlikely scenarios. +- `HOURS` / `MINUTES` / `DAY` — runs for a fixed wall-clock duration regardless of how many simulations are generated. + +> **Note:** the file must have the `.properties` extension. + +### 2. Copy `parameters.txt` into the classpath + +Copy [`examples/simple/parameters.txt`](examples/simple/parameters.txt) to `structSimV1/src/main/resources/parameters.txt`: + +```bash +cp examples/simple/parameters.txt structSimV1/src/main/resources/parameters.txt +``` + +``` +val1=1 +val2=2 +val3=3 +val4=4 +val5=5 +``` + +One `key=value` pair per line. Values must be numbers. + +### 3. Configure modifiers in `Simulation.java` + +Open `structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/Simulation.java` and edit the modifiers list. Each `ConcreteModifier` takes `(parameterKey, operator, delta, probability)`: + +```java +modifiers.add(new ConcreteModifier("val2", '+', 1.0, 0.5)); +modifiers.add(new ConcreteModifier("val2", '+', 10.0, 0.5)); +``` + +Supported operators: `+`, `-`, `*`, `/` + +The `probability` field is only used for pruning when `typeCuttOfPlanning = CRITERIA`. With `INT` mode it has no effect on how many simulations run. + +### 4. Create output directories and run + +```bash +mkdir -p /tmp/structsim-results /tmp/structsim-simulator +cd structSimV1 +mvn exec:java -Dexec.mainClass=ch.hevs.silab.structuredsim.gluecode.Simulation +``` + +Results are written to `pathOUT/SummaryFile.txt`. + +--- + +## Quick start - run the built-in example (Linux and Mac) + +The `examples/simple/` directory is a ready-to-run project matching the tutorial. It modifies `val2` with two modifiers (`+1` and `+10`) and runs 10 iterations. + +```bash +cd examples/simple +./run.sh +``` + +The script will: +1. Build and install `structSimV1` to your local Maven repo +2. Create `/tmp/structsim-results` and `/tmp/structsim-simulator` +3. Run the simulation +4. Print `SummaryFile.txt` when done diff --git a/examples/simple/config.properties b/examples/simple/config.properties new file mode 100644 index 0000000..d27816b --- /dev/null +++ b/examples/simple/config.properties @@ -0,0 +1,15 @@ +# Folder where results and SummaryFile.txt are written +pathOUT = /tmp/structsim-results + +# Name of the parameters file - must be on the classpath (src/main/resources/) +pathParameters = parameters.txt + +# Folder where per-simulation sub-folders are created +pathSimulator = /tmp/structsim-simulator + +# Result file the simulator creates after each run +pathToSimulatorResultFile = /tmp/structsim-simulator/results/results.txt + +# Stop after 10 outer exploration loop iterations +cuttOfPlanning = 10 +typeCuttOfPlanning = INT diff --git a/examples/simple/parameters.txt b/examples/simple/parameters.txt new file mode 100644 index 0000000..a1aff25 --- /dev/null +++ b/examples/simple/parameters.txt @@ -0,0 +1,5 @@ +val1=1 +val2=2 +val3=3 +val4=4 +val5=5 diff --git a/examples/simple/pom.xml b/examples/simple/pom.xml new file mode 100644 index 0000000..929dffb --- /dev/null +++ b/examples/simple/pom.xml @@ -0,0 +1,37 @@ + + + 4.0.0 + + example + simple-simulation + 1.0-SNAPSHOT + jar + + + 11 + 11 + + + + + hevs.ch.silab + hevs.ch.silab + 0.0.1-SNAPSHOT + + + + + + + org.codehaus.mojo + exec-maven-plugin + 3.1.0 + + example.Simulation + + + + + diff --git a/examples/simple/run.sh b/examples/simple/run.sh new file mode 100755 index 0000000..555750a --- /dev/null +++ b/examples/simple/run.sh @@ -0,0 +1,31 @@ +#!/bin/bash +set -e + +REPO_ROOT="$(cd "$(dirname "$0")/../.." && pwd)" +EXAMPLE_DIR="$REPO_ROOT/examples/simple" +BUILD_DIR="$EXAMPLE_DIR/target/classes" + +STRUCT_CLASSES="$REPO_ROOT/structSimV1/target/classes" +LOG4J_JAR="$HOME/.m2/repository/org/apache/logging/log4j/log4j-api/2.24.3/log4j-api-2.24.3.jar" + +echo "==> Compiling structSimV1..." +cd "$REPO_ROOT/structSimV1" +mvn compile -q + +echo "==> Creating output directories..." +mkdir -p /tmp/structsim-results /tmp/structsim-simulator +mkdir -p "$BUILD_DIR" + +echo "==> Compiling example..." +javac -cp "$STRUCT_CLASSES:$LOG4J_JAR" \ + -d "$BUILD_DIR" \ + "$EXAMPLE_DIR/src/main/java/example/Simulation.java" + +echo "==> Running simulation..." +java -cp "$BUILD_DIR:$STRUCT_CLASSES:$LOG4J_JAR:$EXAMPLE_DIR/src/main/resources" \ + example.Simulation + +echo "" +echo "Done! Results written to /tmp/structsim-results/SummaryFile.txt" +echo "" +cat /tmp/structsim-results/SummaryFile.txt diff --git a/examples/simple/src/main/java/example/Simulation.java b/examples/simple/src/main/java/example/Simulation.java new file mode 100644 index 0000000..10af864 --- /dev/null +++ b/examples/simple/src/main/java/example/Simulation.java @@ -0,0 +1,29 @@ +package example; + +import ch.hevs.silab.structuredsim.gluecode.ConcreteModifier; +import ch.hevs.silab.structuredsim.gluecode.SimpleSimulationHandler; +import ch.hevs.silab.structuredsim.interfaces.AModifier; +import ch.hevs.silab.structuredsim.interfaces.StartProgram; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class Simulation extends StartProgram { + + public static void main(String[] args) throws IOException { + + InputStream config = Simulation.class + .getClassLoader() + .getResourceAsStream("config.properties"); + + List modifiers = new ArrayList<>(); + modifiers.add(new ConcreteModifier("val2", '+', 1.0, 0.5)); + modifiers.add(new ConcreteModifier("val2", '+', 10.0, 0.5)); + + SimpleSimulationHandler ssh = new SimpleSimulationHandler(modifiers); + + startProgram(config, ssh); + } +} diff --git a/examples/simple/src/main/resources/config.properties b/examples/simple/src/main/resources/config.properties new file mode 100644 index 0000000..f9a2c05 --- /dev/null +++ b/examples/simple/src/main/resources/config.properties @@ -0,0 +1,6 @@ +pathOUT = /tmp/structsim-results +pathParameters = parameters.txt +pathSimulator = /tmp/structsim-simulator +pathToSimulatorResultFile = /tmp/structsim-simulator/results/results.txt +cuttOfPlanning = 10 +typeCuttOfPlanning = INT diff --git a/examples/simple/src/main/resources/parameters.txt b/examples/simple/src/main/resources/parameters.txt new file mode 100644 index 0000000..a1aff25 --- /dev/null +++ b/examples/simple/src/main/resources/parameters.txt @@ -0,0 +1,5 @@ +val1=1 +val2=2 +val3=3 +val4=4 +val5=5 diff --git a/structSimV1/pom.xml b/structSimV1/pom.xml index 269efa9..a7a50d4 100644 --- a/structSimV1/pom.xml +++ b/structSimV1/pom.xml @@ -16,15 +16,33 @@ - junit - junit - 3.8.1 - test + org.apache.logging.log4j + log4j-api + 2.24.3 - - com.hynnet - jacob - 1.18 - + + org.junit.jupiter + junit-jupiter + 5.11.4 + test + + + org.mockito + mockito-core + 5.10.0 + test + + + + + org.apache.maven.plugins + maven-compiler-plugin + + 11 + 11 + + + + diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Environment.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Environment.java index fda0a15..d63833e 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Environment.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Environment.java @@ -49,7 +49,6 @@ public class Environment implements Comparable { * * @param id : ID * @param setOfParameters : List of Parameters of this Environment - * @param idParamChanged : ID from the parameters changed in this environment * @param probability : Probability */ public Environment(int id, Vector setOfParameters, double probability) { @@ -65,7 +64,12 @@ public Environment(int id, Vector setOfParameters, double probability */ public Environment(int id, Environment e){ this.id = id; - this.setOfParameters = e.setOfParameters; + + this.setOfParameters = new Vector(); + for (Parameter p : e.setOfParameters) { + this.setOfParameters.add(new Parameter(p)); // Constructor by copy + } + this.probability = e.probability; this.trace = new ArrayList(); for(String s :e.trace){ @@ -73,6 +77,14 @@ public Environment(int id, Environment e){ } } + /** + * Default constructor to facilitate the writing + * of the units tests of the FileManagement class + */ + public Environment() { + this(1, new Vector(), 1); + } + /** * Getter for id * @return ID @@ -129,18 +141,13 @@ public void setPathSaveResult(String pathSaveResult) { this.pathSaveResult = pathSaveResult; } - - - public String toStringModifier() { String result ="" ; for(String s : trace){ result += " " + s; } - - return "Simulation ID : " + id + "\t" + "Modifier implemented : " + result ; + return "Simulation ID : " + id + "\t Probability : " + probability + "\t Modifier implemented : " + result; } - public List getTrace() { return trace; @@ -150,10 +157,16 @@ public void setTrace(List trace) { this.trace = trace; } + /** + Allow to order environments by ascending order of probability + @return + 1 if first environment is more probable, + -1 if first environment is less probable, + 0 if they have equal probability + */ @Override - public int compareTo(Environment arg0) { - return (int)(this.probability - arg0.getProbability()); + public int compareTo(Environment other) { + return Double.compare(this.probability, other.probability); } - -} +} \ No newline at end of file diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.java index 840ba51..7608815 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.java @@ -20,7 +20,6 @@ package ch.hevs.silab.structuredsim.experimenthandling; -import java.time.temporal.IsoFields; import java.util.ArrayList; import java.util.Calendar; import java.util.Collections; @@ -28,11 +27,11 @@ import java.util.concurrent.BlockingQueue; import java.util.concurrent.TimeUnit; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import ch.hevs.silab.structuredsim.interfaces.AModifier; -import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import ch.hevs.silab.structuredsim.interfaces.IManageModifier; import ch.hevs.silab.structuredsim.util.FileManagement; @@ -51,6 +50,7 @@ public class ExperimentPlanGenerator implements Runnable { //Variable protected Environment baseEnvironment; protected BlockingQueue planningQueue; + protected Options options; protected ASimulationSystemHandler glueCode; private long endTime =0 ; @@ -93,33 +93,36 @@ private void createNextEnvironments (Environment baseEnv){ int idCpt = baseEnv.getId(); int cpt = 0; - while(!toExplore.isEmpty()){ + // This break statement stops the program at the right time. + if(options.getTypeOfCuttOfPlanning().equals("INT") && cpt >= options.getCuttOfPlanning()){ + break; + } + parentEnv = toExplore.remove(0); for (AModifier modifier : listModifiers) { idCpt ++; + currentEnv = new Environment(idCpt, parentEnv); + currentEnv = modifier.applyModifier(currentEnv); + currentEnv.getTrace().add(modifier.getName() ); - //for(String str : currentEn) - System.out.println("--------------------------------------------" +currentEnv.id + " " + currentEnv.trace.toString()); + + logger.debug("--------------------------------------------" +currentEnv.id + " " + currentEnv.trace.toString()); + currentEnv.setProbability(parentEnv.getProbability() * modifier.getProbability()); if(options.getTypeOfCuttOfPlanning().equals("CRITERIA") && currentEnv.getProbability() > options.getStopCriteria()){ toExplore.add(currentEnv); - } - if(options.getTypeOfCuttOfPlanning().equals("INT")&& - cpt <= options.getCuttOfPlanning()){ + if(options.getTypeOfCuttOfPlanning().equals("INT")) { toExplore.add(currentEnv); } - else{ - break; - } fm.createNewFolderSimulation(currentEnv, glueCode); addEnvToQueue(currentEnv); @@ -127,8 +130,12 @@ private void createNextEnvironments (Environment baseEnv){ } cpt ++; - System.out.println("CPT : " + cpt); - Collections.sort(toExplore); + logger.debug("CPT : " + cpt); + + /* We sort the environments by reverse order, + to put the most probable one in first position */ + toExplore.sort(Collections.reverseOrder()); + } } @@ -160,11 +167,10 @@ private void addEnvToQueue(Environment e){ @Override public void run() { - - //Generate the number of Environment that we want long currentTime = System.currentTimeMillis(); + logger.debug("option = " + options.getTypeOfCuttOfPlanning()); switch(options.getTypeOfCuttOfPlanning()){ case "INT" : diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.java index 46c362f..0e1851e 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.java @@ -23,16 +23,16 @@ import java.util.Vector; import java.util.concurrent.BlockingQueue; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import ch.hevs.silab.structuredsim.util.FileManagement; /** * Name : ExperimentResultHandler *

- * Description : This thread is for displaying where the results are save + * Description : This thread is for displaying where the results are saved *

* Date : 25 july 2017 * @@ -46,8 +46,8 @@ public class ExperimentResultHandler implements Runnable { protected ASimulationSystemHandler glueCode; private FileManagement fm; private static final Logger logger = LogManager.getLogger(ExperimentResultHandler.class.getName()); - protected Options options; + protected Options options; /** @@ -57,8 +57,6 @@ public class ExperimentResultHandler implements Runnable { * : BlockingQueue to get the list fulfilled * @param glueCode * : Class of the glueCode - * @param options - * : options object */ public ExperimentResultHandler(BlockingQueue resultsQueue, Object glueCode, FileManagement fm, Options o) { this.resultsQueue = resultsQueue; @@ -88,7 +86,6 @@ public void run() { */ if(!resultsQueue.isEmpty()){ for (String str : resultsQueue) { - // System.out.println("result queue string : " + str); logger.debug("Result queue string : " + str); Vector measures = glueCode.extractMeasures(str); int positionOfLastSlash = str.lastIndexOf("/"); diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.java index af371a1..c84d7dd 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.java @@ -20,12 +20,11 @@ package ch.hevs.silab.structuredsim.experimenthandling; import java.util.concurrent.BlockingQueue; -import java.util.concurrent.PriorityBlockingQueue; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; -import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import ch.hevs.silab.structuredsim.util.FileManagement; /** @@ -43,6 +42,7 @@ public class ExperimentSimulatorHandler implements Runnable { protected BlockingQueue environnmentQueue; protected BlockingQueue resultsQueue; protected ASimulationSystemHandler glueCode; + protected Options options; private FileManagement fm; private static final Logger logger = LogManager.getLogger(ExperimentSimulatorHandler.class.getName()); @@ -54,8 +54,6 @@ public class ExperimentSimulatorHandler implements Runnable { * * @param environnementQueue * : The BlockignQueue where the environment will be saved - * @param simulationHandler - * : Thread of the simulation * @param o * : options object * @param glueCode @@ -67,15 +65,13 @@ public ExperimentSimulatorHandler(BlockingQueue environnementQueue, this.options = o; this.glueCode = (ASimulationSystemHandler) glueCode; this.resultsQueue = resultsQueue; - // resultsQueue = new PriorityBlockingQueue(); this.fm = fm; this.plan = plan; } /** * Method to save the result - * @param e : Environment - * @return path where the file will be save + * @return path where the file will be saved */ @Override public void run() { @@ -86,22 +82,17 @@ public void run() { do { try { - System.out.println("Size of the Simulation Queue : " + environnmentQueue.size()); + logger.debug("Size of the Simulation Queue : " + environnmentQueue.size()); Environment env = environnmentQueue.take(); - //glueCode.startSimulation(env); + glueCode.startSimulation(options.getPathParameters()); String resultPathForThisSimulation = env.pathSaveResult+"/results_sim"+ env.getId()+ ".txt"; - System.out.println(resultPathForThisSimulation); + logger.debug(resultPathForThisSimulation); fm.copyFile(options.pathToSimulatorResultFile,resultPathForThisSimulation); fm.copyFile(options.pathToSimulatorResultFile, options.pathSimulator + "/"+env.pathSaveResult.substring(env.pathSaveResult.lastIndexOf("/")+1, env.pathSaveResult.length())+"/results_sim"+ env.id +".txt"); - - //String pathResult = saveResult(env); - //env.setPathSaveResult(pathResult); resultsQueue.add(resultPathForThisSimulation); - - // to get out of the loop if (plan.isFinish) { if (environnmentQueue.isEmpty()) { diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Measure.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Measure.java index 2ebe09a..03da2b0 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Measure.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Measure.java @@ -33,7 +33,7 @@ public class Measure { - // Variable + // Variables protected String key; protected String value; diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Options.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Options.java index 6c16eb6..f96f171 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Options.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Options.java @@ -170,11 +170,10 @@ public String getPathToSimulatorResultFile() { /** * Setter for pathToSimulatorResultFolder - * @param pathToSimulatorResultFolder + * @param pathToSimulatorResultFile * */ public void setPathToSimulatorResultFile(String pathToSimulatorResultFile) { this.pathToSimulatorResultFile = pathToSimulatorResultFile; } - } \ No newline at end of file diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Parameter.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Parameter.java index e4f2a84..7a69f29 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Parameter.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/experimenthandling/Parameter.java @@ -36,7 +36,6 @@ public class Parameter { /** * Constructor of the class Parameters - * * @param key : key of the parameter * @param value : value of the parameter */ @@ -44,7 +43,7 @@ public Parameter(String key, double value) { this.key = key; this.value = value; } - + /** * Constructor * @param p : parameters @@ -54,8 +53,6 @@ public Parameter (Parameter p){ this.value = p.value; } - - @Override public String toString() { return "key : " + key + " value : " + value; @@ -93,6 +90,4 @@ public void setValue(double value) { this.value = value; } - - } diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/ConcreteModifier.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/ConcreteModifier.java new file mode 100644 index 0000000..d655f9c --- /dev/null +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/ConcreteModifier.java @@ -0,0 +1,79 @@ +package ch.hevs.silab.structuredsim.gluecode; + +import ch.hevs.silab.structuredsim.experimenthandling.Environment; +import ch.hevs.silab.structuredsim.experimenthandling.ExperimentPlanGenerator; +import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import ch.hevs.silab.structuredsim.interfaces.AModifier; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; + +import java.util.Vector; + +public class ConcreteModifier extends AModifier { + + + private static final Logger logger = LogManager.getLogger(ConcreteModifier.class.getName()); + + String keyToChange; + char operator; + + /** + * Value to add/substract/multiply/divide to the key + */ + double delta; + + public ConcreteModifier(String keyToChange, char operator, double delta, double probability) { + super(probability, operator + "" + delta); + this.keyToChange=keyToChange; + this.probability = probability; + this.operator = operator; + this.delta=delta; + } + + public ConcreteModifier(String keyToChange, char operator, double delta) { + this(keyToChange, operator, delta, 1); + } + + public ConcreteModifier(double delta) { + this("val1", '*', delta, delta); + } + public ConcreteModifier() { + } + + + @Override + public Environment applyModifier(Environment env) { + Vector params = env.getSetOfParameters(); + for (Parameter p : params) { + logger.debug("param=" + p.getKey() + " keyToChange=" + keyToChange); + if (p.getKey().equals(keyToChange)) { + switch(operator) { + case '+': + p.setValue(p.getValue() + delta); + break; + case '-': + p.setValue(p.getValue() - delta); + break; + case '*': + p.setValue(p.getValue() * delta); + break; + case '/': + p.setValue(p.getValue() / delta); + break; + } + } + } + return env; + } + + public static double findValue(Vector params, String key) { + String value = null; + for (Parameter p : params) { + if (p.getKey().equals(key)) { + return p.getValue(); + } + } + return -1; + } + +} diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/MySimulator.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/MySimulator.java new file mode 100644 index 0000000..39254db --- /dev/null +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/MySimulator.java @@ -0,0 +1,36 @@ +package ch.hevs.silab.structuredsim.gluecode; + +import java.io.*; +import java.util.HashMap; +import java.util.Map; + +public class MySimulator { + + public static void run(String pathToInputFile, String pathToResultFile) { + Map params = new HashMap<>(); + + try { + BufferedReader in = new BufferedReader( + new InputStreamReader(new FileInputStream(pathToInputFile), "UTF-8")); + String line; + while ((line = in.readLine()) != null) { + int pos = line.indexOf("="); + String key = line.substring(0, pos).trim(); + double value = Double.parseDouble(line.substring(pos + 1).trim()); + params.put(key, value); + } + in.close(); + + double result = params.get("val1") * params.get("val2"); + + BufferedWriter bw = new BufferedWriter(new FileWriter(pathToResultFile)); + bw.write("result=" + result); + bw.newLine(); + bw.flush(); + bw.close(); + + } catch (Exception e) { + e.printStackTrace(); + } + } +} \ No newline at end of file diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/SimpleSimulationHandler.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/SimpleSimulationHandler.java new file mode 100644 index 0000000..1fcdad1 --- /dev/null +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/SimpleSimulationHandler.java @@ -0,0 +1,139 @@ +package ch.hevs.silab.structuredsim.gluecode; + +import ch.hevs.silab.structuredsim.experimenthandling.Measure; +import ch.hevs.silab.structuredsim.interfaces.AModifier; +import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; + +import java.io.*; +import java.util.ArrayList; +import java.util.List; +import java.util.Vector; + +public class SimpleSimulationHandler extends ASimulationSystemHandler { + + private List modifiers = new ArrayList(); + + public SimpleSimulationHandler() { + } + + public SimpleSimulationHandler(List modifiers) { + this.modifiers = modifiers; + } + + + @Override + public Vector extractMeasures(String resultsFilePath) { + String separator = "="; + Vector measuresList = new Vector(); + String measureKey; + String measureValue; + BufferedReader in; + try { + in = new BufferedReader( + new InputStreamReader(new FileInputStream(resultsFilePath), "UTF-8")); + String line = ""; + while ((line = in.readLine()) != null) { + + int pos = line.indexOf(separator); + measureKey = line.substring(0, pos); + measureValue = (line.substring(pos + 1, line.length())); + measuresList.add(new Measure(measureKey, measureValue)); + } + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return measuresList; + } + + @Override + public List initiateModifierList() {; + listModifierClass = modifiers; + return listModifierClass; + } + + + @Override + public Vector readParametersFile(String parametersFilePath) { + String separator = "="; + Vector parametersList = new Vector(); + String key; + double value; + BufferedReader in; + try { + in = new BufferedReader( + new InputStreamReader(new FileInputStream(parametersFilePath), "UTF-8")); + String line = ""; + while ((line = in.readLine()) != null) { + int pos = line.indexOf(separator); + key = line.substring(0, pos); + value = Double.parseDouble(line.substring(pos + 1, line.length())); + parametersList.add(new Parameter(key, value)); + } + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return parametersList; + + } + + public Vector readParametersFile(InputStream inputStream) { + String separator = "="; + Vector parametersList = new Vector<>(); + String key; + double value; + + try { + BufferedReader in = new BufferedReader( + new InputStreamReader(inputStream, "UTF-8")); + String line = ""; + while ((line = in.readLine()) != null) { + int pos = line.indexOf(separator); + key = line.substring(0, pos); + value = Double.parseDouble(line.substring(pos + 1, line.length())); + parametersList.add(new Parameter(key, value)); + } + in.close(); + } catch (IOException e) { + e.printStackTrace(); + } + return parametersList; + } + + + @Override + public void writeParametersFile(Vector setOfParameters, String locationToStore) { + + try { + BufferedWriter bw = new BufferedWriter(new FileWriter(locationToStore + "/myParamFile.txt")); + for (Parameter p: setOfParameters) { + bw.write(p.getKey() + "=" + p.getValue()); + bw.newLine(); + } + bw.flush(); + bw.close(); + } catch (Exception e) { + e.printStackTrace(); + } + } + + @Override + public void startSimulation(String pathToInputFile) { + String resultFile = options.getPathToSimulatorResultFile(); + new File(resultFile).getParentFile().mkdirs(); + try { + new File(resultFile).createNewFile(); + } catch (IOException e) { + e.printStackTrace(); + } + } + + @Override + public void stopProgram() { + + } +} + + diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/Simulation.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/Simulation.java new file mode 100644 index 0000000..6ad7696 --- /dev/null +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/gluecode/Simulation.java @@ -0,0 +1,31 @@ +package ch.hevs.silab.structuredsim.gluecode; + +import ch.hevs.silab.structuredsim.interfaces.AModifier; +import ch.hevs.silab.structuredsim.interfaces.StartProgram; + +import java.io.IOException; +import java.io.InputStream; +import java.util.ArrayList; +import java.util.List; + +public class Simulation extends StartProgram { + + // Mock-up code for a simple simulation + public static void main(String[] args) throws IOException { + + InputStream pathConfigFile = Simulation.class + .getClassLoader() + .getResourceAsStream("config.properties"); + + List modifiers = new ArrayList(); + + modifiers.add(new ConcreteModifier("val2", '+', 1.0, 0.5)); + modifiers.add(new ConcreteModifier("val2", '+', 10.0, 0.5)); + + //Custom class + SimpleSimulationHandler ssh = new SimpleSimulationHandler(modifiers); + + startProgram(pathConfigFile, ssh); + + } +} diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/AModifier.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/AModifier.java index d103060..4a3519a 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/AModifier.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/AModifier.java @@ -45,6 +45,16 @@ public AModifier(){ this.name ="AModifier"; } + /** + * This constructor is used in the integration tests + * @param probability + * @param name + */ + public AModifier(double probability, String name) { + this.probability=probability; + this.name=name; + } + /** @@ -61,8 +71,7 @@ public AModifier(){ * use the method getParameterToModify to get the Parameter.

Example : Parameters newParam = getParameterToModify(env.getSetOfParameters(), options.getValueToChange); * * - * @param env : Environment. An Environment is one state of the simulation at the instant T. - * @param o : options for the simulation + * @param env : Environment. An Environment is one state of the simulation at the instant T. * @return : environment. */ public abstract Environment applyModifier(Environment env); @@ -82,22 +91,11 @@ public double getProbability() { public void setProbability(double probability) { this.probability = probability; } - - - public String getName() { return name; } - - - public void setName(String name) { this.name = name; } - - - - - } \ No newline at end of file diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.java index 272d8d1..6ca7e38 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.java @@ -19,6 +19,7 @@ * */ package ch.hevs.silab.structuredsim.interfaces; +import java.io.InputStream; import java.util.Vector; import ch.hevs.silab.structuredsim.experimenthandling.Parameter; @@ -44,6 +45,15 @@ public interface IManageParametersFile { */ public Vector readParametersFile(String parametersFilePath); + + + /** + * Method to read parameters from an InputStream instead + * @author Matthias Gaillard + */ + public Vector readParametersFile(InputStream inputStream); + + /** * Method to write a new file of parameters that will be used by your * simulator EACH TIME that a Parameter change ! diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.java index fa996b8..8b64304 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.java @@ -33,7 +33,6 @@ public interface IStartSimulation { /** *Method to start the simulation that is an external application. The result are save in file txt - * @param baseEnvToSimulate : Environment that will get the simulation */ public void startSimulation(String pathToInputFile); diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/StartProgram.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/StartProgram.java index 724c7b0..5a2af40 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/StartProgram.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/interfaces/StartProgram.java @@ -21,16 +21,17 @@ import java.io.IOException; +import java.io.InputStream; import java.util.Vector; import java.util.concurrent.BlockingQueue; import java.util.concurrent.PriorityBlockingQueue; import ch.hevs.silab.structuredsim.experimenthandling.Environment; import ch.hevs.silab.structuredsim.experimenthandling.ExperimentPlanGenerator; -import ch.hevs.silab.structuredsim.experimenthandling.ExperimentResultHandler; import ch.hevs.silab.structuredsim.experimenthandling.ExperimentSimulatorHandler; import ch.hevs.silab.structuredsim.experimenthandling.Options; import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import ch.hevs.silab.structuredsim.gluecode.Simulation; import ch.hevs.silab.structuredsim.util.FileManagement; /** @@ -52,13 +53,12 @@ public class StartProgram { * @param glueCode : glue code object * @throws IOException */ - public static void startProgram(String pathConfigFile, Object glueCode) throws IOException { + public static void startProgram(InputStream pathConfigFile, Object glueCode) throws IOException { FileManagement fm = new FileManagement(); // Create an instance of the "GlueCode" ASimulationSystemHandler glueCodeClass = (ASimulationSystemHandler) glueCode; -// glueCodeClass.fileManagement = fm; // Load the configuration properties file Options o = fm.loadDataFromPropertiesFile(pathConfigFile); @@ -67,8 +67,10 @@ public static void startProgram(String pathConfigFile, Object glueCode) throws I // Get the List of the Parameters Vector listParam = null; - listParam = glueCodeClass.readParametersFile(o.getPathParameters()); - + InputStream isParams = Simulation.class + .getClassLoader() + .getResourceAsStream(o.getPathParameters()); + listParam = glueCodeClass.readParametersFile(isParams); // Select the Parameter to change Environment baseEnv = new Environment(0, listParam, 1); @@ -77,25 +79,28 @@ public static void startProgram(String pathConfigFile, Object glueCode) throws I BlockingQueue resultQueue = new PriorityBlockingQueue(); glueCodeClass.setOptions(o); - - ExperimentPlanGenerator planning = new ExperimentPlanGenerator(queue, baseEnv, o, glueCodeClass, fm); - Thread planningThread = new Thread(planning); - planningThread.setName("Planning Thread"); - planningThread.start(); - - ExperimentSimulatorHandler simulator = new ExperimentSimulatorHandler(queue, resultQueue, o, glueCodeClass, fm, planning); - Thread simultationThread = new Thread(simulator); - simultationThread.setName("Simulation Thread"); - simultationThread.start(); - - /*** - * This thread was moved in the run method of ExperimentSimulatorHandler. - * Because all results need to be analyse and measures extracted only after simulations done. - * ExperimentResultHandler result = new ExperimentResultHandler(resultQueue, glueCodeClass, fm, o); - * Thread resultThread = new Thread(result); - * resultThread.setName("Result Thread"); - * resultThread.start(); - */ + + // This if statement prevents generation of theoretically infinite tree + if(!o.getTypeOfCuttOfPlanning().equals("CRITERIA") || o.getStopCriteria()>0) { + ExperimentPlanGenerator planning = new ExperimentPlanGenerator(queue, baseEnv, o, glueCodeClass, fm); + Thread planningThread = new Thread(planning); + planningThread.setName("Planning Thread"); + planningThread.start(); + + ExperimentSimulatorHandler simulator = new ExperimentSimulatorHandler(queue, resultQueue, o, glueCodeClass, fm, planning); + Thread simultationThread = new Thread(simulator); + simultationThread.setName("Simulation Thread"); + simultationThread.start(); + + /*** + * This thread was moved in the run method of ExperimentSimulatorHandler. + * Because all results need to be analyse and measures extracted only after simulations done. + * ExperimentResultHandler result = new ExperimentResultHandler(resultQueue, glueCodeClass, fm, o); + * Thread resultThread = new Thread(result); + * resultThread.setName("Result Thread"); + * resultThread.start(); + */ + } } } \ No newline at end of file diff --git a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/util/FileManagement.java b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/util/FileManagement.java index f1a122d..ab51927 100644 --- a/structSimV1/src/main/java/ch/hevs/silab/structuredsim/util/FileManagement.java +++ b/structSimV1/src/main/java/ch/hevs/silab/structuredsim/util/FileManagement.java @@ -39,16 +39,14 @@ import java.util.LinkedHashMap; import java.util.Properties; import java.util.Vector; -import java.util.concurrent.BlockingQueue; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.Logger; import ch.hevs.silab.structuredsim.experimenthandling.Environment; import ch.hevs.silab.structuredsim.experimenthandling.Measure; import ch.hevs.silab.structuredsim.experimenthandling.Options; -import ch.hevs.silab.structuredsim.experimenthandling.Parameter; -import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; /** * The goal of this class is to manage parameters and/or results files. @@ -69,6 +67,7 @@ public class FileManagement { // Variables protected String filename; + protected Options options; private String pathResult, pathSimulator; private static final Logger logger = LogManager.getLogger(FileManagement.class.getName()); @@ -119,13 +118,13 @@ public String contentOfAFile() throws IOException { */ public void moveFile(String originFile, String destinationFile) { Path originPath = Paths.get(originFile); + if (!Files.exists(originPath)) return; Path destinationPath = Paths.get(destinationFile); try { Files.move(originPath, destinationPath, REPLACE_EXISTING); } catch (IOException e) { logger.error("Impossible to move this file"); - //System.out.println("Impossible to move this file"); e.printStackTrace(); } } @@ -143,32 +142,13 @@ public void copyFile(String file, String destination) { File dest = new File(destination); try { - Files.copy(fileToCopy.toPath(), dest.toPath()); + Files.copy(fileToCopy.toPath(), dest.toPath(), StandardCopyOption.REPLACE_EXISTING); } catch (Exception e) { logger.error("This file in this folder already exist"); - //e.printStackTrace(); } } - /** - * This method create a new empty file in a specific folder. If the folder - * is not existing, the method create it. - * - * @param folderPath - * : The path to the folder - * @param filename - * : The name of the file to save. - */ - /* - * public void createFile(String folderPath, String filename) { File file = - * new File(folderPath + filename); file.getParentFile().mkdir(); try { - * file.createNewFile(); } catch (IOException e) { - * System.out.println("Sorry but this folder already exist!!!!"); - * e.printStackTrace(); } } - * - */ - /** Method to create an empty Folder * * @param folderPath : Path @@ -207,38 +187,6 @@ public String saveSimultationResult(String result, Environment env) throws IOExc } - /** - * Method to save a summaryFile where all the result will be summarized. - * - * @param resultQueue : the queue with results of simulations - */ - /* public void saveSummaryFile(BlockingQueue resultQueue) { - - do { - - try { - BufferedWriter bw = new BufferedWriter(new FileWriter(options.getFolderPathOUT() + "/SummaryFile.txt")); - bw.write("RunId \t ParameterChanged \t Value \t Probability \t Path"); - bw.newLine(); - - for (Environment env : resultQueue) { - String line = env.toString(); - bw.write(line); - bw.newLine(); - } - - bw.flush(); - bw.close(); - } catch (IOException e) { - e.printStackTrace(); - logger.error("Error to save the summary File"); - } - - } while (resultQueue.isEmpty()); - - } - */ - /** * Method to load data from a properties file and put in an Hashmap * @@ -258,7 +206,8 @@ public Options loadDataFromPropertiesFile(String filePath) { e.printStackTrace(); logger.error("Error to load Data from Properties file"); } - String cuttOfValue = ""; + + String cuttOfValue = properties.getProperty("cuttOfPlanning", ""); for (String key : properties.stringPropertyNames()) { @@ -311,6 +260,61 @@ public Options loadDataFromPropertiesFile(String filePath) { return options; } + /** + * Same method as the previous one, + * but using an InputStream instead of a String + * @param ips + * @return Options + */ + public Options loadDataFromPropertiesFile(InputStream ips) { + Properties properties = new Properties(); + try { + properties.load(ips); + ips.close(); + } catch (IOException e) { + e.printStackTrace(); + logger.error("Error to load Data from Properties file"); + } + + // 1. Read all simple values + options.setPathParameters(properties.getProperty("pathParameters")); + options.setFolderPathOUT(properties.getProperty("pathOUT")); + options.setPathSimulator(properties.getProperty("pathSimulator")); + options.setPathToSimulatorResultFile(properties.getProperty("pathToSimulatorResultFile")); + + // 2. Treat independant values + String cuttOfValue = properties.getProperty("cuttOfPlanning", ""); + String typeCuttOf = properties.getProperty("typeCuttOfPlanning", ""); + + options.setTypeOfCuttOfPlanning(typeCuttOf); + + switch (typeCuttOf) { + case "INT": + options.setCuttOfPlanning(Integer.parseInt(cuttOfValue)); + break; + case "DAY": + Calendar cal1 = Calendar.getInstance(); + cal1.set(Calendar.DATE, Integer.parseInt(cuttOfValue)); + options.setCuttOfPlanningH(cal1); + break; + case "HOURS": + Calendar cal2 = Calendar.getInstance(); + cal2.set(Calendar.HOUR_OF_DAY, Integer.parseInt(cuttOfValue)); + options.setCuttOfPlanningH(cal2); + break; + case "MINUTES": + Calendar cal3 = Calendar.getInstance(); + cal3.set(Calendar.MINUTE, Integer.parseInt(cuttOfValue)); + options.setCuttOfPlanningH(cal3); + break; + case "CRITERIA": + options.setStopCriteria(Double.parseDouble(cuttOfValue)); + break; + } + + return options; + } + /** * Method to write something in a properties file parameters : *

    @@ -334,19 +338,19 @@ public void writeDataInPropertiesFile(LinkedHashMap dataToWrite, Properties properties = new Properties(); properties.putAll(dataToWrite); - // Write the results in the existing file, at the end of the file, - // don't deleted what is already in the file. + /* Write the results in the existing file, at the end of the file, + don't deleted what is already in the file. + Does create the file if it does not exist, + but launch exception when the folder is missing*/ FileOutputStream fops = new FileOutputStream(filePath, keepPreviousResults); properties.store(fops, null); fops.close(); } catch (IOException e) { - //System.out.println(e.toString()); logger.error(e.toString()); } } - /** * Method to create a new folder for each simulation * @param e : current environment @@ -416,6 +420,20 @@ public void createModifierFile(String path, String modifier){ } + public String getFilename() { + return filename; + } + + public void setFilename(String filename) { + this.filename = filename; + } + public Options getOptions() { + return options; + } + + public void setOptions(Options options) { + this.options=options; + } } diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/AppTest.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/AppTest.java deleted file mode 100644 index de7feaa..0000000 --- a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/AppTest.java +++ /dev/null @@ -1,38 +0,0 @@ -package hevs.ch.silab.hevs.ch.silab; - -import junit.framework.Test; -import junit.framework.TestCase; -import junit.framework.TestSuite; - -/** - * Unit test for simple App. - */ -public class AppTest - extends TestCase -{ - /** - * Create the test case - * - * @param testName name of the test case - */ - public AppTest( String testName ) - { - super( testName ); - } - - /** - * @return the suite of tests being tested - */ - public static Test suite() - { - return new TestSuite( AppTest.class ); - } - - /** - * Rigourous Test :-) - */ - public void testApp() - { - assertTrue( true ); - } -} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/IntegrationTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/IntegrationTests.java new file mode 100644 index 0000000..d57567b --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/IntegrationTests.java @@ -0,0 +1,397 @@ +package hevs.ch.silab.hevs.ch.silab.integrationTests; + +import ch.hevs.silab.structuredsim.gluecode.ConcreteModifier; +import ch.hevs.silab.structuredsim.gluecode.SimpleSimulationHandler; +import ch.hevs.silab.structuredsim.gluecode.Simulation; +import ch.hevs.silab.structuredsim.interfaces.AModifier; + +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.io.IOException; + +import java.io.BufferedWriter; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileWriter; + +import static org.junit.jupiter.api.Assertions.*; + + +/** + * This class is used to test the overall behavior of the framework, + * It checks whether the output summary file + * is correctly computed when given inputs. + * Scenarios mentioned in the tests are illustrated + * with pictures in this folder. + * @author Matthias Gaillard + */ +public class IntegrationTests { + private String pathOUT = System.getProperty("java.io.tmpdir").replace("\\", "/") + "/structsim-results"; + private String pathSIM = System.getProperty("java.io.tmpdir").replace("\\", "/") + "/structsim-simulator"; + + + /** + * This method returns a list of predefined modifiers + * depending on a scenario number. + * + * @param scenario + * @return + */ + private List returnModifiersFromScenario(int scenario) { + ArrayList modifiers = new ArrayList<>(); + switch (scenario) { + case 1: + modifiers.add(new ConcreteModifier(0.5)); + return modifiers; + case 2: + modifiers.add(new ConcreteModifier(0.2)); + modifiers.add(new ConcreteModifier(0.5)); + return modifiers; + case 4: + modifiers.add(new ConcreteModifier(0.1)); + modifiers.add(new ConcreteModifier(0.8)); + modifiers.add(new ConcreteModifier(0.5)); + modifiers.add(new ConcreteModifier(0.2)); + return modifiers; + } + return modifiers; + } + + + /** + * This method returns the expected summaryFile + * depending on a scenario number. + * The tree might not be written fully in the summary file + * depending on the cuttOf value, this will be handled as well. + * + * @param scenario + * @return expected summaryFile + */ + private String[] returnExpectedLinesFromScenario(int scenario) { + switch (scenario) { + case 1: + return new String[]{ + "Simulation ID : 1\t Probability : 0.5\t Modifier implemented : *0.5", + "Simulation ID : 2\t Probability : 0.25\t Modifier implemented : *0.5 *0.5", + "Simulation ID : 3\t Probability : 0.125\t Modifier implemented : *0.5 *0.5 *0.5", + "Simulation ID : 4\t Probability : 0.0625\t Modifier implemented : *0.5 *0.5 *0.5 *0.5" + }; + case 2: + return new String[]{ + "Simulation ID : 1\t Probability : 0.2\t Modifier implemented : *0.2", + "Simulation ID : 2\t Probability : 0.5\t Modifier implemented : *0.5", + "Simulation ID : 3\t Probability : 0.1\t Modifier implemented : *0.5 *0.2", + "Simulation ID : 4\t Probability : 0.25\t Modifier implemented : *0.5 *0.5", + "Simulation ID : 5\t Probability : 0.05\t Modifier implemented : *0.5 *0.5 *0.2", + "Simulation ID : 6\t Probability : 0.125\t Modifier implemented : *0.5 *0.5 *0.5", + "Simulation ID : 7\t Probability : 0.04000000000000001\t Modifier implemented : *0.2 *0.2", + "Simulation ID : 8\t Probability : 0.1\t Modifier implemented : *0.2 *0.5", + "Simulation ID : 9\t Probability : 0.025\t Modifier implemented : *0.5 *0.5 *0.5 *0.2", + "Simulation ID : 10\t Probability : 0.0625\t Modifier implemented : *0.5 *0.5 *0.5 *0.5", + "Simulation ID : 11\t Probability : 0.020000000000000004\t Modifier implemented : *0.5 *0.2 *0.2", + "Simulation ID : 12\t Probability : 0.05\t Modifier implemented : *0.5 *0.2 *0.5", + "Simulation ID : 13\t Probability : 0.020000000000000004\t Modifier implemented : *0.2 *0.5 *0.2", + "Simulation ID : 14\t Probability : 0.05\t Modifier implemented : *0.2 *0.5 *0.5", + }; + case 4: + return new String[]{ + "Simulation ID : 1\t Probability : 0.1\t Modifier implemented : *0.1", + "Simulation ID : 2\t Probability : 0.8\t Modifier implemented : *0.8", + "Simulation ID : 3\t Probability : 0.5\t Modifier implemented : *0.5", + "Simulation ID : 4\t Probability : 0.2\t Modifier implemented : *0.2", + + "Simulation ID : 5\t Probability : 0.08000000000000002\t Modifier implemented : *0.8 *0.1", + "Simulation ID : 6\t Probability : 0.6400000000000001\t Modifier implemented : *0.8 *0.8", + "Simulation ID : 7\t Probability : 0.4\t Modifier implemented : *0.8 *0.5", + "Simulation ID : 8\t Probability : 0.16000000000000003\t Modifier implemented : *0.8 *0.2", + + "Simulation ID : 9\t Probability : 0.06400000000000002\t Modifier implemented : *0.8 *0.8 *0.1", + "Simulation ID : 10\t Probability : 0.5120000000000001\t Modifier implemented : *0.8 *0.8 *0.8", + "Simulation ID : 11\t Probability : 0.32000000000000006\t Modifier implemented : *0.8 *0.8 *0.5", + "Simulation ID : 12\t Probability : 0.12800000000000003\t Modifier implemented : *0.8 *0.8 *0.2", + + "Simulation ID : 13\t Probability : 0.051200000000000016\t Modifier implemented : *0.8 *0.8 *0.8 *0.1", + "Simulation ID : 14\t Probability : 0.40960000000000013\t Modifier implemented : *0.8 *0.8 *0.8 *0.8", + "Simulation ID : 15\t Probability : 0.25600000000000006\t Modifier implemented : *0.8 *0.8 *0.8 *0.5", + "Simulation ID : 16\t Probability : 0.10240000000000003\t Modifier implemented : *0.8 *0.8 *0.8 *0.2", + + "Simulation ID : 17\t Probability : 0.05\t Modifier implemented : *0.5 *0.1", + "Simulation ID : 18\t Probability : 0.4\t Modifier implemented : *0.5 *0.8", + "Simulation ID : 19\t Probability : 0.25\t Modifier implemented : *0.5 *0.5", + "Simulation ID : 20\t Probability : 0.1\t Modifier implemented : *0.5 *0.2", + }; + + } + return null; + } + + /** + * Deletes everything in pathOUT + * Claude generated + * @throws IOException + */ + private void cleanOutputDirectory() throws IOException { + Path resultsPath = Paths.get(pathOUT); + if (Files.exists(resultsPath)) { + Files.walk(resultsPath) + .sorted(Comparator.reverseOrder()) + .filter(p -> !p.equals(resultsPath)) // ← Don't delete root path + .forEach(p -> { + try { Files.delete(p); } + catch (IOException e) { e.printStackTrace(); } + }); + } + } + + /** + * Help method, used in all other tests + * It tests content of SummaryFile + * as well as the number of lines in it. + * + * @param cuttOfPlanning + * @param typeCuttOfPlanning + * @param modifiers + * @param expectedLines + * @throws IOException + */ + private void runAndAssertSummaryFile( + String cuttOfPlanning, + String typeCuttOfPlanning, + List modifiers, + String[] expectedLines + ) throws IOException { + + // Arrange + cleanOutputDirectory(); + Files.createDirectories(Paths.get(pathOUT)); + Files.createDirectories(Paths.get(pathSIM)); + File tempDir = Files.createTempDirectory("structsim-test").toFile(); + File tempConfig = new File(tempDir, "config.properties"); + + String configContent = + "pathOUT = " + pathOUT + "\n" + + "pathParameters = parameters.txt\n" + + "pathSimulator = " + pathSIM + "\n" + + "pathToSimulatorResultFile = " + pathSIM + "/results/results.txt\n" + + "cuttOfPlanning = " + cuttOfPlanning + "\n" + + "typeCuttOfPlanning = " + typeCuttOfPlanning + "\n"; + try (BufferedWriter bw = new BufferedWriter(new FileWriter(tempConfig))) { + bw.write(configContent); + } + InputStream pathConfigFile = new FileInputStream(tempConfig); + SimpleSimulationHandler ssh = new SimpleSimulationHandler(modifiers); + + // Act + Simulation s = new Simulation(); + try { + s.startProgram(pathConfigFile, ssh); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // Poll + File summaryFile = new File(pathOUT + "/SummaryFile.txt"); + long timeout = 15_000; + long start = System.currentTimeMillis(); + List lines = new ArrayList<>(); + + while (System.currentTimeMillis() - start < timeout) { + if (summaryFile.exists()) { + lines.clear(); + boolean foundBlankLine = false; + try (BufferedReader br = new BufferedReader(new FileReader(summaryFile))) { + String line; + while ((line = br.readLine()) != null) { + if (line.trim().isEmpty()) { + foundBlankLine = true; + break; + } + lines.add(line); + } + } catch (IOException e) { + } + if (foundBlankLine) break; + } + try { + Thread.sleep(200); + } catch (InterruptedException ie) { + Thread.currentThread().interrupt(); + } + } + + // Assert + assertTrue(summaryFile.exists(), "SummaryFile.txt should exist"); + assertEquals(expectedLines.length, lines.size()); + for (int i = 0; i < expectedLines.length; i++) { + assertEquals(expectedLines[i], lines.get(i), "Incorrect content at line " + (i + 1)); + } + + } + + + /** + * This test tests the generated summary file + * with all scenarios and relevant INT cuttOfValues. + * @throws IOException + */ + @ParameterizedTest + @CsvSource({ + "1,1", + "1,2", + "1,3", + "1,4", + "2,1", + "2,2", + "2,3", + "2,4", + "2,5", + "2,6", + "2,7", + "4,1", + "4,2", + "4,3", + "4,4", + "4,5" + }) + public void test_INTcutoffType(int scenarioNumber, int cuttOfPlanning) throws IOException { + String typeCuttOfPlanning = "INT"; + List modifiers = returnModifiersFromScenario(scenarioNumber); + String[] expectedLines = returnExpectedLinesFromScenario(scenarioNumber); + + /* + The cutOff represents the number of iterations of the algorithm + = number of time a node is explored. + So we need to keep a number of lines equals to + numberOfIterations * numberOfModifiers, which means cuttOfPlanning*scenarioNumber + */ + int numberOfLinesToKeep = cuttOfPlanning * scenarioNumber; + + String[] exactExpectedLines = Arrays.copyOfRange(expectedLines, 0, numberOfLinesToKeep); + runAndAssertSummaryFile(String.valueOf(cuttOfPlanning), typeCuttOfPlanning, modifiers, exactExpectedLines); + } + + /** + * Same as previous test, but here we test the CRITERIA type. + * @param scenarioNumber + * @param cuttOfPlanning + * @param expectedNumberOfLines + * @throws IOException + */ + @ParameterizedTest + @CsvSource(value = { + "1,0.1,4", + "1,0.2,3", + "1,0.3,2", + "1,0.4,2", + "1,0.5,1", + "1,0.6,1", + "1,0.7,1", + "1,0.8,1", + "1,0.9,1", + "2,0.1,10", + "2,0.2,6", + "2,0.3,4", + "2,0.4,4", + "2,0.5,2", + "2,0.6,2", + "2,0.7,2", + "2,0.8,2", + "2,0.9,2", + "4,0.45,20", + "4,0.5,16", + "4,0.6,12", + "4,0.7,8", + "4,0.8,4", + "4,0.9,4", + }) + public void test_CRITERIAcutoffType(int scenarioNumber, double cuttOfPlanning, int expectedNumberOfLines) throws IOException { + String typeCuttOfPlanning = "CRITERIA"; + List modifiers = returnModifiersFromScenario(scenarioNumber); + String[] expectedLines = returnExpectedLinesFromScenario(scenarioNumber); + String[] exactExpectedLines = Arrays.copyOfRange(expectedLines, 0, expectedNumberOfLines); + runAndAssertSummaryFile(String.valueOf(cuttOfPlanning), typeCuttOfPlanning, modifiers, exactExpectedLines); + } + + /** + * This test tests the CRITERIA cuttOfType, with value 1. + * With the current implementation of ExperimentPlanGenerator, + * a first iteration is always done, + * which is why in this test we expect to have as many lines + * as there are modifiers. + * + * @param scenarioNumber + * @param cuttOfPlanning + * @param expectedNumberOfLines + * @throws IOException + */ + @ParameterizedTest + @CsvSource(value = { + "1,1,1", + "2,1,2", + "4,1,4", + }) + public void test_CRITERIAcutoffType_valueOne(int scenarioNumber, double cuttOfPlanning, int expectedNumberOfLines) throws IOException { + String typeCuttOfPlanning = "CRITERIA"; + List modifiers = returnModifiersFromScenario(scenarioNumber); + String[] expectedLines = returnExpectedLinesFromScenario(scenarioNumber); + String[] exactExpectedLines = Arrays.copyOfRange(expectedLines, 0, expectedNumberOfLines); + runAndAssertSummaryFile(String.valueOf(cuttOfPlanning), typeCuttOfPlanning, modifiers, exactExpectedLines); + } + + /** + * This test tests the case of a CRITERIA cutoff value of 0 + * In the current implementation, it will cause the program to crash + * because the generated tree would be arithmetically infinite, + * An if statement was added in the StartProgram class + * to prevent the threads from running if that is the case. + * @throws IOException + */ + @Test + public void test_CRITERIAcutoffType_valueZero() throws IOException { + String typeCuttOfPlanning = "CRITERIA"; + int scenarioNumber = 1; + int cuttOfPlanning = 0; + List modifiers = returnModifiersFromScenario(scenarioNumber); + + new File(pathOUT + "/SummaryFile.txt").delete(); // Delete old summary file + File tempDir = Files.createTempDirectory("structsim-test").toFile(); + File tempConfig = new File(tempDir, "config.properties"); + + String configContent = + "pathOUT = " + pathOUT + "\n" + + "pathParameters = parameters.txt\n" + + "pathSimulator = " + pathSIM + "\n" + + "pathToSimulatorResultFile = " + pathSIM + "/results/results.txt\n" + + "cuttOfPlanning = " + cuttOfPlanning + "\n" + + "typeCuttOfPlanning = " + typeCuttOfPlanning + "\n"; + try (BufferedWriter bw = new BufferedWriter(new FileWriter(tempConfig))) { + bw.write(configContent); + } + InputStream pathConfigFile = new FileInputStream(tempConfig); + SimpleSimulationHandler ssh = new SimpleSimulationHandler(modifiers); + + // Act + Simulation s = new Simulation(); + try { + s.startProgram(pathConfigFile, ssh); + } catch (IOException e) { + throw new RuntimeException(e); + } + File summaryFile = new File(pathOUT + "/SummaryFile.txt"); + + // Assert + assertFalse(summaryFile.exists(), "SummaryFile.txt should not exist"); + + } +} \ No newline at end of file diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario1.jpeg b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario1.jpeg new file mode 100644 index 0000000..b9e84dc Binary files /dev/null and b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario1.jpeg differ diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario2.jpeg b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario2.jpeg new file mode 100644 index 0000000..0110ec4 Binary files /dev/null and b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario2.jpeg differ diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario4.jpeg b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario4.jpeg new file mode 100644 index 0000000..d316f1a Binary files /dev/null and b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/integrationTests/Scenario4.jpeg differ diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/environment/EnvironmentTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/environment/EnvironmentTests.java new file mode 100644 index 0000000..f95fba1 --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/environment/EnvironmentTests.java @@ -0,0 +1,83 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.environment; + +import ch.hevs.silab.structuredsim.experimenthandling.Environment; +import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import org.junit.jupiter.api.Test; + +import java.util.ArrayList; +import java.util.Vector; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from Environment class + * @author Matthias Gaillard + */ +public class EnvironmentTests { + + + /** + * Small cutOff to compare double values + */ + private double delta = 1e-9; + + @Test + public void testConstructor_shouldNotChangeTheOriginalEnv_whenConstructingNewEnv() { + + // Arrange + Parameter p1 = new Parameter("val1", 0); + Vector v = new Vector<>(); + v.add(p1); + Environment e1 = new Environment(1, v, 0.3); + Environment e2 = new Environment(2, e1); + e2.getSetOfParameters().get(0).setValue(1); + + // Act + double expectedE1Value = e1.getSetOfParameters().get(0).getValue(); + double expectedE2Value = e2.getSetOfParameters().get(0).getValue(); + + // Assert + assertEquals(expectedE1Value, 0, delta); + assertEquals(expectedE2Value, 1, delta); + + } + @Test + public void testCompareTo_shouldReturnCorrectValue_whenComparingEnvironments() { + + // Arrange + Environment low = new Environment(1, new Vector(), 0.3); + Environment high = new Environment(2, new Vector(), 0.5); + Environment low2 = new Environment(2, new Vector(), 0.3); + + // Act + int shouldBeNegative = low.compareTo(high); + int shouldBePositive = high.compareTo(low); + int shouldBeZero = low.compareTo(low2); + + // Assert + assertTrue(shouldBeNegative < 0); + assertTrue(shouldBePositive > 0); + assertEquals(shouldBeZero, 0, delta); + + } + + @Test + public void testToStringModifier_shouldReturnCorrectString_whenDisplayingTheEnvAsAString() { + + // Arrange + Environment e = new Environment(1, new Vector(), 0.3); + ArrayList trace = new ArrayList<>(); + trace.add("m1"); + trace.add("m2"); + e.setTrace(trace); + + // Act + String expectedString = "Simulation ID : 1\t Probability : 0.3\t Modifier implemented : m1 m2"; + String actualString = e.toStringModifier(); + + // Assert + assertEquals(expectedString, actualString); + + } + +} \ No newline at end of file diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementContentTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementContentTests.java new file mode 100644 index 0000000..9797add --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementContentTests.java @@ -0,0 +1,86 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import org.junit.jupiter.api.Test; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import static org.junit.jupiter.api.Assertions.*; + + +/** + * This class is used to test methods from FileManagement class + * related to file reading + * @see FileManagementTests + * @author Matthias Gaillard + */ + +public class FileManagementContentTests extends FileManagementTests { + + + // Claude generated + @Test + void contentOfAFile_shouldReturnErrorMessage_whenFileDoesNotExist() throws IOException { + // Arrange + fileManagement.setFilename("/noFile.txt"); + + // Act + String result = fileManagement.contentOfAFile(); + + // Assert + assertEquals("this is not a file", result); + } + + // Claude generated + @Test + void contentOfAFile_shouldReturnContent_whenFileExists() throws IOException { + + // Arrange + Path tempFile = tempDir.resolve("test.txt"); + Files.writeString(tempFile, "Hello World"); + + fileManagement.setFilename(tempFile.toString()); + + // Act + String result = fileManagement.contentOfAFile(); + + // Assert + assertEquals("Hello World", result); + } + + // Claude generated + @Test + void contentOfAFile_shouldConcatenateLines_whenFileHasMultipleLines() throws IOException { + + // Arrange + Path tempFile = tempDir.resolve("multiline.txt"); + Files.write(tempFile, java.util.List.of("line1", "line2", "line3")); + + fileManagement.setFilename(tempFile.toString()); + + // Act + String result = fileManagement.contentOfAFile(); + + // Assert + assertEquals("line1line2line3", result); + } + + // Claude generated + @Test + void contentOfAFile_shouldReturnEmptyString_whenFileIsEmpty() throws IOException { + + // Arrange + Path tempFile = tempDir.resolve("empty.txt"); + Files.createFile(tempFile); + + fileManagement.setFilename(tempFile.toString()); + + // Act + String result = fileManagement.contentOfAFile(); + + // Assert + assertEquals("", result); + } + +} \ No newline at end of file diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementExportFilesTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementExportFilesTests.java new file mode 100644 index 0000000..e21e28c --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementExportFilesTests.java @@ -0,0 +1,79 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import ch.hevs.silab.structuredsim.experimenthandling.Measure; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Vector; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from FileManagement class + * related to measures and modifiers + * @see FileManagementTests + * @see Measure + * @see ch.hevs.silab.structuredsim.interfaces.AModifier + * @author Matthias Gaillard + */ +public class FileManagementExportFilesTests extends FileManagementTests { + + // ChatGPT generated + @Test + void createMeasuresFile_shouldCreateMeasuresFile(@TempDir Path tempDir) throws Exception { + + // Arrange + Vector measures = new Vector<>(); + + Measure m1 = new Measure("throughput", "12"); + Measure m2 = new Measure("latency", "50"); + + measures.add(m1); + measures.add(m2); + + Path measuresFile = tempDir.resolve("measures.txt"); + + // Act + fileManagement.createMeasuresFile( + measures, + measuresFile.toString()); + + // Assert + assertTrue(Files.exists(measuresFile)); + + List lines = Files.readAllLines(measuresFile); + + assertEquals(2, lines.size()); + assertEquals("throughput=12", lines.get(0)); + assertEquals("latency=50", lines.get(1)); + } + + // ChatGPT generated + @Test + void createModifierFile_shouldCreateSummaryFile(@TempDir Path tempDir) throws Exception { + + // Arrange + String modifier = "SIMULATION_FINISHED"; + + // Act + fileManagement.createModifierFile( + tempDir.toString(), + modifier); + + // Assert + Path summaryFile = + tempDir.resolve("SummaryFile.txt"); + + assertTrue(Files.exists(summaryFile)); + + List lines = + Files.readAllLines(summaryFile); + + assertEquals(1, lines.size()); + assertEquals(modifier, lines.get(0)); + } + +} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementFileOperationsTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementFileOperationsTests.java new file mode 100644 index 0000000..5463eb7 --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementFileOperationsTests.java @@ -0,0 +1,158 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; + +import org.junit.jupiter.api.Test; +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from FileManagement class + * related to pure file system (copying, moving...) + * @see FileManagementTests + * @author Matthias Gaillard + */ + +public class FileManagementFileOperationsTests extends FileManagementTests { + + + // Claude generated + @Test + void moveFile_shouldMoveFile_whenOriginExists() throws IOException { + // Arrange + Path origin = tempDir.resolve("origin.txt"); + Path destination = tempDir.resolve("destination.txt"); + Files.writeString(origin, "fileContent"); + + // Act + fileManagement.moveFile(origin.toString(), destination.toString()); + + // Assert + assertFalse(Files.exists(origin)); + assertTrue(Files.exists(destination)); + assertEquals("fileContent", Files.readString(destination)); + } + + // Claude generated + @Test + void moveFile_shouldReplaceDestination_whenDestinationAlreadyExists() throws IOException { + // Arrange + Path origin = tempDir.resolve("origin.txt"); + Path destination = tempDir.resolve("destination.txt"); + Files.writeString(origin, "newContent"); + Files.writeString(destination, "oldContent"); + + // Act + fileManagement.moveFile(origin.toString(), destination.toString()); + + // Assert + assertFalse(Files.exists(origin)); + assertEquals("newContent", Files.readString(destination)); + } + + // Claude generated + @Test + void moveFile_shouldNotThrow_whenOriginDoesNotExist() { + // Arrange + String nonExistentOrigin = tempDir.resolve("ghost.txt").toString(); + String destination = tempDir.resolve("destination.txt").toString(); + + // Act & Assert + assertDoesNotThrow(() -> fileManagement.moveFile(nonExistentOrigin, destination)); + assertFalse(Files.exists(Path.of(destination))); + } + + + // Claude generated + @Test + void copyFile_shouldCopyFile_whenSourceExists() throws IOException { + // Arrange + Path source = tempDir.resolve("source.txt"); + Path destination = tempDir.resolve("destination.txt"); + Files.writeString(source, "file content"); + + // Act + fileManagement.copyFile(source.toString(), destination.toString()); + + // Assert + assertTrue(Files.exists(source), "Source file must still exist after copy"); + assertTrue(Files.exists(destination), "Destination file must have been created"); + assertEquals("file content", Files.readString(destination)); + } + + // Claude generated + @Test + void copyFile_shouldReplaceDestination_whenDestinationAlreadyExists() throws IOException { + // Arrange + Path source = tempDir.resolve("source.txt"); + Path destination = tempDir.resolve("destination.txt"); + Files.writeString(source, "new content"); + Files.writeString(destination, "old content"); + + // Act + fileManagement.copyFile(source.toString(), destination.toString()); + + // Assert + assertTrue(Files.exists(source), "Source file must still exist after copy"); + assertEquals("new content", Files.readString(destination)); + } + + // Claude generated + @Test + void copyFile_shouldNotThrow_whenSourceDoesNotExist() { + // Arrange + String nonExistentSource = tempDir.resolve("ghost.txt").toString(); + String destination = tempDir.resolve("destination.txt").toString(); + + // Act & Assert + // The method catches Exception internally: it must not propagate any exception + assertDoesNotThrow(() -> fileManagement.copyFile(nonExistentSource, destination)); + assertFalse(Files.exists(Path.of(destination)), + "No destination file should be created if source does not exist"); + } + + // Claude generated + @Test + void createFolder_shouldCreateFolder_whenPathIsValid() { + // Arrange + Path newFolder = tempDir.resolve("newFolder"); + + // Act + fileManagement.createFolder(newFolder.toString()); + + // Assert + assertTrue(Files.exists(newFolder), "Folder must exist after creation"); + assertTrue(Files.isDirectory(newFolder), "Created path must be a directory"); + } + + // Claude generated + @Test + void createFolder_shouldNotThrow_whenFolderAlreadyExists() throws IOException { + // Arrange + Path existingFolder = tempDir.resolve("existingFolder"); + Files.createDirectory(existingFolder); + Files.writeString(existingFolder.resolve("file.txt"), "existing content"); + + // Act & Assert + // mkdir() returns false silently if the folder already exists: no exception expected + assertDoesNotThrow(() -> fileManagement.createFolder(existingFolder.toString())); + assertTrue(Files.exists(existingFolder.resolve("file.txt")), + "Existing folder content must remain intact"); + } + + // Claude generated + @Test + void createFolder_shouldNotCreateFolder_whenParentDoesNotExist() { + // Arrange + Path nestedFolder = tempDir.resolve("nonExistentParent/newFolder"); + + // Act + fileManagement.createFolder(nestedFolder.toString()); + + // Assert + assertFalse(Files.exists(nestedFolder), + "Folder must not be created if parent directory does not exist"); + } + +} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementPropertiesTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementPropertiesTests.java new file mode 100644 index 0000000..df73e4c --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementPropertiesTests.java @@ -0,0 +1,243 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import ch.hevs.silab.structuredsim.experimenthandling.Options; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import java.io.ByteArrayInputStream; +import java.io.FileInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Calendar; +import java.util.LinkedHashMap; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from FileManagement class + * related to data serialization + * @see FileManagementTests + * @author Matthias Gaillard + */ + +public class FileManagementPropertiesTests extends FileManagementTests { + + // ChatGPT generated + @Test + void loadDataFromPropertiesFile_shouldLoadPropertiesFile() { + + // Arrange + String propertiesContent = + "pathParameters=params.txt\n" + + "pathOUT=C:/output\n" + + "pathSimulator=simulator.exe\n" + + "pathToSimulatorResultFile=result.txt\n" + + "cuttOfPlanning=10\n" + + "typeCuttOfPlanning=INT\n"; + + InputStream inputStream = + new ByteArrayInputStream( + propertiesContent.getBytes(StandardCharsets.UTF_8)); + + // Act + Options options = + fileManagement.loadDataFromPropertiesFile(inputStream); + + // Assert + assertEquals("params.txt", options.getPathParameters()); + assertEquals("C:/output", options.getFolderPathOUT()); + assertEquals("simulator.exe", options.getPathSimulator()); + assertEquals("result.txt", + options.getPathToSimulatorResultFile()); + + assertEquals("INT", options.getTypeOfCuttOfPlanning()); + assertEquals(10, options.getCuttOfPlanning()); + } + + + + //ChatGPT generated + @Test + void loadDataFromPropertiesFile_shouldLoadCriteriaPlanningType() { + + // Arrange + String propertiesContent = + "cuttOfPlanning=0.95\n" + + "typeCuttOfPlanning=CRITERIA\n"; + + InputStream inputStream = + new ByteArrayInputStream( + propertiesContent.getBytes(StandardCharsets.UTF_8)); + + // Act + Options options = + fileManagement.loadDataFromPropertiesFile(inputStream); + + // Assert + assertEquals("CRITERIA", + options.getTypeOfCuttOfPlanning()); + + assertEquals(0.95, + options.getStopCriteria(), + delta); + } + + //ChatGPT generated + @ParameterizedTest + @CsvSource({ + "DAY,15", + "HOURS,10", + "MINUTES,45" + }) + void loadDataFromPropertiesFile_shouldLoadCalendarBasedPlanningTypes(String type, int value) { + + // Arrange + String propertiesContent = + "cuttOfPlanning=" + value + "\n" + + "typeCuttOfPlanning=" + type + "\n"; + + InputStream inputStream = + new ByteArrayInputStream( + propertiesContent.getBytes(StandardCharsets.UTF_8)); + + // Act + Options options = + fileManagement.loadDataFromPropertiesFile(inputStream); + + // Assert + assertEquals(type, options.getTypeOfCuttOfPlanning()); + + Calendar calendar = options.getCuttOfPlanningH(); + + switch (type) { + case "DAY": + assertEquals(value, calendar.get(Calendar.DATE)); + break; + + case "HOURS": + assertEquals(value, calendar.get(Calendar.HOUR_OF_DAY)); + break; + + case "MINUTES": + assertEquals(value, calendar.get(Calendar.MINUTE)); + break; + } + } + + //ChatGPT generated + @Test + void writeDataInPropertiesFile_shouldCreateAndWritePropertiesFile() throws Exception { + + // Arrange + LinkedHashMap data = new LinkedHashMap<>(); + data.put("key1", "value1"); + data.put("key2", "value2"); + + Path file = tempDir.resolve("test.properties"); + + // Act + fileManagement.writeDataInPropertiesFile( + data, + file.toString(), + false); + + // Assert + assertTrue(Files.exists(file)); + + Properties properties = new Properties(); + + try (FileInputStream fis = + new FileInputStream(file.toFile())) { + properties.load(fis); + } + + assertEquals("value1", properties.getProperty("key1")); + assertEquals("value2", properties.getProperty("key2")); + } + + + //ChatGPT generated + @Test + void writeDataInPropertiesFile_shouldOverwriteExistingFile() throws Exception { + + //Arrange + Path file = tempDir.resolve("test.properties"); + + LinkedHashMap firstData = new LinkedHashMap<>(); + firstData.put("oldKey", "oldValue"); + + fileManagement.writeDataInPropertiesFile( + firstData, + file.toString(), + false); + + LinkedHashMap secondData = new LinkedHashMap<>(); + secondData.put("newKey", "newValue"); + + // Act + fileManagement.writeDataInPropertiesFile( + secondData, + file.toString(), + false); + + Properties properties = new Properties(); + + try (FileInputStream fis = + new FileInputStream(file.toFile())) { + properties.load(fis); + } + + // Assert + assertNull(properties.getProperty("oldKey")); + assertEquals("newValue", properties.getProperty("newKey")); + } + + + //ChatGPT generated + @Test + void writeDataInPropertiesFile_shouldCreateFileIfItDoesNotExist() { + + //Arrange + Path file = tempDir.resolve("newFile.properties"); + + LinkedHashMap data = new LinkedHashMap<>(); + data.put("test", "value"); + + // Act + fileManagement.writeDataInPropertiesFile( + data, + file.toString(), + false); + + // Assert + assertTrue(Files.exists(file)); + } + + //ChatGPT generated + @Test + void writeDataInPropertiesFile_shouldNotCreateFileWhenParentDirectoryDoesNotExist() { + + // Arrange + Path file = + tempDir.resolve("unknown") + .resolve("folder") + .resolve("test.properties"); + + LinkedHashMap data = new LinkedHashMap<>(); + data.put("key", "value"); + + // Act + fileManagement.writeDataInPropertiesFile( + data, + file.toString(), + false); + + // Assert + assertFalse(Files.exists(file)); + } + +} \ No newline at end of file diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementSimulationTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementSimulationTests.java new file mode 100644 index 0000000..69f4779 --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementSimulationTests.java @@ -0,0 +1,137 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import ch.hevs.silab.structuredsim.experimenthandling.Environment; +import ch.hevs.silab.structuredsim.experimenthandling.Options; +import ch.hevs.silab.structuredsim.interfaces.ASimulationSystemHandler; +import org.junit.jupiter.api.Test; + +import java.io.FileInputStream; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.Properties; + +import static org.junit.jupiter.api.Assertions.*; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.ArgumentMatchers.eq; +import static org.mockito.Mockito.*; + +/** + * This class is used to test methods from FileManagement class + * related Environment and Options classes + * @see FileManagementTests + * @see Environment + * @see Options + * @author Matthias Gaillard + */ +public class FileManagementSimulationTests extends FileManagementTests { + + // GPT generated + @Test + void saveSimultationResult_shouldSaveResultAndReturnPath_whenDirectoryExists() throws Exception { + + // Arrange + Options options = new Options(); + options.setFolderPathOUT(tempDir.toString()); + fileManagement.setOptions(options); + + Environment env = new Environment(); + + Path simulationFolder = tempDir.resolve("_sim1"); + Files.createDirectories(simulationFolder); + + String expectedResult = "SUCCESS"; + + // Act + String returnedPath = + fileManagement.saveSimultationResult(expectedResult, env); + + // Assert + String expectedPath = + simulationFolder.resolve("results.txt").toString(); + + assertEquals(Path.of(expectedPath).normalize(), + Path.of(returnedPath).normalize()); + assertTrue(Files.exists(Path.of(returnedPath))); + + Properties properties = new Properties(); + try (FileInputStream fis = new FileInputStream(returnedPath)) { + properties.load(fis); + } + + assertEquals(expectedResult, properties.getProperty("Result")); + } + + + + // ChatGPT generated + @Test + void createNewFolder_shouldCreateResultAndSimulatorFolders() throws IOException { + + Options options = new Options(); + options.setFolderPathOUT(tempDir.resolve("results").toString()); + options.setPathSimulator(tempDir.resolve("simulator").toString()); + + fileManagement.setOptions(options); + + Files.createDirectories(tempDir.resolve("results")); + Files.createDirectories(tempDir.resolve("simulator")); + + Environment env = new Environment(); + + String returnedPath = fileManagement.createNewFolder(env); + + Path expectedResultFolder = + tempDir.resolve("results").resolve("_sim1"); + + Path expectedSimulatorFolder = + tempDir.resolve("simulator").resolve("_sim1"); + + assertEquals( + expectedResultFolder.normalize(), + Path.of(returnedPath).normalize()); + + assertTrue(Files.exists(expectedResultFolder)); + assertTrue(Files.isDirectory(expectedResultFolder)); + + assertTrue(Files.exists(expectedSimulatorFolder)); + assertTrue(Files.isDirectory(expectedSimulatorFolder)); + } + + + // ChatGPT generated + @Test + void createNewFolderSimulation_shouldCreateSimulationFolderAndWriteParametersFile() { + + // Arrange + Options options = new Options(); + options.setFolderPathOUT(tempDir.resolve("results").toString()); + options.setPathSimulator(tempDir.resolve("simulator").toString()); + + fileManagement.setOptions(options); + + Environment env = new Environment(); + + ASimulationSystemHandler glueCode = + mock(ASimulationSystemHandler.class); + + try { + Files.createDirectories(tempDir.resolve("results")); + Files.createDirectories(tempDir.resolve("simulator")); + } catch (IOException e) { + throw new RuntimeException(e); + } + + // Act + fileManagement.createNewFolderSimulation(env, glueCode); + + // Assert + verify(glueCode, times(1)) + .writeParametersFile( + eq(env.getSetOfParameters()), + anyString()); + + assertNotNull(env.getPathSaveResult()); + assertTrue(env.getPathSaveResult().contains("_sim")); + } +} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementTests.java new file mode 100644 index 0000000..57fcd51 --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/fileManagement/FileManagementTests.java @@ -0,0 +1,28 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.fileManagement; + +import ch.hevs.silab.structuredsim.util.FileManagement; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.io.TempDir; +import java.nio.file.Path; + +/** + * This class is used to test methods from FileManagement class + * Subclasses will do the actual tests. + * @see FileManagement + * @author Matthias Gaillard + */ +public class FileManagementTests { + + protected FileManagement fileManagement; + + protected double delta = 1e-9; + + @TempDir + Path tempDir; + + @BeforeEach + void setUp() { + fileManagement = new FileManagement(); + } + +} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/ConcreteModifierTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/ConcreteModifierTests.java new file mode 100644 index 0000000..117c8ee --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/ConcreteModifierTests.java @@ -0,0 +1,95 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.gluecode; + +import ch.hevs.silab.structuredsim.experimenthandling.Environment; +import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import ch.hevs.silab.structuredsim.gluecode.ConcreteModifier; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.CsvSource; + +import java.util.Vector; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from ConcreteModifier class + * @see ConcreteModifier + * @author Matthias Gaillard + */ +public class ConcreteModifierTests { + + + private double delta = 1e-9; + + @ParameterizedTest + @CsvSource({ + "+,1", + "-,2", + "*,3", + "/,4" + }) + public void applyModifier_shouldUpdateTheEnvironmentCorrectly(char operator, double value) { + //Arrange + Environment e = new Environment(); + Vector v = new Vector<>(); + v.add(new Parameter("val1", 1)); + e.setSetOfParameters(v); + + ConcreteModifier modifier = new ConcreteModifier("val1", operator, value); + + //Act + e = modifier.applyModifier(e); + + //Assert + switch(operator) { + case '+': + assertEquals(2, e.getSetOfParameters().get(0).getValue(), delta); + break; + case '-': + assertEquals(-1, e.getSetOfParameters().get(0).getValue(), delta); + break; + case '*': + assertEquals(3, e.getSetOfParameters().get(0).getValue(), delta); + break; + case '/': + assertEquals(0.25, e.getSetOfParameters().get(0).getValue(), delta); + break; + + } + } + + @Test + public void findvalue_shouldFindTheValueInAVector() { + + //Arrange + Vector params = new Vector<>(); + params.add(new Parameter("val1", 3)); + params.add(new Parameter("val2", 10)); + params.add(new Parameter("val3", 7)); + + //Act + double result = ConcreteModifier.findValue(params, "val2"); + + //Assert + assertEquals(10, result, delta); + + } + + @Test + public void findvalue_shouldReturnMinus1_WhenNothingIsFound() { + + //Arrange + Vector params = new Vector<>(); + params.add(new Parameter("val1", 3)); + params.add(new Parameter("val2", 10)); + params.add(new Parameter("val3", 7)); + + //Act + double result = ConcreteModifier.findValue(params, "val31416"); + + //Assert + assertEquals(-1, result, delta); + + } + +} diff --git a/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/SimpleSimulationHandlerTests.java b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/SimpleSimulationHandlerTests.java new file mode 100644 index 0000000..16fc7d5 --- /dev/null +++ b/structSimV1/src/test/java/hevs/ch/silab/hevs/ch/silab/unitTests/gluecode/SimpleSimulationHandlerTests.java @@ -0,0 +1,137 @@ +package hevs.ch.silab.hevs.ch.silab.unitTests.gluecode; + +import ch.hevs.silab.structuredsim.experimenthandling.Measure; +import ch.hevs.silab.structuredsim.experimenthandling.Parameter; +import ch.hevs.silab.structuredsim.gluecode.SimpleSimulationHandler; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.io.TempDir; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.util.List; +import java.util.Vector; + +import static org.junit.jupiter.api.Assertions.*; + +/** + * This class is used to test methods from SimpleSimulationHandler class + * @see SimpleSimulationHandler + * @author Matthias Gaillard + */ +public class SimpleSimulationHandlerTests { + + SimpleSimulationHandler handler; + + @TempDir + Path tempDir; + + @BeforeEach + void setUp() { + handler = new SimpleSimulationHandler(); + } + + //ChatGPT generated + @Test + void extractMeasures_shouldParseFileCorrectly() throws Exception { + // Arrange + Path file = tempDir.resolve("results.txt"); + + Files.write(file, List.of( + "throughput=12", + "latency=50" + )); + + // Act + Vector result = handler.extractMeasures(file.toString()); + + // Assert + assertEquals(2, result.size()); + + assertEquals("throughput", result.get(0).getKey()); + assertEquals("12", result.get(0).getValue()); + + assertEquals("latency", result.get(1).getKey()); + assertEquals("50", result.get(1).getValue()); + } + + //ChatGPT generated + @Test + void readParametersFile_shouldParseFileFromPath() throws Exception { + // Arrange + Path file = tempDir.resolve("params.txt"); + + Files.write(file, List.of( + "val1=10", + "val2=20.5" + )); + + + // Act + Vector result = handler.readParametersFile(file.toString()); + + // Assert + assertEquals(2, result.size()); + + assertEquals("val1", result.get(0).getKey()); + assertEquals(10.0, result.get(0).getValue()); + + assertEquals("val2", result.get(1).getKey()); + assertEquals(20.5, result.get(1).getValue()); + } + + //ChatGPT generated + @Test + void readParametersFile_shouldParseFromInputStream() { + // Arrange + String content = + "val1=1\n" + + "val2=2.5\n"; + + InputStream is = new ByteArrayInputStream(content.getBytes(StandardCharsets.UTF_8)); + + + + // Act + Vector result = handler.readParametersFile(is); + + // Assert + assertEquals(2, result.size()); + + assertEquals("val1", result.get(0).getKey()); + assertEquals(1.0, result.get(0).getValue()); + + assertEquals("val2", result.get(1).getKey()); + assertEquals(2.5, result.get(1).getValue()); + } + + //ChatGPT generated + @Test + void writeParametersFile_shouldCreateFileWithCorrectFormat() throws Exception { + // Arrange + Vector params = new Vector<>(); + params.add(new Parameter("val1", 10)); + params.add(new Parameter("val2", 20.5)); + + + String outputDir = tempDir.toString(); + + // Act + handler.writeParametersFile(params, outputDir); + + // Assert + Path file = tempDir.resolve("myParamFile.txt"); + + assertTrue(Files.exists(file)); + + List lines = Files.readAllLines(file); + + assertEquals(2, lines.size()); + assertEquals("val1=10.0", lines.get(0)); + assertEquals("val2=20.5", lines.get(1)); + } + +} diff --git a/structSimV1/src/test/resources/parameters.txt b/structSimV1/src/test/resources/parameters.txt new file mode 100644 index 0000000..11fbfb3 --- /dev/null +++ b/structSimV1/src/test/resources/parameters.txt @@ -0,0 +1 @@ +val1=1.0 diff --git a/structSimV1/target/classes/META-INF/MANIFEST.MF b/structSimV1/target/classes/META-INF/MANIFEST.MF deleted file mode 100644 index df1e4cd..0000000 --- a/structSimV1/target/classes/META-INF/MANIFEST.MF +++ /dev/null @@ -1,5 +0,0 @@ -Manifest-Version: 1.0 -Built-By: caroline.taramarc -Build-Jdk: 1.8.0_131 -Created-By: Maven Integration for Eclipse - diff --git a/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.properties b/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.properties deleted file mode 100644 index 0d00a58..0000000 --- a/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.properties +++ /dev/null @@ -1,7 +0,0 @@ -#Generated by Maven Integration for Eclipse -#Mon Sep 11 07:54:33 CEST 2017 -version=0.0.1-SNAPSHOT -groupId=hevs.ch.silab -m2e.projectName=StructuredSimulationFramework -m2e.projectLocation=C\:\\Users\\caroline.taramarc\\Documents\\StructuredSimulationFramework\\StructSimWorkspace\\StructuredSimulationFramework\\code -artifactId=hevs.ch.silab diff --git a/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.xml b/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.xml deleted file mode 100644 index 269efa9..0000000 --- a/structSimV1/target/classes/META-INF/maven/hevs.ch.silab/hevs.ch.silab/pom.xml +++ /dev/null @@ -1,30 +0,0 @@ - - 4.0.0 - - hevs.ch.silab - hevs.ch.silab - 0.0.1-SNAPSHOT - jar - - hevs.ch.silab - http://maven.apache.org - - - UTF-8 - - - - - junit - junit - 3.8.1 - test - - - com.hynnet - jacob - 1.18 - - - diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Environment.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Environment.class deleted file mode 100644 index 1e7b71e..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Environment.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.class deleted file mode 100644 index 6ec01af..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentPlanGenerator.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.class deleted file mode 100644 index 486fa26..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentResultHandler.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.class deleted file mode 100644 index 3d13c97..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/ExperimentSimulatorHandler.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Measure.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Measure.class deleted file mode 100644 index 15c1af6..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Measure.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Options.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Options.class deleted file mode 100644 index b20b864..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Options.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Parameter.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Parameter.class deleted file mode 100644 index 75fdd38..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/experimenthandling/Parameter.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/AModifier.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/AModifier.class deleted file mode 100644 index 452223f..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/AModifier.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/ASimulationSystemHandler.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/ASimulationSystemHandler.class deleted file mode 100644 index 6b9c248..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/ASimulationSystemHandler.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IExtractMeasures.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IExtractMeasures.class deleted file mode 100644 index ae3ac7a..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IExtractMeasures.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageModifier.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageModifier.class deleted file mode 100644 index 9498844..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageModifier.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.class deleted file mode 100644 index 2080e84..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IManageParametersFile.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.class deleted file mode 100644 index 159ff4d..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStartSimulation.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStopProgram.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStopProgram.class deleted file mode 100644 index 21e704c..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/IStopProgram.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/StartProgram.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/StartProgram.class deleted file mode 100644 index 6d4269d..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/interfaces/StartProgram.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass1.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass1.class deleted file mode 100644 index f689973..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass1.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass2.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass2.class deleted file mode 100644 index 84daa2d..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/ModifierClass2.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/SimpleSimulationHandler.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/SimpleSimulationHandler.class deleted file mode 100644 index ebde242..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/SimpleSimulationHandler.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/Simulation.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/Simulation.class deleted file mode 100644 index c659573..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/Simulation.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/config.properties b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/config.properties deleted file mode 100644 index 7f97094..0000000 --- a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/mockUpSim/config.properties +++ /dev/null @@ -1,15 +0,0 @@ -# For all path the folder must be created -pathOUT = ./ResultSim -pathParameters = ./data/simulation/parameters.txt -pathSimulator = c:/mySimulator -#the place where the simulator create automatically results file for a simulation. This file need to be save in corresponding simulator folder. -pathToSimulatorResultFile = c:/mySimulator/results/results.txt -# CuttOfPlanning = How many time must the planning run. -cuttOfPlanning = 10 -# type of cuttOfPlanning : INT, HOURS, MINUTES, DAY, CRITERIA -# INT = iteration or laps. -# Criteria = based on the probability. The numbers must be between 1 and 0. ex.:0.5 -typeCuttOfPlanning = INT -# Key/Id of the parameter to change -# If your parameters File is an array, please create key/id for each parameters -valueToChange = val1 diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/ModifClass1.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/ModifClass1.class deleted file mode 100644 index 693edaa..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/ModifClass1.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimDemo.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimDemo.class deleted file mode 100644 index 9c5ef96..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimDemo.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimSimulationHandler.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimSimulationHandler.class deleted file mode 100644 index 9493ca8..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/VissimSimulationHandler.class and /dev/null differ diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/configVissim.properties b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/configVissim.properties deleted file mode 100644 index c343247..0000000 --- a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/configVissim.properties +++ /dev/null @@ -1,12 +0,0 @@ -# For all path the folder must be created -pathOUT = ./ResultSim -pathParameters = ./src/main/java/simulators/vissim/matrixOD.fma -pathSimulator = c:/mySimulator -# CuttOfPlanning = How many time must the planning run. -cuttOfPlanning = 10 -# type of cuttOfPlanning : INT, HOURS, MINUTES, DAY -# INT = iteration or laps. -typeCuttOfPlanning = INT -# Key/Id of the parameter to change -# If your parameters File is an array, please create key/id for each parameters -valueToChange = 4.2 \ No newline at end of file diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/matrixOD.fma b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/matrixOD.fma deleted file mode 100644 index 86b64fd..0000000 --- a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/matrixOD.fma +++ /dev/null @@ -1,9 +0,0 @@ - 0.0 1.0 - 1 - 5 - 1 2 3 4 5 - 0 0 1000 0 0 - 0 0 0 0 0 - 0 0 0 0 0 - 0 0 0 0 0 - 0 0 0 0 0 diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mreza.layx b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mreza.layx deleted file mode 100644 index d759ce7..0000000 --- a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mreza.layx +++ /dev/null @@ -1,876 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mrezaDA.inpx b/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mrezaDA.inpx deleted file mode 100644 index 3d1b8aa..0000000 --- a/structSimV1/target/classes/ch/hevs/silab/structuredsim/simulators/vissim/model_mrezaDA.inpx +++ /dev/null @@ -1,2688 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/structSimV1/target/classes/ch/hevs/silab/structuredsim/util/FileManagement.class b/structSimV1/target/classes/ch/hevs/silab/structuredsim/util/FileManagement.class deleted file mode 100644 index bfbaf32..0000000 Binary files a/structSimV1/target/classes/ch/hevs/silab/structuredsim/util/FileManagement.class and /dev/null differ diff --git a/structSimV1/target/classes/log4j2.xml b/structSimV1/target/classes/log4j2.xml deleted file mode 100644 index 290e1d0..0000000 --- a/structSimV1/target/classes/log4j2.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/structSimV1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/structSimV1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst deleted file mode 100644 index 111c429..0000000 --- a/structSimV1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst +++ /dev/null @@ -1,24 +0,0 @@ -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\Environment.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\simulators\mockUpSim\ModifierClass2.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\Measure.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\util\FileManagement.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\Parameters.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\Options.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IStopProgram.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IStartSimulation.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IChangeParameters.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\simulators\mockUpSim\Simulation.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\ExperimentPlanGenerator.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\AModifier.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\Measures.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\ExperimentSimulatorHandler.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IManageModifier.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\ExperimentHandling\ExperimentResultHandler.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IManageParametersFile.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\simulators\mockUpSim\ModifierClass1.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\StartProgram.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\hevs\ch\silab\hevs\ch\silab\App.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\SimulationSystemHandler.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IExtractMeasures.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\structuredSim\interfaces\IModifier.java -C:\Users\caroline.taramarc\Documents\StructuredSimulationFramework\StructSimWorkspace\hevs.ch.silab\src\main\java\simulators\mockUpSim\SimpleSimulationHandler.java diff --git a/structSimV1/target/test-classes/hevs/ch/silab/hevs/ch/silab/AppTest.class b/structSimV1/target/test-classes/hevs/ch/silab/hevs/ch/silab/AppTest.class deleted file mode 100644 index 7858188..0000000 Binary files a/structSimV1/target/test-classes/hevs/ch/silab/hevs/ch/silab/AppTest.class and /dev/null differ