Changeset 32065 in osm for applications/editors/josm/plugins/mapillary
- Timestamp:
- 2016-02-11T23:17:26+01:00 (9 years ago)
- Location:
- applications/editors/josm/plugins/mapillary
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/mapillary/src/org/openstreetmap/josm/plugins/mapillary/utils/ValidationUtil.java
r32064 r32065 43 43 public static void throwExceptionForInvalidImgKey(String imgKey, boolean nullAllowed) { 44 44 if (!validateSequenceKey(imgKey)) { 45 throw new IllegalArgumentException(I18n.tr("The image key ''{ {0}}'' is invalid!", imgKey));45 throw new IllegalArgumentException(I18n.tr("The image key ''{0}'' is invalid!", imgKey)); 46 46 } 47 47 if (!nullAllowed && imgKey == null) { … … 59 59 public static void throwExceptionForInvalidSeqKey(String seqKey, boolean nullAllowed) { 60 60 if (!validateSequenceKey(seqKey)) { 61 throw new IllegalArgumentException(I18n.tr("The sequence key ''{ {0}}'' is invalid!", seqKey));61 throw new IllegalArgumentException(I18n.tr("The sequence key ''{0}'' is invalid!", seqKey)); 62 62 } 63 63 if (!nullAllowed && seqKey == null) { -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillaryDataTest.java
r32033 r32065 19 19 public class MapillaryDataTest extends AbstractTest { 20 20 21 MapillaryData data;22 MapillaryImage img1;23 MapillaryImage img2;24 MapillaryImage img3;25 MapillaryImage img4;26 MapillarySequence seq;21 private MapillaryData data; 22 private MapillaryImage img1; 23 private MapillaryImage img2; 24 private MapillaryImage img3; 25 private MapillaryImage img4; 26 private MapillarySequence seq; 27 27 28 28 /** … … 32 32 @Before 33 33 public void setUp() { 34 this.img1 = new MapillaryImage("key1 ", new LatLon(0.1, 0.1), 90);35 this.img2 = new MapillaryImage("key2 ", new LatLon(0.2, 0.2), 90);36 this.img3 = new MapillaryImage("key3 ", new LatLon(0.3, 0.3), 90);37 this.img4 = new MapillaryImage("key4 ", new LatLon(0.4, 0.4), 90);34 this.img1 = new MapillaryImage("key1__________________", new LatLon(0.1, 0.1), 90); 35 this.img2 = new MapillaryImage("key2__________________", new LatLon(0.2, 0.2), 90); 36 this.img3 = new MapillaryImage("key3__________________", new LatLon(0.3, 0.3), 90); 37 this.img4 = new MapillaryImage("key4__________________", new LatLon(0.4, 0.4), 90); 38 38 this.seq = new MapillarySequence(); 39 39 40 this.seq.add(Arrays.asList(new MapillaryAbstractImage[] { this.img1, 41 this.img2, this.img3, this.img4 })); 40 this.seq.add(Arrays.asList(new MapillaryAbstractImage[] { img1, img2, img3, img4 })); 42 41 this.img1.setSequence(this.seq); 43 42 this.img2.setSequence(this.seq); … … 61 60 this.data.add(this.img1); 62 61 assertEquals(1, this.data.getImages().size()); 63 this.data.add(new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[] { this.img2, 64 this.img3 }))); 62 this.data.add(new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[] { this.img2, this.img3 }))); 65 63 assertEquals(3, this.data.getImages().size()); 66 this.data.add(new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[] { this.img3, 67 this.img4 }))); 64 this.data.add(new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[] { this.img3, this.img4 }))); 68 65 assertEquals(4, this.data.getImages().size()); 69 66 } … … 75 72 public void sizeTest() { 76 73 assertEquals(4, this.data.size()); 77 this.data.add(new MapillaryImage("key5 ", new LatLon(0.1, 0.1), 90));74 this.data.add(new MapillaryImage("key5__________________", new LatLon(0.1, 0.1), 90)); 78 75 assertEquals(5, this.data.size()); 79 76 } … … 112 109 */ 113 110 @Test 114 public void NextAndPreviousTest() {111 public void nextAndPreviousTest() { 115 112 this.data.setSelectedImage(this.img1); 116 113 … … 129 126 fail(); 130 127 } catch (IllegalStateException e) { 131 } catch (Exception e) {132 fail();133 128 } 134 129 // Test IllegalStateException thrown by selectPrevious() when the … … 138 133 fail(); 139 134 } catch (IllegalStateException e) { 140 } catch (Exception e) {141 fail();142 135 } 143 136 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/MapillarySequenceTest.java
r32033 r32065 18 18 public class MapillarySequenceTest { 19 19 20 MapillaryImage img1;21 MapillaryImage img2;22 MapillaryImage img3;23 MapillaryImage img4;24 MapillarySequence seq;20 private MapillaryImage img1; 21 private MapillaryImage img2; 22 private MapillaryImage img3; 23 private MapillaryImage img4; 24 private MapillarySequence seq; 25 25 26 26 /** … … 30 30 @Before 31 31 public void setUp() { 32 this.img1 = new MapillaryImage("key1", new LatLon(0.1, 0.1), 90);33 this.img2 = new MapillaryImage("key2", new LatLon(0.2, 0.2), 90);34 this.img3 = new MapillaryImage("key3", new LatLon(0.3, 0.3), 90);35 this.img4 = new MapillaryImage("key4", new LatLon(0.4, 0.4), 90);36 this.seq = new MapillarySequence();32 img1 = new MapillaryImage("key1__________________", new LatLon(0.1, 0.1), 90); 33 img2 = new MapillaryImage("key2__________________", new LatLon(0.2, 0.2), 90); 34 img3 = new MapillaryImage("key3__________________", new LatLon(0.3, 0.3), 90); 35 img4 = new MapillaryImage("key4__________________", new LatLon(0.4, 0.4), 90); 36 seq = new MapillarySequence(); 37 37 38 this.seq.add(Arrays.asList(new MapillaryAbstractImage[] { this.img1, 39 this.img2, this.img3, this.img4 })); 40 this.img1.setSequence(this.seq); 41 this.img2.setSequence(this.seq); 42 this.img3.setSequence(this.seq); 43 this.img4.setSequence(this.seq); 38 seq.add(Arrays.asList(new MapillaryAbstractImage[] { img1, img2, img3, img4 })); 39 img1.setSequence(seq); 40 img2.setSequence(seq); 41 img3.setSequence(seq); 42 img4.setSequence(seq); 44 43 } 45 44 … … 64 63 // that is not in the sequence. 65 64 try { 66 this.seq.next(new MapillaryImage("key5 ", new LatLon(0.5, 0.5), 90));65 this.seq.next(new MapillaryImage("key5__________________", new LatLon(0.5, 0.5), 90)); 67 66 fail(); 68 67 } catch (IllegalArgumentException e) { 69 } catch (Exception e) {70 fail();71 68 } 72 69 // Test IllegalArgumentException when asking for the previous image of an … … 76 73 fail(); 77 74 } catch (IllegalArgumentException e) { 78 } catch (Exception e) {79 fail();80 75 } 81 76 } -
applications/editors/josm/plugins/mapillary/test/unit/org/openstreetmap/josm/plugins/mapillary/history/MapillaryRecordTest.java
r32033 r32065 32 32 public class MapillaryRecordTest extends AbstractTest { 33 33 34 MapillaryRecord record;35 MapillaryImage img1;36 MapillaryImage img2;37 MapillaryImage img3;34 private MapillaryRecord record; 35 private MapillaryImage img1; 36 private MapillaryImage img2; 37 private MapillaryImage img3; 38 38 39 39 /** … … 43 43 @Before 44 44 public void setUp() { 45 this.record = new MapillaryRecord();46 this.img1 = new MapillaryImage("key1", new LatLon(0.1, 0.1), 0.1);47 this.img2 = new MapillaryImage("key2", new LatLon(0.2, 0.2), 0.2);48 this.img3 = new MapillaryImage("key3", new LatLon(0.3, 0.3), 0.3);45 record = new MapillaryRecord(); 46 img1 = new MapillaryImage("key1__________________", new LatLon(0.1, 0.1), 0.1); 47 img2 = new MapillaryImage("key2__________________", new LatLon(0.2, 0.2), 0.2); 48 img3 = new MapillaryImage("key3__________________", new LatLon(0.3, 0.3), 0.3); 49 49 MapillaryLayer.getInstance().getData().getImages().clear(); 50 50 } … … 112 112 public void commandMoveTest() { 113 113 CommandMove cmd1 = new CommandMove( 114 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{ this.img1, this.img2})),114 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{img1, img2})), 115 115 0.1, 0.1); 116 116 CommandMove cmd2 = new CommandMove( 117 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{ this.img1, this.img2})),117 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{img1, img2})), 118 118 0.1, 0.1); 119 119 … … 176 176 @Test 177 177 public void commandJoinClass() { 178 CommandJoin cmd1 = new CommandJoin( 179 Arrays.asList(new MapillaryAbstractImage[]{this.img1, this.img2})); 180 CommandJoin cmd2 = new CommandJoin( 181 Arrays.asList(new MapillaryAbstractImage[]{this.img2, this.img3})); 182 183 this.record.addCommand(cmd1); 184 assertEquals(2, this.img1.getSequence().getImages().size()); 185 assertEquals(this.img2, this.img1.next()); 186 this.record.undo(); 187 assertEquals(1, this.img1.getSequence().getImages().size()); 188 this.record.redo(); 189 this.record.addCommand(cmd2); 190 assertEquals(3, this.img1.getSequence().getImages().size()); 191 assertEquals(this.img3, this.img1.next().next()); 178 CommandJoin cmd1 = new CommandJoin(Arrays.asList(new MapillaryAbstractImage[]{img1, img2})); 179 CommandJoin cmd2 = new CommandJoin(Arrays.asList(new MapillaryAbstractImage[]{img2, img3})); 180 181 this.record.addCommand(cmd1); 182 assertEquals(2, img1.getSequence().getImages().size()); 183 assertEquals(img2, img1.next()); 184 this.record.undo(); 185 assertEquals(1, img1.getSequence().getImages().size()); 186 this.record.redo(); 187 this.record.addCommand(cmd2); 188 assertEquals(3, img1.getSequence().getImages().size()); 189 assertEquals(img3, img1.next().next()); 192 190 193 191 try { 194 this.record.addCommand(new CommandJoin(Arrays 195 .asList(new MapillaryAbstractImage[]{this.img1, this.img2, 196 this.img3}))); 192 this.record.addCommand(new CommandJoin(Arrays.asList(new MapillaryAbstractImage[]{img1, img2, img3}))); 197 193 fail(); 198 194 } catch (IllegalArgumentException e) { 199 195 // Expected output. 200 } catch (Exception e) {201 fail();202 196 } 203 197 } … … 231 225 232 226 try { 233 this.record.addCommand(new CommandUnjoin(Arrays 234 .asList(new MapillaryAbstractImage[]{this.img1, this.img2, 235 this.img3}))); 227 this.record.addCommand(new CommandUnjoin(Arrays.asList(new MapillaryAbstractImage[]{img1, img2, img3}))); 236 228 fail(); 237 229 } catch (IllegalArgumentException e) { 238 230 // Expected output. 239 } catch (Exception e) {240 fail();241 231 } 242 232 } … … 247 237 @Test 248 238 public void commandDeleteTest() { 249 CommandJoin join1 = new CommandJoin( 250 Arrays.asList(new MapillaryAbstractImage[]{this.img1, this.img2})); 251 CommandJoin join2 = new CommandJoin( 252 Arrays.asList(new MapillaryAbstractImage[]{this.img2, this.img3})); 239 CommandJoin join1 = new CommandJoin(Arrays.asList(new MapillaryAbstractImage[]{img1, img2})); 240 CommandJoin join2 = new CommandJoin(Arrays.asList(new MapillaryAbstractImage[]{img2, img3})); 253 241 254 242 CommandDelete cmd1 = new CommandDelete( 255 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{ this.img1})));243 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{img1}))); 256 244 CommandDelete cmd2 = new CommandDelete( 257 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{ this.img2, this.img3})));245 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{img2, img3}))); 258 246 259 247 this.record.addCommand(join1); … … 261 249 262 250 MapillaryLayer 263 .getInstance() 264 .getData() 265 .add( 266 new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{this.img1, this.img2, 267 this.img3}))); 251 .getInstance() 252 .getData() 253 .add(new ConcurrentSkipListSet<>(Arrays.asList(new MapillaryAbstractImage[]{img1, img2, img3}))); 268 254 269 255 this.record.addCommand(cmd1);
Note:
See TracChangeset
for help on using the changeset viewer.