Legend:
- Unmodified
- Added
- Removed
-
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanel.java
r9575 r9841 240 240 241 241 public void setUploadStrategySpecification(UploadStrategySpecification strategy) { 242 if (strategy == null) return; 242 if (strategy == null) 243 return; 243 244 rbStrategy.get(strategy.getStrategy()).setSelected(true); 244 245 tfChunkSize.setEnabled(strategy.getStrategy() == UploadStrategy.CHUNKED_DATASET_STRATEGY); … … 256 257 int chunkSize = getChunkSize(); 257 258 UploadStrategySpecification spec = new UploadStrategySpecification(); 258 switch(strategy) { 259 case INDIVIDUAL_OBJECTS_STRATEGY: 260 case SINGLE_REQUEST_STRATEGY: 261 spec.setStrategy(strategy); 262 break; 263 case CHUNKED_DATASET_STRATEGY: 264 spec.setStrategy(strategy).setChunkSize(chunkSize); 265 break; 259 if (strategy != null) { 260 switch(strategy) { 261 case INDIVIDUAL_OBJECTS_STRATEGY: 262 case SINGLE_REQUEST_STRATEGY: 263 spec.setStrategy(strategy); 264 break; 265 case CHUNKED_DATASET_STRATEGY: 266 spec.setStrategy(strategy).setChunkSize(chunkSize); 267 break; 268 } 266 269 } 267 270 if (pnlMultiChangesetPolicyPanel.isVisible()) { -
trunk/src/org/openstreetmap/josm/gui/io/UploadStrategySpecification.java
r9371 r9841 35 35 36 36 /** 37 * Clones another upload strategy. If other is null,assumes default 38 * values. 37 * Clones another upload strategy. If other is null, assumes default values. 39 38 * 40 39 * @param other the other upload strategy 41 40 */ 42 41 public UploadStrategySpecification(UploadStrategySpecification other) { 43 if (other == null) return; 44 this.strategy = other.strategy; 45 this.chunkSize = other.chunkSize; 46 this.policy = other.policy; 47 this.closeChangesetAfterUpload = other.closeChangesetAfterUpload; 42 if (other != null) { 43 this.strategy = other.strategy; 44 this.chunkSize = other.chunkSize; 45 this.policy = other.policy; 46 this.closeChangesetAfterUpload = other.closeChangesetAfterUpload; 47 } 48 48 } 49 49 … … 93 93 94 94 public int getNumRequests(int numObjects) { 95 if (numObjects <= 0) return 0; 95 if (numObjects <= 0) 96 return 0; 96 97 switch(strategy) { 97 98 case INDIVIDUAL_OBJECTS_STRATEGY: return numObjects; … … 114 115 @Override 115 116 public boolean equals(Object obj) { 116 if (this == obj) return true; 117 if (obj == null || getClass() != obj.getClass()) return false; 117 if (this == obj) 118 return true; 119 if (obj == null || getClass() != obj.getClass()) 120 return false; 118 121 UploadStrategySpecification that = (UploadStrategySpecification) obj; 119 122 return chunkSize == that.chunkSize && -
trunk/test/unit/org/openstreetmap/josm/gui/io/UploadStrategySelectionPanelTest.java
r9669 r9841 2 2 package org.openstreetmap.josm.gui.io; 3 3 4 import static org.junit.Assert.assert NotNull;4 import static org.junit.Assert.assertEquals; 5 5 6 6 import org.junit.BeforeClass; 7 7 import org.junit.Test; 8 8 import org.openstreetmap.josm.JOSMFixture; 9 import org.openstreetmap.josm.Main; 10 import org.openstreetmap.josm.io.OsmApi; 11 import org.openstreetmap.josm.io.OsmApiInitializationException; 12 import org.openstreetmap.josm.io.OsmTransferCanceledException; 9 13 10 14 /** … … 19 23 public static void setUpBeforeClass() { 20 24 JOSMFixture.createUnitTestFixture().init(); 25 try { 26 OsmApi.getOsmApi().initialize(null); 27 } catch (OsmTransferCanceledException | OsmApiInitializationException e) { 28 Main.error(e); 29 } 21 30 } 22 31 … … 26 35 @Test 27 36 public void testUploadStrategySelectionPanel() { 28 assertNotNull(new UploadStrategySelectionPanel()); 37 UploadStrategySelectionPanel p = new UploadStrategySelectionPanel(); 38 p.setNumUploadedObjects(Integer.MAX_VALUE); 39 p.rememberUserInput(); 40 p.initFromPreferences(); 41 p.initEditingOfChunkSize(); 42 } 43 44 /** 45 * Test of {@link UploadStrategySelectionPanel#setUploadStrategySpecification} 46 * / {@link UploadStrategySelectionPanel#getUploadStrategySpecification}. 47 */ 48 @Test 49 public void testUploadStrategySpecification() { 50 UploadStrategySelectionPanel p = new UploadStrategySelectionPanel(); 51 52 UploadStrategySpecification def = new UploadStrategySpecification(); 53 assertEquals(def, p.getUploadStrategySpecification()); 54 p.setUploadStrategySpecification(null); 55 assertEquals(def, p.getUploadStrategySpecification()); 56 57 UploadStrategySpecification strat = new UploadStrategySpecification().setStrategy(UploadStrategy.INDIVIDUAL_OBJECTS_STRATEGY); 58 p.setUploadStrategySpecification(strat); 59 assertEquals(strat, p.getUploadStrategySpecification()); 29 60 } 30 61 }
Note:
See TracChangeset
for help on using the changeset viewer.