mirror of https://github.com/apache/cloudstack.git
Make DisplayText Non-Mandatory for Various Forms. (#7180)
Co-authored-by: Rahul Agarwal <rahul.agarwal@shapeblue.com> Co-authored-by: dahn <daan.hoogland@gmail.com> Co-authored-by: João Jandre <48719461+JoaoJandre@users.noreply.github.com>
This commit is contained in:
parent
52fa31b446
commit
723ace8b78
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
|
|
@ -58,7 +59,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the network offering")
|
||||
private String networkOfferingName;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of the network offering")
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "the display text of the network offering, defaults to the value of 'name'.")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.TRAFFIC_TYPE,
|
||||
|
|
@ -182,7 +183,7 @@ public class CreateNetworkOfferingCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? networkOfferingName : displayText;
|
||||
}
|
||||
|
||||
public String getTags() {
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import org.apache.cloudstack.api.response.VsphereStoragePoliciesResponse;
|
|||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.collections.MapUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.offering.DiskOffering;
|
||||
|
|
@ -56,7 +57,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.DISK_SIZE, type = CommandType.LONG, required = false, description = "size of the disk offering in GB (1GB = 1,073,741,824 bytes)")
|
||||
private Long diskSize;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "alternate display text of the disk offering", length = 4096)
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "An alternate display text of the disk offering, defaults to 'name'.", length = 4096)
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the disk offering")
|
||||
|
|
@ -179,7 +180,7 @@ public class CreateDiskOfferingCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? offeringName : displayText;
|
||||
}
|
||||
|
||||
public String getOfferingName() {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
@Parameter(name = ApiConstants.CPU_SPEED, type = CommandType.INTEGER, required = false, description = "the CPU speed of the service offering in MHz.")
|
||||
private Integer cpuSpeed;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of the service offering")
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "The display text of the service offering, defaults to 'name'.")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.PROVISIONINGTYPE, type = CommandType.STRING, description = "provisioning type used to create volumes. Valid values are thin, sparse, fat.")
|
||||
|
|
@ -258,10 +258,7 @@ public class CreateServiceOfferingCmd extends BaseCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
if (StringUtils.isEmpty(displayText)) {
|
||||
throw new InvalidParameterValueException("Failed to create service offering because the offering display text has not been spified.");
|
||||
}
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? serviceOfferingName : displayText;
|
||||
}
|
||||
|
||||
public String getProvisioningType() {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import java.util.Set;
|
|||
import org.apache.cloudstack.api.response.DomainResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.commons.collections.CollectionUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
|
|
@ -56,7 +57,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the vpc offering")
|
||||
private String vpcOfferingName;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of " + "the vpc offering")
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "the display text of the vpc offering, defaults to the 'name'")
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.SUPPORTED_SERVICES,
|
||||
|
|
@ -115,7 +116,7 @@ public class CreateVPCOfferingCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? vpcOfferingName : displayText;
|
||||
}
|
||||
|
||||
public List<String> getSupportedServices() {
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
|
|||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
|
|
@ -55,8 +56,7 @@ public class RegisterIsoCmd extends BaseCmd implements UserCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT,
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "the display text of the ISO. This is usually used for display purposes.",
|
||||
description = "the display text of the ISO, defaults to the 'name'",
|
||||
length = 4096)
|
||||
private String displayText;
|
||||
|
||||
|
|
@ -133,7 +133,7 @@ public class RegisterIsoCmd extends BaseCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? isoName : displayText;
|
||||
}
|
||||
|
||||
public void setDisplayText(String displayText) {
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ import org.apache.cloudstack.api.response.DomainResponse;
|
|||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
import org.apache.cloudstack.api.response.UserResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.event.EventTypes;
|
||||
|
|
@ -61,7 +62,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
|
|||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "name of the project")
|
||||
private String name;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "display text of the project")
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "The display text of the project, defaults to the 'name´.")
|
||||
private String displayText;
|
||||
|
||||
// ///////////////////////////////////////////////////
|
||||
|
|
@ -98,7 +99,7 @@ public class CreateProjectCmd extends BaseAsyncCreateCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? name : displayText;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ import org.apache.cloudstack.api.response.UserVmResponse;
|
|||
import org.apache.cloudstack.api.response.VolumeResponse;
|
||||
import org.apache.cloudstack.api.response.ProjectResponse;
|
||||
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.api.APICommand;
|
||||
|
|
@ -67,8 +68,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT,
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "the display text of the template. This is usually used for display purposes.",
|
||||
description = "The display text of the template, defaults to the 'name'.",
|
||||
length = 4096)
|
||||
private String displayText;
|
||||
|
||||
|
|
@ -144,7 +144,7 @@ public class CreateTemplateCmd extends BaseAsyncCreateCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? templateName : displayText;
|
||||
}
|
||||
|
||||
public Boolean isFeatured() {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import org.apache.cloudstack.api.response.ProjectResponse;
|
|||
import org.apache.cloudstack.api.response.TemplateResponse;
|
||||
import org.apache.cloudstack.api.response.ZoneResponse;
|
||||
import org.apache.cloudstack.context.CallContext;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import com.cloud.exception.ResourceAllocationException;
|
||||
|
|
@ -60,8 +61,7 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
|
|||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT,
|
||||
type = CommandType.STRING,
|
||||
required = true,
|
||||
description = "the display text of the template. This is usually used for display purposes.",
|
||||
description = "The display text of the template, defaults to 'name'.",
|
||||
length = 4096)
|
||||
private String displayText;
|
||||
|
||||
|
|
@ -176,7 +176,7 @@ public class RegisterTemplateCmd extends BaseCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? templateName : displayText;
|
||||
}
|
||||
|
||||
public String getFormat() {
|
||||
|
|
|
|||
|
|
@ -17,6 +17,7 @@
|
|||
package org.apache.cloudstack.api.command.user.vpc;
|
||||
|
||||
import com.cloud.network.NetworkService;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.apache.cloudstack.acl.RoleType;
|
||||
|
|
@ -72,8 +73,8 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
|
|||
@Parameter(name = ApiConstants.NAME, type = CommandType.STRING, required = true, description = "the name of the VPC")
|
||||
private String vpcName;
|
||||
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, required = true, description = "the display text of " +
|
||||
"the VPC")
|
||||
@Parameter(name = ApiConstants.DISPLAY_TEXT, type = CommandType.STRING, description = "The display text of the VPC, defaults to its 'name'.")
|
||||
|
||||
private String displayText;
|
||||
|
||||
@Parameter(name = ApiConstants.CIDR, type = CommandType.STRING, required = true, description = "the cidr of the VPC. All VPC " +
|
||||
|
|
@ -137,7 +138,7 @@ public class CreateVPCCmd extends BaseAsyncCreateCmd implements UserCmd {
|
|||
}
|
||||
|
||||
public String getDisplayText() {
|
||||
return displayText;
|
||||
return StringUtils.isEmpty(displayText) ? vpcName : displayText;
|
||||
}
|
||||
|
||||
public Long getVpcOffering() {
|
||||
|
|
|
|||
|
|
@ -0,0 +1,37 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.offering;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
public class CreateDiskOfferingCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private CreateDiskOfferingCmd createDiskOfferingCmd = new CreateDiskOfferingCmd();
|
||||
|
||||
@Test
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
String netName = "net-offering";
|
||||
ReflectionTestUtils.setField(createDiskOfferingCmd , "offeringName", netName);
|
||||
Assert.assertEquals(createDiskOfferingCmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,37 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.offering;
|
||||
|
||||
import org.apache.cloudstack.api.command.admin.network.CreateNetworkOfferingCmd;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
public class CreateNetworkOfferingCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private CreateNetworkOfferingCmd createNetworkOfferingCmd = new CreateNetworkOfferingCmd();
|
||||
|
||||
@Test
|
||||
public void createVpcNtwkOffWithEmptyDisplayText() {
|
||||
String netName = "network";
|
||||
ReflectionTestUtils.setField(createNetworkOfferingCmd, "networkOfferingName", netName);
|
||||
Assert.assertEquals(createNetworkOfferingCmd.getDisplayText(), netName);
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.admin.offering;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateServiceOfferingCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private CreateServiceOfferingCmd createServiceOfferingCmd;
|
||||
|
||||
@Test
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
String netName = "net-offering";
|
||||
ReflectionTestUtils.setField(createServiceOfferingCmd, "serviceOfferingName", netName);
|
||||
Assert.assertEquals(createServiceOfferingCmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -25,6 +25,8 @@ import org.junit.Test;
|
|||
|
||||
import org.apache.cloudstack.api.ApiCmdTestUtil;
|
||||
import org.apache.cloudstack.api.ApiConstants;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
|
||||
public class CreateVPCOfferingCmdTest {
|
||||
|
||||
|
|
@ -61,4 +63,12 @@ public class CreateVPCOfferingCmdTest {
|
|||
Assert.assertNull(cmd.getServiceProviders());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testCreateVPCOfferingWithEmptyDisplayText() {
|
||||
CreateVPCOfferingCmd cmd = new CreateVPCOfferingCmd();
|
||||
String netName = "net-vpc";
|
||||
ReflectionTestUtils.setField(cmd,"vpcOfferingName", netName);
|
||||
Assert.assertEquals(cmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,40 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.user.iso;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class RegisterIsoCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private RegisterIsoCmd registerIsoCmd = new RegisterIsoCmd();
|
||||
|
||||
@Test
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
String netName = "net-iso";
|
||||
ReflectionTestUtils.setField(registerIsoCmd, "isoName", netName);
|
||||
Assert.assertEquals(registerIsoCmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,40 @@
|
|||
// Licensed to the Apache Software Foundation (ASF) under one
|
||||
// or more contributor license agreements. See the NOTICE file
|
||||
// distributed with this work for additional information
|
||||
// regarding copyright ownership. The ASF licenses this file
|
||||
// to you under the Apache License, Version 2.0 (the
|
||||
// "License"); you may not use this file except in compliance
|
||||
// with the License. You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing,
|
||||
// software distributed under the License is distributed on an
|
||||
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
// KIND, either express or implied. See the License for the
|
||||
// specific language governing permissions and limitations
|
||||
// under the License.
|
||||
|
||||
package org.apache.cloudstack.api.command.user.project;
|
||||
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.mockito.InjectMocks;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
public class CreateProjectCmdTest {
|
||||
|
||||
@InjectMocks
|
||||
private CreateProjectCmd createProjectCmd = new CreateProjectCmd();
|
||||
|
||||
@Test
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
String netName = "net-project";
|
||||
ReflectionTestUtils.setField(createProjectCmd , "name", netName);
|
||||
Assert.assertEquals(createProjectCmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -30,6 +30,8 @@ import org.junit.runner.RunWith;
|
|||
import org.mockito.InjectMocks;
|
||||
import org.mockito.Mock;
|
||||
import org.mockito.runners.MockitoJUnitRunner;
|
||||
import org.springframework.test.util.ReflectionTestUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
@RunWith(MockitoJUnitRunner.class)
|
||||
|
|
@ -139,4 +141,12 @@ public class RegisterTemplateCmdTest {
|
|||
testIsDeployAsIsBase(Hypervisor.HypervisorType.XenServer, true, false);
|
||||
testIsDeployAsIsBase(Hypervisor.HypervisorType.Any, true, false);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
registerTemplateCmd = new RegisterTemplateCmd();
|
||||
String netName = "net-template";
|
||||
ReflectionTestUtils.setField(registerTemplateCmd , "templateName", netName);
|
||||
Assert.assertEquals(registerTemplateCmd.getDisplayText(), netName);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -133,6 +133,12 @@ public class CreateVPCCmdTest extends TestCase {
|
|||
Assert.assertTrue(cmd.getDisplayVpc());
|
||||
}
|
||||
|
||||
public void testGetDisplayTextWhenEmpty() {
|
||||
String netName = "net-vpc";
|
||||
ReflectionTestUtils.setField(cmd, "vpcName", netName);
|
||||
Assert.assertEquals(cmd.getDisplayText(), netName);
|
||||
}
|
||||
|
||||
public void testCreate() throws ResourceAllocationException {
|
||||
Vpc vpc = Mockito.mock(Vpc.class);
|
||||
ReflectionTestUtils.setField(cmd, "zoneId", 1L);
|
||||
|
|
|
|||
|
|
@ -249,5 +249,4 @@ public class CreateNetworkOfferingTest extends TestCase {
|
|||
// System.out.println("Creating Vpc Network Offering");
|
||||
assertNotNull("Vpc Isolated network offering with Vpc and Netscaler provider ", off);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
|
||||
|
||||
# management server clustering parameters, change cluster.node.IP to the machine IP address
|
||||
# in which the management server is running
|
||||
# in which the management server is running
|
||||
cluster.node.IP=127.0.0.1
|
||||
cluster.servlet.port=9090
|
||||
|
||||
|
|
|
|||
|
|
@ -1820,3 +1820,125 @@ class TestProjectSuspendActivate(cloudstackTestCase):
|
|||
"VM should be in Running state after project activation"
|
||||
)
|
||||
return
|
||||
|
||||
class TestProjectWithEmptyDisplayText(cloudstackTestCase):
|
||||
|
||||
@classmethod
|
||||
def setUpClass(cls):
|
||||
cls.testClient = super(
|
||||
TestProjectWithEmptyDisplayText,
|
||||
cls).getClsTestClient()
|
||||
cls.api_client = cls.testClient.getApiClient()
|
||||
|
||||
cls.services = Services().services
|
||||
# Get Zone
|
||||
cls.zone = get_zone(cls.api_client, cls.testClient.getZoneForTests())
|
||||
cls.hypervisor = cls.testClient.getHypervisorInfo()
|
||||
cls.domain = get_domain(cls.api_client)
|
||||
cls.services['mode'] = cls.zone.networktype
|
||||
cls.template = get_test_template(
|
||||
cls.api_client,
|
||||
cls.zone.id,
|
||||
cls.hypervisor
|
||||
)
|
||||
cls._cleanup = []
|
||||
cls.isGlobalSettingInvalid = False
|
||||
configs = Configurations.list(
|
||||
cls.api_client,
|
||||
name='project.invite.required'
|
||||
)
|
||||
|
||||
if (configs[0].value).lower() != 'false':
|
||||
cls.isGlobalSettingInvalid = True
|
||||
return
|
||||
|
||||
# Create account, service offering, disk offering etc.
|
||||
cls.disk_offering = DiskOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["disk_offering"]
|
||||
)
|
||||
cls._cleanup.append(cls.disk_offering)
|
||||
cls.service_offering = ServiceOffering.create(
|
||||
cls.api_client,
|
||||
cls.services["service_offering"],
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls._cleanup.append(cls.service_offering)
|
||||
cls.account = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls._cleanup.append(cls.account)
|
||||
cls.user = Account.create(
|
||||
cls.api_client,
|
||||
cls.services["account"],
|
||||
admin=True,
|
||||
domainid=cls.domain.id
|
||||
)
|
||||
cls._cleanup.append(cls.user)
|
||||
|
||||
# Create project as a domain admin
|
||||
cls.project = Project.create(
|
||||
cls.api_client,
|
||||
cls.services["project"],
|
||||
account=cls.account.name,
|
||||
domainid=cls.account.domainid
|
||||
)
|
||||
cls._cleanup.append(cls.project)
|
||||
cls.services["virtual_machine"]["zoneid"] = cls.zone.id
|
||||
return
|
||||
|
||||
@classmethod
|
||||
def tearDownClass(cls):
|
||||
super(TestProjectWithEmptyDisplayText, cls).tearDownClass()
|
||||
|
||||
def setUp(self):
|
||||
self.apiclient = self.testClient.getApiClient()
|
||||
self.dbclient = self.testClient.getDbConnection()
|
||||
self.cleanup = []
|
||||
|
||||
if self.isGlobalSettingInvalid:
|
||||
self.skipTest("'project.invite.required' should be set to false")
|
||||
return
|
||||
|
||||
def tearDown(self):
|
||||
super(TestProjectWithEmptyDisplayText, self).tearDown()
|
||||
|
||||
@attr(
|
||||
tags=[
|
||||
"advanced",
|
||||
"basic",
|
||||
"sg",
|
||||
"eip",
|
||||
"advancedns",
|
||||
"simulator"],
|
||||
required_hardware="false")
|
||||
def test_11_create_project_with_empty_displayText(self):
|
||||
""" create Project with Empty DisplayText
|
||||
"""
|
||||
# Validate the following
|
||||
# 1. Create a project.
|
||||
# 2. Give empty displayText
|
||||
# 3. Verify displayText takes content of Project name.
|
||||
|
||||
self.services["project"]["displaytext"] = ""
|
||||
|
||||
# Create project as a domain admin
|
||||
project = Project.create(
|
||||
self.apiclient,
|
||||
self.services["project"],
|
||||
account=self.account.name,
|
||||
domainid=self.account.domainid
|
||||
)
|
||||
|
||||
self.cleanup.append(project)
|
||||
|
||||
self.assertEqual(
|
||||
project.displaytext,
|
||||
project.name,
|
||||
"displayText does not matches project name"
|
||||
)
|
||||
|
||||
return
|
||||
|
|
|
|||
|
|
@ -260,7 +260,6 @@ export default {
|
|||
url: [{ required: true, message: this.$t('label.upload.iso.from.local') }],
|
||||
file: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
name: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
zoneid: [{ required: true, message: this.$t('message.error.select') }],
|
||||
ostypeid: [{ required: true, message: this.$t('message.error.select') }]
|
||||
})
|
||||
|
|
|
|||
|
|
@ -441,7 +441,6 @@ export default {
|
|||
url: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
file: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
name: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
zoneids: [
|
||||
{ type: 'array', required: true, message: this.$t('message.error.select') },
|
||||
{
|
||||
|
|
|
|||
|
|
@ -222,7 +222,6 @@ export default {
|
|||
})
|
||||
this.rules = reactive({
|
||||
name: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
zoneid: [{ required: true, message: this.$t('label.required') }],
|
||||
cidr: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
vpcofferingid: [{ required: true, message: this.$t('label.required') }]
|
||||
|
|
|
|||
|
|
@ -707,7 +707,6 @@ export default {
|
|||
})
|
||||
this.rules = reactive({
|
||||
name: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
cpunumber: [
|
||||
{ required: true, message: this.$t('message.error.required.input') },
|
||||
this.naturalNumberRule
|
||||
|
|
|
|||
|
|
@ -357,7 +357,6 @@ export default {
|
|||
})
|
||||
this.rules = reactive({
|
||||
name: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.required.input') }],
|
||||
disksize: [
|
||||
{ required: true, message: this.$t('message.error.required.input') },
|
||||
{ type: 'number', validator: this.validateNumber }
|
||||
|
|
|
|||
|
|
@ -577,7 +577,6 @@ export default {
|
|||
})
|
||||
this.rules = reactive({
|
||||
name: [{ required: true, message: this.$t('message.error.name') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.description') }],
|
||||
networkrate: [{ type: 'number', validator: this.validateNumber }],
|
||||
serviceofferingid: [{ required: true, message: this.$t('message.error.select') }],
|
||||
domainid: [{ type: 'array', required: true, message: this.$t('message.error.select') }],
|
||||
|
|
|
|||
|
|
@ -245,7 +245,6 @@ export default {
|
|||
})
|
||||
this.rules = reactive({
|
||||
name: [{ required: true, message: this.$t('message.error.name') }],
|
||||
displaytext: [{ required: true, message: this.$t('message.error.description') }],
|
||||
domainid: [{ type: 'array', required: true, message: this.$t('message.error.select') }],
|
||||
zoneid: [{
|
||||
type: 'array',
|
||||
|
|
|
|||
Loading…
Reference in New Issue