You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@streams.apache.org by sb...@apache.org on 2016/12/17 19:56:47 UTC
[2/4] incubator-streams git commit: Replace Guava API calls with Java
8 API
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterUrlApiProcessor.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterUrlApiProcessor.java b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterUrlApiProcessor.java
index 0dd43bb..c8d439d 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterUrlApiProcessor.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/processor/TwitterUrlApiProcessor.java
@@ -25,11 +25,12 @@ import org.apache.streams.core.StreamsProcessor;
import org.apache.streams.pojo.json.Activity;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Class gets a global share count from Twitter API for links on Activity datums.
@@ -72,7 +73,7 @@ public class TwitterUrlApiProcessor extends SimpleHTTPGetProcessor implements St
if ( activity.getLinks() != null && activity.getLinks().size() > 0) {
return super.process(entry);
} else {
- return Lists.newArrayList(entry);
+ return Stream.of(entry).collect(Collectors.toList());
}
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
index e3875d5..88642f8 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProvider.java
@@ -32,7 +32,6 @@ import org.apache.streams.twitter.converter.TwitterDateTimeFormat;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.google.common.base.Preconditions;
-import com.google.common.collect.Lists;
import com.google.common.util.concurrent.Futures;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.common.util.concurrent.ListeningExecutorService;
@@ -60,7 +59,6 @@ import java.io.Serializable;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Collection;
-import java.util.Iterator;
import java.util.List;
import java.util.Objects;
import java.util.Queue;
@@ -70,6 +68,8 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.locks.ReadWriteLock;
import java.util.concurrent.locks.ReentrantReadWriteLock;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static java.util.concurrent.Executors.newSingleThreadExecutor;
@@ -156,7 +156,7 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
TwitterUserInformationConfiguration config = new ComponentConfigurator<>(TwitterUserInformationConfiguration.class).detectConfiguration(typesafe, "twitter");
TwitterTimelineProvider provider = new TwitterTimelineProvider(config);
- ObjectMapper mapper = new StreamsJacksonMapper(Lists.newArrayList(TwitterDateTimeFormat.TWITTER_FORMAT));
+ ObjectMapper mapper = new StreamsJacksonMapper(Stream.of(TwitterDateTimeFormat.TWITTER_FORMAT).collect(Collectors.toList()));
PrintStream outStream = new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile)));
provider.prepare(config);
@@ -253,7 +253,7 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
private Collection<Long> retrieveIds(String[] screenNames) {
Twitter client = getTwitterClient();
- List<Long> ids = Lists.newArrayList();
+ List<Long> ids = new ArrayList<>();
try {
for (User twitterUser : client.lookupUsers(screenNames)) {
ids.add(twitterUser.getId());
@@ -313,8 +313,8 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
* account identifiers are converted to IDs (Longs) instead of screenNames (Strings).
*/
protected void consolidateToIDs() {
- List<String> screenNames = Lists.newArrayList();
- ids = Lists.newArrayList();
+ List<String> screenNames = new ArrayList<>();
+ ids = new ArrayList<>();
for (String account : config.getInfo()) {
try {
@@ -329,7 +329,7 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
}
// Twitter allows for batches up to 100 per request, but you cannot mix types
- screenNameBatches = new ArrayList<String[]>();
+ screenNameBatches = new ArrayList<>();
while (screenNames.size() >= 100) {
screenNameBatches.add(screenNames.subList(0, 100).toArray(new String[0]));
screenNames = screenNames.subList(100, screenNames.size());
@@ -339,10 +339,8 @@ public class TwitterTimelineProvider implements StreamsProvider, Serializable {
screenNameBatches.add(screenNames.toArray(new String[ids.size()]));
}
- Iterator<String[]> screenNameBatchIterator = screenNameBatches.iterator();
-
- while (screenNameBatchIterator.hasNext()) {
- Collection<Long> batchIds = retrieveIds(screenNameBatchIterator.next());
+ for (String[] screenNameBatche : screenNameBatches) {
+ Collection<Long> batchIds = retrieveIds(screenNameBatche);
ids.addAll(batchIds);
}
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
index dbf6ac9..67ccf0c 100644
--- a/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
+++ b/streams-contrib/streams-provider-twitter/src/main/java/org/apache/streams/twitter/provider/TwitterTimelineProviderTask.java
@@ -24,16 +24,16 @@ import org.apache.streams.twitter.converter.TwitterDateTimeFormat;
import org.apache.streams.util.ComponentUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import twitter4j.Paging;
import twitter4j.Status;
import twitter4j.Twitter;
-import twitter4j.TwitterException;
import twitter4j.TwitterObjectFactory;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Retrieve recent posts for a single user id.
@@ -42,7 +42,7 @@ public class TwitterTimelineProviderTask implements Runnable {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterTimelineProviderTask.class);
- private static ObjectMapper MAPPER = new StreamsJacksonMapper(Lists.newArrayList(TwitterDateTimeFormat.TWITTER_FORMAT));
+ private static ObjectMapper MAPPER = new StreamsJacksonMapper(Stream.of(TwitterDateTimeFormat.TWITTER_FORMAT).collect(Collectors.toList()));
protected TwitterTimelineProvider provider;
protected Twitter client;
@@ -102,8 +102,6 @@ public class TwitterTimelineProviderTask implements Runnable {
paging.setPage(paging.getPage() + 1);
keepTrying = 10;
- } catch (TwitterException twitterException) {
- keepTrying += TwitterErrorHandler.handleTwitterError(client, id, twitterException);
} catch (Exception ex) {
keepTrying += TwitterErrorHandler.handleTwitterError(client, id, ex);
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/data/TwitterObjectMapperIT.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/data/TwitterObjectMapperIT.java b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/data/TwitterObjectMapperIT.java
index e79dd6a..38b6373 100644
--- a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/data/TwitterObjectMapperIT.java
+++ b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/data/TwitterObjectMapperIT.java
@@ -27,10 +27,7 @@ import org.apache.streams.twitter.pojo.Tweet;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-import com.google.common.base.Optional;
-import com.google.common.collect.Lists;
import org.apache.commons.lang.StringUtils;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -39,6 +36,9 @@ import org.testng.annotations.Test;
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
+import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
import static org.apache.streams.twitter.converter.TwitterDateTimeFormat.TWITTER_FORMAT;
import static org.hamcrest.CoreMatchers.is;
@@ -54,7 +54,7 @@ public class TwitterObjectMapperIT {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterObjectMapperIT.class);
- private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Lists.newArrayList(TWITTER_FORMAT));
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Stream.of(TWITTER_FORMAT).collect(Collectors.toList()));
@Test
public void tests() {
@@ -92,7 +92,7 @@ public class TwitterObjectMapperIT {
assertThat(tweet.getText(), is(not(nullValue())));
assertThat(tweet.getUser(), is(not(nullValue())));
- tweetlinks += Optional.fromNullable(tweet.getEntities().getUrls().size()).or(0);
+ tweetlinks += Optional.ofNullable(tweet.getEntities().getUrls().size()).orElse(0);
} else if ( detected == Retweet.class ) {
@@ -105,7 +105,7 @@ public class TwitterObjectMapperIT {
assertThat(retweet.getRetweetedStatus().getUser().getId(), is(not(nullValue())));
assertThat(retweet.getRetweetedStatus().getUser().getCreatedAt(), is(not(nullValue())));
- retweetlinks += Optional.fromNullable(retweet.getRetweetedStatus().getEntities().getUrls().size()).or(0);
+ retweetlinks += Optional.ofNullable(retweet.getRetweetedStatus().getEntities().getUrls().size()).orElse(0);
} else if ( detected == Delete.class ) {
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityConvertersTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityConvertersTest.java b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityConvertersTest.java
index 24d646b..7bfb8ce 100644
--- a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityConvertersTest.java
+++ b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityConvertersTest.java
@@ -29,13 +29,14 @@ import org.apache.streams.twitter.pojo.Retweet;
import org.apache.streams.twitter.pojo.Tweet;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests {org.apache.streams.twitter.converter.*}
@@ -44,7 +45,7 @@ public class TwitterActivityConvertersTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterActivityConvertersTest.class);
- private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Lists.newArrayList(TwitterDateTimeFormat.TWITTER_FORMAT));
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Stream.of(TwitterDateTimeFormat.TWITTER_FORMAT).collect(Collectors.toList()));
private ActivityConverterUtil activityConverterUtil = ActivityConverterUtil.getInstance();
@@ -66,7 +67,7 @@ public class TwitterActivityConvertersTest {
public void testConvertRetweet() throws Exception {
Retweet retweet = mapper.readValue(retweetJson, Retweet.class);
List<Activity> activityList = activityConverterUtil.convert(retweet);
- Assert.assertTrue(activityList.size() == 1);
+ Assert.assertEquals(activityList.size(), 1);
Activity activity = activityList.get(0);
if ( !ActivityUtil.isValid(activity) ) {
Assert.fail();
@@ -77,7 +78,7 @@ public class TwitterActivityConvertersTest {
public void testConvertDelete() throws Exception {
Delete delete = mapper.readValue(retweetJson, Delete.class);
List<Activity> activityList = activityConverterUtil.convert(delete);
- Assert.assertTrue(activityList.size() == 1);
+ Assert.assertEquals(activityList.size(), 1);
Activity activity = activityList.get(0);
if ( !ActivityUtil.isValid(activity) ) {
Assert.fail();
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityObjectsConvertersTest.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityObjectsConvertersTest.java b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityObjectsConvertersTest.java
index 4f2a4fd..6528441 100644
--- a/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityObjectsConvertersTest.java
+++ b/streams-contrib/streams-provider-twitter/src/test/java/org/apache/streams/twitter/test/utils/TwitterActivityObjectsConvertersTest.java
@@ -29,12 +29,14 @@ import org.apache.streams.twitter.converter.TwitterJsonUserActivityObjectConvert
import org.apache.streams.twitter.pojo.User;
import com.fasterxml.jackson.databind.ObjectMapper;
-import com.google.common.collect.Lists;
import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
+
/**
* Tests {org.apache.streams.twitter.converter.*}
*/
@@ -42,12 +44,13 @@ public class TwitterActivityObjectsConvertersTest {
private static final Logger LOGGER = LoggerFactory.getLogger(TwitterActivityObjectsConvertersTest.class);
- private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Lists.newArrayList(TwitterDateTimeFormat.TWITTER_FORMAT));
+ private ObjectMapper mapper = StreamsJacksonMapper.getInstance(Stream.of(TwitterDateTimeFormat.TWITTER_FORMAT)
+ .collect(Collectors.toList()));
private ActivityObjectConverterProcessorConfiguration activityObjectConverterProcessorConfiguration =
new ActivityObjectConverterProcessorConfiguration()
- .withClassifiers(Lists.newArrayList(new TwitterDocumentClassifier()))
- .withConverters(Lists.newArrayList(new TwitterJsonUserActivityObjectConverter()));
+ .withClassifiers(Stream.of(new TwitterDocumentClassifier()).collect(Collectors.toList()))
+ .withConverters(Stream.of(new TwitterJsonUserActivityObjectConverter()).collect(Collectors.toList()));
private ActivityObjectConverterUtil activityObjectConverterUtil = ActivityObjectConverterUtil.getInstance(activityObjectConverterProcessorConfiguration);
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/provider/YoutubeUserActivityCollector.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/provider/YoutubeUserActivityCollector.java b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/provider/YoutubeUserActivityCollector.java
index 9975dd9..518a762 100644
--- a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/provider/YoutubeUserActivityCollector.java
+++ b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/provider/YoutubeUserActivityCollector.java
@@ -28,7 +28,6 @@ import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.module.SimpleModule;
import com.google.api.client.googleapis.json.GoogleJsonResponseException;
-import com.google.api.client.util.Lists;
import com.google.api.services.youtube.YouTube;
import com.google.api.services.youtube.model.ActivityListResponse;
import com.google.api.services.youtube.model.Video;
@@ -40,6 +39,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.IOException;
+import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.BlockingQueue;
@@ -157,7 +157,7 @@ public class YoutubeUserActivityCollector extends YoutubeDataCollector {
void processActivityFeed(ActivityListResponse feed, DateTime afterDate, DateTime beforeDate) throws IOException, InterruptedException {
for (com.google.api.services.youtube.model.Activity activity : feed.getItems()) {
try {
- List<Video> videos = Lists.newArrayList();
+ List<Video> videos = new ArrayList<>();
if (activity.getContentDetails().getUpload() != null) {
videos.addAll(getVideoList(activity.getContentDetails().getUpload().getVideoId()));
@@ -217,7 +217,7 @@ public class YoutubeUserActivityCollector extends YoutubeDataCollector {
if (videosListResponse.getItems().size() == 0) {
LOGGER.debug("No Youtube videos found for videoId: {}", videoId);
- return Lists.newArrayList();
+ return new ArrayList<>();
}
return videosListResponse.getItems();
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
----------------------------------------------------------------------
diff --git a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
index 40a4495..32a011f 100644
--- a/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
+++ b/streams-contrib/streams-provider-youtube/src/main/java/com/youtube/serializer/YoutubeActivityUtil.java
@@ -31,14 +31,16 @@ import com.google.api.services.youtube.model.Channel;
import com.google.api.services.youtube.model.Thumbnail;
import com.google.api.services.youtube.model.ThumbnailDetails;
import com.google.api.services.youtube.model.Video;
-import com.google.common.collect.Lists;
import org.joda.time.DateTime;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Optional;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class YoutubeActivityUtil {
@@ -192,6 +194,7 @@ public class YoutubeActivityUtil {
* @return a valid Activity ID in format "id:youtube:part1:part2:...partN"
*/
public static String formatId(String... idparts) {
- return String.join(":", Lists.asList("id:youtube", idparts));
+ return String.join(":",
+ Stream.concat(Arrays.stream(new String[]{"id:youtube"}), Arrays.stream(idparts)).collect(Collectors.toList()));
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-monitoring/src/main/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersister.java
----------------------------------------------------------------------
diff --git a/streams-monitoring/src/main/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersister.java b/streams-monitoring/src/main/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersister.java
index 1466f31..cf95f7e 100644
--- a/streams-monitoring/src/main/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersister.java
+++ b/streams-monitoring/src/main/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersister.java
@@ -20,7 +20,6 @@ package org.apache.streams.monitoring.persist.impl;
import org.apache.streams.monitoring.persist.MessagePersister;
-import com.google.common.collect.Lists;
import org.apache.http.HttpResponse;
import org.apache.http.NameValuePair;
import org.apache.http.client.HttpClient;
@@ -31,6 +30,7 @@ import org.apache.http.message.BasicNameValuePair;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import java.util.ArrayList;
import java.util.List;
public class BroadcastMessagePersister implements MessagePersister {
@@ -43,7 +43,7 @@ public class BroadcastMessagePersister implements MessagePersister {
}
@Override
- /**
+ /*
* Given a list of messages as Strings, broadcast them to the broadcastUri
* (if one is defined)
* @param messages
@@ -59,7 +59,7 @@ public class BroadcastMessagePersister implements MessagePersister {
post.setHeader("User-Agent", "Streams");
- List<NameValuePair> urlParameters = Lists.newArrayList();
+ List<NameValuePair> urlParameters = new ArrayList<>();
urlParameters.add(new BasicNameValuePair("messages", serializeMessages(messages)));
post.setEntity(new UrlEncodedFormEntity(urlParameters, "UTF-8"));
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersisterTest.java
----------------------------------------------------------------------
diff --git a/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersisterTest.java b/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersisterTest.java
index fc2ff71..7cc43d5 100644
--- a/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersisterTest.java
+++ b/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/BroadcastMessagePersisterTest.java
@@ -18,9 +18,9 @@
package org.apache.streams.monitoring.persist.impl;
-import com.google.common.collect.Lists;
import org.junit.Test;
+import java.util.ArrayList;
import java.util.List;
import static org.junit.Assert.assertEquals;
@@ -33,7 +33,7 @@ public class BroadcastMessagePersisterTest {
public void testFailedPersist() {
BroadcastMessagePersister persister = new BroadcastMessagePersister("http://fake.url.com/fake_endpointasdfasdfas");
- List<String> messages = Lists.newArrayList();
+ List<String> messages = new ArrayList<>();
for (int x = 0; x < 10; x++) {
messages.add("Fake_message #" + x);
}
@@ -48,7 +48,7 @@ public class BroadcastMessagePersisterTest {
public void testInvalidUrl() {
BroadcastMessagePersister persister = new BroadcastMessagePersister("h");
- List<String> messages = Lists.newArrayList();
+ List<String> messages = new ArrayList<>();
for (int x = 0; x < 10; x++) {
messages.add("Fake_message #" + x);
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/LogstashUdpMessagePersisterTest.java
----------------------------------------------------------------------
diff --git a/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/LogstashUdpMessagePersisterTest.java b/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/LogstashUdpMessagePersisterTest.java
index c85ff90..26076d9 100644
--- a/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/LogstashUdpMessagePersisterTest.java
+++ b/streams-monitoring/src/test/java/org/apache/streams/monitoring/persist/impl/LogstashUdpMessagePersisterTest.java
@@ -18,8 +18,7 @@
package org.apache.streams.monitoring.persist.impl;
-import com.google.common.base.Splitter;
-import com.google.common.collect.Lists;
+import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.slf4j.Logger;
@@ -30,9 +29,8 @@ import java.net.DatagramSocket;
import java.net.SocketException;
import java.util.ArrayList;
import java.util.List;
-
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
public class LogstashUdpMessagePersisterTest {
@@ -69,9 +67,9 @@ public class LogstashUdpMessagePersisterTest {
try {
socket.receive(messageDatagram);
- assertNotNull(messageDatagram);
- List<String> messages = Lists.newArrayList(Splitter.on('\n').split(new String(messageDatagram.getData())));
- assertEquals(messageArray, messages.subList(0,10));
+ Assert.assertNotNull(messageDatagram);
+ List<String> messages = Stream.of((new String(messageDatagram.getData())).split("\n")).collect(Collectors.toList());
+ Assert.assertEquals(messageArray, messages.subList(0,10));
} catch (IOException ex) {
LOGGER.error("Metrics Broadcast Test Failed: " + ex.getMessage());
}
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-cassandra/pom.xml
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-cassandra/pom.xml b/streams-plugins/streams-plugin-cassandra/pom.xml
index 9d94ec5..9316bc3 100644
--- a/streams-plugins/streams-plugin-cassandra/pom.xml
+++ b/streams-plugins/streams-plugin-cassandra/pom.xml
@@ -20,7 +20,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.streams.plugins</groupId>
<artifactId>streams-plugin-cassandra</artifactId>
<version>0.5-incubating-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -66,10 +65,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorCLITest.java
index 63afc2d..4c79cd0 100644
--- a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorCLITest.java
@@ -21,18 +21,15 @@ package org.apache.streams.plugins.cassandra.test;
import org.apache.streams.plugins.cassandra.StreamsCassandraResourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
+import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.cassandra.test.StreamsCassandraResourceGeneratorTest.cqlFilter;
/**
* Test that StreamsCassandraResourceGeneratorCLI generates resources.
@@ -45,28 +42,23 @@ public class StreamsCassandraResourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-resources/test-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsCassandraResourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsCassandraResourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File( targetDirectory );
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(cqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 1 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsCassandraResourceGeneratorTest.cqlFilter, true);
+ Assert.assertEquals(outputCollection.size(), 1);
Path path = Paths.get(testOutput.getAbsolutePath()).resolve("types.cql");
- assert ( path.toFile().exists() );
-
- String typesCqlBytes = new String(
- java.nio.file.Files.readAllBytes(path));
+ Assert.assertTrue(path.toFile().exists());
- assert ( StringUtils.countMatches(typesCqlBytes, "CREATE TYPE") == 133 );
+ String typesCqlBytes = new String(java.nio.file.Files.readAllBytes(path));
+ Assert.assertEquals(StringUtils.countMatches(typesCqlBytes, "CREATE TYPE"), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java
index d470450..d35a0d3 100644
--- a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java
+++ b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorMojoIT.java
@@ -19,13 +19,10 @@
package org.apache.streams.plugins.cassandra.test;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -37,8 +34,8 @@ import java.nio.file.Paths;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-
-import static org.apache.streams.plugins.cassandra.test.StreamsCassandraResourceGeneratorTest.cqlFilter;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests that streams-plugin-cassandra running via maven generates cql resources.
@@ -56,12 +53,12 @@ public class StreamsCassandraResourceGeneratorMojoIT {
verifier = new Verifier( testDir.getAbsolutePath() );
- List cliOptions = new ArrayList<>();
+ List<String> cliOptions = new ArrayList<>();
cliOptions.add( "-N" );
- verifier.executeGoals( Lists.newArrayList(
+ verifier.executeGoals(Stream.of(
"clean",
"dependency:unpack-dependencies",
- "generate-resources"));
+ "generate-resources").collect(Collectors.toList()));
verifier.verifyErrorFreeLog();
@@ -75,19 +72,16 @@ public class StreamsCassandraResourceGeneratorMojoIT {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(cqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 1 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsCassandraResourceGeneratorTest.cqlFilter, true);
+ Assert.assertEquals(outputCollection.size(), 1);
Path path = testOutputPath.resolve("types.cql");
- assert ( path.toFile().exists() );
+ Assert.assertTrue(path.toFile().exists());
- String typesCqlBytes = new String(
- java.nio.file.Files.readAllBytes(path));
+ String typesCqlBytes = new String(java.nio.file.Files.readAllBytes(path));
- assert ( StringUtils.countMatches(typesCqlBytes, "CREATE TYPE") == 133 );
+ Assert.assertEquals(StringUtils.countMatches(typesCqlBytes, "CREATE TYPE"), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorTest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorTest.java b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorTest.java
index 210831f..19b0bb2 100644
--- a/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorTest.java
+++ b/streams-plugins/streams-plugin-cassandra/src/test/java/org/apache/streams/plugins/cassandra/test/StreamsCassandraResourceGeneratorTest.java
@@ -22,11 +22,9 @@ package org.apache.streams.plugins.cassandra.test;
import org.apache.streams.plugins.cassandra.StreamsCassandraGenerationConfig;
import org.apache.streams.plugins.cassandra.StreamsCassandraResourceGenerator;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.apache.commons.lang3.StringUtils;
+import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -35,7 +33,8 @@ import java.io.File;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Collection;
-import javax.annotation.Nullable;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Test that cassandra resources are generated.
@@ -44,16 +43,7 @@ public class StreamsCassandraResourceGeneratorTest {
private static final Logger LOGGER = LoggerFactory.getLogger(StreamsCassandraResourceGeneratorTest.class);
- public static final Predicate<File> cqlFilter = new Predicate<File>() {
- @Override
- public boolean apply(@Nullable File file) {
- if ( file.getName().endsWith(".cql") ) {
- return true;
- } else {
- return false;
- }
- }
- };
+ public static final String[] cqlFilter = new String[]{"cql"};
/**
* Test that cassandra resources are generated.
@@ -71,7 +61,7 @@ public class StreamsCassandraResourceGeneratorTest {
config.setTargetDirectory("target/generated-resources/cassandra");
- config.setExclusions(Sets.newHashSet("attachments"));
+ config.setExclusions(Stream.of("attachments").collect(Collectors.toSet()));
config.setMaxDepth(2);
@@ -80,23 +70,20 @@ public class StreamsCassandraResourceGeneratorTest {
File testOutput = config.getTargetDirectory();
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(cqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 1 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, cqlFilter, true);
+ Assert.assertEquals(outputCollection.size(), 1);
Path path = Paths.get(testOutput.getAbsolutePath()).resolve("types.cql");
- assert ( path.toFile().exists() );
+ Assert.assertTrue(path.toFile().exists());
- String typesCqlBytes = new String(
- java.nio.file.Files.readAllBytes(path));
+ String typesCqlBytes = new String(java.nio.file.Files.readAllBytes(path));
- assert ( StringUtils.countMatches(typesCqlBytes, "CREATE TYPE") == 133 );
+ Assert.assertEquals(StringUtils.countMatches(typesCqlBytes, "CREATE TYPE"), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-elasticsearch/pom.xml
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-elasticsearch/pom.xml b/streams-plugins/streams-plugin-elasticsearch/pom.xml
index d79f92c..30d7973 100644
--- a/streams-plugins/streams-plugin-elasticsearch/pom.xml
+++ b/streams-plugins/streams-plugin-elasticsearch/pom.xml
@@ -20,7 +20,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.streams.plugins</groupId>
<artifactId>streams-plugin-elasticsearch</artifactId>
<version>0.5-incubating-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -67,10 +66,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorCLITest.java
index 887461c..a2cddbb 100644
--- a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorCLITest.java
@@ -21,15 +21,12 @@ package org.apache.streams.plugins.elasticsearch.test;
import org.apache.streams.plugins.elasticsearch.StreamsElasticsearchResourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.elasticsearch.test.StreamsElasticsearchResourceGeneratorTest.jsonFilter;
/**
* Test that StreamsElasticsearchResourceGeneratorCLI generates resources.
@@ -42,18 +39,15 @@ public class StreamsElasticsearchResourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-resources/elasticsearch-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsElasticsearchResourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsElasticsearchResourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File(targetDirectory);
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(jsonFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsElasticsearchResourceGeneratorTest.jsonFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java
index 47b8530..3b24d09 100644
--- a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java
+++ b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorMojoIT.java
@@ -19,11 +19,8 @@
package org.apache.streams.plugins.elasticsearch.test;
-import com.google.common.collect.Lists;
-
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.annotations.Test;
@@ -31,6 +28,8 @@ import org.testng.annotations.Test;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests that streams-plugin-elasticsearch running via maven generates elasticsearch mapping resources.
@@ -48,12 +47,12 @@ public class StreamsElasticsearchResourceGeneratorMojoIT {
verifier = new Verifier( testDir.getAbsolutePath() );
- List cliOptions = new ArrayList<>();
+ List<String> cliOptions = new ArrayList<>();
cliOptions.add( "-N" );
- verifier.executeGoals( Lists.newArrayList(
+ verifier.executeGoals(Stream.of(
"clean",
"dependency:unpack-dependencies",
- "generate-resources"));
+ "generate-resources").collect(Collectors.toList()));
verifier.verifyErrorFreeLog();
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorTest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorTest.java b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorTest.java
index 4322b11..3950aa5 100644
--- a/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorTest.java
+++ b/streams-plugins/streams-plugin-elasticsearch/src/test/java/org/apache/streams/plugins/elasticsearch/test/StreamsElasticsearchResourceGeneratorTest.java
@@ -22,10 +22,6 @@ package org.apache.streams.plugins.elasticsearch.test;
import org.apache.streams.plugins.elasticsearch.StreamsElasticsearchGenerationConfig;
import org.apache.streams.plugins.elasticsearch.StreamsElasticsearchResourceGenerator;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -34,10 +30,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Collection;
-import java.util.Iterator;
-import javax.annotation.Nullable;
-
-import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Test that Elasticsearch resources are generated.
@@ -46,16 +40,7 @@ public class StreamsElasticsearchResourceGeneratorTest {
private static final Logger LOGGER = LoggerFactory.getLogger(StreamsElasticsearchResourceGeneratorTest.class);
- public static final Predicate<File> jsonFilter = new Predicate<File>() {
- @Override
- public boolean apply(@Nullable File file) {
- if ( file.getName().endsWith(".json") ) {
- return true;
- } else {
- return false;
- }
- }
- };
+ public static final String[] jsonFilter = new String[]{"json"};
/**
* Test that Elasticsearch resources are generated.
@@ -73,7 +58,7 @@ public class StreamsElasticsearchResourceGeneratorTest {
config.setTargetDirectory("target/generated-resources/elasticsearch");
- config.setExclusions(Sets.newHashSet("attachments"));
+ config.setExclusions(Stream.of("attachments").collect(Collectors.toSet()));
config.setMaxDepth(2);
@@ -82,53 +67,11 @@ public class StreamsElasticsearchResourceGeneratorTest {
File testOutput = config.getTargetDirectory();
- Predicate<File> jsonFilter = new Predicate<File>() {
- @Override
- public boolean apply(@Nullable File file) {
- if ( file.getName().endsWith(".json") ) {
- return true;
- } else {
- return false;
- }
- }
- };
-
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
-
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(jsonFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
-
- String expectedDirectory = "target/test-classes/expected";
- File testExpected = new File( expectedDirectory );
-
- Iterable<File> expectedIterator = Files.fileTreeTraverser().breadthFirstTraversal(testExpected)
- .filter(jsonFilter);
- Collection<File> expectedCollection = Lists.newArrayList(expectedIterator);
-
- int fails = 0;
-
- Iterator<File> iterator = expectedCollection.iterator();
- while ( iterator.hasNext() ) {
- File objectExpected = iterator.next();
- String expectedEnd = dropSourcePathPrefix(objectExpected.getAbsolutePath(), expectedDirectory);
- File objectActual = new File(config.getTargetDirectory() + "/" + expectedEnd);
- LOGGER.info("Comparing: {} and {}", objectExpected.getAbsolutePath(), objectActual.getAbsolutePath());
- assert ( objectActual.exists());
- if ( FileUtils.contentEquals(objectActual, objectExpected) == true ) {
- LOGGER.info("Exact Match!");
- } else {
- LOGGER.info("No Match!");
- fails++;
- }
- }
- if ( fails > 0 ) {
- LOGGER.info("Fails: {}", fails);
- Assert.fail();
- }
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, jsonFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hbase/pom.xml
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hbase/pom.xml b/streams-plugins/streams-plugin-hbase/pom.xml
index b43a032..89c5f6c 100644
--- a/streams-plugins/streams-plugin-hbase/pom.xml
+++ b/streams-plugins/streams-plugin-hbase/pom.xml
@@ -20,7 +20,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.streams.plugins</groupId>
<artifactId>streams-plugin-hbase</artifactId>
<version>0.5-incubating-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -66,10 +65,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java
index d939372..e4c8943 100644
--- a/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java
+++ b/streams-plugins/streams-plugin-hbase/src/main/java/org/apache/streams/plugins/hbase/StreamsHbaseGenerationConfig.java
@@ -48,7 +48,7 @@ public class StreamsHbaseGenerationConfig extends DefaultGenerationConfig implem
private String columnFamily;
private String sourceDirectory;
- private List<String> sourcePaths = new ArrayList<String>();
+ private List<String> sourcePaths = new ArrayList<>();
private String targetDirectory;
private int maxDepth = 1;
@@ -60,7 +60,7 @@ public class StreamsHbaseGenerationConfig extends DefaultGenerationConfig implem
this.exclusions = exclusions;
}
- private Set<String> exclusions = new HashSet<String>();
+ private Set<String> exclusions = new HashSet<>();
public int getMaxDepth() {
return maxDepth;
@@ -90,7 +90,7 @@ public class StreamsHbaseGenerationConfig extends DefaultGenerationConfig implem
if (null != sourceDirectory) {
return Collections.singleton(URLUtil.parseURL(sourceDirectory)).iterator();
}
- List<URL> sourceUrls = new ArrayList<URL>();
+ List<URL> sourceUrls = new ArrayList<>();
if ( sourcePaths != null && sourcePaths.size() > 0) {
for (String source : sourcePaths) {
sourceUrls.add(URLUtil.parseURL(source));
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java
index 55c4b7a..fde1ded 100644
--- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorCLITest.java
@@ -21,16 +21,12 @@ package org.apache.streams.plugins.test;
import org.apache.streams.plugins.hbase.StreamsHbaseResourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
import java.io.File;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.test.StreamsHbaseResourceGeneratorTest.txtFilter;
/**
* Test that StreamsHbaseResourceGeneratorCLI generates resources.
@@ -43,8 +39,7 @@ public class StreamsHbaseResourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-resources/hbase-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsHbaseResourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsHbaseResourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File(targetDirectory);
@@ -52,9 +47,7 @@ public class StreamsHbaseResourceGeneratorCLITest {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(txtFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsHbaseResourceGeneratorTest.txtFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java
index 27af98d..82d9991 100644
--- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java
+++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorMojoIT.java
@@ -19,11 +19,9 @@
package org.apache.streams.plugins.test;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -33,8 +31,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-
-import static org.apache.streams.plugins.test.StreamsHbaseResourceGeneratorTest.txtFilter;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests that streams-plugin-hbase running via maven generates txt resources.
@@ -52,12 +50,12 @@ public class StreamsHbaseResourceGeneratorMojoIT {
verifier = new Verifier( testDir.getAbsolutePath() );
- List cliOptions = new ArrayList<>();
+ List<String> cliOptions = new ArrayList<>();
cliOptions.add( "-N" );
- verifier.executeGoals( Lists.newArrayList(
+ verifier.executeGoals(Stream.of(
"clean",
"dependency:unpack-dependencies",
- "generate-resources"));
+ "generate-resources").collect(Collectors.toList()));
verifier.verifyErrorFreeLog();
@@ -69,8 +67,7 @@ public class StreamsHbaseResourceGeneratorMojoIT {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput).filter(txtFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsHbaseResourceGeneratorTest.txtFilter, true);
Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java
index 2dd9dd5..13fdfb3 100644
--- a/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java
+++ b/streams-plugins/streams-plugin-hbase/src/test/java/org/apache/streams/plugins/test/StreamsHbaseResourceGeneratorTest.java
@@ -22,10 +22,6 @@ package org.apache.streams.plugins.test;
import org.apache.streams.plugins.hbase.StreamsHbaseGenerationConfig;
import org.apache.streams.plugins.hbase.StreamsHbaseResourceGenerator;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
import org.apache.commons.io.FileUtils;
import org.junit.Assert;
import org.junit.Test;
@@ -34,8 +30,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Collection;
-
-import static org.apache.streams.util.schema.FileUtil.dropSourcePathPrefix;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Test that Activity beans are compatible with the example activities in the spec.
@@ -44,7 +40,7 @@ public class StreamsHbaseResourceGeneratorTest {
private static final Logger LOGGER = LoggerFactory.getLogger(StreamsHbaseResourceGeneratorTest.class);
- public static final Predicate<File> txtFilter = file -> file.getName().endsWith(".txt");
+ public static final String[] txtFilter = new String[]{"txt"};
/**
* Tests that all example activities can be loaded into Activity beans.
@@ -62,7 +58,7 @@ public class StreamsHbaseResourceGeneratorTest {
config.setTargetDirectory("target/generated-resources/hbase");
- config.setExclusions(Sets.newHashSet("attachments"));
+ config.setExclusions(Stream.of("attachments").collect(Collectors.toSet()));
config.setColumnFamily("cf");
config.setMaxDepth(2);
@@ -76,36 +72,7 @@ public class StreamsHbaseResourceGeneratorTest {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(txtFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
-
- String expectedDirectory = "target/test-classes/expected";
- File testExpected = new File( expectedDirectory );
-
- Iterable<File> expectedIterator = Files.fileTreeTraverser().breadthFirstTraversal(testExpected)
- .filter(txtFilter);
- Collection<File> expectedCollection = Lists.newArrayList(expectedIterator);
-
- int fails = 0;
-
- for (File objectExpected : expectedCollection) {
- String expectedEnd = dropSourcePathPrefix(objectExpected.getAbsolutePath(), expectedDirectory);
- File objectActual = new File(config.getTargetDirectory() + "/" + expectedEnd);
- LOGGER.info("Comparing: {} and {}", objectExpected.getAbsolutePath(), objectActual.getAbsolutePath());
- assert (objectActual.exists());
- if (FileUtils.contentEquals(objectActual, objectExpected)) {
- LOGGER.info("Exact Match!");
- } else {
- LOGGER.info("No Match!");
- fails++;
- }
- }
- if ( fails > 0 ) {
- LOGGER.info("Fails: {}", fails);
- Assert.fail();
- }
-
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, txtFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hive/pom.xml
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hive/pom.xml b/streams-plugins/streams-plugin-hive/pom.xml
index 98f1eb8..133f30f 100644
--- a/streams-plugins/streams-plugin-hive/pom.xml
+++ b/streams-plugins/streams-plugin-hive/pom.xml
@@ -20,7 +20,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.streams.plugins</groupId>
<artifactId>streams-plugin-hive</artifactId>
<version>0.5-incubating-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -66,10 +65,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java
index 827a992..7031047 100644
--- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorCLITest.java
@@ -21,15 +21,12 @@ package org.apache.streams.plugins.test;
import org.apache.streams.plugins.hive.StreamsHiveResourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.junit.Test;
+import org.testng.Assert;
import java.io.File;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.test.StreamsHiveResourceGeneratorTest.hqlFilter;
/**
* Test whether StreamsHiveResourceGeneratorCLI generates resources.
@@ -42,18 +39,15 @@ public class StreamsHiveResourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-resources/hive-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsHiveResourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsHiveResourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File(targetDirectory);
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(hqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
+ Collection<File> testOutputFiles = FileUtils.listFiles(testOutput, StreamsHiveResourceGeneratorTest.hqlFilter, true);
+ Assert.assertEquals(testOutputFiles.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java
index 1032752..f174e28 100644
--- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java
+++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorMojoIT.java
@@ -19,12 +19,9 @@
package org.apache.streams.plugins.test;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-
+import org.apache.commons.io.FileUtils;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -34,8 +31,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-
-import static org.apache.streams.plugins.test.StreamsHiveResourceGeneratorTest.hqlFilter;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests that streams-plugin-hive running via maven generates txt resources.
@@ -53,12 +50,12 @@ public class StreamsHiveResourceGeneratorMojoIT {
verifier = new Verifier( testDir.getAbsolutePath() );
- List cliOptions = new ArrayList<>();
+ List<String> cliOptions = new ArrayList<>();
cliOptions.add( "-N" );
- verifier.executeGoals( Lists.newArrayList(
+ verifier.executeGoals(Stream.of(
"clean",
"dependency:unpack-dependencies",
- "generate-resources"));
+ "generate-resources").collect(Collectors.toList()));
verifier.verifyErrorFreeLog();
@@ -70,9 +67,7 @@ public class StreamsHiveResourceGeneratorMojoIT {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(hqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsHiveResourceGeneratorTest.hqlFilter, true);
Assert.assertEquals (outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java
index a5374a0..9bd6107 100644
--- a/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java
+++ b/streams-plugins/streams-plugin-hive/src/test/java/org/apache/streams/plugins/test/StreamsHiveResourceGeneratorTest.java
@@ -22,10 +22,8 @@ package org.apache.streams.plugins.test;
import org.apache.streams.plugins.hive.StreamsHiveGenerationConfig;
import org.apache.streams.plugins.hive.StreamsHiveResourceGenerator;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
import org.junit.Ignore;
import org.junit.Test;
import org.slf4j.Logger;
@@ -33,7 +31,8 @@ import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Collection;
-import javax.annotation.Nullable;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Test that Activity beans are compatible with the example activities in the spec.
@@ -43,16 +42,7 @@ public class StreamsHiveResourceGeneratorTest {
private static final Logger LOGGER = LoggerFactory.getLogger(StreamsHiveResourceGeneratorTest.class);
- public static final Predicate<File> hqlFilter = new Predicate<File>() {
- @Override
- public boolean apply(@Nullable File file) {
- if ( file.getName().endsWith(".hql") ) {
- return true;
- } else {
- return false;
- }
- }
- };
+ public static final String[] hqlFilter = new String[]{"hql"};
/**
* Tests that all example activities can be loaded into Activity beans.
@@ -70,7 +60,7 @@ public class StreamsHiveResourceGeneratorTest {
config.setTargetDirectory("target/generated-resources/test");
- config.setExclusions(Sets.newHashSet("attachments"));
+ config.setExclusions(Stream.of("attachments").collect(Collectors.toSet()));
config.setMaxDepth(2);
@@ -79,43 +69,11 @@ public class StreamsHiveResourceGeneratorTest {
File testOutput = config.getTargetDirectory();
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
-
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(hqlFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
-
- /* TODO: figure out how to compare without AL header interfering
- String expectedDirectory = "target/test-classes/expected";
- File testExpected = new File( expectedDirectory );
-
- Iterable<File> expectedIterator = Files.fileTreeTraverser().breadthFirstTraversal(testExpected)
- .filter(hqlFilter);
- Collection<File> expectedCollection = Lists.newArrayList(expectedIterator);
-
- int fails = 0;
-
- Iterator<File> iterator = expectedCollection.iterator();
- while( iterator.hasNext() ) {
- File objectExpected = iterator.next();
- String expectedEnd = dropSourcePathPrefix(objectExpected.getAbsolutePath(), expectedDirectory);
- File objectActual = new File(config.getTargetDirectory() + "/" + expectedEnd);
- LOGGER.info("Comparing: {} and {}", objectExpected.getAbsolutePath(), objectActual.getAbsolutePath());
- assert( objectActual.exists());
- if( FileUtils.contentEquals(objectActual, objectExpected) == true ) {
- LOGGER.info("Exact Match!");
- } else {
- LOGGER.info("No Match!");
- fails++;
- }
- }
- if( fails > 0 ) {
- LOGGER.info("Fails: {}", fails);
- Assert.fail();
- }
- */
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
+
+ Collection<File> testOutputFiles = FileUtils.listFiles(testOutput, hqlFilter, true);
+ Assert.assertEquals(testOutputFiles.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pig/pom.xml
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pig/pom.xml b/streams-plugins/streams-plugin-pig/pom.xml
index 67a1eb2..57317e9 100644
--- a/streams-plugins/streams-plugin-pig/pom.xml
+++ b/streams-plugins/streams-plugin-pig/pom.xml
@@ -20,7 +20,6 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
- <groupId>org.apache.streams.plugins</groupId>
<artifactId>streams-plugin-pig</artifactId>
<version>0.5-incubating-SNAPSHOT</version>
<packaging>maven-plugin</packaging>
@@ -66,10 +65,6 @@
<scope>test</scope>
</dependency>
<dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- </dependency>
- <dependency>
<groupId>org.reflections</groupId>
<artifactId>reflections</artifactId>
<version>0.9.9</version>
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java
index 6802667..9921ca0 100644
--- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorCLITest.java
@@ -21,15 +21,12 @@ package org.apache.streams.plugins.pig.test;
import org.apache.streams.plugins.pig.StreamsPigResourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.junit.Test;
+import org.testng.Assert;
import java.io.File;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.pig.test.StreamsPigResourceGeneratorTest.pigFilter;
/**
* Test whether StreamsPigResourceGeneratorCLI generates resources.
@@ -42,18 +39,15 @@ public class StreamsPigResourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-resources/pig-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsPigResourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsPigResourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File(targetDirectory);
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(pigFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsPigResourceGeneratorTest.pigFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java
index bccfcee..f168c56 100644
--- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java
+++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorMojoIT.java
@@ -19,12 +19,9 @@
package org.apache.streams.plugins.pig.test;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
-
+import org.apache.commons.io.FileUtils;
import org.apache.maven.it.Verifier;
import org.apache.maven.it.util.ResourceExtractor;
-
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.testng.Assert;
@@ -34,8 +31,8 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
-
-import static org.apache.streams.plugins.pig.test.StreamsPigResourceGeneratorTest.pigFilter;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Tests that streams-plugin-pig running via maven generates pig resources.
@@ -53,12 +50,12 @@ public class StreamsPigResourceGeneratorMojoIT {
verifier = new Verifier( testDir.getAbsolutePath() );
- List cliOptions = new ArrayList<>();
+ List<String> cliOptions = new ArrayList<>();
cliOptions.add( "-N" );
- verifier.executeGoals( Lists.newArrayList(
+ verifier.executeGoals(Stream.of(
"clean",
"dependency:unpack-dependencies",
- "generate-resources"));
+ "generate-resources").collect(Collectors.toList()));
verifier.verifyErrorFreeLog();
@@ -70,9 +67,7 @@ public class StreamsPigResourceGeneratorMojoIT {
Assert.assertTrue(testOutput.exists());
Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(pigFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, StreamsPigResourceGeneratorTest.pigFilter, true);
Assert.assertEquals(outputCollection.size(), 133 );
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java
index a51778f..3c280bf 100644
--- a/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java
+++ b/streams-plugins/streams-plugin-pig/src/test/java/org/apache/streams/plugins/pig/test/StreamsPigResourceGeneratorTest.java
@@ -22,17 +22,16 @@ package org.apache.streams.plugins.pig.test;
import org.apache.streams.plugins.pig.StreamsPigGenerationConfig;
import org.apache.streams.plugins.pig.StreamsPigResourceGenerator;
-import com.google.common.base.Predicate;
-import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+import org.testng.Assert;
import java.io.File;
import java.util.Collection;
-import javax.annotation.Nullable;
+import java.util.stream.Collectors;
+import java.util.stream.Stream;
/**
* Test that Activity beans are compatible with the example activities in the spec.
@@ -41,16 +40,7 @@ public class StreamsPigResourceGeneratorTest {
private static final Logger LOGGER = LoggerFactory.getLogger(StreamsPigResourceGeneratorTest.class);
- public static final Predicate<File> pigFilter = new Predicate<File>() {
- @Override
- public boolean apply(@Nullable File file) {
- if ( file.getName().endsWith(".pig") ) {
- return true;
- } else {
- return false;
- }
- }
- };
+ public static final String[] pigFilter = new String[]{"pig"};
/**
* Tests that StreamsPigResourceGenerator via SDK generates pig resources.
@@ -68,7 +58,7 @@ public class StreamsPigResourceGeneratorTest {
config.setTargetDirectory("target/generated-resources/pig");
- config.setExclusions(Sets.newHashSet("attachments"));
+ config.setExclusions(Stream.of("attachments").collect(Collectors.toSet()));
config.setMaxDepth(2);
@@ -77,42 +67,11 @@ public class StreamsPigResourceGeneratorTest {
File testOutput = config.getTargetDirectory();
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
-
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(pigFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() == 133 );
-
- // TODO: figure out how to do a match to a test resources that has an apache header.
- // String expectedDirectory = "target/test-classes/expected";
- // File testExpected = new File( expectedDirectory );
- //
- // Iterable<File> expectedIterator = Files.fileTreeTraverser().breadthFirstTraversal(testExpected)
- // .filter(pigFilter);
- // Collection<File> expectedCollection = Lists.newArrayList(expectedIterator);
- //
- // int fails = 0;
- //
- // Iterator<File> iterator = expectedCollection.iterator();
- // while( iterator.hasNext() ) {
- // File objectExpected = iterator.next();
- // String expectedEnd = dropSourcePathPrefix(objectExpected.getAbsolutePath(), expectedDirectory);
- // File objectActual = new File(config.getTargetDirectory() + "/" + expectedEnd);
- // LOGGER.info("Comparing: {} and {}", objectExpected.getAbsolutePath(), objectActual.getAbsolutePath());
- // assert( objectActual.exists());
- // if( FileUtils(objectActual, objectExpected) == true ) {
- // LOGGER.info("Exact Match!");
- // } else {
- // LOGGER.info("No Match!");
- // fails++;
- // }
- // }
- // if( fails > 0 ) {
- // LOGGER.info("Fails: {}", fails);
- // Assert.fail();
- // }
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
+
+ Collection<File> outputCollection = FileUtils.listFiles(testOutput, pigFilter, true);
+ Assert.assertEquals(outputCollection.size(), 133);
}
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java
index b2b156f..d3b15a3 100644
--- a/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java
+++ b/streams-plugins/streams-plugin-pojo/src/main/java/org/apache/streams/plugins/StreamsPojoGenerationConfig.java
@@ -70,7 +70,7 @@ public class StreamsPojoGenerationConfig extends DefaultGenerationConfig {
if (null != sourceDirectory) {
return Collections.singleton(URLUtil.parseURL(sourceDirectory)).iterator();
}
- List<URL> sourceUrls = new ArrayList<URL>();
+ List<URL> sourceUrls = new ArrayList<>();
if ( sourcePaths != null && sourcePaths.size() > 0) {
for (String source : sourcePaths) {
sourceUrls.add(URLUtil.parseURL(source));
http://git-wip-us.apache.org/repos/asf/incubator-streams/blob/db897a21/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java
----------------------------------------------------------------------
diff --git a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java
index 4239a31..1c72626 100644
--- a/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java
+++ b/streams-plugins/streams-plugin-pojo/src/test/java/org/apache/streams/plugins/test/StreamsPojoSourceGeneratorCLITest.java
@@ -21,24 +21,21 @@ package org.apache.streams.plugins.test;
import org.apache.streams.plugins.StreamsPojoSourceGenerator;
-import com.google.common.collect.Lists;
-import com.google.common.io.Files;
+import org.apache.commons.io.FileUtils;
+import org.junit.Assert;
import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import java.io.File;
import java.util.Collection;
-import java.util.List;
-
-import static org.apache.streams.plugins.test.StreamsPojoSourceGeneratorTest.javaFilter;
/**
* Test whether StreamsPojoSourceGeneratorCLI generates source files.
*/
public class StreamsPojoSourceGeneratorCLITest {
- private static final Logger LOGGER = LoggerFactory.getLogger(StreamsPojoSourceGeneratorTest.class);
+ private static final Logger LOGGER = LoggerFactory.getLogger(StreamsPojoSourceGeneratorCLITest.class);
@Test
public void testStreamsPojoSourceGeneratorCLI() throws Exception {
@@ -46,18 +43,15 @@ public class StreamsPojoSourceGeneratorCLITest {
String sourceDirectory = "target/test-classes/activitystreams-schemas";
String targetDirectory = "target/generated-sources/test-cli";
- List<String> argsList = Lists.newArrayList(sourceDirectory, targetDirectory);
- StreamsPojoSourceGenerator.main(argsList.toArray(new String[0]));
+ StreamsPojoSourceGenerator.main(new String[]{sourceDirectory, targetDirectory});
File testOutput = new File(targetDirectory);
- assert ( testOutput != null );
- assert ( testOutput.exists() == true );
- assert ( testOutput.isDirectory() == true );
+ Assert.assertNotNull(testOutput);
+ Assert.assertTrue(testOutput.exists());
+ Assert.assertTrue(testOutput.isDirectory());
- Iterable<File> outputIterator = Files.fileTreeTraverser().breadthFirstTraversal(testOutput)
- .filter(javaFilter);
- Collection<File> outputCollection = Lists.newArrayList(outputIterator);
- assert ( outputCollection.size() > 133 );
+ Collection<File> testOutputFiles = FileUtils.listFiles(testOutput, StreamsPojoSourceGeneratorTest.javaFilter, true);
+ Assert.assertTrue(testOutputFiles.size() > 133);
}
}