Commit 6c627813 authored by Stefan Schuhbaeck's avatar Stefan Schuhbaeck
Browse files

Merge branch 'measurementAreaRefactorProcessors_rebased' into 'master'

Measurement area refactor processors rebased

See merge request !55
parents dcffc7d3 83cb5e48
Pipeline #103785 passed with stages
in 137 minutes and 9 seconds
package org.vadere.simulator.projects.dataprocessing.processor; package org.vadere.simulator.projects.dataprocessing.processor;
import org.mockito.Mockito;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory; import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor; import org.vadere.state.attributes.processor.AttributesAreaDensityVoronoiProcessor;
import org.vadere.state.attributes.scenario.AttributesMeasurementArea;
import org.vadere.state.scenario.Agent; import org.vadere.state.scenario.Agent;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle; import org.vadere.util.geometry.shapes.VRectangle;
...@@ -28,8 +31,12 @@ public class AreaDensityVoronoiProcessorTestEnv extends ProcessorTestEnv<Timeste ...@@ -28,8 +31,12 @@ public class AreaDensityVoronoiProcessorTestEnv extends ProcessorTestEnv<Timeste
testedProcessor.setId(nextProcessorId()); testedProcessor.setId(nextProcessorId());
AttributesAreaDensityVoronoiProcessor attr = AttributesAreaDensityVoronoiProcessor attr =
(AttributesAreaDensityVoronoiProcessor) testedProcessor.getAttributes(); (AttributesAreaDensityVoronoiProcessor) testedProcessor.getAttributes();
attr.setVoronoiArea(new VRectangle(0, 0, 16, 16));
attr.setMeasurementArea(new VRectangle(0, 0, 16, 16)); attr.setVoronoiMeasurementAreaId(42);
attr.setMeasurementAreaId(42);
MeasurementArea measurementArea = new MeasurementArea(
new AttributesMeasurementArea(42, new VRectangle(0, 0, 16, 16)));
Mockito.when(manager.getMeasurementArea(42)).thenReturn(measurementArea);
try { try {
outputFile = outputFileFactory.createDefaultOutputfileByDataKey( outputFile = outputFileFactory.createDefaultOutputfileByDataKey(
......
...@@ -20,13 +20,11 @@ public class AreaSpeedProcessorTest extends ProcessorTest { ...@@ -20,13 +20,11 @@ public class AreaSpeedProcessorTest extends ProcessorTest {
assertEquals("Must be zero after init.", 0, p.getData().size()); assertEquals("Must be zero after init.", 0, p.getData().size());
assertEquals("Must be zero after init.", 0, (int) r.valOfField("lastStep")); assertEquals("Must be zero after init.", 0, (int) r.valOfField("lastStep"));
AttributesAreaProcessor attr = (AttributesAreaProcessor) p.getAttributes(); AttributesAreaProcessor attr = (AttributesAreaProcessor) p.getAttributes();
assertEquals(attr.getMeasurementArea(), r.valOfField("measurementArea"));
} }
@Test @Test
public void doUpdate() throws Exception { public void doUpdate() throws Exception {
AttributesAreaProcessor attr = (AttributesAreaProcessor) p.getAttributes(); AttributesAreaProcessor attr = (AttributesAreaProcessor) p.getAttributes();
attr.setMeasurementArea(new VRectangle(0, 0, 4, 5));
processorTestEnv.init(); processorTestEnv.init();
super.doUpdate(); super.doUpdate();
} }
......
...@@ -4,8 +4,11 @@ import org.mockito.Mockito; ...@@ -4,8 +4,11 @@ import org.mockito.Mockito;
import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey; import org.vadere.simulator.projects.dataprocessing.datakey.TimestepKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory; import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.processor.AttributesAreaSpeedProcessor; import org.vadere.state.attributes.processor.AttributesAreaSpeedProcessor;
import org.vadere.state.attributes.scenario.AttributesMeasurementArea;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
...@@ -45,6 +48,11 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou ...@@ -45,6 +48,11 @@ public class AreaSpeedProcessorTestEnv extends ProcessorTestEnv<TimestepKey, Dou
addRequiredProcessors(pedPosProcEnv); addRequiredProcessors(pedPosProcEnv);
Mockito.when(manager.getProcessor(pedPosProcId)).thenReturn(pedPosProc); Mockito.when(manager.getProcessor(pedPosProcId)).thenReturn(pedPosProc);
attr.setMeasurementAreaId(99);
MeasurementArea measurementArea = new MeasurementArea(
new AttributesMeasurementArea(99, new VRectangle(0, 0, 4, 5)));
Mockito.when(manager.getMeasurementArea(99)).thenReturn(measurementArea);
try { try {
outputFile = outputFileFactory.createDefaultOutputfileByDataKey( outputFile = outputFileFactory.createDefaultOutputfileByDataKey(
TimestepKey.class, TimestepKey.class,
......
...@@ -24,7 +24,6 @@ public class PedestrianWaitingEndTimeProcessorTest extends ProcessorTest { ...@@ -24,7 +24,6 @@ public class PedestrianWaitingEndTimeProcessorTest extends ProcessorTest {
assertInit(p); assertInit(p);
AttributesPedestrianWaitingEndTimeProcessor attr = AttributesPedestrianWaitingEndTimeProcessor attr =
(AttributesPedestrianWaitingEndTimeProcessor) p.getAttributes(); (AttributesPedestrianWaitingEndTimeProcessor) p.getAttributes();
assertEquals(attr.getWaitingArea(), r.valOfField("waitingArea"));
for (SimulationState s : processorTestEnv.getSimStates()) { for (SimulationState s : processorTestEnv.getSimStates()) {
p.update(s); p.update(s);
......
package org.vadere.simulator.projects.dataprocessing.processor; package org.vadere.simulator.projects.dataprocessing.processor;
import org.mockito.Mockito;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory; import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.processor.AttributesPedestrianWaitingEndTimeProcessor;
import org.vadere.state.attributes.scenario.AttributesMeasurementArea;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
...@@ -27,6 +32,13 @@ public class PedestrianWaitingEndTimeProcessorTestEnv extends ProcessorTestEnv<P ...@@ -27,6 +32,13 @@ public class PedestrianWaitingEndTimeProcessorTestEnv extends ProcessorTestEnv<P
e.printStackTrace(); e.printStackTrace();
} }
outputFile.setVadereWriterFactory(VadereWriterFactory.getStringWriterFactory()); outputFile.setVadereWriterFactory(VadereWriterFactory.getStringWriterFactory());
AttributesPedestrianWaitingEndTimeProcessor attr =
(AttributesPedestrianWaitingEndTimeProcessor) testedProcessor.getAttributes();
attr.setWaitingAreaId(42);
MeasurementArea measurementArea = new MeasurementArea(
new AttributesMeasurementArea(42, new VRectangle(0, 0, 16, 16)));
Mockito.when(manager.getMeasurementArea(42)).thenReturn(measurementArea);
} }
......
...@@ -25,7 +25,6 @@ public class PedestrianWaitingTimeProcessorTest extends ProcessorTest{ ...@@ -25,7 +25,6 @@ public class PedestrianWaitingTimeProcessorTest extends ProcessorTest{
@Test @Test
public void doUpdate() throws Exception { public void doUpdate() throws Exception {
r.setValOfFile("waitingArea", new VRectangle(0, 0, 2, 5));
super.doUpdate(); super.doUpdate();
} }
...@@ -35,9 +34,7 @@ public class PedestrianWaitingTimeProcessorTest extends ProcessorTest{ ...@@ -35,9 +34,7 @@ public class PedestrianWaitingTimeProcessorTest extends ProcessorTest{
AttributesPedestrianWaitingTimeProcessor attr = AttributesPedestrianWaitingTimeProcessor attr =
(AttributesPedestrianWaitingTimeProcessor) p.getAttributes(); (AttributesPedestrianWaitingTimeProcessor) p.getAttributes();
assertEquals(attr.getWaitingArea(), r.valOfField("waitingArea"));
r.setValOfFile("waitingArea", new VRectangle(0, 0, 2, 5));
for (SimulationState s : processorTestEnv.getSimStates()) { for (SimulationState s : processorTestEnv.getSimStates()) {
p.update(s); p.update(s);
} }
......
...@@ -3,8 +3,12 @@ package org.vadere.simulator.projects.dataprocessing.processor; ...@@ -3,8 +3,12 @@ package org.vadere.simulator.projects.dataprocessing.processor;
import org.mockito.Mockito; import org.mockito.Mockito;
import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey; import org.vadere.simulator.projects.dataprocessing.datakey.PedestrianIdKey;
import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory; import org.vadere.simulator.projects.dataprocessing.writer.VadereWriterFactory;
import org.vadere.state.attributes.processor.AttributesPedestrianWaitingTimeProcessor;
import org.vadere.state.attributes.scenario.AttributesMeasurementArea;
import org.vadere.state.scenario.MeasurementArea;
import org.vadere.state.scenario.Pedestrian; import org.vadere.state.scenario.Pedestrian;
import org.vadere.util.geometry.shapes.VPoint; import org.vadere.util.geometry.shapes.VPoint;
import org.vadere.util.geometry.shapes.VRectangle;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
...@@ -32,6 +36,16 @@ public class PedestrianWaitingTimeProcessorTestEnv extends ProcessorTestEnv<Pede ...@@ -32,6 +36,16 @@ public class PedestrianWaitingTimeProcessorTestEnv extends ProcessorTestEnv<Pede
e.printStackTrace(); e.printStackTrace();
} }
outputFile.setVadereWriterFactory(VadereWriterFactory.getStringWriterFactory()); outputFile.setVadereWriterFactory(VadereWriterFactory.getStringWriterFactory());
AttributesPedestrianWaitingTimeProcessor attr =
(AttributesPedestrianWaitingTimeProcessor) testedProcessor.getAttributes();
attr.setWaitingAreaId(42);
MeasurementArea measurementArea = new MeasurementArea(
new AttributesMeasurementArea(42, new VRectangle(0, 0, 2, 5)));
Mockito.when(manager.getMeasurementArea(42)).thenReturn(measurementArea);
} }
......
...@@ -43,7 +43,7 @@ public abstract class ProcessorTestEnv<K extends DataKey<K>, V> { ...@@ -43,7 +43,7 @@ public abstract class ProcessorTestEnv<K extends DataKey<K>, V> {
/** /**
* Factories * Factories
*/ */
DataProcessorFactory processorFactory; org.vadere.simulator.projects.dataprocessing.processor.DataProcessorFactory processorFactory;
OutputFileFactory outputFileFactory; OutputFileFactory outputFileFactory;
/** /**
* Needed for DataProcessor doUpdate call. (mocked) * Needed for DataProcessor doUpdate call. (mocked)
...@@ -70,7 +70,7 @@ public abstract class ProcessorTestEnv<K extends DataKey<K>, V> { ...@@ -70,7 +70,7 @@ public abstract class ProcessorTestEnv<K extends DataKey<K>, V> {
testedProcessor = null; testedProcessor = null;
outputFile = null; outputFile = null;
requiredProcessors = new LinkedList<>(); requiredProcessors = new LinkedList<>();
processorFactory = DataProcessorFactory.instance(); processorFactory = org.vadere.simulator.projects.dataprocessing.processor.DataProcessorFactory.instance();
outputFileFactory = OutputFileFactory.instance(); outputFileFactory = OutputFileFactory.instance();
} }
......
...@@ -6,6 +6,7 @@ import org.junit.After; ...@@ -6,6 +6,7 @@ import org.junit.After;
import org.junit.Test; import org.junit.Test;
import org.vadere.simulator.entrypoints.Version; import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.io.TestUtils; import org.vadere.simulator.projects.io.TestUtils;
import org.vadere.simulator.projects.migration.jsontranformation.JsonMigrationAssistant;
import org.vadere.state.util.StateJsonConverter; import org.vadere.state.util.StateJsonConverter;
import org.vadere.simulator.utils.reflection.TestResourceHandler; import org.vadere.simulator.utils.reflection.TestResourceHandler;
import org.vadere.util.io.IOUtils; import org.vadere.util.io.IOUtils;
...@@ -18,7 +19,7 @@ import joptsimple.internal.Strings; ...@@ -18,7 +19,7 @@ import joptsimple.internal.Strings;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
public class JoltMigrationAssistantTest implements TestResourceHandler { public class JsonMigrationAssistantTest implements TestResourceHandler {
@Override @Override
public Path getTestDir() { public Path getTestDir() {
...@@ -41,9 +42,9 @@ public class JoltMigrationAssistantTest implements TestResourceHandler { ...@@ -41,9 +42,9 @@ public class JoltMigrationAssistantTest implements TestResourceHandler {
// String json = IOUtils.readTextFileFromResources("/migration/testProject_v0.1/scenarios/WithDots_basic_1_chicken_osm1.scenario"); // String json = IOUtils.readTextFileFromResources("/migration/testProject_v0.1/scenarios/WithDots_basic_1_chicken_osm1.scenario");
JsonNode node = StateJsonConverter.deserializeToNode(json); JsonNode node = StateJsonConverter.deserializeToNode(json);
JoltMigrationAssistant joltMigrationAssistant = new JoltMigrationAssistant(); JsonMigrationAssistant jsonMigrationAssistant = new JsonMigrationAssistant();
try { try {
JsonNode newNode = joltMigrationAssistant.transform(node, Version.V0_2); JsonNode newNode = jsonMigrationAssistant.transform(node, Version.V0_2);
} catch (MigrationException e) { } catch (MigrationException e) {
e.printStackTrace(); e.printStackTrace();
} }
...@@ -56,9 +57,9 @@ public class JoltMigrationAssistantTest implements TestResourceHandler { ...@@ -56,9 +57,9 @@ public class JoltMigrationAssistantTest implements TestResourceHandler {
public void TestTransformProject() throws URISyntaxException, IOException { public void TestTransformProject() throws URISyntaxException, IOException {
Path projectPath = getRelativeTestPath("testProject_v0.1"); Path projectPath = getRelativeTestPath("testProject_v0.1");
JoltMigrationAssistant joltMigrationAssistant = new JoltMigrationAssistant(); JsonMigrationAssistant jsonMigrationAssistant = new JsonMigrationAssistant();
MigrationResult res = joltMigrationAssistant.analyzeProject(projectPath.toString()); MigrationResult res = jsonMigrationAssistant.analyzeProject(projectPath.toString());
assertEquals("", new MigrationResult(12, 0, 11, 1), res); assertEquals("", new MigrationResult(12, 0, 11, 1), res);
System.out.println(Strings.repeat('#', 80)); System.out.println(Strings.repeat('#', 80));
} }
......
package org.vadere.simulator.projects.migration.jolttranformation; package org.vadere.simulator.projects.migration.jsontranformation;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -6,8 +6,6 @@ import org.junit.Test; ...@@ -6,8 +6,6 @@ import org.junit.Test;
import org.vadere.simulator.entrypoints.Version; import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.MigrationException; import org.vadere.simulator.projects.migration.MigrationException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path; import java.nio.file.Path;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
...@@ -16,7 +14,7 @@ import static org.junit.Assert.assertThat; ...@@ -16,7 +14,7 @@ import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
public class JoltTransformV0toV1Test extends JoltTransformationTest { public class JoltTransformV0toV1Test extends JsonTransformationTest {
@Override @Override
...@@ -27,10 +25,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest { ...@@ -27,10 +25,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest {
// Source postHook should not bee used here // Source postHook should not bee used here
@Test @Test
public void TestPostHooks1() throws MigrationException { public void TestPostHooks1() throws MigrationException {
JoltTransformation transformation = JoltTransformation.get(Version.NOT_A_RELEASE); JsonTransformation transformation = AbstractJsonTransformation.get(Version.NOT_A_RELEASE);
String TEST1 = "/migration/vNOT-A-RELEASE_to_v0.1_Test1.scenario"; String TEST1 = "/migration/vNOT-A-RELEASE_to_v0.1_Test1.scenario";
JsonNode in = getJsonFromResource(TEST1); JsonNode in = getJsonFromResource(TEST1);
JsonNode out = transformation.applyTransformation(in); JsonNode out = transformation.applyAll(in);
// will test that sources exists. // will test that sources exists.
JsonNode sources = pathMustExist(out, "vadere/topography/sources"); JsonNode sources = pathMustExist(out, "vadere/topography/sources");
assertEquals("Therer must be one source", 1, sources.size()); assertEquals("Therer must be one source", 1, sources.size());
...@@ -49,10 +47,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest { ...@@ -49,10 +47,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest {
// All postHooks should bee used here // All postHooks should bee used here
@Test @Test
public void TestPostHooks2() throws MigrationException { public void TestPostHooks2() throws MigrationException {
JoltTransformation transformation = factory.getJoltTransformV0toV1(); JsonTransformation transformation = factory.getJoltTransformV0toV1();
String TEST2 = "/migration/vNOT-A-RELEASE_to_v0.1_Test2.scenario"; String TEST2 = "/migration/vNOT-A-RELEASE_to_v0.1_Test2.scenario";
JsonNode in = getJsonFromResource(TEST2); JsonNode in = getJsonFromResource(TEST2);
JsonNode out = transformation.applyTransformation(in); JsonNode out = transformation.applyAll(in);
JsonNode sources = pathMustExist(out, "vadere/topography/sources"); JsonNode sources = pathMustExist(out, "vadere/topography/sources");
assertEquals("Therer must be one source", 1, sources.size()); assertEquals("Therer must be one source", 1, sources.size());
...@@ -70,10 +68,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest { ...@@ -70,10 +68,10 @@ public class JoltTransformV0toV1Test extends JoltTransformationTest {
// should fail because no main model was found // should fail because no main model was found
@Test(expected = MigrationException.class) @Test(expected = MigrationException.class)
public void TestPostHooks3() throws MigrationException { public void TestPostHooks3() throws MigrationException {
JoltTransformation transformation = factory.getJoltTransformV0toV1(); JsonTransformation transformation = factory.getJoltTransformV0toV1();
String TEST3 = "/migration/vNOT-A-RELEASE_to_v0.1_Test3.scenario"; String TEST3 = "/migration/vNOT-A-RELEASE_to_v0.1_Test3.scenario";
JsonNode in = getJsonFromResource(TEST3); JsonNode in = getJsonFromResource(TEST3);
transformation.applyTransformation(in); transformation.applyAll(in);
fail("should not be reached! The Transformation should fail with MigrationException"); fail("should not be reached! The Transformation should fail with MigrationException");
} }
......
package org.vadere.simulator.projects.migration.jolttranformation; package org.vadere.simulator.projects.migration.jsontranformation;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -6,13 +6,11 @@ import org.junit.Test; ...@@ -6,13 +6,11 @@ import org.junit.Test;
import org.vadere.simulator.entrypoints.Version; import org.vadere.simulator.entrypoints.Version;
import org.vadere.simulator.projects.migration.MigrationException; import org.vadere.simulator.projects.migration.MigrationException;
import java.io.IOException;
import java.net.URISyntaxException;
import java.nio.file.Path; import java.nio.file.Path;
import static org.junit.Assert.*; import static org.junit.Assert.*;
public class JoltTransformV1toV2Test extends JoltTransformationTest { public class JoltTransformV1toV2Test extends JsonTransformationTest {
@Override @Override
public Path getTestDir() { public Path getTestDir() {
...@@ -21,8 +19,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest { ...@@ -21,8 +19,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest {
@Test @Test
public void Test1() throws MigrationException { public void Test1() throws MigrationException {
JoltTransformation t = JoltTransformation.get(Version.V0_1); JsonTransformation t = AbstractJsonTransformation.get(Version.V0_1);
JsonNode node = t.applyTransformation(getJsonFromResource("/migration/v0.1_to_v0.2_Test1.scenario")); JsonNode node = t.applyAll(getJsonFromResource("/migration/v0.1_to_v0.2_Test1.scenario"));
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesPotentialCompact"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesPotentialCompact");
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesOSM"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesOSM");
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesFloorField"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesFloorField");
...@@ -31,8 +29,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest { ...@@ -31,8 +29,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest {
@Test @Test
public void Test2() throws MigrationException { public void Test2() throws MigrationException {
JoltTransformation t = JoltTransformation.get(Version.V0_1); JsonTransformation t = AbstractJsonTransformation.get(Version.V0_1);
JsonNode node = t.applyTransformation(getJsonFromResource("/migration/v0.1_to_v0.2_Test2.scenario")); JsonNode node = t.applyAll(getJsonFromResource("/migration/v0.1_to_v0.2_Test2.scenario"));
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesPotentialCompact"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesPotentialCompact");
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesOSM"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesOSM");
pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesFloorField"); pathMustExist(node, "scenario/attributesModel/org.vadere.state.attributes.models.AttributesFloorField");
...@@ -42,8 +40,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest { ...@@ -42,8 +40,8 @@ public class JoltTransformV1toV2Test extends JoltTransformationTest {
// Test default values if only name is given. // Test default values if only name is given.
@Test @Test
public void Test3() throws MigrationException { public void Test3() throws MigrationException {
JoltTransformation t = JoltTransformation.get(Version.V0_1); JsonTransformation t = AbstractJsonTransformation.get(Version.V0_1);
JsonNode node = t.applyTransformation(getJsonFromResource("/migration/v0.1_to_v0.2_Test3.scenario")); JsonNode node = t.applyAll(getJsonFromResource("/migration/v0.1_to_v0.2_Test3.scenario"));
pathMustExist(node, "scenario/attributesModel"); pathMustExist(node, "scenario/attributesModel");
assertEquals("should be empty", 0, pathMustExist(node, "scenario/attributesModel").size()); assertEquals("should be empty", 0, pathMustExist(node, "scenario/attributesModel").size());
assertThat(pathMustExist(node, "name"), nodeHasText("XXXX")); assertThat(pathMustExist(node, "name"), nodeHasText("XXXX"));
......
package org.vadere.simulator.projects.migration.jolttranformation; package org.vadere.simulator.projects.migration.jsontranformation;
import java.nio.file.Path; import java.nio.file.Path;
public class JoltTransformV2toV3Test extends JoltTransformationTest{ public class JoltTransformV2toV3Test extends JsonTransformationTest {
@Override @Override
public Path getTestDir() { public Path getTestDir() {
......
package org.vadere.simulator.projects.migration.jolttranformation; package org.vadere.simulator.projects.migration.jsontranformation;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
import org.junit.After; import org.junit.After;
...@@ -16,7 +16,7 @@ import static org.hamcrest.core.IsNot.not; ...@@ -16,7 +16,7 @@ import static org.hamcrest.core.IsNot.not;
import static org.junit.Assert.assertThat; import static org.junit.Assert.assertThat;
import static org.junit.Assert.fail; import static org.junit.Assert.fail;
public class JoltTransformV3toV4Test extends JoltTransformationTest { public class JoltTransformV3toV4Test extends JsonTransformationTest {
private ArrayList<Path> scenarios; private ArrayList<Path> scenarios;
private ArrayList<Path> bakScenarios; private ArrayList<Path> bakScenarios;
...@@ -55,7 +55,7 @@ public class JoltTransformV3toV4Test extends JoltTransformationTest { ...@@ -55,7 +55,7 @@ public class JoltTransformV3toV4Test extends JoltTransformationTest {
public void TestTransform() { public void TestTransform() {
MigrationAssistant ma = MigrationAssistant.getNewInstance(MigrationOptions.defaultOptions()); MigrationAssistant ma = MigrationAssistant.getNewInstance(MigrationOptions.defaultOptions());
try { try {
String out = ma.convertFile(scenarios.get(0), Version.V0_4); String out = ma.migrateScenarioFile(scenarios.get(0), Version.V0_4);
// System.out.println(out); // System.out.println(out);
assertThat("New Version must be V0.4", out, v04); assertThat("New Version must be V0.4", out, v04);
assertThat("New Entry missing", out, useFixedSeed); assertThat("New Entry missing", out, useFixedSeed);
......
package org.vadere.simulator.projects.migration.jolttranformation; package org.vadere.simulator.projects.migration.jsontranformation;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
...@@ -6,14 +6,14 @@ import org.vadere.simulator.entrypoints.Version; ...@@ -6,14 +6,14 @@ import org.vadere.simulator.entrypoints.Version;