summaryrefslogtreecommitdiff
path: root/app/src/test
diff options
context:
space:
mode:
Diffstat (limited to 'app/src/test')
-rw-r--r--app/src/test/java/se/leap/bitmaskclient/ProviderTest.java30
1 files changed, 30 insertions, 0 deletions
diff --git a/app/src/test/java/se/leap/bitmaskclient/ProviderTest.java b/app/src/test/java/se/leap/bitmaskclient/ProviderTest.java
index 794c3087..495d5b3f 100644
--- a/app/src/test/java/se/leap/bitmaskclient/ProviderTest.java
+++ b/app/src/test/java/se/leap/bitmaskclient/ProviderTest.java
@@ -1,9 +1,15 @@
package se.leap.bitmaskclient;
+import org.json.JSONException;
import org.junit.Test;
+import java.io.IOException;
+import java.util.HashSet;
+import java.util.Set;
+
import se.leap.bitmaskclient.testutils.TestSetupHelper;
+import static junit.framework.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
/**
@@ -18,4 +24,28 @@ public class ProviderTest {
assertTrue("Providers should be same:", p1.equals(p2));
}
+ @Test
+ public void testEquals_sameFields_returnsFalse() throws Exception {
+ Provider p1 = TestSetupHelper.getConfiguredProvider();
+ Provider p2 = TestSetupHelper.getConfiguredProvider();
+ p2.setMainUrl("http://somethingsdiffer.org");
+ assertFalse("Providers should be same:", p1.equals(p2));
+ }
+
+ // see ProviderManagerTest testing add(...)
+ @Test
+ public void testEqualsThroughSetContains_differentFields_returnsFalse() throws Exception {
+ Provider p1 = TestSetupHelper.getConfiguredProvider();
+ Provider p2 = TestSetupHelper.getConfiguredProvider();
+ p2.setMainUrl("http://somethingsdiffer.org");
+ Provider p3 = new Provider("https://anotherprovider.net");
+
+ Set<Provider> defaultProviders = new HashSet<>();
+ defaultProviders.add(p1);
+ defaultProviders.add(p2);
+
+ assertTrue(defaultProviders.contains(p1));
+ assertTrue(defaultProviders.contains(p2));
+ assertFalse(defaultProviders.contains(p3));
+ }
}