The expiration time for new job artifacts in CI/CD pipelines is now 30 days (GitLab default). Previously generated artifacts in already completed jobs will not be affected by the change. The latest artifacts for all jobs in the latest successful pipelines will be kept. More information: https://gitlab.lrz.de/help/user/admin_area/settings/continuous_integration.html#default-artifacts-expiration

Commit 2e8e0ee7 authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Reimplement JSON tests

parent 07801a88
package org.vadere.gui.vadere;
import org.junit.BeforeClass;
import org.apache.commons.io.IOUtils;
import org.junit.Test;
import org.vadere.simulator.projects.ScenarioRunManager;
import org.vadere.simulator.projects.VadereProject;
import org.vadere.simulator.projects.io.JsonConverter;
import static org.junit.Assert.*;
import java.io.IOException;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
import java.io.InputStream;
import java.io.UncheckedIOException;
public class TestVadereTestProject {
private static VadereProject testProject;
private static String testProjectName = "testprojectname";
private static String testName = "testname";
@BeforeClass
public static void setUpBeforeClass() throws Exception {
ConcurrentMap<String, ScenarioRunManager> tests = new ConcurrentHashMap<>();
tests.put(testName + "1", new ScenarioRunManager(testName + "1"));
tests.put(testName + "2", new ScenarioRunManager(testName + "2"));
tests.put(testName + "3", new ScenarioRunManager(testName + "3"));
// testProject = new VadereProject(testProjectName, tests); // TODO [priority=medium] [task=test] fix test
}
@Test
public void testToJSON() throws IOException {
public void testToJson() throws IOException {
final String scenarioJson = loadTestScenarioJson();
final ScenarioRunManager srm = JsonConverter.deserializeScenarioRunManager(scenarioJson);
final String serializedJson = JsonConverter.serializeScenarioRunManager(srm);
// TODO implement json test
/*
* String json = IOUtils.toPrettyPrintJson(IOVadere.toJson(testProject));
* // System.out.println(json);
*
* Map<String, Object> store = fromJson(json, Map.class);
*
* assertEquals(testProject.getName(), store.get("name"));
*
* List<Map<Object, String>> tests = (List<Map<Object, String>>) store.get("scenarios");
* assertEquals(IOVadere.toJson(testProject.getScenario(0)),
* IOVadere.toJson(IOVadere.fromJson(IOUtils.toJson(tests.get(0)))));
* assertEquals(IOVadere.toJson(testProject.getScenario(1)),
* IOVadere.toJson(IOVadere.fromJson(IOUtils.toJson(tests.get(1)))));
* assertEquals(IOVadere.toJson(testProject.getScenario(2)),
* IOVadere.toJson(IOVadere.fromJson(IOUtils.toJson(tests.get(2)))));
*/
}
@Test
public void testFromJSON() throws IOException {
// TODO implement json test
/*
* String json = IOUtils.toPrettyPrintJson(IOVadere.toJson(testProject));
* VadereProject testInstanceNew = IOVadere.projectFromJson(json);
*
* assertEquals(IOVadere.toJson(testProject), IOVadere.toJson(testInstanceNew));
*/
public void testFromJson() throws IOException {
final String scenarioJson = loadTestScenarioJson();
final ScenarioRunManager srm = JsonConverter.deserializeScenarioRunManager(scenarioJson);
assertEquals("Neues_Szenario", srm.getName());
assertEquals(3, srm.getAttributesModel().size());
assertEquals(21, srm.getDataProcessingJsonManager().getDataProcessors().size());
assertEquals(6, srm.getDataProcessingJsonManager().getOutputFiles().size());
assertTrue(srm.getAttributesPedestrian() != null);
assertTrue(srm.getAttributesSimulation() != null);
assertTrue(srm.getTopography() != null);
}
private String loadTestScenarioJson() {
try {
final InputStream resourceAsStream = getClass().getResourceAsStream("/test-scenario.scenario");
return IOUtils.toString(resourceAsStream);
} catch (IOException e) {
throw new UncheckedIOException(e);
}
}
}
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