use of org.ovirt.engine.api.model.Cluster in project ovirt-engine by oVirt.
the class BackendGlusterBricksResourceTest method setUpParentMocks.
/**
* The method {@link BackendGlusterBricksResource#list()} internally invokes
* {@link BackendGlusterVolumeResource#get()} to fetch the volume object, and then invokes the query to fetch the
* bricks of that volume. This method mocks the volume resource to return pre-defined volume id
*/
private void setUpParentMocks() {
GlusterVolume volume = new GlusterVolume();
volume.setId(volumeId.toString());
Cluster cluster = new Cluster();
cluster.setId(clusterId.toString());
volume.setCluster(cluster);
ClusterResource clusterResourceMock = mock(ClusterResource.class);
when(clusterResourceMock.get()).thenReturn(cluster);
BackendGlusterVolumesResource volumesResourceMock = mock(BackendGlusterVolumesResource.class);
when(volumesResourceMock.getParent()).thenReturn(clusterResourceMock);
parentMock = mock(BackendGlusterVolumeResource.class);
when(parentMock.getParent()).thenReturn(volumesResourceMock);
when(parentMock.get()).thenReturn(volume);
collection.setParent(parentMock);
doAnswer(invocation -> {
GlusterVolume model = (GlusterVolume) invocation.getArguments()[0];
Cluster clusterModel = new Cluster();
clusterModel.setId(clusterId.toString());
model.setCluster(clusterModel);
model.setId(volumeId.toString());
return model;
}).when(parentMock).addParents(isA(GlusterVolume.class));
}
use of org.ovirt.engine.api.model.Cluster in project ovirt-engine by oVirt.
the class LinkHelperTest method testClusterNetworkLinks.
@Test
public void testClusterNetworkLinks() throws Exception {
Network network = new Network();
network.setId(NETWORK_ID);
network.setCluster(new Cluster());
network.getCluster().setId(CLUSTER_ID);
LinkHelper.addLinks(network);
assertEquals(CLUSTER_NETWORK_HREF, network.getHref());
}
use of org.ovirt.engine.api.model.Cluster in project ovirt-engine by oVirt.
the class LinkHelperTest method doTestVmLinks.
private void doTestVmLinks(boolean suggestParent) throws Exception {
Vm vm = new Vm();
vm.setId(VM_ID);
vm.setCluster(new Cluster());
vm.getCluster().setId(CLUSTER_ID);
vm.setTemplate(new Template());
vm.getTemplate().setId(TEMPLATE_ID);
vm.setVmPool(new VmPool());
vm.getVmPool().setId(VM_POOL_ID);
if (suggestParent) {
LinkHelper.addLinks(vm, Vm.class);
} else {
LinkHelper.addLinks(vm);
}
assertEquals(VM_HREF, vm.getHref());
assertEquals(CLUSTER_HREF, vm.getCluster().getHref());
assertEquals(TEMPLATE_HREF, vm.getTemplate().getHref());
assertEquals(VM_POOL_HREF, vm.getVmPool().getHref());
}
use of org.ovirt.engine.api.model.Cluster in project ovirt-engine by oVirt.
the class LinkHelperTest method testClusterLinks.
@Test
public void testClusterLinks() throws Exception {
Cluster cluster = new Cluster();
cluster.setId(CLUSTER_ID);
cluster.setDataCenter(new DataCenter());
cluster.getDataCenter().setId(DATA_CENTER_ID);
LinkHelper.addLinks(cluster);
assertEquals(CLUSTER_HREF, cluster.getHref());
assertEquals(DATA_CENTER_HREF, cluster.getDataCenter().getHref());
}
use of org.ovirt.engine.api.model.Cluster in project ovirt-engine by oVirt.
the class BackendGlusterVolumeResourceTest method setupParentExpectations.
private void setupParentExpectations() {
Cluster cluster = new Cluster();
cluster.setName(defaultClusterName);
cluster.setId(clusterId.toString());
clusterResourceMock = mock(ClusterResource.class);
when(clusterResourceMock.get()).thenReturn(cluster);
volumesResourceMock = mock(BackendGlusterVolumesResource.class);
when(volumesResourceMock.getParent()).thenReturn(clusterResourceMock);
doAnswer(invocation -> {
GlusterVolume model = (GlusterVolume) invocation.getArguments()[0];
Cluster clusterModel = new Cluster();
clusterModel.setId(clusterId.toString());
model.setCluster(clusterModel);
return model;
}).when(volumesResourceMock).addParents(isA(GlusterVolume.class));
}
Aggregations