diff --git a/pom.xml b/pom.xml
index a4257d9c78..88e29f51df 100644
--- a/pom.xml
+++ b/pom.xml
@@ -260,6 +260,7 @@
com.jcabi
jcabi-http
+ 1.10.2
com.jcabi
@@ -278,7 +279,7 @@
com.jcabi
jcabi-github
- 0.18.7
+ 0.18.9
com.jcabi
diff --git a/src/main/java/com/rultor/agents/twitter/Tweets.java b/src/main/java/com/rultor/agents/twitter/Tweets.java
index 10904c080b..12060512a6 100644
--- a/src/main/java/com/rultor/agents/twitter/Tweets.java
+++ b/src/main/java/com/rultor/agents/twitter/Tweets.java
@@ -33,6 +33,7 @@
import com.jcabi.aspects.Tv;
import com.jcabi.github.Github;
import com.jcabi.github.Issue;
+import com.jcabi.github.Language;
import com.jcabi.github.Repo;
import com.jcabi.log.Logger;
import com.jcabi.xml.XML;
@@ -107,6 +108,7 @@ public Iterable process(final XML xml) throws IOException {
* @return Tweet text
* @throws IOException If fails
*/
+ @SuppressWarnings("PMD.InsufficientStringBufferDeclaration")
private static String tweet(final Repo.Smart repo, final String tag)
throws IOException {
final StringBuilder text = new StringBuilder(2 * Tv.HUNDRED);
@@ -120,10 +122,13 @@ private static String tweet(final Repo.Smart repo, final String tag)
)
);
}
- return text.append(", ").append(tag)
+ text.append(", ").append(tag)
.append(" released https://github.com/")
- .append(repo.coordinates())
- .toString();
+ .append(repo.coordinates());
+ for (final Language lang : repo.languages()) {
+ text.append(String.format(" #%s", lang.name()));
+ }
+ return text.toString();
}
}
diff --git a/src/test/java/com/rultor/agents/twitter/TweetsTest.java b/src/test/java/com/rultor/agents/twitter/TweetsTest.java
index 3a649e720f..7654364ff1 100644
--- a/src/test/java/com/rultor/agents/twitter/TweetsTest.java
+++ b/src/test/java/com/rultor/agents/twitter/TweetsTest.java
@@ -29,12 +29,15 @@
*/
package com.rultor.agents.twitter;
+import com.google.common.base.Function;
+import com.google.common.base.Joiner;
+import com.google.common.collect.Iterables;
import com.jcabi.github.Issue;
+import com.jcabi.github.Language;
import com.jcabi.github.Repo;
import com.jcabi.github.mock.MkGithub;
-import com.rultor.spi.Agent;
import com.rultor.spi.Talk;
-import org.junit.Ignore;
+import java.io.IOException;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
@@ -54,12 +57,53 @@ public final class TweetsTest {
* @throws Exception In case of error.
*/
@Test
- @Ignore
public void postsTweet() throws Exception {
final Repo repo = new MkGithub().randomRepo();
- final Issue issue = repo.issues().create("", "");
final Twitter twitter = Mockito.mock(Twitter.class);
- final Agent agent = new Tweets(repo.github(), twitter);
+ final Talk talk = TweetsTest.talk(repo, repo.issues().create("", ""));
+ new Tweets(repo.github(), twitter).execute(talk);
+ Mockito.verify(twitter).post(
+ Matchers.contains("test")
+ );
+ }
+
+ /**
+ * Tweets can post a tweet with language tags.
+ * @throws Exception In case of error.
+ */
+ @Test
+ public void postsTweetWithLanguages() throws Exception {
+ final Repo repo = new MkGithub().randomRepo();
+ final Twitter twitter = Mockito.mock(Twitter.class);
+ new Tweets(repo.github(), twitter).execute(
+ TweetsTest.talk(repo, repo.issues().create("", ""))
+ );
+ Mockito.verify(twitter).post(
+ Matchers.contains(
+ Joiner.on(' ').join(
+ Iterables.transform(
+ repo.languages(),
+ new Function() {
+ @Override
+ public String apply(final Language lang) {
+ return String.format("#%s", lang.name());
+ }
+ }
+ )
+ )
+ )
+ );
+ }
+
+ /**
+ * Creates a talk with repo and issue.
+ * @param repo Repo to use
+ * @param issue Issue to use
+ * @return Created Talk
+ * @throws IOException In case of error
+ */
+ private static Talk talk(final Repo repo, final Issue issue)
+ throws IOException {
final Talk talk = new Talk.InFile();
talk.modify(
new Directives().xpath("/talk").add("wire")
@@ -73,10 +117,6 @@ public void postsTweet() throws Exception {
.add("type").set("release").up()
.add("args").add("arg").attr("name", "tag").set("1.7")
);
- agent.execute(talk);
- Mockito.verify(twitter).post(
- Matchers.contains("test")
- );
+ return talk;
}
-
}