Changeset 2381 in josm for trunk/test/functional


Ignore:
Timestamp:
2009-11-02T07:51:28+01:00 (10 years ago)
Author:
jttt
Message:

Change most occurrences of Dataset.nodes/ways/relations with getNodes()/../.. or addPrimitive

Location:
trunk/test/functional/org/openstreetmap/josm/io
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/test/functional/org/openstreetmap/josm/io/MultiFetchServerObjectReaderTest.java

    r2199 r2381  
    3535import org.openstreetmap.josm.data.projection.Mercator;
    3636import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    37 import org.xml.sax.SAXException;
    3837
    3938public class MultiFetchServerObjectReaderTest {
     
    124123        logger.info("creating data set on the server ...");
    125124        ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
    126         primitives.addAll(testDataSet.nodes);
    127         primitives.addAll(testDataSet.ways);
    128         primitives.addAll(testDataSet.relations);
     125        primitives.addAll(testDataSet.getNodes());
     126        primitives.addAll(testDataSet.getWays());
     127        primitives.addAll(testDataSet.getRelations());
    129128
    130129        OsmServerWriter writer = new OsmServerWriter();
     
    247246        }
    248247        DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE);
    249         assertEquals(10, out.nodes.size());
     248        assertEquals(10, out.getNodes().size());
    250249        Iterator<Node> it = out.nodes.iterator();
    251250        while(it.hasNext()) {
     
    261260    public void testMultiGet10Ways() throws OsmTransferException {
    262261        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    263         ArrayList<Way> ways= new ArrayList<Way>(ds.ways);
     262        ArrayList<Way> ways= new ArrayList<Way>(ds.getWays());
    264263        for (int i =0; i< 10; i++) {
    265264            reader.append(ways.get(i));
    266265        }
    267266        DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE);
    268         assertEquals(10, out.ways.size());
    269         Iterator<Way> it = out.ways.iterator();
    270         while(it.hasNext()) {
    271             Way w1 = it.next();
     267        assertEquals(10, out.getWays().size());
     268        for (Way w1: out.getWays()) {
    272269            Way w2 = (Way)ds.getPrimitiveById(w1.getId(), OsmPrimitiveType.WAY);
    273270            assertNotNull(w2);
     
    281278    public void testMultiGet10Relations() throws OsmTransferException {
    282279        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    283         ArrayList<Relation> relations= new ArrayList<Relation>(ds.relations);
     280        ArrayList<Relation> relations= new ArrayList<Relation>(ds.getRelations());
    284281        for (int i =0; i< 10; i++) {
    285282            reader.append(relations.get(i));
    286283        }
    287284        DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE);
    288         assertEquals(10, out.relations.size());
    289         Iterator<Relation> it = out.relations.iterator();
    290         while(it.hasNext()) {
    291             Relation r1 = it.next();
     285        assertEquals(10, out.getRelations().size());
     286        for (Relation r1: out.getRelations()) {
    292287            Relation r2 = (Relation)ds.getPrimitiveById(r1.getId(), OsmPrimitiveType.RELATION);
    293288            assertNotNull(r2);
     
    301296    public void testMultiGet800Nodes() throws OsmTransferException {
    302297        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    303         ArrayList<Node> nodes = new ArrayList<Node>(ds.nodes);
     298        ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes());
    304299        for (int i =0; i< 812; i++) {
    305300            reader.append(nodes.get(i));
    306301        }
    307302        DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE);
    308         assertEquals(812, out.nodes.size());
     303        assertEquals(812, out.getNodes().size());
    309304        Iterator<Node> it = out.nodes.iterator();
    310305        while(it.hasNext()) {
     
    320315    public void multiGetWithNonExistingNode() throws OsmTransferException {
    321316        MultiFetchServerObjectReader reader = new MultiFetchServerObjectReader();
    322         ArrayList<Node> nodes = new ArrayList<Node>(ds.nodes);
     317        ArrayList<Node> nodes = new ArrayList<Node>(ds.getNodes());
    323318        for (int i =0; i< 10; i++) {
    324319            reader.append(nodes.get(i));
     
    327322        reader.append(n); // doesn't exist
    328323        DataSet out = reader.parseOsm(NullProgressMonitor.INSTANCE);
    329         assertEquals(10, out.nodes.size());
    330         Iterator<Node> it = out.nodes.iterator();
    331         while(it.hasNext()) {
    332             Node n1 = it.next();
     324        assertEquals(10, out.getNodes().size());
     325        for (Node n1:out.getNodes()) {
    333326            Node n2 = (Node)ds.getPrimitiveById(n1.getId(), OsmPrimitiveType.NODE);
    334327            assertNotNull(n2);
  • trunk/test/functional/org/openstreetmap/josm/io/OsmServerBackreferenceReaderTest.java

    r2199 r2381  
    3434import org.openstreetmap.josm.data.projection.Mercator;
    3535import org.openstreetmap.josm.gui.progress.NullProgressMonitor;
    36 import org.xml.sax.SAXException;
    3736
    3837public class OsmServerBackreferenceReaderTest {
     
    4039
    4140    protected static Node lookupNode(DataSet ds, int i) {
    42         for (Node n: ds.nodes) {
     41        for (Node n : ds.getNodes()) {
    4342            if (("node-" + i).equals(n.get("name"))) return n;
    4443        }
     
    4847
    4948    protected static Way lookupWay(DataSet ds, int i) {
    50         for (Way w: ds.ways) {
     49        for (Way w : ds.getWays()) {
    5150            if (("way-" + i).equals(w.get("name"))) return w;
    5251        }
     
    5554
    5655    protected static Relation lookupRelation(DataSet ds, int i) {
    57         for (Relation r: ds.relations) {
     56        for (Relation r : ds.getRelations()) {
    5857            if (("relation-" + i).equals(r.get("name"))) return r;
    5958        }
     
    103102                }
    104103            }
    105             ds.relations.add(r);
     104            ds.addPrimitive(r);
    106105        }
    107106    }
     
    127126        logger.info("creating data set on the server ...");
    128127        ArrayList<OsmPrimitive> primitives = new ArrayList<OsmPrimitive>();
    129         primitives.addAll(ds.nodes);
    130         primitives.addAll(ds.ways);
    131         primitives.addAll(ds.relations);
     128        primitives.addAll(ds.getNodes());
     129        primitives.addAll(ds.getWays());
     130        primitives.addAll(ds.getRelations());
    132131        OsmServerWriter writer = new OsmServerWriter();
    133132        Changeset cs  = new Changeset();
     
    253252        reader.setReadFull(false);
    254253        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
    255         assertEquals(10, referers.nodes.size());
    256         assertEquals(1, referers.ways.size());
    257         assertEquals(0, referers.relations.size());
    258         for (Way way: referers.ways) {
     254        assertEquals(10, referers.getNodes().size());
     255        assertEquals(1, referers.getWays().size());
     256        assertEquals(0, referers.getRelations().size());
     257        for (Way way : referers.getWays()) {
    259258            assertEquals(w.getId(), way.getId());
    260259            assertEquals(false, way.incomplete);
     
    272271        reader.setReadFull(true);
    273272        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
    274         assertEquals(10, referers.nodes.size());
    275         assertEquals(1, referers.ways.size());
    276         assertEquals(0, referers.relations.size());
    277         for (Way way: referers.ways) {
     273        assertEquals(10, referers.getNodes().size());
     274        assertEquals(1, referers.getWays().size());
     275        assertEquals(0, referers.getRelations().size());
     276        for (Way way : referers.getWays()) {
    278277            assertEquals(w.getId(), way.getId());
    279278            assertEquals(false, way.incomplete);
     
    292291        reader.setReadFull(false);
    293292        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
    294         assertEquals(0, referers.nodes.size()); // no nodes loaded
    295         assertEquals(6, referers.ways.size());  // 6 ways referred by two relations
    296         for (Way w1: referers.ways) {
     293        assertEquals(0, referers.getNodes().size()); // no nodes loaded
     294        assertEquals(6, referers.getWays().size());  // 6 ways referred by two relations
     295        for (Way w1 : referers.getWays()) {
    297296            assertEquals(true, w1.incomplete);
    298297        }
    299         assertEquals(2, referers.relations.size());  // two relations referring to w
     298        assertEquals(2, referers.getRelations().size());  // two relations referring to w
    300299
    301300        Relation r = lookupRelation(referers, 0);
     
    316315        reader.setReadFull(true);
    317316        DataSet referers = reader.parseOsm(NullProgressMonitor.INSTANCE);
    318         assertEquals(6, referers.ways.size());  // 6 ways referred by two relations
    319         for (Way w1: referers.ways) {
     317        assertEquals(6, referers.getWays().size());  // 6 ways referred by two relations
     318        for (Way w1 : referers.getWays()) {
    320319            assertEquals(false, w1.incomplete);
    321320        }
    322         assertEquals(2, referers.relations.size());  // two relations referring to
     321        assertEquals(2, referers.getRelations().size());  // two relations referring to
    323322        Set<Long> expectedNodeIds = new HashSet<Long>();
    324         for (Way way: referers.ways) {
    325             Way orig = (Way)ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY);
    326             for(Node n: orig.getNodes()) {
     323        for (Way way : referers.getWays()) {
     324            Way orig = (Way) ds.getPrimitiveById(way.getId(), OsmPrimitiveType.WAY);
     325            for (Node n : orig.getNodes()) {
    327326                expectedNodeIds.add(n.getId());
    328327            }
    329328        }
    330         assertEquals(expectedNodeIds.size(), referers.nodes.size());
    331         for (Node n : referers.nodes) {
     329        assertEquals(expectedNodeIds.size(), referers.getNodes().size());
     330        for (Node n : referers.getNodes()) {
    332331            assertEquals(true, expectedNodeIds.contains(n.getId()));
    333332        }
     
    342341    @Test
    343342    public void testBackrefrenceForRelation() throws OsmTransferException {
    344         Relation r = lookupRelation(ds,1);
     343        Relation r = lookupRelation(ds, 1);
    345344        assertNotNull(r);
    346345        // way with name "relation-1" is referred to by four relations:
     
    370369        referringRelationsIds.add(r.getId());
    371370
    372         for (Relation r1: referers.relations) {
    373             if (! referringRelationsIds.contains(r1.getId())) {
     371        for (Relation r1 : referers.getRelations()) {
     372            if (!referringRelationsIds.contains(r1.getId())) {
    374373                assertEquals(true, r1.incomplete);
    375374            }
     
    401400        }
    402401
    403         assertEquals(expectedWayIds.size(), referers.ways.size());
    404         for (Way w1 : referers.ways) {
     402        assertEquals(expectedWayIds.size(), referers.getWays().size());
     403        for (Way w1 : referers.getWays()) {
    405404            assertEquals(true, expectedWayIds.contains(w1.getId()));
    406405            assertEquals(true, w1.incomplete);
     
    409408        // make sure we didn't read any nodes
    410409        //
    411         assertEquals(0, referers.nodes.size());
     410        assertEquals(0, referers.getNodes().size());
    412411    }
    413412
     
    438437    @Test
    439438    public void testBackrefrenceForRelation_Full() throws OsmTransferException {
    440         Relation r = lookupRelation(ds,1);
     439        Relation r = lookupRelation(ds, 1);
    441440        assertNotNull(r);
    442441        // way with name "relation-1" is referred to by four relations:
     
    468467        // all relations are fully loaded
    469468        //
    470         for (Relation r1: referers.relations) {
     469        for (Relation r1 : referers.getRelations()) {
    471470            assertEquals(false, r1.incomplete);
    472471        }
     
    497496        }
    498497        for (long id : expectedWayIds) {
    499             Way w = (Way)referers.getPrimitiveById(id, OsmPrimitiveType.WAY);
     498            Way w = (Way) referers.getPrimitiveById(id, OsmPrimitiveType.WAY);
    500499            assertNotNull(w);
    501500            assertEquals(false, w.incomplete);
     
    503502
    504503        Set<Long> expectedNodeIds = new HashSet<Long>();
    505         for(int i=6; i< 10;i++) {
     504        for (int i = 6; i < 10; i++) {
    506505            Relation r1 = lookupRelation(ds, i);
    507506            expectedNodeIds.addAll(getNodeIdsInRelation(r1));
    508507        }
    509508
    510         assertEquals(expectedNodeIds.size(), referers.nodes.size());
    511         for(Node n : referers.nodes) {
     509        assertEquals(expectedNodeIds.size(), referers.getNodes().size());
     510        for (Node n : referers.getNodes()) {
    512511            assertEquals(true, expectedNodeIds.contains(n.getId()));
    513512        }
Note: See TracChangeset for help on using the changeset viewer.