| 1 | // License: GPL. For details, see LICENSE file.
|
|---|
| 2 | package relcontext.relationfix;
|
|---|
| 3 |
|
|---|
| 4 | import java.util.stream.Stream;
|
|---|
| 5 |
|
|---|
| 6 | import org.junit.jupiter.api.BeforeEach;
|
|---|
| 7 | import org.openstreetmap.josm.TestUtils;
|
|---|
| 8 | import org.openstreetmap.josm.data.osm.DataSet;
|
|---|
| 9 | import org.openstreetmap.josm.data.osm.Relation;
|
|---|
| 10 | import org.openstreetmap.josm.data.osm.RelationMember;
|
|---|
| 11 | import relcontext.ChosenRelation;
|
|---|
| 12 | import relcontext.actions.SortAndFixAction;
|
|---|
| 13 |
|
|---|
| 14 | /**
|
|---|
| 15 | * Test class for {@link AssociatedStreetFixer}
|
|---|
| 16 | */
|
|---|
| 17 | class AssociatedStreetFixerTest implements RelationFixerTest {
|
|---|
| 18 | private AssociatedStreetFixer instance;
|
|---|
| 19 |
|
|---|
| 20 | @BeforeEach
|
|---|
| 21 | void setup() {
|
|---|
| 22 | this.instance = new AssociatedStreetFixer();
|
|---|
| 23 | this.instance.setFixAction(new SortAndFixAction(new ChosenRelation()));
|
|---|
| 24 | }
|
|---|
| 25 |
|
|---|
| 26 | @Override
|
|---|
| 27 | public RelationFixer getInstance() {
|
|---|
| 28 | return this.instance;
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | @Override
|
|---|
| 32 | public Stream<Relation> getBadRelations() {
|
|---|
| 33 | final Relation relation = TestUtils.newRelation("type=associatedStreet name=FooBar",
|
|---|
| 34 | new RelationMember("street_misspelled", TestUtils.newWay("highway=residential name=Baz",
|
|---|
| 35 | TestUtils.newNode(""), TestUtils.newNode(""))),
|
|---|
| 36 | new RelationMember("house_misspelled", TestUtils.newNode("")));
|
|---|
| 37 | final DataSet ds = new DataSet();
|
|---|
| 38 | ds.addPrimitiveRecursive(relation);
|
|---|
| 39 | return Stream.of(relation);
|
|---|
| 40 | }
|
|---|
| 41 |
|
|---|
| 42 | @Override
|
|---|
| 43 | public Stream<Relation> getGoodRelations() {
|
|---|
| 44 | final Relation relation = TestUtils.newRelation("type=associatedStreet name=FooBar",
|
|---|
| 45 | new RelationMember("street", TestUtils.newWay("highway=residential name=FooBar", TestUtils.newNode(""), TestUtils.newNode(""))),
|
|---|
| 46 | new RelationMember("house", TestUtils.newNode("")));
|
|---|
| 47 | final DataSet ds = new DataSet();
|
|---|
| 48 | ds.addPrimitiveRecursive(relation);
|
|---|
| 49 | return Stream.of(relation);
|
|---|
| 50 | }
|
|---|
| 51 | }
|
|---|