mirror of
https://github.com/apache/cloudstack.git
synced 2025-10-26 08:42:29 +01:00
fix unit test
This commit is contained in:
parent
ad3b226ab2
commit
8aaf5ba3a0
@ -22,8 +22,6 @@ import java.util.List;
|
|||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import org.apache.cloudstack.framework.async.AsyncCallbackDispatcher;
|
|
||||||
import org.apache.cloudstack.framework.async.AsyncCallbackHandler;
|
|
||||||
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.storage.EndPoint;
|
||||||
import org.apache.cloudstack.storage.command.CommandResult;
|
import org.apache.cloudstack.storage.command.CommandResult;
|
||||||
@ -91,16 +89,8 @@ public class ImageMotionServiceImpl implements ImageMotionService {
|
|||||||
TemplateInfo template = templateStore.getTemplate();
|
TemplateInfo template = templateStore.getTemplate();
|
||||||
imageService.grantTemplateAccess(template, ep);
|
imageService.grantTemplateAccess(template, ep);
|
||||||
|
|
||||||
AsyncCallbackDispatcher caller = new AsyncCallbackDispatcher(this)
|
ims.copyTemplateAsync(templateStore, ep, callback);
|
||||||
.setParentCallback(callback)
|
|
||||||
.setOperationName("imagemotionService.copytemplate.callback");
|
|
||||||
|
|
||||||
ims.copyTemplateAsync(templateStore, ep, caller);
|
|
||||||
}
|
|
||||||
|
|
||||||
@AsyncCallbackHandler(operationName="imagemotionService.copytemplate.callback")
|
|
||||||
public void copyTemplateAsyncCallback( AsyncCallbackDispatcher callback) {
|
|
||||||
AsyncCallbackDispatcher parentCaller = callback.getParentCallback();
|
|
||||||
parentCaller.complete(callback.getResult());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -31,6 +31,4 @@ public interface TemplateInfo {
|
|||||||
String getPath();
|
String getPath();
|
||||||
|
|
||||||
String getUuid();
|
String getUuid();
|
||||||
|
|
||||||
long getVirtualSize();
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -8,13 +8,13 @@ public class TemplateTO {
|
|||||||
private final String uuid;
|
private final String uuid;
|
||||||
private final VolumeDiskType diskType;
|
private final VolumeDiskType diskType;
|
||||||
private final ImageDataStoreTO imageDataStore;
|
private final ImageDataStoreTO imageDataStore;
|
||||||
private final long size;
|
private final long size = 0;
|
||||||
public TemplateTO(TemplateInfo template) {
|
public TemplateTO(TemplateInfo template) {
|
||||||
this.path = template.getPath();
|
this.path = template.getPath();
|
||||||
this.uuid = template.getUuid();
|
this.uuid = template.getUuid();
|
||||||
this.diskType = template.getDiskType();
|
this.diskType = template.getDiskType();
|
||||||
this.imageDataStore = new ImageDataStoreTO(template.getImageDataStore());
|
this.imageDataStore = new ImageDataStoreTO(template.getImageDataStore());
|
||||||
this.size = template.getVirtualSize();
|
// this.size = template.getVirtualSize();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getPath() {
|
public String getPath() {
|
||||||
|
|||||||
@ -15,7 +15,11 @@ public class VolumeTO {
|
|||||||
this.path = volume.getPath();
|
this.path = volume.getPath();
|
||||||
this.volumeType = volume.getType();
|
this.volumeType = volume.getType();
|
||||||
this.diskType = volume.getDiskType();
|
this.diskType = volume.getDiskType();
|
||||||
this.dataStore = new PrimaryDataStoreTO(volume.getDataStore());
|
if (volume.getDataStore() != null) {
|
||||||
|
this.dataStore = new PrimaryDataStoreTO(volume.getDataStore());
|
||||||
|
} else {
|
||||||
|
this.dataStore = null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getUuid() {
|
public String getUuid() {
|
||||||
|
|||||||
@ -41,6 +41,11 @@ import com.cloud.utils.exception.CloudRuntimeException;
|
|||||||
public class VolumeEntityImpl implements VolumeEntity {
|
public class VolumeEntityImpl implements VolumeEntity {
|
||||||
private VolumeInfo volumeInfo;
|
private VolumeInfo volumeInfo;
|
||||||
private final VolumeService vs;
|
private final VolumeService vs;
|
||||||
|
|
||||||
|
protected VolumeEntityImpl() {
|
||||||
|
this.vs = null;
|
||||||
|
}
|
||||||
|
|
||||||
public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
|
public VolumeEntityImpl(VolumeInfo volumeObject, VolumeService vs) {
|
||||||
this.volumeInfo = volumeObject;
|
this.volumeInfo = volumeObject;
|
||||||
this.vs = vs;
|
this.vs = vs;
|
||||||
|
|||||||
@ -106,7 +106,7 @@ public class AsyncCallbackDispatcher<T> implements AsyncCompletionCallback {
|
|||||||
} catch (IllegalAccessException e) {
|
} catch (IllegalAccessException e) {
|
||||||
throw new RuntimeException("IllegalAccessException when invoking RPC callback for command: " + callback.getCallbackMethod().getName());
|
throw new RuntimeException("IllegalAccessException when invoking RPC callback for command: " + callback.getCallbackMethod().getName());
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName());
|
throw new RuntimeException("InvocationTargetException when invoking RPC callback for command: " + callback.getCallbackMethod().getName(), e);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@ -2,7 +2,9 @@ package org.apache.cloudstack.storage.datastore.driver;
|
|||||||
|
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.apache.cloudstack.framework.async.AsyncCompletionCallback;
|
||||||
import org.apache.cloudstack.storage.EndPoint;
|
import org.apache.cloudstack.storage.EndPoint;
|
||||||
|
import org.apache.cloudstack.storage.command.CommandResult;
|
||||||
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
import org.apache.cloudstack.storage.datastore.PrimaryDataStore;
|
||||||
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
import org.apache.cloudstack.storage.volume.TemplateOnPrimaryDataStoreInfo;
|
||||||
import org.apache.cloudstack.storage.volume.VolumeObject;
|
import org.apache.cloudstack.storage.volume.VolumeObject;
|
||||||
@ -15,13 +17,6 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean createVolumeFromBaseImage(VolumeObject volume,
|
|
||||||
TemplateOnPrimaryDataStoreInfo template) {
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean deleteVolume(VolumeObject vo) {
|
public boolean deleteVolume(VolumeObject vo) {
|
||||||
// TODO Auto-generated method stub
|
// TODO Auto-generated method stub
|
||||||
@ -76,4 +71,10 @@ public class SolidfirePrimaryDataStoreDriver implements PrimaryDataStoreDriver {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void createVolumeFromBaseImageAsync(VolumeObject volume, TemplateOnPrimaryDataStoreInfo template, AsyncCompletionCallback<CommandResult> callback) {
|
||||||
|
// TODO Auto-generated method stub
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -100,7 +100,7 @@ public class VolumeTest {
|
|||||||
results.add(host);
|
results.add(host);
|
||||||
Mockito.when(hostDao.listAll()).thenReturn(results);
|
Mockito.when(hostDao.listAll()).thenReturn(results);
|
||||||
Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
|
Mockito.when(hostDao.findHypervisorHostInCluster(Mockito.anyLong())).thenReturn(results);
|
||||||
CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(UUID.randomUUID().toString());
|
CreateVolumeAnswer createVolumeFromImageAnswer = new CreateVolumeAnswer(null,UUID.randomUUID().toString());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Mockito.when(agentMgr.send(Mockito.anyLong(), Mockito.any(CreateVolumeFromBaseImageCommand.class))).thenReturn(createVolumeFromImageAnswer);
|
Mockito.when(agentMgr.send(Mockito.anyLong(), Mockito.any(CreateVolumeFromBaseImageCommand.class))).thenReturn(createVolumeFromImageAnswer);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user