Search in sources :

Example 11 with Cluster

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));
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) ClusterResource(org.ovirt.engine.api.resource.ClusterResource)

Example 12 with Cluster

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());
}
Also used : Network(org.ovirt.engine.api.model.Network) Cluster(org.ovirt.engine.api.model.Cluster) Test(org.junit.Test)

Example 13 with Cluster

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());
}
Also used : VmPool(org.ovirt.engine.api.model.VmPool) Vm(org.ovirt.engine.api.model.Vm) Cluster(org.ovirt.engine.api.model.Cluster) Template(org.ovirt.engine.api.model.Template)

Example 14 with Cluster

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());
}
Also used : DataCenter(org.ovirt.engine.api.model.DataCenter) Cluster(org.ovirt.engine.api.model.Cluster) Test(org.junit.Test)

Example 15 with Cluster

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));
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Cluster(org.ovirt.engine.api.model.Cluster) ClusterResource(org.ovirt.engine.api.resource.ClusterResource)

Aggregations

Cluster (org.ovirt.engine.api.model.Cluster)33 Host (org.ovirt.engine.api.model.Host)7 Test (org.junit.Test)6 GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)5 CpuProfile (org.ovirt.engine.api.model.CpuProfile)4 Vm (org.ovirt.engine.api.model.Vm)4 VmPool (org.ovirt.engine.api.model.VmPool)4 ClusterResource (org.ovirt.engine.api.resource.ClusterResource)4 WebApplicationException (javax.ws.rs.WebApplicationException)3 Response (javax.ws.rs.core.Response)3 DataCenter (org.ovirt.engine.api.model.DataCenter)3 V3Cluster (org.ovirt.engine.api.v3.types.V3Cluster)3 Consumes (javax.ws.rs.Consumes)2 AffinityGroup (org.ovirt.engine.api.model.AffinityGroup)2 Display (org.ovirt.engine.api.model.Display)2 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)2 Quota (org.ovirt.engine.api.model.Quota)2 StorageDomain (org.ovirt.engine.api.model.StorageDomain)2 Template (org.ovirt.engine.api.model.Template)2 BackendClusterResource (org.ovirt.engine.api.restapi.resource.BackendClusterResource)2