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));
}
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);
}
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);
}
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;
}
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);
}
Aggregations