Index: applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java
===================================================================
--- applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java	(revision 31492)
+++ applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java	(revision 31500)
@@ -2,4 +2,5 @@
 
 import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.fail;
 
 import java.util.Arrays;
@@ -9,8 +10,14 @@
 import org.openstreetmap.josm.plugins.mapillary.AbstractTest;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryAbstractImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryData;
 import org.openstreetmap.josm.plugins.mapillary.MapillaryImage;
+import org.openstreetmap.josm.plugins.mapillary.MapillaryLayer;
 import org.openstreetmap.josm.plugins.mapillary.history.MapillaryRecord;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandDelete;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandImport;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandJoin;
 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandMove;
 import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandTurn;
+import org.openstreetmap.josm.plugins.mapillary.history.commands.CommandUnjoin;
 import org.openstreetmap.josm.plugins.mapillary.history.commands.MapillaryCommand;
 
@@ -38,4 +45,5 @@
     this.img2 = new MapillaryImage("key2", 0.2, 0.2, 0.2);
     this.img3 = new MapillaryImage("key3", 0.3, 0.3, 0.3);
+    MapillaryLayer.getInstance().getData().getImages().clear();
   }
 
@@ -55,6 +63,5 @@
         0.1, 0.1);
     MapillaryCommand cmd1 = new CommandMove(
-        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }),
-        0.1, 0.1);
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }), 0.1, 0.1);
     MapillaryCommand cmd31 = new CommandMove(
         Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img1 }),
@@ -98,5 +105,5 @@
 
   /**
-   * Tests CommandMoveImage class.
+   * Tests {@link CommandMove} class.
    */
   @Test
@@ -132,5 +139,5 @@
 
   /**
-   * Tests CommandTurnImage class.
+   * Tests {@link CommandTurn} class.
    */
   @Test
@@ -161,3 +168,133 @@
     assertEquals(0.1, this.img1.getCa(), 0.01);
   }
+
+  /**
+   * Tests {@link CommandJoin} class.
+   */
+  @Test
+  public void commandJoinClass() {
+    CommandJoin cmd1 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }));
+    CommandJoin cmd2 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    this.record.addCommand(cmd1);
+    assertEquals(2, this.img1.getSequence().getImages().size());
+    assertEquals(this.img2, this.img1.next());
+    this.record.undo();
+    assertEquals(1, this.img1.getSequence().getImages().size());
+    this.record.redo();
+    this.record.addCommand(cmd2);
+    assertEquals(3, this.img1.getSequence().getImages().size());
+    assertEquals(this.img3, this.img1.next().next());
+
+    try {
+      this.record.addCommand(new CommandJoin(Arrays
+          .asList(new MapillaryAbstractImage[] { this.img1, this.img2,
+              this.img3 })));
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected output.
+    } catch (Exception e) {
+      fail();
+    }
+  }
+
+  /**
+   * Tests {@link CommandUnjoin} class.
+   */
+  @Test
+  public void commandUnjoinClass() {
+    CommandJoin join1 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }));
+    CommandJoin join2 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    CommandUnjoin cmd1 = new CommandUnjoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }));
+    CommandUnjoin cmd2 = new CommandUnjoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    this.record.addCommand(join1);
+    this.record.addCommand(join2);
+
+    this.record.addCommand(cmd1);
+    assertEquals(1, this.img1.getSequence().getImages().size());
+    this.record.undo();
+    assertEquals(3, this.img1.getSequence().getImages().size());
+    this.record.redo();
+    this.record.addCommand(cmd2);
+    assertEquals(1, this.img1.getSequence().getImages().size());
+    assertEquals(1, this.img2.getSequence().getImages().size());
+
+    try {
+      this.record.addCommand(new CommandUnjoin(Arrays
+          .asList(new MapillaryAbstractImage[] { this.img1, this.img2,
+              this.img3 })));
+      fail();
+    } catch (IllegalArgumentException e) {
+      // Expected output.
+    } catch (Exception e) {
+      fail();
+    }
+  }
+
+  /**
+   * Test {@link CommandDelete} class.
+   */
+  @Test
+  public void commandDeleteTest() {
+    CommandJoin join1 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2 }));
+    CommandJoin join2 = new CommandJoin(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    CommandDelete cmd1 = new CommandDelete(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }));
+    CommandDelete cmd2 = new CommandDelete(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    this.record.addCommand(join1);
+    this.record.addCommand(join2);
+
+    MapillaryLayer
+        .getInstance()
+        .getData()
+        .add(
+            Arrays.asList(new MapillaryAbstractImage[] { this.img1, this.img2,
+                this.img3 }));
+
+    this.record.addCommand(cmd1);
+    assertEquals(false, MapillaryLayer.getInstance().getData().getImages()
+        .contains(this.img1));
+    assertEquals(null, this.img2.previous());
+    this.record.undo();
+    assertEquals(true, MapillaryLayer.getInstance().getData().getImages()
+        .contains(this.img1));
+    this.record.redo();
+    this.record.addCommand(cmd2);
+    assertEquals(0, MapillaryLayer.getInstance().getData().size());
+  }
+
+  /**
+   * Test {@link CommandImport} class.
+   */
+  @Test
+  public void commandImportTest() {
+    MapillaryData data = MapillaryLayer.getInstance().getData();
+    data.remove(data.getImages());
+
+    CommandImport cmd1 = new CommandImport(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img1 }));
+    CommandImport cmd2 = new CommandImport(
+        Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }));
+
+    this.record.addCommand(cmd1);
+    assertEquals(1, data.size());
+    this.record.undo();
+    assertEquals(0, data.size());
+    this.record.redo();
+    this.record.addCommand(cmd2);
+    assertEquals(3, data.size());
+  }
 }
