Skip to content

Commit 6fe6102

Browse files
committed
Code coverage increase 1
1 parent 972d7a6 commit 6fe6102

23 files changed

+2016
-3
lines changed

plugins/network-elements/netris/src/main/java/org/apache/cloudstack/api/command/AddNetrisProviderCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
@APICommand(name = AddNetrisProviderCmd.APINAME, description = "Add Netris Provider to CloudStack",
3737
responseObject = NetrisProviderResponse.class, requestHasSensitiveInfo = false,
38-
responseHasSensitiveInfo = false, since = "4.20")
38+
responseHasSensitiveInfo = false, since = "4.21.0")
3939
public class AddNetrisProviderCmd extends BaseCmd {
4040
public static final String APINAME = "addNetrisProvider";
4141
public static final Logger LOGGER = LoggerFactory.getLogger(AddNetrisProviderCmd.class.getName());

plugins/network-elements/netris/src/main/java/org/apache/cloudstack/api/command/DeleteNetrisProviderCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
@APICommand(name = APINAME, description = "delete Netris Provider to CloudStack",
3737
responseObject = NetrisProviderResponse.class, requestHasSensitiveInfo = false,
38-
responseHasSensitiveInfo = false, since = "4.20.0")
38+
responseHasSensitiveInfo = false, since = "4.21.0")
3939
public class DeleteNetrisProviderCmd extends BaseCmd {
4040
public static final String APINAME = "deleteNetrisProvider";
4141

plugins/network-elements/netris/src/main/java/org/apache/cloudstack/api/command/ListNetrisProvidersCmd.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434

3535
@APICommand(name = ListNetrisProvidersCmd.APINAME, description = "list all Netris providers added to CloudStack",
3636
responseObject = NetrisProviderResponse.class, requestHasSensitiveInfo = false,
37-
responseHasSensitiveInfo = false, since = "4.20.0")
37+
responseHasSensitiveInfo = false, since = "4.21.0")
3838
public class ListNetrisProvidersCmd extends BaseListCmd {
3939
public static final String APINAME = "listNetrisProviders";
4040

plugins/network-elements/netris/src/main/java/org/apache/cloudstack/resource/NetrisPortGroup.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@
1919
public class NetrisPortGroup {
2020
private String ports;
2121

22+
public NetrisPortGroup() {
23+
}
24+
2225
public NetrisPortGroup(String ports) {
2326
this.ports = ports;
2427
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.agent.api;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
public class AddOrUpdateNetrisStaticRouteCommandTest {
23+
24+
private static final long ZONE_ID = 1L;
25+
private static final Long ACCOUNT_ID = 2L;
26+
private static final Long DOMAIN_ID = 3L;
27+
private static final String NAME = "test-vpc";
28+
private static final Long ID = 4L;
29+
private static final boolean IS_VPC = true;
30+
private static final String PREFIX = "10.0.0.0/24";
31+
private static final String NEXT_HOP = "10.0.0.1";
32+
private static final Long ROUTE_ID = 5L;
33+
private static final boolean UPDATE_ROUTE = true;
34+
35+
@Test
36+
public void testConstructorAndGetters() {
37+
// Act
38+
AddOrUpdateNetrisStaticRouteCommand command = new AddOrUpdateNetrisStaticRouteCommand(
39+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, NAME, ID, IS_VPC, PREFIX, NEXT_HOP, ROUTE_ID, UPDATE_ROUTE);
40+
41+
// Assert
42+
Assert.assertEquals(ZONE_ID, command.getZoneId());
43+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
44+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
45+
Assert.assertEquals(NAME, command.getName());
46+
Assert.assertEquals(ID, command.getId());
47+
Assert.assertEquals(IS_VPC, command.isVpc());
48+
Assert.assertEquals(PREFIX, command.getPrefix());
49+
Assert.assertEquals(NEXT_HOP, command.getNextHop());
50+
Assert.assertEquals(ROUTE_ID, command.getRouteId());
51+
Assert.assertEquals(UPDATE_ROUTE, command.isUpdateRoute());
52+
}
53+
54+
@Test
55+
public void testConstructorWithNullValues() {
56+
// Act
57+
AddOrUpdateNetrisStaticRouteCommand command = new AddOrUpdateNetrisStaticRouteCommand(
58+
ZONE_ID, null, null, NAME, null, IS_VPC, PREFIX, NEXT_HOP, null, UPDATE_ROUTE);
59+
60+
// Assert
61+
Assert.assertEquals(ZONE_ID, command.getZoneId());
62+
Assert.assertNull(command.getAccountId());
63+
Assert.assertNull(command.getDomainId());
64+
Assert.assertEquals(NAME, command.getName());
65+
Assert.assertNull(command.getId());
66+
Assert.assertEquals(IS_VPC, command.isVpc());
67+
Assert.assertEquals(PREFIX, command.getPrefix());
68+
Assert.assertEquals(NEXT_HOP, command.getNextHop());
69+
Assert.assertNull(command.getRouteId());
70+
Assert.assertEquals(UPDATE_ROUTE, command.isUpdateRoute());
71+
}
72+
73+
@Test
74+
public void testConstructorWithEmptyStrings() {
75+
// Act
76+
AddOrUpdateNetrisStaticRouteCommand command = new AddOrUpdateNetrisStaticRouteCommand(
77+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, "", ID, IS_VPC, "", "", ROUTE_ID, UPDATE_ROUTE);
78+
79+
// Assert
80+
Assert.assertEquals(ZONE_ID, command.getZoneId());
81+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
82+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
83+
Assert.assertEquals("", command.getName());
84+
Assert.assertEquals(ID, command.getId());
85+
Assert.assertEquals(IS_VPC, command.isVpc());
86+
Assert.assertEquals("", command.getPrefix());
87+
Assert.assertEquals("", command.getNextHop());
88+
Assert.assertEquals(ROUTE_ID, command.getRouteId());
89+
Assert.assertEquals(UPDATE_ROUTE, command.isUpdateRoute());
90+
}
91+
}
Lines changed: 144 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,144 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.agent.api;
18+
19+
import org.apache.cloudstack.resource.NetrisPortGroup;
20+
import org.junit.Assert;
21+
import org.junit.Test;
22+
23+
public class CreateNetrisACLCommandTest {
24+
25+
private static final long ZONE_ID = 1L;
26+
private static final Long ACCOUNT_ID = 2L;
27+
private static final Long DOMAIN_ID = 3L;
28+
private static final String NAME = "test-network";
29+
private static final Long ID = 4L;
30+
private static final String VPC_NAME = "test-vpc";
31+
private static final Long VPC_ID = 5L;
32+
private static final boolean IS_VPC = true;
33+
private static final String ACTION = "allow";
34+
private static final String SOURCE_PREFIX = "10.0.0.0/24";
35+
private static final String DEST_PREFIX = "10.0.1.0/24";
36+
private static final Integer DEST_PORT_START = 80;
37+
private static final Integer DEST_PORT_END = 80;
38+
private static final String PROTOCOL = "tcp";
39+
private static final Integer ICMP_TYPE = 8;
40+
private static final String NETRIS_ACL_NAME = "test-acl";
41+
private static final String REASON = "test reason";
42+
private static final String PORTS = "80,443";
43+
44+
@Test
45+
public void testConstructorAndGetters() {
46+
// Act
47+
CreateNetrisACLCommand command = new CreateNetrisACLCommand(
48+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, NAME, ID, VPC_NAME, VPC_ID, IS_VPC, ACTION,
49+
SOURCE_PREFIX, DEST_PREFIX, DEST_PORT_START, DEST_PORT_END, PROTOCOL);
50+
51+
// Assert
52+
Assert.assertEquals(ZONE_ID, command.getZoneId());
53+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
54+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
55+
Assert.assertEquals(NAME, command.getName());
56+
Assert.assertEquals(ID, command.getId());
57+
Assert.assertEquals(IS_VPC, command.isVpc());
58+
Assert.assertEquals(VPC_NAME, command.getVpcName());
59+
Assert.assertEquals(VPC_ID, command.getVpcId());
60+
Assert.assertEquals(ACTION, command.getAction());
61+
Assert.assertEquals(SOURCE_PREFIX, command.getSourcePrefix());
62+
Assert.assertEquals(DEST_PREFIX, command.getDestPrefix());
63+
Assert.assertEquals(DEST_PORT_START, command.getDestPortStart());
64+
Assert.assertEquals(DEST_PORT_END, command.getDestPortEnd());
65+
Assert.assertEquals(PROTOCOL, command.getProtocol());
66+
}
67+
68+
@Test
69+
public void testConstructorWithNullValues() {
70+
// Act
71+
CreateNetrisACLCommand command = new CreateNetrisACLCommand(
72+
ZONE_ID, null, null, NAME, null, VPC_NAME, null, IS_VPC, ACTION,
73+
SOURCE_PREFIX, DEST_PREFIX, null, null, PROTOCOL);
74+
75+
// Assert
76+
Assert.assertEquals(ZONE_ID, command.getZoneId());
77+
Assert.assertNull(command.getAccountId());
78+
Assert.assertNull(command.getDomainId());
79+
Assert.assertEquals(NAME, command.getName());
80+
Assert.assertNull(command.getId());
81+
Assert.assertEquals(IS_VPC, command.isVpc());
82+
Assert.assertEquals(VPC_NAME, command.getVpcName());
83+
Assert.assertNull(command.getVpcId());
84+
Assert.assertEquals(ACTION, command.getAction());
85+
Assert.assertEquals(SOURCE_PREFIX, command.getSourcePrefix());
86+
Assert.assertEquals(DEST_PREFIX, command.getDestPrefix());
87+
Assert.assertNull(command.getDestPortStart());
88+
Assert.assertNull(command.getDestPortEnd());
89+
Assert.assertEquals(PROTOCOL, command.getProtocol());
90+
}
91+
92+
@Test
93+
public void testSetters() {
94+
// Arrange
95+
CreateNetrisACLCommand command = new CreateNetrisACLCommand(
96+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, NAME, ID, VPC_NAME, VPC_ID, IS_VPC, ACTION,
97+
SOURCE_PREFIX, DEST_PREFIX, DEST_PORT_START, DEST_PORT_END, PROTOCOL);
98+
99+
NetrisPortGroup portGroup = new NetrisPortGroup(PORTS);
100+
String newVpcName = "new-vpc";
101+
Long newVpcId = 6L;
102+
103+
// Act
104+
command.setVpcName(newVpcName);
105+
command.setVpcId(newVpcId);
106+
command.setPortGroup(portGroup);
107+
command.setIcmpType(ICMP_TYPE);
108+
command.setNetrisAclName(NETRIS_ACL_NAME);
109+
command.setReason(REASON);
110+
111+
// Assert
112+
Assert.assertEquals(newVpcName, command.getVpcName());
113+
Assert.assertEquals(newVpcId, command.getVpcId());
114+
Assert.assertEquals(portGroup, command.getPortGroup());
115+
Assert.assertEquals(ICMP_TYPE, command.getIcmpType());
116+
Assert.assertEquals(NETRIS_ACL_NAME, command.getNetrisAclName());
117+
Assert.assertEquals(REASON, command.getReason());
118+
Assert.assertEquals(PORTS, command.getPortGroup().getPorts());
119+
}
120+
121+
@Test
122+
public void testConstructorWithEmptyStrings() {
123+
// Act
124+
CreateNetrisACLCommand command = new CreateNetrisACLCommand(
125+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, "", ID, "", VPC_ID, IS_VPC, "",
126+
"", "", DEST_PORT_START, DEST_PORT_END, "");
127+
128+
// Assert
129+
Assert.assertEquals(ZONE_ID, command.getZoneId());
130+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
131+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
132+
Assert.assertEquals("", command.getName());
133+
Assert.assertEquals(ID, command.getId());
134+
Assert.assertEquals(IS_VPC, command.isVpc());
135+
Assert.assertEquals("", command.getVpcName());
136+
Assert.assertEquals(VPC_ID, command.getVpcId());
137+
Assert.assertEquals("", command.getAction());
138+
Assert.assertEquals("", command.getSourcePrefix());
139+
Assert.assertEquals("", command.getDestPrefix());
140+
Assert.assertEquals(DEST_PORT_START, command.getDestPortStart());
141+
Assert.assertEquals(DEST_PORT_END, command.getDestPortEnd());
142+
Assert.assertEquals("", command.getProtocol());
143+
}
144+
}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
// Licensed to the Apache Software Foundation (ASF) under one
2+
// or more contributor license agreements. See the NOTICE file
3+
// distributed with this work for additional information
4+
// regarding copyright ownership. The ASF licenses this file
5+
// to you under the Apache License, Version 2.0 (the
6+
// "License"); you may not use this file except in compliance
7+
// with the License. You may obtain a copy of the License at
8+
//
9+
// http://www.apache.org/licenses/LICENSE-2.0
10+
//
11+
// Unless required by applicable law or agreed to in writing,
12+
// software distributed under the License is distributed on an
13+
// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
14+
// KIND, either express or implied. See the License for the
15+
// specific language governing permissions and limitations
16+
// under the License.
17+
package org.apache.cloudstack.agent.api;
18+
19+
import org.junit.Assert;
20+
import org.junit.Test;
21+
22+
public class CreateNetrisVnetCommandTest {
23+
24+
private static final Long ZONE_ID = 1L;
25+
private static final Long ACCOUNT_ID = 2L;
26+
private static final Long DOMAIN_ID = 3L;
27+
private static final String VPC_NAME = "test-vpc";
28+
private static final Long VPC_ID = 4L;
29+
private static final String VNET_NAME = "test-vnet";
30+
private static final Long NETWORK_ID = 5L;
31+
private static final String CIDR = "10.0.0.0/24";
32+
private static final String GATEWAY = "10.0.0.1";
33+
private static final boolean IS_VPC = true;
34+
private static final Integer VXLAN_ID = 100;
35+
private static final String NETRIS_TAG = "test-tag";
36+
private static final String IPV6_CIDR = "2001:db8::/64";
37+
private static final Boolean GLOBAL_ROUTING = true;
38+
39+
@Test
40+
public void testConstructorAndGetters() {
41+
// Act
42+
CreateNetrisVnetCommand command = new CreateNetrisVnetCommand(
43+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, VPC_NAME, VPC_ID, VNET_NAME, NETWORK_ID, CIDR, GATEWAY, IS_VPC);
44+
45+
// Assert
46+
Assert.assertEquals(ZONE_ID.longValue(), command.getZoneId());
47+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
48+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
49+
Assert.assertEquals(VNET_NAME, command.getName());
50+
Assert.assertEquals(NETWORK_ID, command.getId());
51+
Assert.assertEquals(IS_VPC, command.isVpc());
52+
Assert.assertEquals(VPC_NAME, command.getVpcName());
53+
Assert.assertEquals(VPC_ID, command.getVpcId());
54+
Assert.assertEquals(CIDR, command.getCidr());
55+
Assert.assertEquals(GATEWAY, command.getGateway());
56+
}
57+
58+
@Test
59+
public void testSetters() {
60+
// Arrange
61+
CreateNetrisVnetCommand command = new CreateNetrisVnetCommand(
62+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, VPC_NAME, VPC_ID, VNET_NAME, NETWORK_ID, CIDR, GATEWAY, IS_VPC);
63+
64+
// Act
65+
command.setVxlanId(VXLAN_ID);
66+
command.setNetrisTag(NETRIS_TAG);
67+
command.setIpv6Cidr(IPV6_CIDR);
68+
command.setGlobalRouting(GLOBAL_ROUTING);
69+
70+
// Assert
71+
Assert.assertEquals(VXLAN_ID, command.getVxlanId());
72+
Assert.assertEquals(NETRIS_TAG, command.getNetrisTag());
73+
Assert.assertEquals(IPV6_CIDR, command.getIpv6Cidr());
74+
Assert.assertEquals(GLOBAL_ROUTING, command.isGlobalRouting());
75+
}
76+
77+
@Test
78+
public void testConstructorWithEmptyStrings() {
79+
// Act
80+
CreateNetrisVnetCommand command = new CreateNetrisVnetCommand(
81+
ZONE_ID, ACCOUNT_ID, DOMAIN_ID, "", VPC_ID, "", NETWORK_ID, "", "", IS_VPC);
82+
83+
// Assert
84+
Assert.assertEquals(ZONE_ID.longValue(), command.getZoneId());
85+
Assert.assertEquals(ACCOUNT_ID, command.getAccountId());
86+
Assert.assertEquals(DOMAIN_ID, command.getDomainId());
87+
Assert.assertEquals("", command.getName());
88+
Assert.assertEquals(NETWORK_ID, command.getId());
89+
Assert.assertEquals(IS_VPC, command.isVpc());
90+
Assert.assertEquals("", command.getVpcName());
91+
Assert.assertEquals(VPC_ID, command.getVpcId());
92+
Assert.assertEquals("", command.getCidr());
93+
Assert.assertEquals("", command.getGateway());
94+
}
95+
}

0 commit comments

Comments
 (0)