This is an automated email from the ASF dual-hosted git repository.
rohit pushed a commit to branch 4.11
in repository https://gitbox.apache.org/repos/asf/cloudstack.git
The following commit(s) were added to refs/heads/4.11 by this push:
new a6196b0 Fixes: #2881 Improve Exception message (#2889)
a6196b0 is described below
commit a6196b0a605c2afbeffdfc1866b3949663c67882
Author: Frank Maximus <[email protected]>
AuthorDate: Tue Oct 9 12:13:48 2018 +0200
Fixes: #2881 Improve Exception message (#2889)
Network.Service and Network.Provider were missing a toString() method.
Added this so appending (a list of) them will be understandable.
---
api/src/com/cloud/network/Network.java | 21 +++++++++++++++++++++
.../cloud/network/element/NuageVspElementTest.java | 22 +++++++++++++++++++---
2 files changed, 40 insertions(+), 3 deletions(-)
diff --git a/api/src/com/cloud/network/Network.java
b/api/src/com/cloud/network/Network.java
index 75196a4..d983081 100644
--- a/api/src/com/cloud/network/Network.java
+++ b/api/src/com/cloud/network/Network.java
@@ -21,6 +21,9 @@ import java.net.URI;
import java.util.ArrayList;
import java.util.List;
+import org.apache.commons.lang.builder.ToStringBuilder;
+import org.apache.commons.lang.builder.ToStringStyle;
+
import org.apache.cloudstack.acl.ControlledEntity;
import org.apache.cloudstack.api.Displayable;
import org.apache.cloudstack.api.Identity;
@@ -95,6 +98,12 @@ public interface Network extends ControlledEntity,
StateObject<Network.State>, I
return success;
}
+ @Override public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+ .append("name", name)
+ .toString();
+ }
+
public static Service getService(String serviceName) {
for (Service service : supportedServices) {
if (service.getName().equalsIgnoreCase(serviceName)) {
@@ -186,6 +195,12 @@ public interface Network extends ControlledEntity,
StateObject<Network.State>, I
}
return null;
}
+
+ @Override public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+ .append("name", name)
+ .toString();
+ }
}
public static class Capability {
@@ -241,6 +256,12 @@ public interface Network extends ControlledEntity,
StateObject<Network.State>, I
}
return null;
}
+
+ @Override public String toString() {
+ return new ToStringBuilder(this, ToStringStyle.SHORT_PREFIX_STYLE)
+ .append("name", name)
+ .toString();
+ }
}
enum Event {
diff --git
a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
index e48d9a4..9a87dac 100644
---
a/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
+++
b/plugins/network-elements/nuage-vsp/test/com/cloud/network/element/NuageVspElementTest.java
@@ -26,9 +26,6 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Set;
-import com.cloud.network.dao.NetworkDao;
-import com.cloud.network.dao.NetworkVO;
-import com.cloud.tags.dao.ResourceTagDao;
import org.junit.Before;
import org.junit.Test;
import org.mockito.InjectMocks;
@@ -50,6 +47,7 @@ import com.cloud.exception.CloudException;
import com.cloud.exception.ConcurrentOperationException;
import com.cloud.exception.InsufficientCapacityException;
import com.cloud.exception.ResourceUnavailableException;
+import com.cloud.exception.UnsupportedServiceException;
import com.cloud.host.HostVO;
import com.cloud.host.dao.HostDao;
import com.cloud.network.Network;
@@ -62,7 +60,9 @@ import com.cloud.network.NuageVspDeviceVO;
import com.cloud.network.dao.FirewallRulesDao;
import com.cloud.network.dao.IPAddressDao;
import com.cloud.network.dao.IPAddressVO;
+import com.cloud.network.dao.NetworkDao;
import com.cloud.network.dao.NetworkServiceMapDao;
+import com.cloud.network.dao.NetworkVO;
import com.cloud.network.dao.NuageVspDao;
import com.cloud.network.dao.PhysicalNetworkDao;
import com.cloud.network.dao.PhysicalNetworkVO;
@@ -77,14 +77,18 @@ import com.cloud.offerings.NetworkOfferingVO;
import com.cloud.offerings.dao.NetworkOfferingDao;
import com.cloud.offerings.dao.NetworkOfferingServiceMapDao;
import com.cloud.resource.ResourceManager;
+import com.cloud.tags.dao.ResourceTagDao;
import com.cloud.user.Account;
import com.cloud.util.NuageVspEntityBuilder;
import com.cloud.vm.DomainRouterVO;
import com.cloud.vm.ReservationContext;
import com.cloud.vm.dao.DomainRouterDao;
+import static org.hamcrest.Matchers.is;
import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.mock;
@@ -233,6 +237,18 @@ public class NuageVspElementTest extends NuageTest {
Service.Connectivity,
Service.Firewall);
assertTrue(_nuageVspElement.verifyServicesCombination(services));
+
+
+ services = Sets.newHashSet(
+ Service.Dhcp,
+ Service.StaticNat,
+ Service.Firewall);
+ try {
+ _nuageVspElement.verifyServicesCombination(services);
+ fail("Expected Exception");
+ } catch (UnsupportedServiceException e) {
+ assertThat(e.getMessage(), is("Provider
Network.Provider[name=NuageVsp] requires services:
[Network.Service[name=Connectivity]]"));
+ }
}
@Test