@Test public void testGetId() { BasicDBObject mongo = this.buildMongoBlacklist(); Blacklist list = new Blacklist(mongo); assertEquals(mongo.get("_id"), list.getId()); }
@Test public void testGetStreamRules() { BasicDBObject mongoList = this.buildMongoBlacklist(); BasicDBObject mongoRule1 = new BasicDBObject(); mongoRule1.put("_id", new ObjectId()); mongoRule1.put("blacklist_id", mongoList.get("_id")); mongoRule1.put("term", "^foo.+"); BasicDBObject mongoRule2 = new BasicDBObject(); mongoRule2.put("_id", new ObjectId()); mongoRule1.put("blacklist_id", mongoList.get("_id")); mongoRule2.put("term", ".+bar"); BasicDBList rules = new BasicDBList(); rules.add(mongoRule1); rules.add(mongoRule2); mongoList.put("blacklisted_terms", rules); Blacklist blacklist = new Blacklist(mongoList); assertEquals(2, blacklist.getRules().size()); assertEquals("^foo.+", blacklist.getRules().get(0).getTerm()); assertEquals(".+bar", blacklist.getRules().get(1).getTerm()); }
@Test public void testGetStreamRulesWithBlacklistThatHasNoRules() { BasicDBObject mongoList = this.buildMongoBlacklist(); mongoList.put("blacklisted_terms", null); Blacklist blacklist = new Blacklist(mongoList); assertEquals(0, blacklist.getRules().size()); // All is fine if there are no exceptions thrown and we get here. }
@Test public void testGetTitle() { Blacklist list = new Blacklist(this.buildMongoBlacklist()); assertEquals("foo", list.getTitle()); }