use of org.ovirt.engine.api.model.Host in project ovirt-engine by oVirt.
the class BackendHostResourceTest method testUpdateWithClusterName.
@Test
public void testUpdateWithClusterName() throws Exception {
String clusterName = "Default";
setUpGetEntityExpectations(3);
setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { clusterName }, getCluster(clusterName, GUIDS[1]));
setUriInfo(setUpActionExpectations(ActionType.ChangeVDSCluster, ChangeVDSClusterParameters.class, new String[] { "ClusterId", "VdsId" }, new Object[] { GUIDS[1], GUIDS[0] }, true, true, new ActionReturnValue(), false));
setUriInfo(setUpActionExpectations(ActionType.UpdateVds, UpdateVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, true, true));
org.ovirt.engine.api.model.Cluster cluster = new org.ovirt.engine.api.model.Cluster();
cluster.setName(clusterName);
Host host = getModel(0);
host.setCluster(cluster);
verifyModel(resource.update(host), 0);
}
use of org.ovirt.engine.api.model.Host in project ovirt-engine by oVirt.
the class BackendHostsResourceTest method getModel.
static Host getModel(int index) {
Host model = new Host();
model.setName(NAMES[index]);
model.setAddress(ADDRESSES[index]);
model.setRootPassword(ROOT_PASSWORD);
return model;
}
use of org.ovirt.engine.api.model.Host in project ovirt-engine by oVirt.
the class BackendHostsResourceTest method doTestBadAddHost.
private void doTestBadAddHost(boolean valid, boolean success, String detail) throws Exception {
setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { "Default" }, setUpCluster(GUIDS[1]));
setUriInfo(setUpActionExpectations(ActionType.AddVds, AddVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, valid, success));
Host model = getModel(0);
try {
collection.add(model);
fail("expected WebApplicationException");
} catch (WebApplicationException wae) {
verifyFault(wae, detail);
}
}
use of org.ovirt.engine.api.model.Host in project ovirt-engine by oVirt.
the class BackendHostsResourceTest method testAddHost.
@Test
public void testAddHost() throws Exception {
setUriInfo(setUpBasicUriExpectations());
setUpEntityQueryExpectations(QueryType.GetClusterByName, NameQueryParameters.class, new String[] { "Name" }, new Object[] { "Default" }, setUpCluster(GUIDS[1]));
setUpCreationExpectations(ActionType.AddVds, AddVdsActionParameters.class, new String[] { "RootPassword" }, new Object[] { ROOT_PASSWORD }, true, true, GUIDS[0], QueryType.GetVdsByVdsId, IdQueryParameters.class, new String[] { "Id" }, new Object[] { GUIDS[0] }, getEntity(0));
Host model = getModel(0);
Response response = collection.add(model);
assertEquals(201, response.getStatus());
assertTrue(response.getEntity() instanceof Host);
verifyModel((Host) response.getEntity(), 0);
}
use of org.ovirt.engine.api.model.Host in project ovirt-engine by oVirt.
the class CompletenessAssertorTest method testMissingSubFieldAlternatives.
@Test
public void testMissingSubFieldAlternatives() throws Exception {
Vm vm = new Vm();
vm.setDescription("incomplete");
vm.setHost(new Host());
try {
CompletenessAssertor.validateParameters(vm, "host.id|name");
fail("expected WebApplicationException on incomplete model");
} catch (WebApplicationException wae) {
verifyIncompleteException(wae, "Vm", "host.id|name");
}
}
Aggregations