Commit 1bfb0606 authored by Christina's avatar Christina
Browse files

adapted and extended unit tests

parent 8b975532
Pipeline #238211 failed with stages
in 3 minutes and 1 second
......@@ -53,6 +53,8 @@ public class TargetChangerController {
this.probabilitiesToChangeTarget = targetChanger.getAttributes().getProbabilitiesToChangeTarget();
seed = random.nextInt();
binomialDistributions = getBinomialDistributions();
}
......@@ -84,6 +86,16 @@ public class TargetChangerController {
// Public Methods
public void update(double simTimeInSec) {
int numberTargets = targetChanger.getAttributes().getNextTarget().size();
int numberProbabilitesToChangeTarget = targetChanger.getAttributes().getProbabilitiesToChangeTarget().size();
if (! ( (numberProbabilitesToChangeTarget == 1) || (numberProbabilitesToChangeTarget== numberProbabilitesToChangeTarget)) ) {
log.error("The size of probabilitesToChangeTarget must be 1 or equal to nextTarget.");
}
for (DynamicElement element : getDynamicElementsNearTargetChangerArea()) {
final Agent agent;
......
......@@ -231,7 +231,7 @@ public class TargetChangerControllerTest {
@Test
public void targetChangerWithListOfTargetsAndStaticTargets() {
LinkedList<Integer> nextTarget = createIntegerList(2, 1);
LinkedList<Double> probability = new LinkedList<Double>(Arrays.asList(1.0)); // must be 1
LinkedList<Double> probability = new LinkedList<Double>(Arrays.asList(1.0,1.0)); // must be 1
pedestrians.forEach(p -> p.setTargets(createIntegerList(1)));
AttributesTargetChanger attributesTargetChanger = createAttributesWithFixedRectangle();
......@@ -250,6 +250,30 @@ public class TargetChangerControllerTest {
assertListEqual(pedestrians.get(1).getTargets(), createIntegerList(2, 1));
}
@Test
public void targetChangerSkipFirstTargetInListOftaticTargets() {
LinkedList<Integer> nextTarget = createIntegerList(2, 1);
LinkedList<Double> probability = new LinkedList<Double>(Arrays.asList(0.0,1.0)); // must be 1
pedestrians.forEach(p -> p.setTargets(createIntegerList(1)));
AttributesTargetChanger attributesTargetChanger = createAttributesWithFixedRectangle();
attributesTargetChanger.setNextTarget(nextTarget);
attributesTargetChanger.setProbabilitiesToChangeTarget(probability);
TargetChanger targetChanger = new TargetChanger(attributesTargetChanger);
TargetChangerController controllerUnderTest = createTargetChangerController(targetChanger);
assertListContainsSingleTarget(pedestrians.get(0).getTargets(), createIntegerList(1));
assertListContainsSingleTarget(pedestrians.get(1).getTargets(), createIntegerList(1));
controllerUnderTest.update(simTimeInSec);
assertListContainsSingleTarget(pedestrians.get(0).getTargets(), createIntegerList(1));
assertListEqual(pedestrians.get(1).getTargets(), createIntegerList( 1));
}
@Test
public void targetChangerWithListOfTargetsAndDynamicTargets() { //must choose first element
LinkedList<Integer> nextTarget = createIntegerList(1, 2);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment