Code example for HashSet

Methods: add

0
 
        final MongoCredential credentials1 = MongoCredential.createMongoCRCredential("user", "db1", password);
        final MongoCredential credentials2 = MongoCredential.createMongoCRCredential("user", "db2", password);
        credentialsList = Arrays.asList(credentials1, credentials2);
        store = new MongoCredentialsStore(credentialsList);
        expected = new HashSet<String>();
        expected.add("db1");
        expected.add("db2");
        assertEquals(expected, store.getDatabases());
        assertEquals(credentials1, store.get("db1"));
        assertEquals(credentials2, store.get("db2"));
        assertNull(store.get("db3"));
        assertEquals(credentialsList, store.asList());
 
        credentialsList = Arrays.asList(credentials1, MongoCredential.createMongoCRCredential("user2", "db1", password));
        try { 
            new MongoCredentialsStore(credentialsList);
            fail("should throw");
        } catch (IllegalArgumentException e) {
            // expected 
        }