Commit 9cce77a8 authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

simplify tests

parent d0fddaea
Pipeline #146633 failed with stages
in 41 minutes and 28 seconds
......@@ -52,18 +52,9 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory();
VTrajectory traj2 = new VTrajectory();
VTrajectory traj3 = new VTrajectory();
//trajectoryID
traj1.add(new FootStep(new VPoint(1,0), new VPoint(1,0), 0, 1));
traj2.add(new FootStep(new VPoint(0,0), new VPoint(0,0), 0, 1));
traj3.add(new FootStep(new VPoint(7,4), new VPoint(7,4), 0, 1));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3); //not in area
b.clear().add(1, new VPoint(1,0), 0)
.add(2, new VPoint(0,0), 0)
.add(3, new VPoint(7,4), 0); //not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(0.0);
......@@ -77,17 +68,9 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory();
VTrajectory traj2 = new VTrajectory();
VTrajectory traj3 = new VTrajectory();
traj1.add(new FootStep(new VPoint(1,1), new VPoint(1,1), 1, 2.0));
traj2.add(new FootStep(new VPoint(3,4), new VPoint(3,4), 1, 2.0));
traj3.add(new FootStep(new VPoint(8,4), new VPoint(8,4), 1, 2.0));
b.clear().add(1, traj1) //dist = 1.0
.add(2, traj2) //dist = 5.0
.add(3, traj3); //not in area
b.clear().add(1, new VPoint(1,1), 1) //dist = 1.0
.add(2, new VPoint(3,4), 1) //dist = 5.0
.add(3, new VPoint(8,4), 1); //not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
double simTime = 1.0;
......@@ -104,17 +87,9 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory();
VTrajectory traj2 = new VTrajectory();
VTrajectory traj3 = new VTrajectory();
traj1.add(new FootStep(new VPoint(3,1), new VPoint(3,1), 1.0, 2.0));
traj2.add(new FootStep(new VPoint(5,4), new VPoint(5,4), 1.0, 2.0));
traj3.add(new FootStep(new VPoint(8,8), new VPoint(8,8), 1.0, 2.0));
b.clear().add(1, traj1) //dist = 2.0
.add(2, traj2) //not in area
.add(3, traj3); //not in area
b.clear().add(1, new VPoint(3,1), 2) //dist = 2.0
.add(2, new VPoint(5,4), 2) //not in area
.add(3, new VPoint(8,8), 2); //not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
double simTime = 2.0;
......@@ -131,17 +106,9 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory();
VTrajectory traj2 = new VTrajectory();
VTrajectory traj3 = new VTrajectory();
traj1.add(new FootStep(new VPoint(6,1), new VPoint(6,1), 2, 3.0));
traj2.add(new FootStep(new VPoint(7,4), new VPoint(7,4), 2, 3.0));
traj3.add(new FootStep(new VPoint(9,8), new VPoint(9,8), 2, 3.0));
b.clear().add(1, traj1) // not in area
.add(2, traj2) // not in area
.add(3, traj3); // not in area
b.clear().add(1, new VPoint(6,1), 3) // not in area
.add(2, new VPoint(7,4), 3) // not in area
.add(3, new VPoint(9,8), 3); // not in area
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
double simTime = 3.0;
......
......@@ -45,22 +45,14 @@ public class PedestrianDensityCountingProcessorTestEnv extends ProcessorTestEnv<
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1,1), new VPoint(1,1), 0,0));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(1.2,1.2), new VPoint(1.2,1.2), 0,0));
VPoint p = new VPoint(1.4, 1.4);
VPoint pPrecise = p.clone().addPrecise(new VPoint(Math.sqrt(radius) - 0.001, Math.sqrt(radius) - 0.001));
VTrajectory traj3 = new VTrajectory().add(new FootStep(p, p, 0,0));
VTrajectory traj4 = new VTrajectory().add(new FootStep(pPrecise, pPrecise, 0,0));
VTrajectory traj5 = new VTrajectory().add(new FootStep(new VPoint(10,10), new VPoint(10,10), 0,0));
b.clear().add(1, traj1);
b.add(2, traj2);
b.add(3, traj3);
b.add(4, traj4);
b.add(5, traj5);
b.clear().add(1, new VPoint(1,1), 0);
b.add(2, new VPoint(1.2,1.2), 0);
b.add(3, p, 0);
b.add(4, pPrecise, 0);
b.add(5, new VPoint(10,10), 0);
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
......
......@@ -52,22 +52,14 @@ public class PedestrianFlowProcessorTestEnv extends ProcessorTestEnv<TimestepPed
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1,1), new VPoint(1,1), 0,0));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(1.2,1.2), new VPoint(1.2,1.2), 0,0));
VPoint p = new VPoint(1.4, 1.4);
VPoint pPrecise = p.clone().addPrecise(new VPoint(Math.sqrt(radius) - 0.001, Math.sqrt(radius) - 0.001));
VTrajectory traj3 = new VTrajectory().add(new FootStep(p, p, 0,0));
VTrajectory traj4 = new VTrajectory().add(new FootStep(pPrecise, pPrecise, 0,0));
VTrajectory traj5 = new VTrajectory().add(new FootStep(new VPoint(10,10), new VPoint(10,10), 0,0));
b.clear().add(1, traj1);
b.add(2, traj2);
b.add(3, traj3);
b.add(4, traj4);
b.add(5, traj5);
b.clear().add(1, new VPoint(1,1), 0);
b.add(2, new VPoint(1.2,1.2), 0);
b.add(3, p, 0);
b.add(4, pPrecise, 0);
b.add(5, new VPoint(10,10), 0);
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
Mockito.when(state.getSimTimeInSec()).thenReturn(0.0);
......@@ -91,35 +83,14 @@ public class PedestrianFlowProcessorTestEnv extends ProcessorTestEnv<TimestepPed
VPoint mov = new VPoint(3.0, 4.0); //dist = 5 time = 1 -> 5ms^-1
VTrajectory traj1 = new VTrajectory().add(
new FootStep(
new VPoint(1,1).addPrecise(mov),
new VPoint(1,1).addPrecise(mov), 1,1));
VTrajectory traj2 = new VTrajectory().add(
new FootStep(
new VPoint(1.2,1.2).addPrecise(mov),
new VPoint(1.2,1.2).addPrecise(mov), 1,1));
VPoint p = new VPoint(1.4, 1.4);
VPoint pPrecise = p.clone().addPrecise(
new VPoint(Math.sqrt(radius) - 0.001, Math.sqrt(radius) - 0.001));
VTrajectory traj3 = new VTrajectory().add(
new FootStep(p.addPrecise(mov), p.addPrecise(mov), 1,1));
VTrajectory traj4 = new VTrajectory().add(
new FootStep(pPrecise.addPrecise(mov), pPrecise.addPrecise(mov), 1,1));
VTrajectory traj5 = new VTrajectory().add(
new FootStep(new VPoint(10,10).addPrecise(mov), new VPoint(10,10).addPrecise(mov), 1,1));
VPoint pPrecise = p.clone().addPrecise(new VPoint(Math.sqrt(radius) - 0.001, Math.sqrt(radius) - 0.001));
b.clear().add(1, traj1);
b.add(2, traj2);
b.add(3, traj3);
b.add(4, traj4);
b.add(5, traj5);
b.clear().add(1, new VPoint(1,1).addPrecise(mov), 1);
b.add(2, new VPoint(1.2,1.2).addPrecise(mov), 1);
b.add(3, p.addPrecise(mov), 1);
b.add(4, pPrecise.addPrecise(mov), 1);
b.add(5, new VPoint(10,10).addPrecise(mov), 1);
Mockito.when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
Mockito.when(state.getSimTimeInSec()).thenReturn(1.0);
......
......@@ -38,13 +38,10 @@ public class PedestrianLastPositionProcessorTestEnv extends ProcessorTestEnv<Ped
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.0, 1.2), new VPoint(1.0, 1.2), 0,0));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(4.45, 1.2), new VPoint(4.45, 1.2), 0,0));
VTrajectory traj5 = new VTrajectory().add(new FootStep(new VPoint(3.546, 7.2342), new VPoint(3.546, 7.2342), 0,0));
b.clear().add(1, new VPoint(1.0, 1.2), 0)
.add(3, new VPoint(4.45, 1.2), 0)
.add(5, new VPoint(3.546, 7.2342), 0);
b.clear().add(1, traj1)
.add(3, traj3)
.add(5, traj5);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
addToExpectedOutput(new PedestrianIdKey(1), new VPoint(1.0, 1.2));
......@@ -58,13 +55,9 @@ public class PedestrianLastPositionProcessorTestEnv extends ProcessorTestEnv<Ped
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(33.2, 3.22), new VPoint(33.2, 3.22), 0,0));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(3.2, 22.3), new VPoint(3.2, 22.3), 0,0));
VTrajectory traj7 = new VTrajectory().add(new FootStep(new VPoint(1.2, 3.3), new VPoint(1.2, 3.3), 0,0));
b.clear().add(1, traj1)
.add(3, traj3)
.add(7, traj7);
b.clear().add(1, new VPoint(33.2, 3.22), 0)
.add(3, new VPoint(3.2, 22.3), 0)
.add(7, new VPoint(1.2, 3.3), 0);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
//overwrite Values!
......
......@@ -46,14 +46,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1,1), new VPoint(1,1), 0,0));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(2.3,2.3), new VPoint(2.3,2.3), 0,0));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 0,0));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1,1), 0)
.add(2, new VPoint(2.3,2.3), 0)
.add(3, new VPoint(5.7,3.3), 0);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(0.0);
......@@ -70,14 +65,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.5,1.0), new VPoint(1.5,1.0), 1,1));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(5.3,6.3), new VPoint(5.3,6.3), 1,1));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 1,1));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1.5,1.0), 1)
.add(2, new VPoint(5.3,6.3), 1)
.add(3, new VPoint(5.7,3.3), 1);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(1.0);
......@@ -94,13 +84,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.5,1.0), new VPoint(1.5,1.0), 2,2));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(5.3,6.3), new VPoint(5.3,6.3), 2,2));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 2,2));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1.5,1.0), 2)
.add(2, new VPoint(5.3,6.3), 2)
.add(3, new VPoint(5.7,3.3), 2);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(2.0);
......@@ -120,13 +106,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.0,1.0), new VPoint(1.0,1.0), 0,0));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(2.3,2.3), new VPoint(2.3,2.3), 0,0));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 0,0));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1.0,1.0), 0)
.add(2, new VPoint(2.3,2.3), 0)
.add(3, new VPoint(5.7,3.3), 0);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(0.0);
......@@ -144,13 +126,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.5,1.0), new VPoint(1.5,1.0), 1,1));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(5.3,6.3), new VPoint(5.3,6.3), 1,1));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 1,1));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1.5,1.0), 1)
.add(2, new VPoint(5.3,6.3), 1)
.add(3, new VPoint(5.7,3.3), 1);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(1.0);
......@@ -168,13 +146,9 @@ public class PedestrianVelocityProcessorTestEnv extends ProcessorTestEnv<Timeste
@Override
public void mockIt() {
VTrajectory traj1 = new VTrajectory().add(new FootStep(new VPoint(1.5,1.0), new VPoint(1.5,1.0), 2,2));
VTrajectory traj2 = new VTrajectory().add(new FootStep(new VPoint(5.3,6.3), new VPoint(5.3,6.3), 2,2));
VTrajectory traj3 = new VTrajectory().add(new FootStep(new VPoint(5.7,3.3), new VPoint(5.7,3.3), 2,2));
b.clear().add(1, traj1)
.add(2, traj2)
.add(3, traj3);
b.clear().add(1, new VPoint(1.5,1.0), 2)
.add(2, new VPoint(5.3,6.3), 2)
.add(3, new VPoint(5.7,3.3), 2);
when(state.getTopography().getElements(Pedestrian.class)).thenReturn(b.getList());
when(state.getSimTimeInSec()).thenReturn(2.0);
......
......@@ -5,6 +5,7 @@ import org.vadere.state.attributes.scenario.AttributesAgent;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.DynamicElement;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.state.simulation.FootStep;
import org.vadere.state.simulation.VTrajectory;
import org.vadere.util.geometry.shapes.VPoint;
......@@ -43,6 +44,14 @@ public class PedestrianListBuilder {
return this;
}
public PedestrianListBuilder add(int id, VPoint pos, double simTimeSec){
// Mock a footstep, because start/end position and time are the same, pos will be taken as the position
// when for simulation time (in seconds) simTimeSec
FootStep fs = new FootStep(pos, pos, simTimeSec, simTimeSec);
VTrajectory trajectory = new VTrajectory().add(fs);
return add(id, trajectory);
}
public PedestrianListBuilder add(int id, VTrajectory trajectory){
Pedestrian p = new Pedestrian(new AttributesAgent(id), new Random());
Class<?> pclass = p.getClass();
......
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