rhtyd closed pull request #2889: Fixes: #2881 Improve Exception message URL: https://github.com/apache/cloudstack/pull/2889
This is a PR merged from a forked repository. As GitHub hides the original diff on merge, it is displayed below for the sake of provenance: As this is a foreign pull request (from a fork), the diff is supplied below (as it won't show otherwise due to GitHub magic): diff --git a/api/src/com/cloud/network/Network.java b/api/src/com/cloud/network/Network.java index 75196a469d3..d9830810958 100644 --- a/api/src/com/cloud/network/Network.java +++ b/api/src/com/cloud/network/Network.java @@ -21,6 +21,9 @@ 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 boolean containsCapability(Capability cap) { 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 static Provider getProvider(String providerName) { } 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 static Capability getCapability(String capabilityName) { } 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 e48d9a46ced..9a87dac1997 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.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.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.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.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 void testVerifyServiceCombination() { 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 ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services