use of org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin in project cloudstack by apache.
the class RegisterTemplateCmdByAdminTest method testZoneidMinusOne.
@Test
public void testZoneidMinusOne() throws ResourceAllocationException {
// If zoneId is passed as -1, then zone ids list should be null.
registerTemplateCmdByAdmin = new RegisterTemplateCmdByAdmin();
registerTemplateCmdByAdmin.zoneId = -1L;
Assert.assertNull(registerTemplateCmdByAdmin.getZoneIds());
}
use of org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin in project cloudstack by apache.
the class RegisterTemplateCmdByAdminTest method testZoneidPresentZoneidListAbsent.
@Test
public void testZoneidPresentZoneidListAbsent() throws ResourceAllocationException {
registerTemplateCmdByAdmin = new RegisterTemplateCmdByAdmin();
registerTemplateCmdByAdmin.zoneIds = null;
registerTemplateCmdByAdmin.zoneId = 1L;
Assert.assertEquals((Long) 1L, registerTemplateCmdByAdmin.getZoneIds().get(0));
}
use of org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin in project cloudstack by apache.
the class RegisterTemplateCmdByAdminTest method testZoneidListMoreThanMinusOne.
@Test
public void testZoneidListMoreThanMinusOne() throws ResourceAllocationException {
try {
registerTemplateCmdByAdmin = new RegisterTemplateCmdByAdmin();
registerTemplateCmdByAdmin.zoneIds = new ArrayList<>();
registerTemplateCmdByAdmin.zoneIds.add(-1L);
registerTemplateCmdByAdmin.zoneIds.add(1L);
registerTemplateCmdByAdmin.execute();
} catch (ServerApiException e) {
if (e.getErrorCode() != ApiErrorCode.PARAM_ERROR) {
Assert.fail("Parameter zoneids cannot combine all zones (-1) option with other zones");
}
}
}
use of org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin in project cloudstack by apache.
the class RegisterTemplateCmdByAdminTest method testZoneidAndZoneIdListBothPresent.
@Test
public void testZoneidAndZoneIdListBothPresent() throws ResourceAllocationException {
try {
registerTemplateCmdByAdmin = new RegisterTemplateCmdByAdmin();
registerTemplateCmdByAdmin.zoneId = -1L;
registerTemplateCmdByAdmin.zoneIds = new ArrayList<>();
registerTemplateCmdByAdmin.zoneIds.add(-1L);
registerTemplateCmdByAdmin.execute();
} catch (ServerApiException e) {
if (e.getErrorCode() != ApiErrorCode.PARAM_ERROR) {
Assert.fail("Api should fail when both zoneid and zoneids are passed");
}
}
}
use of org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin in project cloudstack by apache.
the class RegisterTemplateCmdByAdminTest method testZoneidListMinusOne.
@Test
public void testZoneidListMinusOne() throws ResourceAllocationException {
// If zoneId List has only one parameter -1, then zone ids list should be null.
registerTemplateCmdByAdmin = new RegisterTemplateCmdByAdmin();
registerTemplateCmdByAdmin.zoneIds = new ArrayList<>();
registerTemplateCmdByAdmin.zoneIds.add(-1L);
Assert.assertNull(registerTemplateCmdByAdmin.getZoneIds());
}
Aggregations