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 6c859e21 authored by Daniel Lehmberg's avatar Daniel Lehmberg
Browse files

Adapted tests with the new column names

parent 740fea64
Pipeline #115283 passed with stages
in 129 minutes and 55 seconds
...@@ -178,18 +178,22 @@ public abstract class OutputFile<K extends DataKey<K>> { ...@@ -178,18 +178,22 @@ public abstract class OutputFile<K extends DataKey<K>> {
return String.join(DataProcessingJsonManager.DEFAULT_SEPARATOR, this.getIndices()); return String.join(DataProcessingJsonManager.DEFAULT_SEPARATOR, this.getIndices());
} }
public static String addHeaderProcInfo(String columnName, int procId){
return columnName + headerNameAdd.replace("?", "" + procId);
}
private List<String> uniqueHeaderNames(){ private List<String> uniqueHeaderNames(){
// This function adds to every header "headerNameAdd", for ALL headers EVERY time // This function adds to every header "headerNameAdd", for ALL headers EVERY time
// (cmp. headersWithNameMangling) // (cmp. headersWithNameMangling)
LinkedList<String> headers = new LinkedList<>(); LinkedList<String> headers = new LinkedList<>();
for (DataProcessor l: dataProcessors) { for (DataProcessor dataProcessor: dataProcessors) {
List<String> allProcHeaders = Arrays.asList(l.getHeaders()); List<String> allProcHeaders = Arrays.asList(dataProcessor.getHeaders());
for (String singleHeader: allProcHeaders) { for (String singleHeader: allProcHeaders) {
// add the processor id to make header unique // add the processor id to make header unique
headers.addLast(singleHeader + headerNameAdd.replace("?", "" + l.getId())); String adaptedColumnName = OutputFile.addHeaderProcInfo(singleHeader, dataProcessor.getId());
headers.addLast(adaptedColumnName);
} }
} }
......
...@@ -76,7 +76,9 @@ public abstract class IOOutput { ...@@ -76,7 +76,9 @@ public abstract class IOOutput {
private static boolean testTrajectories (final VadereProject project, final File directory) { private static boolean testTrajectories (final VadereProject project, final File directory) {
try { try {
TrajectoryReader reader = new TrajectoryReader(getPathToOutputFile(project, directory.getName(), IOUtils.TRAJECTORY_FILE_EXTENSION)); TrajectoryReader reader = new TrajectoryReader(getPathToOutputFile(project, directory.getName(), IOUtils.TRAJECTORY_FILE_EXTENSION));
return reader.checkFile(); reader.checkFile();
return true;
} catch (IOException | VadereClassNotFoundException e) { } catch (IOException | VadereClassNotFoundException e) {
logger.error("Error in output file " + directory.getName()); logger.error("Error in output file " + directory.getName());
return false; return false;
......
...@@ -7,6 +7,7 @@ import java.io.File; ...@@ -7,6 +7,7 @@ import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.vadere.simulator.models.MainModel; import org.vadere.simulator.models.MainModel;
import org.vadere.simulator.models.MainModelBuilder; import org.vadere.simulator.models.MainModelBuilder;
...@@ -68,13 +69,13 @@ public class TestOutputFile { ...@@ -68,13 +69,13 @@ public class TestOutputFile {
List<String> header = testScenario.getDataProcessingJsonManager().getOutputFiles().get(0).getEntireHeader(); List<String> header = testScenario.getDataProcessingJsonManager().getOutputFiles().get(0).getEntireHeader();
//Note these fail if the name conflict is handled differently, for now hard coded.
assertTrue(header.contains("timeStep")); assertTrue(header.contains("timeStep"));
assertTrue(header.contains("pedestrianId")); assertTrue(header.contains("pedestrianId"));
assertTrue(header.contains("x-Proc1"));
assertTrue(header.contains("y-Proc1")); assertTrue(header.contains(OutputFile.addHeaderProcInfo("x", 1)));
assertTrue(header.contains("x-Proc2")); assertTrue(header.contains(OutputFile.addHeaderProcInfo("y", 1)));
assertTrue(header.contains("y-Proc2")); assertTrue(header.contains(OutputFile.addHeaderProcInfo("x", 2)));
assertTrue(header.contains(OutputFile.addHeaderProcInfo("y", 2)));
} }
......
package org.vadere.simulator.projects.dataprocessing.processor; package org.vadere.simulator.projects.dataprocessing.processor;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
public class PedestrianLastPositionProcessorTest extends ProcessorTest { public class PedestrianLastPositionProcessorTest extends ProcessorTest {
......
...@@ -8,7 +8,6 @@ import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile; ...@@ -8,7 +8,6 @@ import org.vadere.simulator.projects.dataprocessing.outputfile.OutputFile;
import org.vadere.simulator.utils.reflection.ReflectionHelper; import org.vadere.simulator.utils.reflection.ReflectionHelper;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
/** /**
* Base Test for all Processors. * Base Test for all Processors.
...@@ -51,10 +50,14 @@ public abstract class ProcessorTest { ...@@ -51,10 +50,14 @@ public abstract class ProcessorTest {
} }
int l = processorTestEnv.getSimStates().size(); int l = processorTestEnv.getSimStates().size();
p.postLoop(processorTestEnv.getSimStates().get(l - 1)); p.postLoop(processorTestEnv.getSimStates().get(l - 1));
processorTestEnv.getOutputFile().write();
OutputFile outputFile = processorTestEnv.getOutputFile();
outputFile.write();
// NOTE: these are the column names that have the additional information of the data processor ID.
assertEquals(processorTestEnv.getHeader(), outputFile.getHeaderLine());
String header = String.join(processorTestEnv.getDelimiter(), p.getHeaders()); String header = String.join(processorTestEnv.getDelimiter(), p.getHeaders());
assertTrue(processorTestEnv.getHeader().contains(header));
if (header.equals("")){ if (header.equals("")){
assertEquals(processorTestEnv.getExpectedOutputAsList(), processorTestEnv.getOutput(0)); assertEquals(processorTestEnv.getExpectedOutputAsList(), processorTestEnv.getOutput(0));
} else { } else {
......
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