source: osm/applications/editors/josm/plugins/reltoolbox/test/unit/relcontext/relationfix/PublicTransportFixerTest.java

Last change on this file was 36103, checked in by taylor.smock, 2 years ago

reltoolbox: Preferentially use the source relation dataset

If the source relation does not have a dataset, use the current edit dataset instead.

This also adds some basic tests.

File size: 2.1 KB
Line 
1// License: GPL. For details, see LICENSE file.
2package relcontext.relationfix;
3
4import java.util.Arrays;
5import java.util.stream.Stream;
6
7import org.junit.jupiter.api.BeforeEach;
8import org.openstreetmap.josm.TestUtils;
9import org.openstreetmap.josm.data.osm.DataSet;
10import org.openstreetmap.josm.data.osm.Relation;
11import org.openstreetmap.josm.data.osm.RelationMember;
12import relcontext.ChosenRelation;
13import relcontext.actions.SortAndFixAction;
14
15/**
16 * Test class for {@link PublicTransportFixer}
17 */
18class 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}
Note: See TracBrowser for help on using the repository browser.