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

Last change on this file was 36483, checked in by stoecker, 8 months ago

set eol-style, fix checkstyle issues, add ignores

  • Property svn:eol-style set to native
File size: 3.2 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.Node;
11import org.openstreetmap.josm.data.osm.Relation;
12import org.openstreetmap.josm.data.osm.RelationMember;
13import org.openstreetmap.josm.data.osm.Way;
14import relcontext.ChosenRelation;
15import relcontext.actions.SortAndFixAction;
16
17/**
18 * Test class for {@link BoundaryFixer}
19 */
20class BoundaryFixerTest implements RelationFixerTest {
21
22 private BoundaryFixer instance;
23
24 @BeforeEach
25 void setup() {
26 this.instance = new BoundaryFixer();
27 this.instance.setFixAction(new SortAndFixAction(new ChosenRelation()));
28 }
29
30 @Override
31 public RelationFixer getInstance() {
32 return instance;
33 }
34
35 @Override
36 public Stream<Relation> getBadRelations() {
37 final Relation wayRelation = TestUtils.newRelation("type=boundary boundary=administrative",
38 new RelationMember("outer_misspelled", TestUtils.newWay("", TestUtils.newNode(""), TestUtils.newNode(""))));
39 final Relation nodeRelation = TestUtils.newRelation("type=boundary boundary=administrative",
40 new RelationMember("admin_centre_misspelled", TestUtils.newNode("")));
41 final Relation relationRelation = TestUtils.newRelation("type=boundary boundary=administrative",
42 new RelationMember("subarea_misspelled", TestUtils.newRelation("")));
43 Relation[] relations = {nodeRelation, wayRelation, relationRelation};
44 for (Relation relation : relations) {
45 final DataSet ds = new DataSet();
46 ds.addPrimitiveRecursive(relation);
47 }
48 // Ensure that the boundary is enclosed
49 final Node tNode = TestUtils.newNode("");
50 wayRelation.getDataSet().addPrimitive(tNode);
51 final Way way2 = TestUtils.newWay("", wayRelation.getMember(0).getWay().firstNode(),
52 tNode, wayRelation.getMember(0).getWay().lastNode());
53 wayRelation.getDataSet().addPrimitive(way2);
54 wayRelation.addMember(new RelationMember("outer_misspelled", way2));
55 return Arrays.stream(relations);
56 }
57
58 @Override
59 public Stream<Relation> getGoodRelations() {
60 final Relation wayRelation = TestUtils.newRelation("type=boundary boundary=administrative",
61 new RelationMember("outer", TestUtils.newWay("", TestUtils.newNode(""), TestUtils.newNode(""))));
62 final Relation nodeRelation = TestUtils.newRelation("type=boundary boundary=administrative",
63 new RelationMember("admin_centre", TestUtils.newNode("place=city")));
64 final Relation relationRelation = TestUtils.newRelation("type=boundary boundary=administrative",
65 new RelationMember("subarea", TestUtils.newRelation("")));
66 Relation[] relations = {nodeRelation, wayRelation, relationRelation};
67 for (Relation relation : relations) {
68 final DataSet ds = new DataSet();
69 ds.addPrimitiveRecursive(relation);
70 }
71 return Arrays.stream(relations);
72 }
73}
Note: See TracBrowser for help on using the repository browser.