Starting from 2021-07-01, all LRZ GitLab users will be required to explicitly accept the GitLab Terms of Service. Please see the detailed information at https://doku.lrz.de/display/PUBLIC/GitLab and make sure that your projects conform to the requirements.

Commit ecd5102f authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

VoroniProcessorTest

parent 752f6a9b
package org.vadere.simulator.projects.dataprocessing.processor;
import org.junit.Before;
import org.junit.Test;
import static org.junit.Assert.*;
public class AreaDensityVoronoiProcessorTest extends ProcessorTest {
@Before
public void setup(){
processorTestEnv = new AreaDensityVoronoiProcessorTestEnv();
super.setup();
}
@Test
public void doUpdate() throws Exception {
super.doUpdate();
}
@Test
public void init() throws Exception {
super.init();
}
}
\ No newline at end of file
package org.vadere.simulator.projects.dataprocessing.processor;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor;
import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
import java.util.StringJoiner;
import static org.mockito.ArgumentMatchers.doubleThat;
import static org.mockito.Mockito.when;
public class AreaDensityVoronoiProcessorTestEnv extends ProcessorTestEnv <TimestepKey, Double>{
PedestrianListBuilder b = new PedestrianListBuilder();
AreaDensityVoronoiProcessorTestEnv(){
testedProcessor = processorFactory.createDataProcessor(AreaDensityVoronoiProcessor.class);
testedProcessor.setId(nextProcessorId());
AttributesAreaDensityVoronoiProcessor attr =
(AttributesAreaDensityVoronoiProcessor)testedProcessor.getAttributes();
attr.setVoronoiArea(new VRectangle(0, 0, 16,16));
attr.setMeasurementArea(new VRectangle(0, 0, 16,16));
outputFile = outputFileFactory.createDefaultOutputfileByDataKey(
TimestepKey.class,
testedProcessor.getId()
);
outputFile.setVadereWriterFactory(VadereWriterFactory.getStringWriterFactory());
}
@Override
public void loadDefaultSimulationStateMocks() {
// addSimState(new SimulationStateMock(1) {
// @Override
// public void mockIt() {
// b.clear().add(1, new VPoint(1,1));
// b.add(2, new VPoint(3,1));
// b.add(3, new VPoint(3,3));
// b.add(4, new VPoint(1,3));
// when(state.getTopography().getElements(Agent.class)).thenReturn(b.getAgentList());
//
// int step = state.getStep();
// addToExpectedOutput(new TimestepKey(step), 0.25);
// }
// });
SimulationStateMock fourCoLinear = new SimulationStateMock(1) {
@Override
public void mockIt() {
b.clear().add(1, new VPoint(1.0,1.0));
b.add(2, new VPoint(2.0,2.0));
b.add(3, new VPoint(3.0,3.0));
b.add(4, new VPoint(4.0,4.0));
when(state.getTopography().getElements(Agent.class)).thenReturn(b.getAgentList());
int step = state.getStep();
addToExpectedOutput(new TimestepKey(step), 8.0/16.0);
}
};
SimulationStateMock oneCircleEvent = new SimulationStateMock(1) {
@Override
public void mockIt() {
b.clear().add(1, new VPoint(3.0,6.5));
b.add(2, new VPoint(6.0,8.0));
VPoint m = new VPoint(6.0, 4.0); //circle mid
b.add(3, m.add(new VPoint(2.5,3.0)));
when(state.getTopography().getElements(Agent.class)).thenReturn(b.getAgentList());
int step = state.getStep();
addToExpectedOutput(new TimestepKey(step), 8.0/16.0);
}
};
addSimState(oneCircleEvent);
}
@Override
List<String> getExpectedOutputAsList() {
List<String> outputList = new ArrayList<>();
expectedOutput.entrySet()
.stream()
.sorted(Comparator.comparing(Map.Entry::getKey))
.forEach(e -> {
StringJoiner sj = new StringJoiner(getDelimiter());
sj.add(Integer.toString(e.getKey().getTimestep()))
.add(Double.toString(e.getValue()));
outputList.add(sj.toString());
});
return outputList;
}
}
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