@Test public void testOnAdd() throws IvoryException, JAXBException { store.publish(EntityType.CLUSTER, cluster); Feed feed1 = (Feed) EntityType.FEED.getUnmarshaller().unmarshal( FeedGroupMapTest.class .getResourceAsStream("/config/feed/feed-0.1.xml")); feed1.setName("f1"); feed1.setGroups("group1,group2,group3"); Location location = new Location(); location.setPath("/projects/bi/rmc/daily/ad/${YEAR}/fraud/${MONTH}-${DAY}/ad"); location.setType(LocationType.DATA); feed1.setLocations(new Locations()); feed1.getLocations().getLocations().add(location); store.publish(EntityType.FEED, feed1); Map<String, FeedGroup> groupMapping = FeedGroupMap.get() .getGroupsMapping(); FeedGroup group = groupMapping.get("group1"); Assert.assertEquals(group.getName(), "group1"); Assert.assertEquals(group.getFeeds().size(), 1); assertFields(group, feed1); group = groupMapping.get("group2"); Assert.assertEquals(group.getName(), "group2"); Assert.assertEquals(group.getFeeds().size(), 1); assertFields(group, feed1); group = groupMapping.get("group3"); Assert.assertEquals(group.getName(), "group3"); Assert.assertEquals(group.getFeeds().size(), 1); assertFields(group, feed1); Feed feed2 = (Feed) EntityType.FEED.getUnmarshaller().unmarshal( FeedGroupMapTest.class .getResourceAsStream("/config/feed/feed-0.1.xml")); feed2.setName("f2"); feed2.setGroups("group1,group5,group3"); location.setPath("/projects/bi/rmc/daily/ad/${YEAR}/${MONTH}/${DAY}/ad2"); location.setType(LocationType.DATA); feed2.setLocations(new Locations()); feed2.getLocations().getLocations().add(location); store.publish(EntityType.FEED, feed2); groupMapping = FeedGroupMap.get().getGroupsMapping(); group = groupMapping.get("group1"); Assert.assertEquals(group.getName(), "group1"); Assert.assertEquals(group.getFeeds().size(), 2); assertFields(group, feed2); group = groupMapping.get("group2"); Assert.assertEquals(group.getName(), "group2"); Assert.assertEquals(group.getFeeds().size(), 1); assertFields(group, feed2); group = groupMapping.get("group3"); Assert.assertEquals(group.getName(), "group3"); Assert.assertEquals(group.getFeeds().size(), 2); assertFields(group, feed2); group = groupMapping.get("group5"); Assert.assertEquals(group.getName(), "group5"); Assert.assertEquals(group.getFeeds().size(), 1); assertFields(group, feed2); }
@Override public void onAdd(Entity entity) throws IvoryException { if (entity.getEntityType().equals(EntityType.FEED)) { Feed feed = (Feed) entity; if (feed.getGroups() == null || feed.getGroups().equals("")) { return; } Set<FeedGroup> groupSet = getGroups(feed); addGroups(feed.getName(), groupSet); } }
FeedGroupMap implements ConfigurationChangeListener { @Override public void onAdd(Entity entity) throws IvoryException { if (entity.getEntityType().equals(EntityType.FEED)) { Feed feed = (Feed) entity; if (feed.getGroups() == null || feed.getGroups().equals("")) { return; } Set<FeedGroup> groupSet = getGroups(feed); addGroups(feed.getName(), groupSet); } } }
FeedGroupMap implements ConfigurationChangeListener { @Override public void onAdd(Entity entity) throws IvoryException { if (entity.getEntityType().equals(EntityType.FEED)) { Feed feed = (Feed) entity; if (feed.getGroups() == null || feed.getGroups().equals("")) { return; } Set<FeedGroup> groupSet = getGroups(feed); addGroups(feed.getName(), groupSet); } } private  FeedGroupMap(); }
FeedGroupMap implements ConfigurationChangeListener { @Override public void onAdd(Entity entity) throws IvoryException { if (entity.getEntityType().equals(EntityType.FEED)) { Feed feed = (Feed) entity; if (feed.getGroups() == null || feed.getGroups().equals("")) { return; } Set<FeedGroup> groupSet = getGroups(feed); addGroups(feed.getName(), groupSet); } } private  FeedGroupMap(); static FeedGroupMap get(); Map<String, FeedGroup> getGroupsMapping(); @Override void onAdd(Entity entity); @Override void onRemove(Entity entity); @Override void onChange(Entity oldEntity, Entity newEntity); Set<FeedGroup> getGroups(String groups, Frequency frequency, String path); Set<FeedGroup> getGroups(org.apache.ivory.entity.v0.feed.Feed feed); }
FeedGroupMap implements ConfigurationChangeListener { @Override public void onAdd(Entity entity) throws IvoryException { if (entity.getEntityType().equals(EntityType.FEED)) { Feed feed = (Feed) entity; if (feed.getGroups() == null || feed.getGroups().equals("")) { return; } Set<FeedGroup> groupSet = getGroups(feed); addGroups(feed.getName(), groupSet); } } private  FeedGroupMap(); static FeedGroupMap get(); Map<String, FeedGroup> getGroupsMapping(); @Override void onAdd(Entity entity); @Override void onRemove(Entity entity); @Override void onChange(Entity oldEntity, Entity newEntity); Set<FeedGroup> getGroups(String groups, Frequency frequency, String path); Set<FeedGroup> getGroups(org.apache.ivory.entity.v0.feed.Feed feed);  }