Search in sources :

Example 1 with RegisterTemplateCmdByAdmin

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());
}
Also used : RegisterTemplateCmdByAdmin(org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin) Test(org.junit.Test)

Example 2 with RegisterTemplateCmdByAdmin

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));
}
Also used : RegisterTemplateCmdByAdmin(org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin) Test(org.junit.Test)

Example 3 with RegisterTemplateCmdByAdmin

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");
        }
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) RegisterTemplateCmdByAdmin(org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin) Test(org.junit.Test)

Example 4 with RegisterTemplateCmdByAdmin

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");
        }
    }
}
Also used : ServerApiException(org.apache.cloudstack.api.ServerApiException) RegisterTemplateCmdByAdmin(org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin) Test(org.junit.Test)

Example 5 with RegisterTemplateCmdByAdmin

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());
}
Also used : RegisterTemplateCmdByAdmin(org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin) Test(org.junit.Test)

Aggregations

RegisterTemplateCmdByAdmin (org.apache.cloudstack.api.command.admin.template.RegisterTemplateCmdByAdmin)6 Test (org.junit.Test)6 ServerApiException (org.apache.cloudstack.api.ServerApiException)3