Search in sources :

Example 11 with GlusterVolume

use of org.ovirt.engine.api.model.GlusterVolume 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)

Example 12 with GlusterVolume

use of org.ovirt.engine.api.model.GlusterVolume in project ovirt-engine by oVirt.

the class BackendGlusterVolumesResourceTest method testAdd.

@Test
public void testAdd() {
    setUriInfo(setUpBasicUriExpectations());
    setUpVolumeCreationExpectations(false);
    collection.setParent(parentMock);
    Response response = collection.add(createModel());
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof GlusterVolume);
    verifyModel((GlusterVolume) response.getEntity(), 1);
}
Also used : Response(javax.ws.rs.core.Response) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 13 with GlusterVolume

use of org.ovirt.engine.api.model.GlusterVolume in project ovirt-engine by oVirt.

the class BackendGlusterVolumesResourceTest method testAddForce.

@Test
public void testAddForce() {
    UriInfo uriInfo = setUpBasicUriExpectations();
    setUriInfo(setUpGetMatrixConstraintsExpectations(BackendResource.FORCE_CONSTRAINT, true, "true", uriInfo));
    setUpVolumeCreationExpectations(true);
    collection.setParent(parentMock);
    Response response = collection.add(createModel());
    assertEquals(201, response.getStatus());
    assertTrue(response.getEntity() instanceof GlusterVolume);
    verifyModel((GlusterVolume) response.getEntity(), 1);
}
Also used : Response(javax.ws.rs.core.Response) GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) UriInfo(javax.ws.rs.core.UriInfo) Test(org.junit.Test) AbstractBackendCollectionResourceTest(org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)

Example 14 with GlusterVolume

use of org.ovirt.engine.api.model.GlusterVolume in project ovirt-engine by oVirt.

the class BackendGlusterVolumesResourceTest method createModel.

private GlusterVolume createModel() {
    GlusterVolume volume = new GlusterVolume();
    volume.setName("testVol1");
    volume.setCluster(new Cluster());
    volume.getCluster().setId(clusterId.toString());
    volume.setVolumeType(org.ovirt.engine.api.model.GlusterVolumeType.DISTRIBUTE);
    volume.setBricks(new GlusterBricks());
    volume.getBricks().getGlusterBricks().add(createBrick("/export/vol1/brick1"));
    return volume;
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterBricks(org.ovirt.engine.api.model.GlusterBricks) Cluster(org.ovirt.engine.api.model.Cluster)

Example 15 with GlusterVolume

use of org.ovirt.engine.api.model.GlusterVolume in project ovirt-engine by oVirt.

the class GlusterVolumeMapperTest method testStatusMapping.

private void testStatusMapping(GlusterStatus backendStatus, GlusterVolumeStatus restStatus) {
    GlusterVolumeEntity volume = new GlusterVolumeEntity();
    volume.setStatus(backendStatus);
    GlusterVolume restVolume = GlusterVolumeMapper.map(volume, null);
    assertEquals(restVolume.getStatus(), restStatus);
}
Also used : GlusterVolume(org.ovirt.engine.api.model.GlusterVolume) GlusterVolumeEntity(org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)

Aggregations

GlusterVolume (org.ovirt.engine.api.model.GlusterVolume)18 GlusterBrick (org.ovirt.engine.api.model.GlusterBrick)7 Test (org.junit.Test)6 GlusterBricks (org.ovirt.engine.api.model.GlusterBricks)6 AbstractBackendCollectionResourceTest (org.ovirt.engine.api.restapi.resource.AbstractBackendCollectionResourceTest)6 Cluster (org.ovirt.engine.api.model.Cluster)5 Response (javax.ws.rs.core.Response)3 Action (org.ovirt.engine.api.model.Action)3 GlusterVolumeRemoveBricksParameters (org.ovirt.engine.core.common.action.gluster.GlusterVolumeRemoveBricksParameters)3 UriInfo (javax.ws.rs.core.UriInfo)2 Options (org.ovirt.engine.api.model.Options)2 ClusterResource (org.ovirt.engine.api.resource.ClusterResource)2 GlusterVolumeEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeEntity)2 ArrayList (java.util.ArrayList)1 Option (org.ovirt.engine.api.model.Option)1 TransportType (org.ovirt.engine.api.model.TransportType)1 V3GlusterVolume (org.ovirt.engine.api.v3.types.V3GlusterVolume)1 CreateGlusterVolumeParameters (org.ovirt.engine.core.common.action.gluster.CreateGlusterVolumeParameters)1 GlusterVolumeOptionEntity (org.ovirt.engine.core.common.businessentities.gluster.GlusterVolumeOptionEntity)1 IdQueryParameters (org.ovirt.engine.core.common.queries.IdQueryParameters)1