| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package relcontext.relationfix;
|
|---|
| 3 |
|
|---|
| 4 | import java.util.Arrays;
|
|---|
| 5 | import java.util.stream.Stream;
|
|---|
| 6 |
|
|---|
| 7 | import org.junit.jupiter.api.BeforeEach;
|
|---|
| 8 | import org.openstreetmap.josm.TestUtils;
|
|---|
| 9 | import org.openstreetmap.josm.data.osm.DataSet;
|
|---|
| 10 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| 11 | import org.openstreetmap.josm.data.osm.RelationMember;
|
|---|
| 12 | import relcontext.ChosenRelation;
|
|---|
| 13 | import relcontext.actions.SortAndFixAction;
|
|---|
| 14 |
|
|---|
| 15 | /**
|
|---|
| 16 | * Test class for {@link PublicTransportFixer}
|
|---|
| 17 | */
|
|---|
| 18 | class PublicTransportFixerTest implements RelationFixerTest {
|
|---|
| 19 | private PublicTransportFixer instance;
|
|---|
| 20 |
|
|---|
| 21 | @BeforeEach
|
|---|
| 22 | void setup() {
|
|---|
| 23 | this.instance = new PublicTransportFixer();
|
|---|
| 24 | this.instance.setFixAction(new SortAndFixAction(new ChosenRelation()));
|
|---|
| 25 | }
|
|---|
| 26 |
|
|---|
| 27 | @Override
|
|---|
| 28 | public RelationFixer getInstance() {
|
|---|
| 29 | return this.instance;
|
|---|
| 30 | }
|
|---|
| 31 |
|
|---|
| 32 | @Override
|
|---|
| 33 | public Stream<Relation> getBadRelations() {
|
|---|
| 34 | final Relation badWay = TestUtils.newRelation("type=public_transport",
|
|---|
| 35 | new RelationMember("", TestUtils.newWay("public_transport=platform")));
|
|---|
| 36 | final Relation badNode = TestUtils.newRelation("type=public_transport",
|
|---|
| 37 | new RelationMember("", TestUtils.newNode("public_transport=stop_position")));
|
|---|
| 38 | final Relation[] relations = {badWay, badNode};
|
|---|
| 39 | for (Relation relation : relations) {
|
|---|
| 40 | final DataSet ds = new DataSet();
|
|---|
| 41 | ds.addPrimitiveRecursive(relation);
|
|---|
| 42 | }
|
|---|
| 43 | return Arrays.stream(relations);
|
|---|
| 44 | }
|
|---|
| 45 |
|
|---|
| 46 | @Override
|
|---|
| 47 | public Stream<Relation> getGoodRelations() {
|
|---|
| 48 | final Relation way = TestUtils.newRelation("type=public_transport",
|
|---|
| 49 | new RelationMember("platform", TestUtils.newWay("public_transport=platform")));
|
|---|
| 50 | final Relation node = TestUtils.newRelation("type=public_transport",
|
|---|
| 51 | new RelationMember("stop", TestUtils.newNode("public_transport=stop_position")));
|
|---|
| 52 | final Relation[] relations = {way, node};
|
|---|
| 53 | for (Relation relation : relations) {
|
|---|
| 54 | final DataSet ds = new DataSet();
|
|---|
| 55 | ds.addPrimitiveRecursive(relation);
|
|---|
| 56 | }
|
|---|
| 57 | return Arrays.stream(relations);
|
|---|
| 58 | }
|
|---|
| 59 | }
|
|---|