use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class JcrPropertyTest method testMergeProps.
@Test
public void testMergeProps() {
testFeed();
Map<String, Object> props = new HashMap<>();
props.put("name", "An Old User");
props.put("age", 140);
Map<String, Object> props2 = metadata.commit(() -> {
List<? extends Feed> feeds = feedProvider.getFeeds();
Feed feed = null;
// grab the first feed
if (feeds != null) {
feed = feeds.get(0);
}
feedProvider.mergeFeedProperties(feed.getId(), props);
return feed.getProperties();
}, MetadataAccess.SERVICE);
props.put("address", "Some road");
props2 = metadata.commit(() -> {
List<? extends Feed> feeds = feedProvider.getFeeds();
Feed feed = null;
// grab the first feed
if (feeds != null) {
feed = feeds.get(0);
}
feedProvider.mergeFeedProperties(feed.getId(), props);
return feed.getProperties();
}, MetadataAccess.SERVICE);
org.junit.Assert.assertEquals("Some road", props2.get("address"));
// Now Replace
props.remove("address");
props2 = metadata.commit(() -> {
List<? extends Feed> feeds = feedProvider.getFeeds();
Feed feed = null;
// grab the first feed
if (feeds != null) {
feed = feeds.get(0);
}
feedProvider.replaceProperties(feed.getId(), props);
return feed.getProperties();
}, MetadataAccess.SERVICE);
Assert.assertNull(props2.get("address"));
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedManagerFeedTest method setupFeedAndTemplate.
private void setupFeedAndTemplate(String categorySystemName, String feedName, String templateName) {
// first create the category
metadata.commit(() -> {
Category category = feedTestUtil.findOrCreateCategory(categorySystemName);
return category.getId();
}, MetadataAccess.SERVICE);
// creqte the feed
metadata.commit(() -> {
Feed feed = feedTestUtil.findOrCreateFeed(categorySystemName, feedName, templateName);
return feed.getId();
}, MetadataAccess.SERVICE);
// ensure the feed relates to the template
metadata.read(() -> {
FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
List<Feed> feeds = template.getFeeds();
Assert.assertTrue(feeds != null && feeds.size() > 0);
}, MetadataAccess.SERVICE);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedManagerFeedTest method testLotsOfFeeds.
/**
* Test querying a large number of feeds
*/
@Test
public void testLotsOfFeeds() {
// increase to query more .. i.e. 1000
int numberOfFeeds = 5;
int numberOfFeedsPerCategory = 20;
String templateName = "my_template";
int categories = numberOfFeeds / numberOfFeedsPerCategory;
// create all the categories
metadata.commit(() -> {
for (int i = 1; i <= categories; i++) {
Category category = feedTestUtil.createCategory("category_" + i);
}
}, MetadataAccess.ADMIN);
metadata.commit(() -> {
FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
}, MetadataAccess.ADMIN);
// create the feeds
metadata.commit(() -> {
FeedManagerTemplate template = feedTestUtil.findOrCreateTemplate(templateName);
Category category = null;
int categoryNum = 0;
String categoryName = "category" + categoryNum;
for (int i = 0; i < numberOfFeeds; i++) {
if (i % numberOfFeedsPerCategory == 0) {
categoryNum++;
categoryName = "category_" + categoryNum;
category = feedTestUtil.findOrCreateCategory(categoryName);
}
Feed feed = feedTestUtil.findOrCreateFeed(category, "feed_" + i, template);
}
}, MetadataAccess.ADMIN);
// now query it
long time = System.currentTimeMillis();
Integer size = metadata.read(() -> {
List<Feed> feeds = feedProvider.findAll();
return feeds.size();
}, MetadataAccess.SERVICE);
long stopTime = System.currentTimeMillis();
log.info("Time to query {} feeds was {} ms", size, (stopTime - time));
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedTestUtil method findOrCreateFeed.
public Feed findOrCreateFeed(Category category, String feedSystemName, FeedManagerTemplate template) {
Feed feed = feedProvider.ensureFeed(category.getId(), feedSystemName);
feed.setDisplayName(feedSystemName);
feed.setTemplate(template);
feed.setJson(sampleFeedJson());
return feedProvider.update(feed);
}
use of com.thinkbiganalytics.metadata.api.feed.Feed in project kylo by Teradata.
the class FeedTestUtil method findOrCreateFeed.
public Feed findOrCreateFeed(String categorySystemName, String feedSystemName, String feedTemplate) {
Category category = findOrCreateCategory(categorySystemName);
Feed feed = feedProvider.ensureFeed(category.getId(), feedSystemName);
feed.setDisplayName(feedSystemName);
FeedManagerTemplate template = findOrCreateTemplate(feedTemplate);
feed.setTemplate(template);
return feedProvider.update(feed);
}
Aggregations