Changeset 12728 in josm


Ignore:
Timestamp:
2017-09-05T01:22:57+02:00 (3 months ago)
Author:
Don-vip
Message:

see #13036 - fix more unit tests

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/JoinAreasAction.java

    r12718 r12728  
    6161    private final transient LinkedList<Command> cmds = new LinkedList<>();
    6262    private int cmdsCount;
     63    private DataSet ds;
    6364    private final transient List<Relation> addedRelations = new LinkedList<>();
    6465
     
    538539            // retrieve effective dataset before joining the ways (which affects the selection, thus, the <ways> collection)
    539540            // Dataset retrieving allows to call this code without relying on Main.getCurrentDataSet(), thus, on a mapview instance
    540             DataSet ds = ways.iterator().next().getDataSet();
     541            ds = ways.iterator().next().getDataSet();
    541542
    542543            // Do the job of joining areas
     
    15391540
    15401541        Relation newRel;
     1542        RelationRole soleOuter;
    15411543        switch (multiouters.size()) {
    15421544        case 0:
     
    15441546        case 1:
    15451547            // Found only one to be part of a multipolygon relation, so just add it back as well
    1546             newRel = new Relation(multiouters.get(0).rel);
    1547             newRel.addMember(new RelationMember(multiouters.get(0).role, outer));
    1548             cmds.add(new ChangeCommand(multiouters.get(0).rel, newRel));
     1548            soleOuter = multiouters.get(0);
     1549            newRel = new Relation(soleOuter.rel);
     1550            newRel.addMember(new RelationMember(soleOuter.role, outer));
     1551            cmds.add(new ChangeCommand(ds, soleOuter.rel, newRel));
    15491552            return;
    15501553        default:
     
    15661569            }
    15671570            newRel.addMember(new RelationMember("outer", outer));
    1568             cmds.add(new AddCommand(outer.getDataSet(), newRel));
     1571            cmds.add(new AddCommand(ds, newRel));
    15691572        }
    15701573    }
  • trunk/test/unit/org/openstreetmap/josm/actions/JoinAreasActionTest.java

    r12659 r12728  
    6363            MainApplication.getLayerManager().addLayer(layer);
    6464            try {
    65                 new JoinAreasAction().join(ds.getWays());
     65                new JoinAreasAction(false).join(ds.getWays());
    6666            } finally {
    6767                // Ensure we clean the place before leaving, even if test fails.
     
    125125                assertTrue(test + "; expected way, but got: " + osm, osm instanceof Way);
    126126            }
    127             new JoinAreasAction().join((Collection) primitives);
     127            new JoinAreasAction(false).join((Collection) primitives);
    128128            Collection<OsmPrimitive> joinedCol = dsToJoin.getPrimitives(osm -> !osm.isDeleted() && Objects.equals(osm.get("test"), test));
    129129            assertEquals("in test " + test + ":", 1, joinedCol.size());
  • trunk/test/unit/org/openstreetmap/josm/actions/upload/FixDataHookTest.java

    r12641 r12728  
    1515import org.openstreetmap.josm.command.SequenceCommand;
    1616import org.openstreetmap.josm.data.APIDataSet;
    17 import org.openstreetmap.josm.data.osm.Node;
     17import org.openstreetmap.josm.data.osm.DataSet;
    1818import org.openstreetmap.josm.data.osm.OsmPrimitive;
    1919import org.openstreetmap.josm.data.osm.Relation;
     
    4646        assertTrue(MainApplication.undoRedo.commands.isEmpty());
    4747
    48         // Complete data set
    49         Node emptyNode = new Node();
     48        // Complete data set (except empty which cannot be tested anymore)
    5049        Way emptyWay = new Way();
    5150        Relation emptyRelation = new Relation();
     
    7574        r2.put(" space_both ", "test");
    7675        APIDataSet ads = new APIDataSet();
    77         ads.init(Arrays.asList(emptyNode, emptyWay, emptyRelation, w1, w2, w3, w4, w5, w6, w7, r1, r2));
     76        ads.init(new DataSet(emptyWay, emptyRelation, w1, w2, w3, w4, w5, w6, w7, r1, r2));
    7877
    7978        MainApplication.undoRedo.commands.clear();
  • trunk/test/unit/org/openstreetmap/josm/gui/dialogs/relation/GenericRelationEditorTest.java

    r12564 r12728  
    9090    @Test
    9191    public void testAddPrimitivesToRelation() {
    92         assertNull(GenericRelationEditor.addPrimitivesToRelation(new Relation(1), Collections.<OsmPrimitive>emptyList()));
    93         assertNull(GenericRelationEditor.addPrimitivesToRelation(new Relation(1), Collections.singleton(new Relation(1))));
     92        Relation r = new Relation(1);
     93        new DataSet(r);
     94        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.<OsmPrimitive>emptyList()));
     95        assertNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(1))));
    9496
    95         assertNotNull(GenericRelationEditor.addPrimitivesToRelation(new Relation(1), Collections.singleton(new Node(1))));
    96         assertNotNull(GenericRelationEditor.addPrimitivesToRelation(new Relation(1), Collections.singleton(new Way(1))));
    97         assertNotNull(GenericRelationEditor.addPrimitivesToRelation(new Relation(1), Collections.singleton(new Relation(2))));
     97        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Node(1))));
     98        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Way(1))));
     99        assertNotNull(GenericRelationEditor.addPrimitivesToRelation(r, Collections.singleton(new Relation(2))));
    98100    }
    99101
Note: See TracChangeset for help on using the changeset viewer.