Changeset 12111 in josm for trunk/test/unit/org


Ignore:
Timestamp:
2017-05-11T00:54:50+02:00 (8 years ago)
Author:
michael2402
Message:

CreateCircleActionTest: Remove reflection hack for addSelected: It works as expected now

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/actions/CreateCircleActionTest.java

    r11275 r12111  
    66
    77import java.lang.reflect.Field;
    8 import java.lang.reflect.Method;
    98import java.util.Arrays;
    109import java.util.Collection;
    11 import java.util.Collections;
    1210
    1311import org.junit.Rule;
     
    1917import org.openstreetmap.josm.data.osm.DataSet;
    2018import org.openstreetmap.josm.data.osm.Node;
    21 import org.openstreetmap.josm.data.osm.OsmPrimitive;
    2219import org.openstreetmap.josm.data.osm.Way;
    2320import org.openstreetmap.josm.gui.layer.OsmDataLayer;
     
    4441
    4542    /**
    46      * FIXME: Conveniance method to prevent Selection Change events.
    47      * A more proper way should be to define a TestingDataSet class with limited
    48      * functionalities, but DataSet is declare as final (due to Cloneable interface).
    49      *
    50      * I don't know why, but in other tests there are no problem to add selected primitives
    51      * but in this case there is a problem with an even listener of selection change.
    52      * @param p primitive
    53      * @param ds data set
    54      * @throws ReflectiveOperationException if an error occurs
    55      */
    56     public void addSelected(OsmPrimitive p, DataSet ds) throws ReflectiveOperationException {
    57         Method method = ds.getClass().getDeclaredMethod("addSelected",
    58                                                         new Class<?>[] {Collection.class, boolean.class});
    59         Utils.setObjectsAccessible(method);
    60         method.invoke(ds, Collections.singleton(p), false);
    61     }
    62 
    63     /**
    6443     * Test case: When Create Circle action is performed with a single way selected,
    6544     * circle direction must equals way direction.
     
    8362        dataSet.addPrimitive(w);
    8463
    85         addSelected(w, dataSet);
     64        dataSet.addSelected(w);
    8665
    8766        CreateCircleAction action = new CreateCircleAction();
     
    145124        dataSet.addPrimitive(n3);
    146125
    147         addSelected(n1, dataSet);
    148         addSelected(n2, dataSet);
    149         addSelected(n3, dataSet);
     126        dataSet.addSelected(n1);
     127        dataSet.addSelected(n2);
     128        dataSet.addSelected(n3);
    150129
    151130        // Mock left/right hand traffic database
Note: See TracChangeset for help on using the changeset viewer.