Commit 7ee38247 authored by Jakob Schöttl's avatar Jakob Schöttl
Browse files

Change visibility and add tests

parent 4bd6bd5d
......@@ -135,11 +135,11 @@ public class SeatingModel implements ActiveCallback, Model {
}
}
private boolean isInnerCompartment(final int compartmentIndex) {
boolean isInnerCompartment(final int compartmentIndex) {
return compartmentIndex > 0 && compartmentIndex < trainModel.getCompartmentCount() - 1;
}
private int getDirectionFromEntranceAreaToCompartment(int entranceAreaIndex, int compartmentIndex) {
int getDirectionFromEntranceAreaToCompartment(int entranceAreaIndex, int compartmentIndex) {
// entrance areas: 0 1 2 3
// compartments: 0 1 2 3 4
if (compartmentIndex <= entranceAreaIndex)
......
package org.vadere.simulator.models.seating;
import static org.junit.Assert.*;
import java.util.ArrayList;
import java.util.List;
import java.util.Random;
......@@ -18,6 +20,7 @@ public class TestSeatingModel {
private Topography topography;
private List<Attributes> attributes;
private AttributesAgent attributesPedestrian;
private SeatingModel seatingModel;
@Before
public void setUp() {
......@@ -26,6 +29,8 @@ public class TestSeatingModel {
attributes = new ArrayList<>();
attributes.add(new AttributesSeating());
attributesPedestrian = new AttributesAgent();
seatingModel = new SeatingModel();
seatingModel.initialize(attributes, topography, attributesPedestrian, random);
}
@Test(expected=IllegalStateException.class)
......@@ -38,4 +43,29 @@ public class TestSeatingModel {
new SeatingModel().initialize(new ArrayList<>(0), topography, attributesPedestrian, random);
}
@Test
public void testIsInnerCompartment() {
assertFalse(seatingModel.isInnerCompartment(0));
assertTrue(seatingModel.isInnerCompartment(1));
assertTrue(seatingModel.isInnerCompartment(TestTopographyAndModelBuilder.nCompartments - 2));
assertFalse(seatingModel.isInnerCompartment(TestTopographyAndModelBuilder.nCompartments - 1));
}
@Test
public void testGetDirectionFromEntranceAreaToCompartment() {
// entrance areas: 0 1 2 3
// compartments: 0 1 2 3 4
assertEquals(-1, seatingModel.getDirectionFromEntranceAreaToCompartment(0, 0));
assertEquals(-1, seatingModel.getDirectionFromEntranceAreaToCompartment(1, 0));
assertEquals(-1, seatingModel.getDirectionFromEntranceAreaToCompartment(2, 0));
assertEquals(-1, seatingModel.getDirectionFromEntranceAreaToCompartment(2, 1));
assertEquals(-1, seatingModel.getDirectionFromEntranceAreaToCompartment(2, 2));
assertEquals(1, seatingModel.getDirectionFromEntranceAreaToCompartment(0, 1));
assertEquals(1, seatingModel.getDirectionFromEntranceAreaToCompartment(1, 2));
assertEquals(1, seatingModel.getDirectionFromEntranceAreaToCompartment(1, 3));
assertEquals(1, seatingModel.getDirectionFromEntranceAreaToCompartment(1, 4));
assertEquals(1, seatingModel.getDirectionFromEntranceAreaToCompartment(3, 4));
}
}
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