Changeset 13497 in josm for trunk/test


Ignore:
Timestamp:
2018-03-04T15:18:05+01:00 (18 months ago)
Author:
Don-vip
Message:

fix #16051, see #8039, see #10456 - more fixes for download/upload policies and locked status (merge of layers)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java

    r12479 r13497  
    33
    44import static org.junit.Assert.assertEquals;
     5import static org.junit.Assert.assertFalse;
    56import static org.junit.Assert.assertTrue;
    67
     
    1415import org.junit.Test;
    1516import org.openstreetmap.josm.data.coor.LatLon;
     17import org.openstreetmap.josm.data.osm.DataSet.DownloadPolicy;
    1618import org.openstreetmap.josm.data.osm.DataSet.UploadPolicy;
    1719import org.openstreetmap.josm.testutils.JOSMTestRules;
     
    194196    }
    195197
     198    /**
     199     * Unit test for {@link DataSet#mergeFrom} - Policies.
     200     */
     201    @Test
     202    public void testMergePolicies() {
     203        DataSet ds1 = new DataSet();
     204        DataSet ds2 = new DataSet();
     205
     206        ds1.setUploadPolicy(UploadPolicy.BLOCKED);
     207        ds2.setUploadPolicy(UploadPolicy.NORMAL);
     208        ds1.mergeFrom(ds2);
     209        assertEquals(UploadPolicy.BLOCKED, ds1.getUploadPolicy());
     210
     211        ds1.setUploadPolicy(UploadPolicy.NORMAL);
     212        ds2.setUploadPolicy(UploadPolicy.BLOCKED);
     213        ds1.mergeFrom(ds2);
     214        assertEquals(UploadPolicy.BLOCKED, ds1.getUploadPolicy());
     215
     216        ds1.setDownloadPolicy(DownloadPolicy.BLOCKED);
     217        ds2.setDownloadPolicy(DownloadPolicy.NORMAL);
     218        ds1.mergeFrom(ds2);
     219        assertEquals(DownloadPolicy.BLOCKED, ds1.getDownloadPolicy());
     220
     221        ds1.setDownloadPolicy(DownloadPolicy.NORMAL);
     222        ds2.setDownloadPolicy(DownloadPolicy.BLOCKED);
     223        ds1.mergeFrom(ds2);
     224        assertEquals(DownloadPolicy.BLOCKED, ds1.getDownloadPolicy());
     225
     226        ds2.lock();
     227        assertFalse(ds1.isLocked());
     228        assertTrue(ds2.isLocked());
     229        ds1.mergeFrom(ds2);
     230        assertTrue(ds1.isLocked());
     231    }
     232
    196233    private static void assertEqualsDataSet(DataSet ds1, DataSet ds2) {
    197234        assertEquals(new ArrayList<>(ds1.getNodes()), new ArrayList<>(ds2.getNodes()));
     
    202239        assertEquals(ds1.getVersion(), ds2.getVersion());
    203240    }
     241
     242    /**
     243     * Checks that enum values are defined in the correct order.
     244     */
     245    @Test
     246    public void testEnumOrder() {
     247        assertTrue(DownloadPolicy.BLOCKED.compareTo(DownloadPolicy.NORMAL) > 0);
     248        assertTrue(UploadPolicy.BLOCKED.compareTo(UploadPolicy.NORMAL) > 0);
     249        assertTrue(UploadPolicy.BLOCKED.compareTo(UploadPolicy.DISCOURAGED) > 0);
     250        assertTrue(UploadPolicy.DISCOURAGED.compareTo(UploadPolicy.NORMAL) > 0);
     251    }
    204252}
Note: See TracChangeset for help on using the changeset viewer.