Skip to content

Commit 8aaf5ba

Browse files
committed
fix unit test
1 parent ad3b226 commit 8aaf5ba

8 files changed

Lines changed: 25 additions & 27 deletions

File tree

engine/storage/imagemotion/src/org/apache/cloudstack/storage/image/motion/ImageMotionServiceImpl.java

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@
2222

2323
import javax.inject.Inject;
2424

25-
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
26-
import org.apache.cloudstack.framework.async.AsyncCallbackHandler;
2725
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
2826
import org.apache.cloudstack.storage.EndPoint;
2927
import org.apache.cloudstack.storage.command.CommandResult;
@@ -91,16 +89,8 @@ public void copyTemplateAsync(TemplateOnPrimaryDataStoreInfo templateStore, Asyn
9189
TemplateInfo template = templateStore.getTemplate();
9290
imageService.grantTemplateAccess(template, ep);
9391

94-
AsyncCallbackDispatcher caller = new AsyncCallbackDispatcher(this)
95-
.setParentCallback(callback)
96-
.setOperationName("imagemotionService.copytemplate.callback");
97-
98-
ims.copyTemplateAsync(templateStore, ep, caller);
99-
}
100-
101-
@AsyncCallbackHandler(operationName="imagemotionService.copytemplate.callback")
102-
public void copyTemplateAsyncCallback( AsyncCallbackDispatcher callback) {
103-
AsyncCallbackDispatcher parentCaller = callback.getParentCallback();
104-
parentCaller.complete(callback.getResult());
92+
ims.copyTemplateAsync(templateStore, ep, callback);
10593
}
94+
95+
10696
}

engine/storage/src/org/apache/cloudstack/storage/image/TemplateInfo.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,4 @@ public interface TemplateInfo {
3131
String getPath();
3232

3333
String getUuid();
34-
35-
long getVirtualSize();
3634
}

engine/storage/src/org/apache/cloudstack/storage/to/TemplateTO.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ public class TemplateTO {
88
private final String uuid;
99
private final VolumeDiskType diskType;
1010
private final ImageDataStoreTO imageDataStore;
11-
private final long size;
11+
private final long size = 0;
1212
public TemplateTO(TemplateInfo template) {
1313
this.path = template.getPath();
1414
this.uuid = template.getUuid();
1515
this.diskType = template.getDiskType();
1616
this.imageDataStore = new ImageDataStoreTO(template.getImageDataStore());
17-
this.size = template.getVirtualSize();
17+
// this.size = template.getVirtualSize();
1818
}
1919

2020
public String getPath() {

engine/storage/src/org/apache/cloudstack/storage/to/VolumeTO.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,11 @@ public VolumeTO(VolumeInfo volume) {
1515
this.path = volume.getPath();
1616
this.volumeType = volume.getType();
1717
this.diskType = volume.getDiskType();
18-
this.dataStore = new PrimaryDataStoreTO(volume.getDataStore());
18+
if (volume.getDataStore() != null) {
19+
this.dataStore = new PrimaryDataStoreTO(volume.getDataStore());
20+
} else {
21+
this.dataStore = null;
22+
}
1923
}
2024

2125
public String getUuid() {

engine/storage/src/org/apache/cloudstack/storage/volume/VolumeEntityImpl.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,11 @@
4141
public class VolumeEntityImpl implements VolumeEntity {
4242
private VolumeInfo volumeInfo;
4343
private final VolumeService vs;
44+
45+
protected VolumeEntityImpl() {
46+
this.vs = null;
47+
}
48+
4449
public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
4550
this.volumeInfo = volumeObject;
4651
this.vs = vs;

framework/ipc/src/org/apache/cloudstack/framework/async/AsyncCallbackDispatcher.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ public static boolean dispatch(Object target, AsyncCallbackDispatcher callback)
106106
} catch (IllegalAccessException e) {
107107
throw new RuntimeException("IllegalAccessException when invoking RPC callback for command: " + callback.getCallbackMethod().getName());
108108
} catch (InvocationTargetException e) {
109-
throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName());
109+
throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName(), e);
110110
}
111111

112112
return true;

plugins/storage/volume/solidfire/src/org/apache/cloudstack/storage/datastore/driver/SolidfirePrimaryDataStoreDriver.java

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,9 @@
22

33
import java.util.Map;
44

5+
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
56
import org.apache.cloudstack.storage.EndPoint;
7+
import org.apache.cloudstack.storage.command.CommandResult;
68
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
79
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
810
import org.apache.cloudstack.storage.volume.VolumeObject;
@@ -15,13 +17,6 @@ public boolean createVolume(VolumeObject vol) {
1517
return false;
1618
}
1719

18-
@Override
19-
public boolean createVolumeFromBaseImage(VolumeObject volume,
20-
TemplateOnPrimaryDataStoreInfo template) {
21-
// TODO Auto-generated method stub
22-
return false;
23-
}
24-
2520
@Override
2621
public boolean deleteVolume(VolumeObject vo) {
2722
// TODO Auto-generated method stub
@@ -76,4 +71,10 @@ public void setDataStore(PrimaryDataStore dataStore) {
7671

7772
}
7873

74+
@Override
75+
public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template, AsyncCompletionCallback<CommandResult> callback) {
76+
// TODO Auto-generated method stub
77+
78+
}
79+
7980
}

plugins/storage/volume/solidfire/test/org/apache/cloudstack/storage/test/VolumeTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public void setUp() {
100100
results.add(host);
101101
Mockito.when(hostDao.listAll()).thenReturn(results);
102102
Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
103-
CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(UUID.randomUUID().toString());
103+
CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(null,UUID.randomUUID().toString());
104104

105105
try {
106106
Mockito.when(agentMgr.send(Mockito.anyLong(), Mockito.any(CreateVolumeFromBaseImageCommand.class))).thenReturn(createVolumeFromImageAnswer);

0 commit comments

Comments
 (0)