Index: /trunk/src/org/openstreetmap/josm/data/osm/Changeset.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/Changeset.java	(revision 11114)
+++ /trunk/src/org/openstreetmap/josm/data/osm/Changeset.java	(revision 11115)
@@ -208,9 +208,10 @@
     public void setKeys(Map<String, String> keys) {
         CheckParameterUtil.ensureParameterNotNull(keys, "keys");
-        for (String value : keys.values()) {
-            if (value != null && value.length() > MAX_CHANGESET_TAG_LENGTH) {
+        keys.values().stream()
+                .filter(value -> (value != null && value.length() > MAX_CHANGESET_TAG_LENGTH))
+                .findFirst()
+                .ifPresent(value -> {
                 throw new IllegalArgumentException("Changeset tag value is too long: "+value);
-            }
-        }
+        });
         this.tags = keys;
     }
Index: /trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java	(revision 11114)
+++ /trunk/src/org/openstreetmap/josm/data/osm/ChangesetCache.java	(revision 11115)
@@ -10,4 +10,5 @@
 import java.util.Set;
 import java.util.concurrent.CopyOnWriteArrayList;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.Main;
@@ -183,11 +184,7 @@
      */
     public List<Changeset> getOpenChangesets() {
-        List<Changeset> ret = new ArrayList<>();
-        for (Changeset cs: cache.values()) {
-            if (cs.isOpen()) {
-                ret.add(cs);
-            }
-        }
-        return ret;
+        return cache.values().stream()
+                .filter(Changeset::isOpen)
+                .collect(Collectors.toList());
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java	(revision 11114)
+++ /trunk/src/org/openstreetmap/josm/data/osm/ChangesetDataSet.java	(revision 11115)
@@ -3,9 +3,9 @@
 
 import java.util.HashMap;
-import java.util.HashSet;
 import java.util.Iterator;
 import java.util.Map;
 import java.util.Map.Entry;
 import java.util.Set;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
@@ -117,11 +117,8 @@
     public Set<HistoryOsmPrimitive> getPrimitivesByModificationType(ChangesetModificationType cmt) {
         CheckParameterUtil.ensureParameterNotNull(cmt, "cmt");
-        Set<HistoryOsmPrimitive> ret = new HashSet<>();
-        for (Entry<PrimitiveId, ChangesetModificationType> entry: modificationTypes.entrySet()) {
-            if (entry.getValue().equals(cmt)) {
-                ret.add(primitives.get(entry.getKey()));
-            }
-        }
-        return ret;
+        return modificationTypes.entrySet().stream()
+                .filter(entry -> entry.getValue().equals(cmt))
+                .map(entry -> primitives.get(entry.getKey()))
+                .collect(Collectors.toSet());
     }
 
Index: /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 11114)
+++ /trunk/src/org/openstreetmap/josm/data/osm/DataSet.java	(revision 11115)
@@ -21,4 +21,5 @@
 import java.util.concurrent.locks.ReentrantReadWriteLock;
 import java.util.function.Predicate;
+import java.util.stream.Collectors;
 
 import org.openstreetmap.josm.Main;
@@ -420,11 +421,7 @@
         try {
             // QuadBuckets might be useful here (don't forget to do reindexing after some of rm is changed)
-            List<Relation> result = new ArrayList<>();
-            for (Relation r: relations) {
-                if (r.getBBox().intersects(bbox)) {
-                    result.add(r);
-                }
-            }
-            return result;
+            return relations.stream()
+                    .filter(r -> r.getBBox().intersects(bbox))
+                    .collect(Collectors.toList());
         } finally {
             lock.readLock().unlock();
Index: /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java
===================================================================
--- /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java	(revision 11114)
+++ /trunk/src/org/openstreetmap/josm/gui/conflict/pair/ListMergeModel.java	(revision 11115)
@@ -226,9 +226,9 @@
         synchronized (listeners) {
             PropertyChangeEvent evt = new PropertyChangeEvent(this, FROZEN_PROP, oldValue, newValue);
-            for (PropertyChangeListener listener: listeners) {
+            listeners.forEach((listener) -> {
                 listener.propertyChange(evt);
+            });
             }
         }
-    }
 
     public final void setFrozen(boolean isFrozen) {
@@ -678,9 +678,6 @@
             if (row >= getEntries().size()) return false;
             T e1 = getEntries().get(row);
-            for (T e2: getOppositeEntries()) {
-                if (isEqualEntry(e1, e2)) return true;
+            return getOppositeEntries().stream().anyMatch(e2 -> isEqualEntry(e1, e2));
             }
-            return false;
-        }
 
         protected List<T> getEntries() {
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetCacheTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetCacheTest.java	(revision 11114)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetCacheTest.java	(revision 11115)
@@ -7,6 +7,9 @@
 import static org.junit.Assert.assertTrue;
 
+import java.util.ArrayList;
+import java.util.Collections;
 import java.util.List;
 
+import org.junit.Assert;
 import org.junit.Test;
 import org.openstreetmap.josm.TestUtils;
@@ -180,3 +183,34 @@
         cache.removeChangesetCacheListener(listener);
     }
+
+    /**
+     * Unit test of method {@link ChangesetCache#getOpenChangesets}.
+     */
+    @Test
+    public void testGetOpenChangesets() {
+        final ChangesetCache cache = ChangesetCache.getInstance();
+        // empty cache => empty list
+        Assert.assertTrue(
+                "Empty cache should produce an empty list.",
+                cache.getOpenChangesets().isEmpty()
+        );
+
+        // cache with only closed changesets => empty list
+        Changeset closedCs = new Changeset(1);
+        closedCs.setOpen(false);
+        cache.update(closedCs);
+        Assert.assertTrue(
+                "Cache with only closed changesets should produce an empty list.",
+                cache.getOpenChangesets().isEmpty()
+        );
+
+        // cache with open and closed changesets => list with only the open ones
+        Changeset openCs = new Changeset(2);
+        openCs.setOpen(true);
+        cache.update(openCs);
+        Assert.assertEquals(
+                Collections.singletonList(openCs),
+                cache.getOpenChangesets()
+        );
+    }
 }
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java	(revision 11115)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetDataSetTest.java	(revision 11115)
@@ -0,0 +1,64 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.data.osm;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.Assert;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+import org.openstreetmap.josm.data.osm.ChangesetDataSet.ChangesetModificationType;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.Date;
+import java.util.Set;
+import org.openstreetmap.josm.data.coor.LatLon;
+import org.openstreetmap.josm.data.osm.history.HistoryNode;
+import org.openstreetmap.josm.data.osm.history.HistoryOsmPrimitive;
+
+/**
+ * Unit tests for class {@link ChangesetDataSet}.
+ */
+public class ChangesetDataSetTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules();
+
+    /**
+     * Unit test of method {@link ChangesetDataSet#getPrimitivesByModificationType}.
+     */
+    @Test
+    public void testGetPrimitivesByModificationType() {
+        final ChangesetDataSet cds = new ChangesetDataSet();
+        // empty object, null parameter => IllegalArgumentException
+        try {
+            cds.getPrimitivesByModificationType(null);
+            Assert.fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
+        } catch (IllegalArgumentException e) {
+            // Was expected
+        }
+        
+        // empty object, a modification type => empty list
+        Assert.assertTrue(
+            "Empty data set should produce an empty list.",
+            cds.getPrimitivesByModificationType(
+                    ChangesetModificationType.CREATED).isEmpty()
+        );
+        
+        // object with various items and modification types, fetch for CREATED
+        // => list containing only the CREATED item
+        HistoryOsmPrimitive prim1 = new HistoryNode(1, 1, true, User.getAnonymous(), 1, new Date(), LatLon.ZERO);
+        HistoryOsmPrimitive prim2 = new HistoryNode(2, 1, true, User.createLocalUser("test"), 1, new Date(), LatLon.NORTH_POLE);
+        HistoryOsmPrimitive prim3 = new HistoryNode(3, 1, true, User.getAnonymous(), 1, new Date(), LatLon.SOUTH_POLE);
+        cds.put(prim1, ChangesetModificationType.CREATED);
+        cds.put(prim2, ChangesetModificationType.DELETED);
+        cds.put(prim3, ChangesetModificationType.UPDATED);
+        Set<HistoryOsmPrimitive> result = cds.getPrimitivesByModificationType(
+                    ChangesetModificationType.CREATED);
+        Assert.assertEquals("We should have found only one item.", 1, result.size());
+        Assert.assertTrue("The item found is prim1.", result.contains(prim1));
+        
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java	(revision 11115)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/ChangesetTest.java	(revision 11115)
@@ -0,0 +1,66 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.data.osm;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.HashMap;
+import java.util.Map;
+import org.junit.Assert;
+import static org.openstreetmap.josm.data.osm.Changeset.MAX_CHANGESET_TAG_LENGTH;
+
+/**
+ * Unit tests for class {@link Changeset}.
+ */
+public class ChangesetTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules();
+
+    /**
+     * Unit test of method {@link Changeset#setKeys}.
+     */
+    @Test
+    public void testSetKeys() {
+        final Changeset cs = new Changeset();
+        // Cannot add null map => IllegalArgumentException
+        try {
+            cs.setKeys(null);
+            Assert.fail("Should have thrown an IllegalArgumentException as we gave a null argument.");
+        } catch (IllegalArgumentException e) {
+            // Was expected
+        }
+        
+        // Add a map with no values
+        // => the key list is empty
+        Map<String, String> keys = new HashMap<>();
+        
+        // Add a map with valid values : null and short texts
+        // => all the items are in the keys
+        keys.put("empty", null);
+        keys.put("test", "test");
+        cs.setKeys(keys);
+        Assert.assertEquals("Both valid keys should have been put in the ChangeSet.", 2, cs.getKeys().size());
+        
+        // Add a map with too long values => IllegalArgumentException
+        keys = new HashMap<>();
+        StringBuilder b = new StringBuilder(MAX_CHANGESET_TAG_LENGTH + 1);
+        for (int i = 0; i < MAX_CHANGESET_TAG_LENGTH + 1; i++){
+           b.append("x");
+        }
+        keys.put("test", b.toString());
+        try {
+            cs.setKeys(keys);
+            Assert.fail("Should have thrown an IllegalArgumentException as we gave a too long value.");
+        } catch (IllegalArgumentException e) {
+            // Was expected
+        }
+                
+    }
+}
Index: /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java
===================================================================
--- /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java	(revision 11115)
+++ /trunk/test/unit/org/openstreetmap/josm/data/osm/DataSetTest.java	(revision 11115)
@@ -0,0 +1,57 @@
+// License: GPL. For details, see LICENSE file.
+package org.openstreetmap.josm.data.osm;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.Assert;
+import org.openstreetmap.josm.testutils.JOSMTestRules;
+
+import edu.umd.cs.findbugs.annotations.SuppressFBWarnings;
+import java.util.List;
+import org.openstreetmap.josm.data.coor.LatLon;
+
+/**
+ * Unit tests for class {@link DataSet}.
+ */
+public class DataSetTest {
+
+    /**
+     * Setup test.
+     */
+    @Rule
+    @SuppressFBWarnings(value = "URF_UNREAD_PUBLIC_OR_PROTECTED_FIELD")
+    public JOSMTestRules test = new JOSMTestRules();
+
+    /**
+     * Unit test of method {@link DataSet#searchRelations}.
+     */
+    @Test
+    public void testSearchRelations() {
+        final DataSet ds = new DataSet();
+        // null bbox => empty list
+        Assert.assertTrue(
+            "Empty data set should produce an empty list.",
+            ds.searchRelations(null).isEmpty()
+        );
+        
+        // empty data set, any bbox => empty list
+        BBox bbox = new BBox(LatLon.NORTH_POLE, LatLon.SOUTH_POLE);
+        Assert.assertTrue(
+            "Empty data set should produce an empty list.",
+            ds.searchRelations(bbox).isEmpty()
+        );
+        
+        // data set with elements in the given bbox => these elements
+        Node node = new Node(LatLon.ZERO);
+        Relation r = new Relation(1);
+        RelationMember rm = new RelationMember("role", node);
+        r.addMember(rm);
+        ds.addPrimitive(node);
+        ds.addPrimitive(r);
+        bbox = new BBox(new LatLon(-1.0, -1.0), new LatLon(1.0, 1.0));
+        List<Relation> result = ds.searchRelations(bbox);
+        Assert.assertEquals("We should have found only one item.", 1, result.size());
+        Assert.assertTrue("The item found is relation r.", result.contains(r));
+        
+    }
+}
