diff --git a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NetworkPropertiesTest.java b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NetworkPropertiesTest.java index 1aa892f5122..e780c24239b 100644 --- a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NetworkPropertiesTest.java +++ b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/NetworkPropertiesTest.java @@ -13,15 +13,18 @@ package org.eclipse.kura.nm; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.Optional; import org.eclipse.kura.configuration.Password; @@ -42,13 +45,12 @@ public class NetworkPropertiesTest { private List stringListResult; private Map resultMap; - private Boolean hasNullPointExceptionBeenThrown = false; - private Boolean hasNoSuchElementExceptionBeenThrown = false; + private Exception occurredException; @Test public void constructorShouldThrowWithNullMap() { givenNetworkPropertiesBuiltWith(null); - thenANullPointerExceptionOccured(); + thenExceptionOccurred(NullPointerException.class); } @Test @@ -91,7 +93,7 @@ public void getShouldThrowWithNullValue() { givenMapWith("testKey1", null); givenNetworkPropertiesBuiltWith(this.properties); whenGetIsCalledWith("testKey1", String.class); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -99,7 +101,7 @@ public void getShouldThrowWithMissingKey() { givenMapWith("testKey1", null); givenNetworkPropertiesBuiltWith(this.properties); whenGetIsCalledWith("testKey1-nonExistant", String.class); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -107,7 +109,7 @@ public void getShouldThrowWithEmptyString() { givenMapWith("Empty-String", ""); givenNetworkPropertiesBuiltWith(this.properties); whenGetIsCalledWith("Empty-String", String.class); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -115,7 +117,7 @@ public void getShouldThrowWithEmptyPassword() { givenMapWith("Empty-Password", new Password("")); givenNetworkPropertiesBuiltWith(this.properties); whenGetIsCalledWith("Empty-Password", Password.class); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -282,7 +284,7 @@ public void getStringListShouldThrowWithNullValue() { givenMapWith("testKey-comma-seperated", null); givenNetworkPropertiesBuiltWith(this.properties); whenGetStringListIsCalledWith("testKey-comma-seperated"); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -290,7 +292,7 @@ public void getStringListShouldThrowWithNonExistantKey() { givenMapWith("testKey-comma-seperated", null); givenNetworkPropertiesBuiltWith(this.properties); whenGetStringListIsCalledWith("testKey-comma-seperated-not-existant"); - thenANoSuchElementExceptionOccured(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -366,14 +368,10 @@ public void givenMapWith(String key, Object pair) { } public void givenNetworkPropertiesBuiltWith(Map properties) { - try { this.netProps = new NetworkProperties(properties); - - } catch (NullPointerException e) { - this.hasNullPointExceptionBeenThrown = true; - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; + } catch (Exception e) { + this.occurredException = e; } } @@ -404,42 +402,32 @@ public void whenGetIsCalledWith(String key, Class clazz) { throw new IllegalArgumentException("Data type is not supported with this Test"); } - } catch (NullPointerException e) { - this.hasNullPointExceptionBeenThrown = true; - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; + } catch (Exception e) { + this.occurredException = e; } } public void whenGetOptIsCalledWith(String key, Class clazz) { try { this.optResult = this.netProps.getOpt(clazz, key, ""); - } catch (NullPointerException e) { - this.hasNullPointExceptionBeenThrown = true; - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; + } catch (Exception e) { + this.occurredException = e; } } public void whenGetStringListIsCalledWith(String key) { try { this.stringListResult = this.netProps.getStringList(key, ""); - - } catch (NullPointerException e) { - this.hasNullPointExceptionBeenThrown = true; - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; + } catch (Exception e) { + this.occurredException = e; } } public void whenGetOptStringListIsCalledWith(String key) { try { this.optResult = this.netProps.getOptStringList(key, ""); - - } catch (NullPointerException e) { - this.hasNullPointExceptionBeenThrown = true; - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; + } catch (Exception e) { + this.occurredException = e; } } @@ -492,17 +480,22 @@ private void thenOptionalPasswordResultEquals(Optional optPasswordResu } } - public void thenANullPointerExceptionOccured() { - assertTrue(this.hasNullPointExceptionBeenThrown); - } - - public void thenANoSuchElementExceptionOccured() { - assertTrue(this.hasNoSuchElementExceptionBeenThrown); + private void thenExceptionOccurred(Class expectedException) { + assertNotNull(this.occurredException); + assertEquals(expectedException.getName(), this.occurredException.getClass().getName()); } public void thenNoExceptionsOccured() { - assertFalse(this.hasNullPointExceptionBeenThrown); - assertFalse(this.hasNoSuchElementExceptionBeenThrown); + String errorMessage = "Empty message"; + if (Objects.nonNull(this.occurredException)) { + StringWriter sw = new StringWriter(); + this.occurredException.printStackTrace(new PrintWriter(sw)); + + errorMessage = String.format("No exception expected, \"%s\" found. Caused by: %s", + this.occurredException.getClass().getName(), sw.toString()); + } + + assertNull(errorMessage, this.occurredException); } } diff --git a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMSettingsConverterTest.java b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMSettingsConverterTest.java index c7926874d36..16efac74383 100644 --- a/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMSettingsConverterTest.java +++ b/kura/test/org.eclipse.kura.nm.test/src/test/java/org/eclipse/kura/nm/configuration/NMSettingsConverterTest.java @@ -15,11 +15,14 @@ import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.assertNull; import static org.junit.Assert.fail; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; +import java.io.PrintWriter; +import java.io.StringWriter; import java.nio.charset.StandardCharsets; import java.security.PrivateKey; import java.security.cert.Certificate; @@ -30,6 +33,7 @@ import java.util.List; import java.util.Map; import java.util.NoSuchElementException; +import java.util.Objects; import java.util.Optional; import org.eclipse.kura.configuration.Password; @@ -44,21 +48,18 @@ public class NMSettingsConverterTest { - Map> internalComparatorMap = new HashMap<>(); - Map> resultMap; + private Map> resultMap; - Map>> internalComparatorAllSettingsMap = new HashMap<>(); - Map>> resultAllSettingsMap = new HashMap<>(); + private Map>> internalComparatorAllSettingsMap = new HashMap<>(); + private Map>> resultAllSettingsMap = new HashMap<>(); - Map internetNetworkPropertiesInstanciationMap = new HashMap<>(); + private Map internetNetworkPropertiesInstanciationMap = new HashMap<>(); - NetworkProperties networkProperties; - Connection mockedConnection; + private NetworkProperties networkProperties; + private Connection mockedConnection; - Boolean hasNoSuchElementExceptionBeenThrown = false; - Boolean hasAnIllegalArgumentExceptionThrown = false; - Boolean hasAGenericExecptionBeenThrown = false; - SemanticVersion nmVersion = SemanticVersion.parse("1.40"); + private Exception occurredException; + private SemanticVersion nmVersion = SemanticVersion.parse("1.40"); private static final List IP6_BYTE_ARRAY_ADDRESS = Arrays .asList(new Byte[] { 32, 1, 72, 96, 72, 96, 0, 0, 0, 0, 0, 0, 0, 0, -120, 68 }); @@ -68,28 +69,28 @@ public void buildSettingsShouldThrowWhenGivenEmptyMap() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test public void buildIpv4SettingsShouldThrowWhenGivenEmptyMap() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test public void build80211WirelessSettingsShouldThrowErrorWhenGivenEmptyMap() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test public void build80211WirelessSecuritySettingsShouldThrowWhenGivenEmptyMap() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -99,7 +100,7 @@ public void buildIpv4SettingsShouldThrowWithUnmanagedStatus() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -109,7 +110,7 @@ public void buildIpv4SettingsShouldThrowWithUnknownStatus() { givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -119,7 +120,7 @@ public void buildIpv4SettingsShouldWorkWhenDisabled() { whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "disabled"); thenResultingMapNotContains("ignore-auto-dns"); thenResultingMapNotContains("ignore-auto-routes"); @@ -137,7 +138,7 @@ public void buildIpv4SettingsShouldWorkWhenGivenExpectedMapAndDhcpIsTrueAndEnabl givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapNotContains("ignore-auto-dns"); @@ -157,7 +158,7 @@ public void buildIpv4SettingsShouldWorkWhenGivenExpectedMapAndDhcpIsFalseAndEnab whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "manual"); thenResultingMapContains("address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingMapContains("dns", new Variant<>(Arrays.asList(new UInt32(16843009)), "au").getValue()); @@ -174,7 +175,7 @@ public void buildIpv4SettingsShouldWorkWhenGivenExpectedMapAndDhcpIsTrueAndEnabl whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("ignore-auto-dns", true); thenResultingMapContains("ignore-auto-routes", true); @@ -193,7 +194,7 @@ public void buildIpv4SettingsShouldWorkWhenGivenExpectedMapAndDhcpIsFalseAndEnab whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "manual"); thenResultingMapContains("address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingMapContains("ignore-auto-dns", true); @@ -211,7 +212,7 @@ public void buildIpv4SettingsShouldPopulateWanPriorityProperty() { whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("route-metric", new Variant<>(new Long(30)).getValue()); } @@ -225,7 +226,7 @@ public void buildIpv4SettingsShouldNotPopulateWanPriorityPropertyIfNotWAN() { whenBuildIpv4SettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("ignore-auto-dns", true); thenResultingMapContains("ignore-auto-routes", true); @@ -240,7 +241,7 @@ public void buildIpv6SettingsShouldThrowWhitWrongMethod() { whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -251,7 +252,7 @@ public void buildIpv6SettingsShouldNotSetIgnoreAutoDNSWhenGivenExpectedMapWithAu whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapNotContains("ignore-auto-dns"); } @@ -264,7 +265,7 @@ public void buildIpv6SettingsShouldSetWhenGivenExpectedMapWithAutoEnableAndWAN() whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); } @@ -276,7 +277,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithDhcpEnableAndWAN( whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "dhcp"); } @@ -292,7 +293,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithManualEnableAndEn whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "manual"); thenResultingMapContains("address-data", buildAddressDataWith("fe80::eed:f0a1:d03a:1028", new UInt32(25))); thenResultingMapContains("dns", Arrays.asList(IP6_BYTE_ARRAY_ADDRESS)); @@ -309,7 +310,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithAutoEnableAndEnab whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("ignore-auto-dns", true); thenResultingMapContains("ignore-auto-routes", true); @@ -328,7 +329,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithManualEnableAndEn whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "manual"); thenResultingMapContains("address-data", buildAddressDataWith("fe80::eed:f0a1:d03a:1028", new UInt32(25))); thenResultingMapContains("ignore-auto-dns", true); @@ -345,7 +346,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithAutoEnableAndWANE whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("addr-gen-mode", 0); thenResultingMapContains("ip6-privacy", 0); @@ -361,7 +362,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithAutoEnableAndWANS whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("addr-gen-mode", 1); thenResultingMapContains("ip6-privacy", 1); @@ -377,7 +378,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithAutoEnableAndWANS whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "auto"); thenResultingMapContains("addr-gen-mode", 1); thenResultingMapContains("ip6-privacy", 2); @@ -393,7 +394,7 @@ public void buildIpv6SettingsShouldWorkWhenGivenExpectedMapWithDisabled() { whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("method", "disabled"); thenResultingMapNotContains("addr-gen-mode"); thenResultingMapNotContains("ip6-privacy"); @@ -409,7 +410,7 @@ public void buildIpv6SettingsShouldThrowWhenGivenExpectedMapWithWrongAddressGenM whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -422,7 +423,7 @@ public void buildIpv6SettingsShouldThrowWhenGivenExpectedMapWithWrongPrivacy() { whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -437,7 +438,7 @@ public void buildIpv6SettingsShouldThrowIllegalArgumentExceptionWhenGivenExpecte whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -452,12 +453,12 @@ public void buildIpv6SettingsShouldThrowIllegalArgumentExceptionWhenGivenExpecte whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } - + @Test public void buildIpv6SettingsShouldHaveMtuWhenSupported() { - givenMapWith("net.interface.wlan0.config.ip6.address.method", "netIPv6MethodAuto"); + givenMapWith("net.interface.wlan0.config.ip6.address.method", "netIPv6MethodAuto"); givenMapWith("net.interface.wlan0.config.ip6.status", "netIPv6StatusEnabledWAN"); givenMapWith("net.interface.wlan0.config.ip6.mtu", 2345); givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); @@ -465,13 +466,13 @@ public void buildIpv6SettingsShouldHaveMtuWhenSupported() { whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mtu", new UInt32(2345)); } - + @Test public void buildIpv6SettingsShouldNotHaveMtuWhenNotSupported() { - givenMapWith("net.interface.wlan0.config.ip6.address.method", "netIPv6MethodAuto"); + givenMapWith("net.interface.wlan0.config.ip6.address.method", "netIPv6MethodAuto"); givenMapWith("net.interface.wlan0.config.ip6.status", "netIPv6StatusEnabledWAN"); givenMapWith("net.interface.wlan0.config.ip6.mtu", 3456); givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); @@ -479,31 +480,31 @@ public void buildIpv6SettingsShouldNotHaveMtuWhenNotSupported() { whenBuildIpv6SettingsIsRunWith(this.networkProperties, "wlan0", this.nmVersion); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapNotContains("mtu"); } - + @Test public void buildEthernetSettingsShouldHavePromiscWhenSupported() { - givenMapWith("net.interface.eth0.config.promisc", -1); - givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); + givenMapWith("net.interface.eth0.config.promisc", -1); + givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); givenNetworkManagerVersion("1.32"); - + whenBuildEthernetSettingsIsRunWith(networkProperties, "eth0", nmVersion); - - thenNoExceptionsHaveBeenThrown(); + + thenNoExceptionOccurred(); thenResultingMapContains("accept-all-mac-addresses", -1); } - - @Test + + @Test public void buildEthernetSettingsShouldNotHavePromiscWhenNotSupported() { - givenMapWith("net.interface.eth0.config.promisc", 1); - givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); + givenMapWith("net.interface.eth0.config.promisc", 1); + givenNetworkPropsCreatedWithTheMap(this.internetNetworkPropertiesInstanciationMap); givenNetworkManagerVersion("1.31"); - + whenBuildEthernetSettingsIsRunWith(networkProperties, "eth0", nmVersion); - - thenNoExceptionsHaveBeenThrown(); + + thenNoExceptionOccurred(); thenResultingMapNotContains("accept-all-mac-addresses"); } @@ -513,7 +514,7 @@ public void build8021xSettingsShouldThrowIfIsEmpty() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -523,7 +524,7 @@ public void build8021xSettingsShouldThrowIfEapIsInvalid() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -534,7 +535,7 @@ public void build8021xSettingsShouldThrowIfInnerAuthIsInvalid() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -547,7 +548,7 @@ public void build8021xSettingsShouldWorkWithTtlsAndMschapV2() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContainsArray("eap", new Variant<>(new String[] { "ttls" }).getValue()); thenResultingMapContains("phase2-auth", "mschapv2"); @@ -573,7 +574,7 @@ public void build8021xSettingsShouldWorkWithTtlsAndMschapV2AndOptionalParams() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContainsArray("eap", new Variant<>(new String[] { "ttls" }).getValue()); thenResultingMapContains("phase2-auth", "mschapv2"); @@ -595,7 +596,7 @@ public void build8021xSettingsShouldWorkWithPeapAndMschapV2() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContainsArray("eap", new Variant<>(new String[] { "peap" }).getValue()); thenResultingMapNotContains("anonymous-identity"); @@ -620,7 +621,7 @@ public void build8021xSettingsShouldWorkWithPeapAndMschapV2AndCertificates() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContainsArray("eap", new Variant<>(new String[] { "peap" }).getValue()); thenResultingMapContains("anonymous-identity", "anonymous-identity-test-var"); @@ -637,7 +638,7 @@ public void build8021xSettingsShouldThrowIfTlsIsEmpty() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -656,7 +657,7 @@ public void build8021xSettingsShouldWorkWithTls() { whenBuild8021xSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContainsArray("eap", new Variant<>(new String[] { "tls" }).getValue()); thenResultingMapNotContains("phase2-auth"); @@ -680,7 +681,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndSetToInfr whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "a"); @@ -698,7 +699,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndModeAp() whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "ap"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "a"); @@ -716,7 +717,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndModeMalfo whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -730,7 +731,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndBandBg() whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "bg"); @@ -748,7 +749,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndBandBgExt whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "bg"); @@ -766,7 +767,7 @@ public void build80211WirelessSettingsShouldWorkWhenGivenExpectedMapAndMalformed whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -780,7 +781,7 @@ public void build80211WirelessSettingsShouldWorkWithChannel0And2Ghz() { whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "bg"); @@ -798,7 +799,7 @@ public void build80211WirelessSettingsShouldWorkWithChannel0And5Ghz() { whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "a"); @@ -816,7 +817,7 @@ public void build80211WirelessSettingsAutomaticBandSelectionShouldWorkWithChanne whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("channel", new UInt32(0)); @@ -834,7 +835,7 @@ public void build80211WirelessSettingsAutomaticBandSelectionShouldWorkWithChanne whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "bg"); @@ -852,7 +853,7 @@ public void build80211WirelessSettingsAutomaticBandSelectionShouldWorkWithChanne whenBuild80211WirelessSettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("mode", "infrastructure"); thenResultingMapContainsBytes("ssid", "ssidtest"); thenResultingMapContains("band", "a"); @@ -871,7 +872,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenExpectedMap() { whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("psk", new Password("test").toString()); thenResultingMapContains("key-mgmt", "wpa-psk"); thenResultingMapContains("group", new Variant<>(Arrays.asList("ccmp"), "as").getValue()); @@ -891,7 +892,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenExpectedMapTkip whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("psk", new Password("test").toString()); thenResultingMapContains("key-mgmt", "wpa-psk"); thenResultingMapContains("group", new Variant<>(Arrays.asList("tkip"), "as").getValue()); @@ -911,7 +912,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenExpectedMapCcmp whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("psk", new Password("test").toString()); thenResultingMapContains("key-mgmt", "wpa-psk"); thenResultingMapContains("group", new Variant<>(Arrays.asList("tkip", "ccmp"), "as").getValue()); @@ -931,7 +932,7 @@ public void build80211WirelessSecuritySettingsShouldThrowWhenGivenMalformedCiphe whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -946,7 +947,7 @@ public void build80211WirelessSecuritySettingsShouldThrowWhenGivenSecurityTypeNo whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -961,7 +962,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenSecurityTypeWep whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("key-mgmt", "none"); thenResultingMapContains("wep-key-type", 1); thenResultingMapContains("wep-key0", "test"); @@ -981,7 +982,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenSecurityTypeWpa whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("key-mgmt", "wpa-psk"); thenResultingMapContains("proto", new Variant<>(Arrays.asList("wpa"), "as").getValue()); thenResultingMapNotContains("wep-key-type"); @@ -1000,7 +1001,7 @@ public void build80211WirelessSecuritySettingsShouldWorkWhenGivenSecurityTypeWpa whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("key-mgmt", "wpa-psk"); thenResultingMapContains("proto", new Variant<>(Arrays.asList("rsn"), "as").getValue()); thenResultingMapNotContains("wep-key-type"); @@ -1019,7 +1020,7 @@ public void build80211WirelessSecuritySettingsShouldThrowWhenGivenMalformedSecur whenBuild80211WirelessSecuritySettingsIsRunWith(this.networkProperties, "wlan0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1028,7 +1029,7 @@ public void buildGsmSettingsShouldThrowWithMissingRequiredArgument() { whenBuildGsmSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1038,7 +1039,7 @@ public void buildGsmSettingsShouldWorkWhenGivenExpectedMap() { whenBuildGsmSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("apn", "mobile.provider.com"); } @@ -1052,7 +1053,7 @@ public void buildGsmSettingsShouldWorkWhenGivenExpectedMapAndOptionalParameters( whenBuildGsmSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("apn", "mobile.provider.com"); thenResultingMapContains("username", "username"); thenResultingMapContains("password", "password"); @@ -1068,7 +1069,7 @@ public void buildGsmSettingsShouldWorkWithEmptyUsernamePassword() { whenBuildGsmSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("apn", "mobile.provider.com"); thenResultingMapNotContains("username"); thenResultingMapNotContains("password"); @@ -1080,7 +1081,7 @@ public void buildPPPSettingsShouldNotThrowWithEmptyMap() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); } @Test @@ -1091,7 +1092,7 @@ public void buildPPPSettingsShouldWorkWhenGivenOptionalLcpParameters() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("lcp-echo-interval", 30); thenResultingMapContains("lcp-echo-failure", 5); } @@ -1103,7 +1104,7 @@ public void buildPPPSettingsShouldWorkWithAuthTypeAuto() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapNotContains("refuse-eap"); thenResultingMapNotContains("refuse-chap"); thenResultingMapNotContains("refuse-pap"); @@ -1118,7 +1119,7 @@ public void buildPPPSettingsShouldWorkWithAuthTypeNone() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("refuse-eap", true); thenResultingMapContains("refuse-chap", true); thenResultingMapContains("refuse-pap", true); @@ -1133,7 +1134,7 @@ public void buildPPPSettingsShouldWorkWithAuthTypeChap() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("refuse-eap", true); thenResultingMapContains("refuse-chap", false); thenResultingMapContains("refuse-pap", true); @@ -1148,7 +1149,7 @@ public void buildPPPSettingsShouldWorkWithAuthTypePap() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("refuse-eap", true); thenResultingMapContains("refuse-chap", true); thenResultingMapContains("refuse-pap", false); @@ -1163,7 +1164,7 @@ public void buildPPPSettingsShouldThrowWithUnsupportedAuthType() { whenBuildPPPSettingsIsRunWith(this.networkProperties, "ttyACM0"); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1174,7 +1175,7 @@ public void buildVlanSettingsShouldWorkWithRequiredSettings() { whenBuildVlanSettingsIsRunWith(this.networkProperties, "eth0.30"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("parent", "eth0"); thenResultingMapContains("id", new UInt32(30)); thenResultingMapContains("flags", new UInt32(1)); @@ -1194,7 +1195,7 @@ public void buildVlanSettingsShouldWorkWithFullSettings() { whenBuildVlanSettingsIsRunWith(this.networkProperties, "eth1.40"); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("parent", "eth1"); thenResultingMapContains("id", new UInt32(40)); thenResultingMapContains("flags", new UInt32(3)); @@ -1209,7 +1210,7 @@ public void buildVlanSettingsShouldThrowWhenMissingParent() { whenBuildVlanSettingsIsRunWith(this.networkProperties, "eth0.30"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1219,14 +1220,14 @@ public void buildVlanSettingsShouldThrowWhenMissingVlanId() { whenBuildVlanSettingsIsRunWith(this.networkProperties, "eth0.30"); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test public void buildConnectionSettingsShouldWorkWithWifi() { whenBuildConnectionSettings(Optional.empty(), "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("type", "802-11-wireless"); thenResultingMapContains("autoconnect-retries", 1); } @@ -1235,7 +1236,7 @@ public void buildConnectionSettingsShouldWorkWithWifi() { public void buildConnectionSettingsShouldWorkWithEthernet() { whenBuildConnectionSettings(Optional.empty(), "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("type", "802-3-ethernet"); thenResultingMapContains("autoconnect-retries", 1); } @@ -1244,14 +1245,14 @@ public void buildConnectionSettingsShouldWorkWithEthernet() { public void buildConnectionSettingsShouldWorkWithUnsupported() { whenBuildConnectionSettings(Optional.empty(), "modem0", NMDeviceType.NM_DEVICE_TYPE_ADSL); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test public void buildConnectionSettingsShouldWorkWithVlan() { whenBuildConnectionSettings(Optional.empty(), "eth0.40", NMDeviceType.NM_DEVICE_TYPE_VLAN); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("type", "vlan"); thenResultingMapContains("autoconnect-retries", 1); } @@ -1264,7 +1265,7 @@ public void buildConnectionSettingsShouldWorkWithWifiMockedConnection() { whenBuildConnectionSettings(Optional.of(this.mockedConnection), "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingMapContains("test", "test"); thenResultingMapContains("autoconnect-retries", 1); } @@ -1277,7 +1278,7 @@ public void buildSettingsShouldThrowWithStatusUnmanagedIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1288,7 +1289,7 @@ public void buildSettingsShouldThrowWithStatusUnknownIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1312,7 +1313,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1362,7 +1363,7 @@ public void buildSettingsShouldWorkWith8021x() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1406,7 +1407,7 @@ public void buildSettingsShouldWorkWithExpectedConfiguredForInputsWiFiWanIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1450,7 +1451,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1494,7 +1495,7 @@ public void buildSettingsShouldNotSet80211WirelessSecuritySettingsIfSecurityType whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1535,7 +1536,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiWanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1568,7 +1569,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndUnm whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1582,7 +1583,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndLan whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1608,7 +1609,7 @@ public void buildSettingsShouldWorkWithExpectedInputsEthernetAndWanIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1639,7 +1640,7 @@ public void buildSettingsShouldWorkWithExpectedInputsVlanAndWanIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "myVlan", "myVlan", NMDeviceType.NM_DEVICE_TYPE_VLAN); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); @@ -1670,7 +1671,7 @@ public void buildSettingsShouldWorkWithModemSettingsIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "1-1.1", "ttyACM0", NMDeviceType.NM_DEVICE_TYPE_MODEM); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "disabled"); thenResultingBuildAllMapContains("ipv4", "method", "auto"); thenResultingBuildAllMapContains("connection", "id", "kura-ttyACM0-connection"); @@ -1693,7 +1694,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullIpIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1709,7 +1710,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullPrefixIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1725,7 +1726,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullStatusIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1751,7 +1752,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullWifiSsidIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1777,7 +1778,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullWifiPasswordIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1803,7 +1804,7 @@ public void buildSettingsShouldThrowDhcpDisabledAndNullWifiSecurityTypeIp4() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -1815,7 +1816,7 @@ public void buildSettingsShouldThrowWithStatusUnmanagedIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1827,7 +1828,7 @@ public void buildSettingsShouldThrowWithStatusUnknownIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1853,7 +1854,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiUnmangedIp whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -1880,7 +1881,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -1923,7 +1924,7 @@ public void buildSettingsShouldWorkWithExpectedConfiguredForInputsWiFiWanIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -1967,7 +1968,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -2011,7 +2012,7 @@ public void buildSettingsShouldNotSet80211WirelessSecuritySettingsIfSecurityType whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -2054,7 +2055,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiWanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -2087,7 +2088,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndUnm whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -2102,7 +2103,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndLan whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -2130,7 +2131,7 @@ public void buildSettingsShouldWorkWithExpectedInputsEthernetAndWanIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("ipv6", "method", "manual"); thenResultingBuildAllMapContains("ipv6", "address-data", @@ -2155,7 +2156,7 @@ public void buildSettingsShouldWorkWithModemSettingsIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "1-1.1", "ttyACM0", NMDeviceType.NM_DEVICE_TYPE_MODEM); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "auto"); thenResultingBuildAllMapContains("ipv4", "method", "disabled"); thenResultingBuildAllMapContains("connection", "id", "kura-ttyACM0-connection"); @@ -2179,7 +2180,7 @@ public void buildSettingsShouldThrowWithManualAndNullIpIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2196,7 +2197,7 @@ public void buildSettingsShouldThrowWithManualAndNullPrefixIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2240,7 +2241,7 @@ public void buildSettingsShouldThrowWithManualAndNullWifiSsidIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2267,7 +2268,7 @@ public void buildSettingsShouldThrowWithManualAndNullWifiPasswordIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2294,7 +2295,7 @@ public void buildSettingsShouldThrowWithManualAndNullWifiSecurityTypeIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2306,7 +2307,7 @@ public void buildSettingsShouldThrowWithStatusUnmanagedIp4AndIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -2318,7 +2319,7 @@ public void buildSettingsShouldThrowWithStatusUnknownIp4AndIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -2347,7 +2348,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiUnmangedIp whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -2377,7 +2378,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanIp4AndI whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapNotContains("ipv4", "gateway"); @@ -2430,7 +2431,7 @@ public void buildSettingsShouldWorkWithExpectedConfiguredForInputsWiFiWanIp4AndI whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapContains("ipv4", "ignore-auto-dns", true); @@ -2480,7 +2481,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiLanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapNotContains("ipv4", "gateway"); @@ -2530,7 +2531,7 @@ public void buildSettingsShouldNotSet80211WirelessSecuritySettingsIfSecurityType whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapNotContains("ipv4", "gateway"); @@ -2583,7 +2584,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForWiFiWanAndHidd whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapContains("ipv4", "gateway", "192.168.0.1"); @@ -2622,7 +2623,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndUnm whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenIllegalArgumentExceptionThrown(); + thenExceptionOccurred(IllegalArgumentException.class); } @Test @@ -2640,7 +2641,7 @@ public void buildSettingsShouldWorkWithExpectedInputsConfiguredForEthernetAndLan whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapContains("ipv4", "ignore-auto-dns", true); @@ -2678,7 +2679,7 @@ public void buildSettingsShouldWorkWithExpectedInputsEthernetAndWanIp4AndIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv4", "method", "manual"); thenResultingBuildAllMapContains("ipv4", "address-data", buildAddressDataWith("192.168.0.12", new UInt32(25))); thenResultingBuildAllMapContains("ipv4", "gateway", "192.168.0.1"); @@ -2710,7 +2711,7 @@ public void buildSettingsShouldWorkWithModemSettingsIp4AndIp6() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "1-1.1", "ttyACM0", NMDeviceType.NM_DEVICE_TYPE_MODEM); - thenNoExceptionsHaveBeenThrown(); + thenNoExceptionOccurred(); thenResultingBuildAllMapContains("ipv6", "method", "auto"); thenResultingBuildAllMapContains("ipv4", "method", "auto"); thenResultingBuildAllMapContains("connection", "id", "kura-ttyACM0-connection"); @@ -2739,7 +2740,7 @@ public void buildSettingsShouldThrowWithManualIp6DhcpDisableIp4AndNullIp() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2761,7 +2762,7 @@ public void buildSettingsShouldThrowWithManualIp6DhcpDisableIp4AndNullPrefix() { whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "eth0", "eth0", NMDeviceType.NM_DEVICE_TYPE_ETHERNET); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2816,7 +2817,7 @@ public void buildSettingsShouldThrowWithManualIp6DhcpDisableIp4AndNullWifiSsid() whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2848,7 +2849,7 @@ public void buildSettingsShouldThrowWithManualIp6DhcpDisableIp4AndNullWifiPasswo whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } @Test @@ -2880,7 +2881,7 @@ public void buildSettingsShouldThrowWithManualIp6DhcpDisableIp4AndNullWifiSecuri whenBuildSettingsIsRunWith(this.networkProperties, Optional.empty(), "wlan0", "wlan0", NMDeviceType.NM_DEVICE_TYPE_WIFI); - thenNoSuchElementExceptionThrown(); + thenExceptionOccurred(NoSuchElementException.class); } /* @@ -2909,7 +2910,7 @@ public void givenMockConnection() { Mockito.when(this.mockedConnection.GetSettings()).thenReturn(this.internalComparatorAllSettingsMap); } - + public void givenNetworkManagerVersion(String nmVersion) { this.nmVersion = SemanticVersion.parse(nmVersion); } @@ -2928,132 +2929,88 @@ public void whenBuildSettingsIsRunWith(NetworkProperties properties, Optional connection, String iface, NMDeviceType deviceType) { try { this.resultMap = NMSettingsConverter.buildConnectionSettings(connection, iface, deviceType); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } public void whenBuild80211WirelessSecuritySettingsIsRunWith(NetworkProperties props, String iface) { try { this.resultMap = NMSettingsConverter.build80211WirelessSecuritySettings(props, iface); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } private void whenBuildGsmSettingsIsRunWith(NetworkProperties props, String iface) { try { this.resultMap = NMSettingsConverter.buildGsmSettings(props, iface); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } private void whenBuildPPPSettingsIsRunWith(NetworkProperties props, String iface) { try { this.resultMap = NMSettingsConverter.buildPPPSettings(props, iface); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } private void whenBuildVlanSettingsIsRunWith(NetworkProperties props, String iface) { try { this.resultMap = NMSettingsConverter.buildVlanSettings(props, iface); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } - + private void whenBuildEthernetSettingsIsRunWith(NetworkProperties props, String iface, SemanticVersion nmVersion) { try { this.resultMap = NMSettingsConverter.buildEthernetSettings(props, iface, nmVersion); - } catch (NoSuchElementException e) { - this.hasNoSuchElementExceptionBeenThrown = true; - } catch (IllegalArgumentException e) { - this.hasAnIllegalArgumentExceptionThrown = true; } catch (Exception e) { - this.hasAGenericExecptionBeenThrown = true; + this.occurredException = e; } } @@ -3099,18 +3056,22 @@ public void thenResultingBuildAllMapContainsBytes(String key, String subKey, Obj new String((byte[]) this.resultAllSettingsMap.get(key).get(subKey).getValue(), StandardCharsets.UTF_8)); } - public void thenNoSuchElementExceptionThrown() { - assertTrue(this.hasNoSuchElementExceptionBeenThrown); + private void thenExceptionOccurred(Class expectedException) { + assertNotNull(this.occurredException); + assertEquals(expectedException.getName(), this.occurredException.getClass().getName()); } - public void thenIllegalArgumentExceptionThrown() { - assertTrue(this.hasAnIllegalArgumentExceptionThrown); - } + public void thenNoExceptionOccurred() { + String errorMessage = "Empty message"; + if (Objects.nonNull(this.occurredException)) { + StringWriter sw = new StringWriter(); + this.occurredException.printStackTrace(new PrintWriter(sw)); + + errorMessage = String.format("No exception expected, \"%s\" found. Caused by: %s", + this.occurredException.getClass().getName(), sw.toString()); + } - public void thenNoExceptionsHaveBeenThrown() { - assertFalse(this.hasNoSuchElementExceptionBeenThrown); - assertFalse(this.hasAGenericExecptionBeenThrown); - assertFalse(this.hasAnIllegalArgumentExceptionThrown); + assertNull(errorMessage, this.occurredException); } /*