ticks = new SolidList<>(this.pulse.ticks());
final StringBuilder msg = new StringBuilder(Tv.THOUSAND);
final Response response;
- if (Iterables.isEmpty(ticks)) {
+ if (ticks.isEmpty()) {
response = new RsWithStatus(HttpURLConnection.HTTP_NO_CONTENT);
msg.append("There is no activity yet, refresh in a few seconds");
} else {
final long age = System.currentTimeMillis()
- - Iterables.getLast(ticks).start();
+ - ticks.get(ticks.size() - 1).start();
if (age > TimeUnit.MINUTES.toMillis((long) Tv.FIVE)) {
response = new RsWithStatus(
HttpURLConnection.HTTP_INTERNAL_ERROR
diff --git a/src/test/java/com/rultor/agents/daemons/TailITCase.java b/src/test/java/com/rultor/agents/daemons/TailITCase.java
index bbf0bdefde..b1f99edfb0 100644
--- a/src/test/java/com/rultor/agents/daemons/TailITCase.java
+++ b/src/test/java/com/rultor/agents/daemons/TailITCase.java
@@ -29,7 +29,6 @@
*/
package com.rultor.agents.daemons;
-import com.google.common.base.Charsets;
import com.jcabi.ssh.SSH;
import com.jcabi.ssh.Shell;
import com.rultor.Time;
@@ -37,6 +36,7 @@
import com.rultor.agents.shells.PfShell;
import com.rultor.spi.Profile;
import com.rultor.spi.Talk;
+import java.nio.charset.Charset;
import org.apache.commons.io.IOUtils;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
@@ -93,7 +93,7 @@ public void tailsNonUtf() throws Exception {
MatcherAssert.assertThat(
IOUtils.toString(
new Tail(talk.read(), hash).read(),
- Charsets.UTF_8
+ Charset.forName("UTF-8")
),
Matchers.is(String.format("%sĂȘ\n", clean))
);
diff --git a/src/test/java/com/rultor/agents/github/AnswerTest.java b/src/test/java/com/rultor/agents/github/AnswerTest.java
index 95b085360a..e3bba4e2a6 100644
--- a/src/test/java/com/rultor/agents/github/AnswerTest.java
+++ b/src/test/java/com/rultor/agents/github/AnswerTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.agents.github;
-import com.google.common.collect.Iterables;
import com.jcabi.aspects.Tv;
import com.jcabi.github.Comment;
import com.jcabi.github.Issue;
@@ -37,6 +36,7 @@
import com.jcabi.github.mock.MkGithub;
import java.io.IOException;
import java.util.Date;
+import org.cactoos.list.SolidList;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
@@ -85,7 +85,7 @@ public void preventsSpam() throws Exception {
answer.post(true, "oops");
}
MatcherAssert.assertThat(
- Iterables.size(issue.comments().iterate(new Date(0L))),
+ new SolidList<>(issue.comments().iterate(new Date(0L))).size(),
Matchers.is(Tv.SIX)
);
}
diff --git a/src/test/java/com/rultor/agents/github/ReleaseBinariesTest.java b/src/test/java/com/rultor/agents/github/ReleaseBinariesTest.java
index 95ec105c9e..b78e5d2c82 100644
--- a/src/test/java/com/rultor/agents/github/ReleaseBinariesTest.java
+++ b/src/test/java/com/rultor/agents/github/ReleaseBinariesTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.agents.github;
-import com.google.common.io.Files;
import com.jcabi.aspects.Tv;
import com.jcabi.github.Issue;
import com.jcabi.github.Releases;
@@ -44,6 +43,8 @@
import org.apache.commons.io.IOUtils;
import org.apache.commons.lang3.RandomUtils;
import org.apache.commons.lang3.StringUtils;
+import org.cactoos.io.LengthOf;
+import org.cactoos.io.TeeInput;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
@@ -82,9 +83,9 @@ public void attachesBinaryToRelease() throws Exception {
final File bin = FileUtils.getFile(
dir.getAbsolutePath(), "repo", target, name.replace("${tag}", tag)
);
- Files.createParentDirs(bin);
+ bin.mkdirs();
final byte[] content = RandomUtils.nextBytes(Tv.HUNDRED);
- Files.write(content, bin);
+ new LengthOf(new TeeInput(content, bin)).value();
final Talk talk = ReleaseBinariesTest
.talk(repo.issues().create("", ""), tag, dir);
new CommentsTag(repo.github()).execute(talk);
diff --git a/src/test/java/com/rultor/agents/req/BracketsTest.java b/src/test/java/com/rultor/agents/req/BracketsTest.java
new file mode 100644
index 0000000000..437f9b5420
--- /dev/null
+++ b/src/test/java/com/rultor/agents/req/BracketsTest.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (c) 2009-2018, rultor.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met: 1) Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer. 2) Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution. 3) Neither the name of the rultor.com nor
+ * the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.rultor.agents.req;
+
+import org.cactoos.list.SolidList;
+import org.hamcrest.MatcherAssert;
+import org.hamcrest.Matchers;
+import org.junit.Test;
+
+/**
+ * Tests for {@link Brackets}.
+ *
+ * @author Filipe Freire (livrofubia@gmail.com)
+ * @version $Id$
+ * @since ?
+ */
+public final class BracketsTest {
+ /**
+ * Brackets can fetch environment vars.
+ * @throws Exception In case of error.
+ */
+ @Test
+ public void escapesInput() throws Exception {
+ final Brackets brackets = new Brackets(
+ new SolidList<>(
+ "Elegant",
+ "Objects"
+ )
+ );
+ MatcherAssert.assertThat(
+ brackets.toString(),
+ Matchers.equalTo("( 'Elegant' 'Objects' )")
+ );
+ }
+}
diff --git a/src/test/java/com/rultor/agents/req/DecryptTest.java b/src/test/java/com/rultor/agents/req/DecryptTest.java
index ab0187f0a3..f81d262d63 100644
--- a/src/test/java/com/rultor/agents/req/DecryptTest.java
+++ b/src/test/java/com/rultor/agents/req/DecryptTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.agents.req;
-import com.google.common.base.Joiner;
import com.jcabi.log.VerboseProcess;
import com.jcabi.xml.XMLDocument;
import com.rultor.spi.Profile;
@@ -39,6 +38,7 @@
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.io.FileUtils;
import org.apache.commons.io.IOUtils;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assume;
@@ -52,28 +52,14 @@
* @author Yegor Bugayenko (yegor256@gmail.com)
* @version $Id$
* @since 1.37.4
+ * @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class DecryptTest {
/**
- * Encoded test file.
+ * Newline.
*/
- private static final String ASC = Joiner.on('\n').join(
- "-----BEGIN PGP MESSAGE-----",
- "Version: GnuPG v1\n",
- "hQEMA5qETcGag5w6AQgAvm/P0JUlQAdOtGng5zHLx5cV+BrbpFt1m2ja4BjacYMU",
- "wcubtJSh+n0XNLk6zMMCsrDnTfzvi/FEFaRsPVb/ZJHiJGvwhNGyenQWgd6bczIL",
- "1UxBZ1BpHTPv5hVK43fb6cYq+e/gniBMvIKlKV+Qh/NVtiQACQJ5xL1M16S9SQuY",
- "hjnVEL3JNHiLEAfPS/8xS05DY/w1k/JyPXMZlrR7YGMxUsG6aDaFPAdjcdSbzGCT",
- "j4yZPdZtyqePFGXn0VJE7GRywWcmk3Nj+oZzgx6DLV3PH40HSYNuyA9a2xFpghTr",
- "7uiYRf+rRzXlx7qnBLsvETlhc77zpf0FW4pLq/08ttLADQFsIU2BNHJGPw+96GKJ",
- "AVNAm0OxfaMz+U+gy2kIgteuMQmfkYDF0u9HE7NwZ1PlXO5Oszhfdim2LPSyxYMi",
- "sKlVilWhPwdumSjmY0IG1B6yc8ZLG4BjBucu3dMjj98iKRjlKvEmqqdUmoZY+l/N",
- "Ye9gRf0UY44jJ0f4H81osGtmXg1dRc47OE/pUGGbIare4GNvBB/oiksvoCDOOEKy",
- "cj6IAjR/BnSZ1mYvSShSPatu7QRFdd/HFRt76pGj2G6ibnnDNpfjDwgNaWbiGUU=",
- "=d2bb",
- "-----END PGP MESSAGE-----"
- );
+ private static final String NEWLINE = "\n";
/**
* Test port for proxy settings test.
@@ -101,14 +87,18 @@ public void decryptsAssets() throws Exception {
"test/test"
)
).commands();
- final String script = Joiner.on('\n').join(
+ final String script = new JoinedText(
+ NEWLINE,
"set -x",
"set -e",
"set -o pipefail",
- Joiner.on('\n').join(commands)
- );
+ new JoinedText(
+ NEWLINE,
+ commands
+ ).asString()
+ ).asString();
final File dir = this.temp.newFolder();
- FileUtils.write(new File(dir, "a.txt.asc"), DecryptTest.ASC);
+ FileUtils.write(new File(dir, "a.txt.asc"), new FakePGP().asString());
final String[] keys = {"pubring", "secring"};
for (final String key : keys) {
final String gpg = IOUtils.toString(
@@ -164,14 +154,19 @@ public void testHttpProxyHandling() throws IOException {
* @return XML document
*/
private XMLDocument createTestProfileXML() {
- return new XMLDocument(
- Joiner.on("").join(
- "",
- "",
- "a.txt.asc",
- "",
- "
"
- )
- );
+ try {
+ return new XMLDocument(
+ new JoinedText(
+ "",
+ "",
+ "",
+ "a.txt.asc",
+ "",
+ "
"
+ ).asString()
+ );
+ } catch (final IOException ex) {
+ throw new IllegalStateException(ex);
+ }
}
}
diff --git a/src/test/java/com/rultor/agents/req/DockerRunTest.java b/src/test/java/com/rultor/agents/req/DockerRunTest.java
index ecf09fb133..0e1c13efc1 100644
--- a/src/test/java/com/rultor/agents/req/DockerRunTest.java
+++ b/src/test/java/com/rultor/agents/req/DockerRunTest.java
@@ -29,10 +29,10 @@
*/
package com.rultor.agents.req;
-import com.google.common.base.Joiner;
import com.jcabi.immutable.ArrayMap;
import com.jcabi.xml.XMLDocument;
import com.rultor.spi.Profile;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
@@ -47,6 +47,11 @@
*/
public final class DockerRunTest {
+ /**
+ * Space char.
+ */
+ private static final String SPACE = " ";
+
/**
* DockerRun can fetch environment vars.
* @throws Exception In case of error.
@@ -55,13 +60,14 @@ public final class DockerRunTest {
public void fetchesEnvVars() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"",
"- A=5
- B=f e
",
"HELLO='1'",
"",
"works
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -92,12 +98,13 @@ public void fetchesEnvVars() throws Exception {
public void fetchesScript() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"",
"mvn clean",
"",
"- pw
- ls
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -118,7 +125,8 @@ public void fetchesScript() throws Exception {
public void executesWithComment() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"",
"- echo \"first\"
",
"- # some comment
",
@@ -130,7 +138,7 @@ public void executesWithComment() throws Exception {
"",
// @checkstyle MultipleStringLiterals (1 line)
"
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -182,11 +190,12 @@ public void fetchesFromEmptyProfile() throws Exception {
public void fetchesInstallScript() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"hi",
"- one
- two
",
"
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -205,14 +214,15 @@ public void fetchesInstallScript() throws Exception {
public void fetchesUninstallScript() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"",
"",
"- one
- two
",
"",
"hi",
"
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -234,10 +244,11 @@ public void fetchesUninstallScript() throws Exception {
public void fetchesEnvVarsDefaults() throws Exception {
final Profile profile = new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ SPACE,
"A=123",
"ALPHA=909
"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
diff --git a/src/test/java/com/rultor/agents/req/FakePGP.java b/src/test/java/com/rultor/agents/req/FakePGP.java
new file mode 100644
index 0000000000..561a2ae22d
--- /dev/null
+++ b/src/test/java/com/rultor/agents/req/FakePGP.java
@@ -0,0 +1,83 @@
+/**
+ * Copyright (c) 2009-2018, rultor.com
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met: 1) Redistributions of source code must retain the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer. 2) Redistributions in binary form must reproduce the above
+ * copyright notice, this list of conditions and the following
+ * disclaimer in the documentation and/or other materials provided
+ * with the distribution. 3) Neither the name of the rultor.com nor
+ * the names of its contributors may be used to endorse or promote
+ * products derived from this software without specific prior written
+ * permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT
+ * NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
+ * THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
+ * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+package com.rultor.agents.req;
+
+import java.io.IOException;
+import org.cactoos.list.SolidList;
+import org.cactoos.text.JoinedText;
+
+/**
+ * Fake PGP Signature.
+ *
+ * @author Filipe Freire (livrofubia@gmail.com)
+ * @version $Id$
+ * @since ?
+ */
+final class FakePGP {
+
+ /**
+ * Returns FakePGP string.
+ *
+ * @return String
+ * @throws IOException ex
+ */
+ public String asString() throws IOException {
+ return new JoinedText(
+ "\n",
+ new SolidList<>(
+ "-----BEGIN PGP MESSAGE-----",
+ "Version: GnuPG v1\n",
+ "hQEMA5qETcGag5w6AQgAvm/P0JUlQAd",
+ "OtGng5zHLx5cV+BrbpFt1m2ja4BjacYMU",
+ "wcubtJSh+n0XNLk6zMMCsrDnTfzvi/F",
+ "EFaRsPVb/ZJHiJGvwhNGyenQWgd6bczIL",
+ "1UxBZ1BpHTPv5hVK43fb6cYq+e/gniB",
+ "MvIKlKV+Qh/NVtiQACQJ5xL1M16S9SQuY",
+ "hjnVEL3JNHiLEAfPS/8xS05DY/w1k/J",
+ "yPXMZlrR7YGMxUsG6aDaFPAdjcdSbzGCT",
+ "j4yZPdZtyqePFGXn0VJE7GRywWcmk3N",
+ "j+oZzgx6DLV3PH40HSYNuyA9a2xFpghTr",
+ "7uiYRf+rRzXlx7qnBLsvETlhc77zpf0",
+ "FW4pLq/08ttLADQFsIU2BNHJGPw+96GKJ",
+ "AVNAm0OxfaMz+U+gy2kIgteuMQmfkYD",
+ "F0u9HE7NwZ1PlXO5Oszhfdim2LPSyxYMi",
+ "sKlVilWhPwdumSjmY0IG1B6yc8ZLG4B",
+ "jBucu3dMjj98iKRjlKvEmqqdUmoZY+l/N",
+ "Ye9gRf0UY44jJ0f4H81osGtmXg1dRc4",
+ "7OE/pUGGbIare4GNvBB/oiksvoCDOOEKy",
+ "cj6IAjR/BnSZ1mYvSShSPatu7QRFdd/",
+ "HFRt76pGj2G6ibnnDNpfjDwgNaWbiGUU=",
+ "=d2bb",
+ "-----END PGP MESSAGE-----"
+ )
+ ).asString();
+ }
+
+}
diff --git a/src/test/java/com/rultor/agents/req/StartsRequestITCase.java b/src/test/java/com/rultor/agents/req/StartsRequestITCase.java
index 234e34defd..1ed4dc4317 100644
--- a/src/test/java/com/rultor/agents/req/StartsRequestITCase.java
+++ b/src/test/java/com/rultor/agents/req/StartsRequestITCase.java
@@ -29,13 +29,13 @@
*/
package com.rultor.agents.req;
-import com.google.common.base.Joiner;
import com.jcabi.ssh.SSH;
import com.jcabi.ssh.Shell;
import com.jcabi.xml.XMLDocument;
import com.rultor.spi.Agent;
import com.rultor.spi.Profile;
import com.rultor.spi.Talk;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Assume;
@@ -86,7 +86,8 @@ public void composesCorrectDeployRequest() throws Exception {
);
final String repo = String.format("/tmp/%d.git", System.nanoTime());
new Shell.Plain(new Shell.Safe(shell)).exec(
- Joiner.on(';').join(
+ new JoinedText(
+ ";",
"cd /tmp",
String.format("git init %s", repo),
String.format("cd %s", repo),
@@ -100,17 +101,18 @@ public void composesCorrectDeployRequest() throws Exception {
"git commit -am 'modified file'",
"git checkout master",
"git config receive.denyCurrentBranch ignore"
- )
+ ).asString()
);
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"",
"echo 'Hello, world!'",
"echo 'I am' $(id -u -n)",
"
"
- )
+ ).asString()
)
)
);
@@ -127,17 +129,19 @@ public void composesCorrectDeployRequest() throws Exception {
agent.execute(talk);
final String dir = String.format("/tmp/test-%d", System.nanoTime());
final String stdout = new Shell.Plain(shell).exec(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
String.format("mkdir %s", dir),
String.format("cd %s", dir),
talk.read().xpath("//script/text()").get(0)
- )
+ ).asString()
);
new Shell.Plain(new Shell.Safe(shell)).exec(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
String.format("rm -rf %s", repo),
String.format("sudo rm -rf %s", dir)
- )
+ ).asString()
);
MatcherAssert.assertThat(
stdout,
diff --git a/src/test/java/com/rultor/agents/req/StartsRequestTest.java b/src/test/java/com/rultor/agents/req/StartsRequestTest.java
index 430928cfcf..c7e38e141b 100644
--- a/src/test/java/com/rultor/agents/req/StartsRequestTest.java
+++ b/src/test/java/com/rultor/agents/req/StartsRequestTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.agents.req;
-import com.google.common.base.Joiner;
import com.jcabi.immutable.Array;
import com.jcabi.log.VerboseProcess;
import com.jcabi.matchers.XhtmlMatchers;
@@ -41,7 +40,7 @@
import java.io.IOException;
import java.util.logging.Level;
import org.apache.commons.io.FileUtils;
-import org.apache.commons.lang3.StringUtils;
+import org.cactoos.text.JoinedText;
import org.hamcrest.Matcher;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
@@ -109,13 +108,14 @@ public void startsDeployRequest() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ " ",
"",
"echo HEY",
"",
"-Xmx2g -Xms1g",
"
"
- )
+ ).asString()
)
)
);
@@ -132,10 +132,11 @@ public void startsDeployRequest() throws Exception {
agent.execute(talk);
talk.modify(
new Directives().xpath("/talk/daemon/script").set(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
talk.read().xpath("/talk/daemon/script/text()").get(0),
"cd ..; cat entry.sh; cat script.sh"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -176,12 +177,13 @@ public void startsReleaseRequest() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- StringUtils.join(
+ new JoinedText(
+ "",
"",
"echo HEY",
"a/b",
"
"
- )
+ ).asString()
)
)
);
@@ -210,10 +212,11 @@ public void startsMergeRequest() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- StringUtils.join(
+ new JoinedText(
+ "",
"",
"echo HEY
"
- )
+ ).asString()
)
)
);
@@ -248,12 +251,13 @@ public void runsReleaseWithDockerfile() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- StringUtils.join(
+ new JoinedText(
+ "",
"",
"echo HEY",
String.format("%s", dir),
"
"
- )
+ ).asString()
)
)
);
@@ -300,10 +304,11 @@ public void decryptsAssets() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- StringUtils.join(
+ new JoinedText(
+ "",
"",
"a.txt.asc
"
- )
+ ).asString()
)
)
);
@@ -334,12 +339,13 @@ public void runsAsRootIfRequested() throws Exception {
final Agent agent = new StartsRequest(
new Profile.Fixed(
new XMLDocument(
- StringUtils.join(
+ new JoinedText(
+ "",
"",
"true",
"",
"echo BOOM
"
- )
+ ).asString()
)
)
);
@@ -356,10 +362,11 @@ public void runsAsRootIfRequested() throws Exception {
agent.execute(talk);
talk.modify(
new Directives().xpath("/talk/daemon/script").set(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
talk.read().xpath("/talk/daemon/script/text()").get(0),
"cd ..; cat entry.sh"
- )
+ ).asString()
)
);
MatcherAssert.assertThat(
@@ -375,7 +382,8 @@ public void runsAsRootIfRequested() throws Exception {
* @throws java.io.IOException If fails
*/
private String exec(final Talk talk) throws IOException {
- final String script = Joiner.on('\n').join(
+ final String script = new JoinedText(
+ "\n",
"set -x",
"set -e",
"set -o pipefail",
@@ -390,7 +398,7 @@ private String exec(final Talk talk) throws IOException {
" done",
"} ",
talk.read().xpath("//script/text()").get(0)
- );
+ ).asString();
return new VerboseProcess(
new ProcessBuilder().command(
"/bin/bash", "-c", script
@@ -410,7 +418,8 @@ private File repo() throws IOException {
new ProcessBuilder().command(
"/bin/bash",
"-c",
- Joiner.on(';').join(
+ new JoinedText(
+ ";",
"set -x",
"set -e",
"set -o pipefail",
@@ -425,7 +434,7 @@ private File repo() throws IOException {
"git commit -am 'modified file'",
"git checkout master",
"git config receive.denyCurrentBranch ignore"
- )
+ ).asString()
).directory(repo)
).stdout();
return repo;
diff --git a/src/test/java/com/rultor/agents/shells/RegistersShellTest.java b/src/test/java/com/rultor/agents/shells/RegistersShellTest.java
index 2c8676e1a7..f5a07b99eb 100644
--- a/src/test/java/com/rultor/agents/shells/RegistersShellTest.java
+++ b/src/test/java/com/rultor/agents/shells/RegistersShellTest.java
@@ -29,12 +29,12 @@
*/
package com.rultor.agents.shells;
-import com.google.common.base.Joiner;
import com.jcabi.matchers.XhtmlMatchers;
import com.jcabi.xml.XMLDocument;
import com.rultor.spi.Agent;
import com.rultor.spi.Profile;
import com.rultor.spi.Talk;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.junit.Test;
import org.mockito.Mockito;
@@ -62,14 +62,15 @@ public void registersShell() throws Exception {
final Agent agent = new RegistersShell(
new Profile.Fixed(
new XMLDocument(
- Joiner.on(' ').join(
+ new JoinedText(
+ " ",
"",
String.format("%s", host),
String.format("%d", port),
String.format("%s", key),
String.format("%s", login),
"
"
- )
+ ).asString()
)
),
"localhost", 22, "rultor", "def-key"
diff --git a/src/test/java/com/rultor/agents/twitter/TweetsTest.java b/src/test/java/com/rultor/agents/twitter/TweetsTest.java
index 44173c2488..a90f4d5d98 100644
--- a/src/test/java/com/rultor/agents/twitter/TweetsTest.java
+++ b/src/test/java/com/rultor/agents/twitter/TweetsTest.java
@@ -29,15 +29,13 @@
*/
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.Talk;
import java.io.IOException;
+import org.cactoos.iterable.Mapped;
+import org.cactoos.text.JoinedText;
import org.junit.Test;
import org.mockito.Matchers;
import org.mockito.Mockito;
@@ -80,17 +78,13 @@ public void postsTweetWithLanguages() throws Exception {
);
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());
- }
- }
+ new JoinedText(
+ " ",
+ new Mapped<>(
+ lang -> String.format("#%s", lang.name()),
+ repo.languages()
)
- )
+ ).asString()
)
);
}
diff --git a/src/test/java/com/rultor/profiles/GithubProfileTest.java b/src/test/java/com/rultor/profiles/GithubProfileTest.java
index e1a5c58de1..107e355821 100644
--- a/src/test/java/com/rultor/profiles/GithubProfileTest.java
+++ b/src/test/java/com/rultor/profiles/GithubProfileTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.profiles;
-import com.google.common.base.Joiner;
import com.jcabi.github.Coordinates;
import com.jcabi.github.Github;
import com.jcabi.github.Repo;
@@ -38,8 +37,9 @@
import com.jcabi.matchers.XhtmlMatchers;
import com.rultor.spi.Profile;
import java.io.IOException;
+import java.util.Base64;
import javax.json.Json;
-import org.apache.commons.codec.binary.Base64;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Test;
@@ -61,7 +61,8 @@ public final class GithubProfileTest {
@Test
public void fetchesYamlConfig() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets:",
" test.xml: jeff/test1#test.xml",
" beta: jeff/test1#test.xml",
@@ -70,7 +71,7 @@ public void fetchesYamlConfig() throws Exception {
" - donald",
"merge:",
" script: hello!"
- )
+ ).asString()
);
final String yaml = "friends:\n - jeff/test2";
repo.github()
@@ -80,7 +81,10 @@ public void fetchesYamlConfig() throws Exception {
Json.createObjectBuilder()
.add("path", ".rultor.yml")
.add("message", "rultor config")
- .add("content", Base64.encodeBase64String(yaml.getBytes()))
+ .add(
+ "content",
+ Base64.getEncoder().encodeToString(yaml.getBytes())
+ )
.build()
);
final Profile profile = new GithubProfile(repo);
@@ -122,10 +126,11 @@ public void throwsWhenYamlIsBroken() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void throwsWhenAssetIsMisconfigured() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets: ",
" something.xml: -invalid.user.name/test1#test.xml"
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -137,10 +142,11 @@ public void throwsWhenAssetIsMisconfigured() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void throwsWhenAssetsUsernameContainsUnderscore() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets: ",
" something.xml: invalid_username/test1#test.xml"
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -154,10 +160,11 @@ public void throwsWhenAssetsUsernameContainsUnderscore() throws Exception {
public void throwsWhenAssetsUsernameStartsWithUnderscore()
throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets: ",
" something.xml: _invalidusername/test1#test.xml"
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -179,14 +186,15 @@ public void acceptsAssetsFromDotRepo() throws Exception {
.add("message", "just test")
.add(
"content",
- Base64.encodeBase64String(
- Joiner.on('\n').join(
+ Base64.getEncoder().encodeToString(
+ new JoinedText(
+ "\n",
"assets: ",
String.format(
" something.xml: jeff/%s#.rultor.yml", name
),
"friends:", String.format(" - jeff/%s", name)
- ).getBytes()
+ ).asString().getBytes()
)
).build()
);
@@ -203,10 +211,11 @@ public void acceptsAssetsFromDotRepo() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void throwsWhenRultorConfigIsAbsent() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets: ",
" something.xml: jeff/test2#.rultor.yml"
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -218,10 +227,11 @@ public void throwsWhenRultorConfigIsAbsent() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void throwsWhenFriendNotDefined() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets: ",
" a.xml: jeff/test1#test.xml"
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -234,12 +244,13 @@ public void throwsWhenFriendNotDefined() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void testAssetNotFound() throws Exception {
final Repo repo = GithubProfileTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets:",
" test.xml: jeff/test1#test.xmls",
"merge:",
" script: hello!"
- )
+ ).asString()
);
final String yaml = "friends:\n - jeff/test2";
repo.github()
@@ -249,7 +260,10 @@ public void testAssetNotFound() throws Exception {
Json.createObjectBuilder()
.add("path", ".rultor.yml")
.add("message", "rultor config")
- .add("content", Base64.encodeBase64String(yaml.getBytes()))
+ .add(
+ "content",
+ Base64.getEncoder().encodeToString(yaml.getBytes())
+ )
.build()
);
final Profile profile = new GithubProfile(repo);
@@ -271,7 +285,10 @@ private static Repo repo(final String yaml) throws IOException {
Json.createObjectBuilder()
.add("path", "test.xml")
.add("message", "just test msg")
- .add("content", Base64.encodeBase64String("hey".getBytes()))
+ .add(
+ "content",
+ Base64.getEncoder().encodeToString("hey".getBytes())
+ )
.build()
);
final Repo repo = github.repos().create(
@@ -281,7 +298,10 @@ private static Repo repo(final String yaml) throws IOException {
Json.createObjectBuilder()
.add("path", ".rultor.yml")
.add("message", "just test")
- .add("content", Base64.encodeBase64String(yaml.getBytes()))
+ .add(
+ "content",
+ Base64.getEncoder().encodeToString(yaml.getBytes())
+ )
.build()
);
return repo;
diff --git a/src/test/java/com/rultor/profiles/GithubProfileValidationTest.java b/src/test/java/com/rultor/profiles/GithubProfileValidationTest.java
index 10d92312fc..d65d0d04a8 100644
--- a/src/test/java/com/rultor/profiles/GithubProfileValidationTest.java
+++ b/src/test/java/com/rultor/profiles/GithubProfileValidationTest.java
@@ -29,7 +29,6 @@
*/
package com.rultor.profiles;
-import com.google.common.base.Joiner;
import com.jcabi.github.Github;
import com.jcabi.github.Repo;
import com.jcabi.github.Repos;
@@ -37,9 +36,10 @@
import com.rultor.spi.Profile;
import java.io.IOException;
import java.io.InputStream;
+import java.util.Base64;
import java.util.Map;
import javax.json.Json;
-import org.apache.commons.codec.binary.Base64;
+import org.cactoos.text.JoinedText;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.junit.Ignore;
@@ -78,10 +78,11 @@ public void acceptsEmptyYaml() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectsYamlWithoutMergeScript() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"merge:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -94,10 +95,11 @@ public void rejectsYamlWithoutMergeScript() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectsYamlWithoutDeployScript() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"deploy:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -110,10 +112,11 @@ public void rejectsYamlWithoutDeployScript() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectsYamlWithoutReleaseScript() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"release:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -125,11 +128,12 @@ public void rejectsYamlWithoutReleaseScript() throws Exception {
@Test
public void acceptsYamlWithOnlyMerge() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"merge:",
" script:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -141,11 +145,12 @@ public void acceptsYamlWithOnlyMerge() throws Exception {
@Test
public void acceptsYamlWithOnlyRelease() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"release:",
" script:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -157,11 +162,12 @@ public void acceptsYamlWithOnlyRelease() throws Exception {
@Test
public void acceptsYamlWithOnlyDeploy() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"deploy:",
" script:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -173,7 +179,8 @@ public void acceptsYamlWithOnlyDeploy() throws Exception {
@Test
public void acceptsYamlWithAllCommands() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"deploy:",
" script:",
" - pwd",
@@ -183,7 +190,7 @@ public void acceptsYamlWithAllCommands() throws Exception {
"merge:",
" script:",
" - pwd"
- )
+ ).asString()
);
new GithubProfile(repo).read();
}
@@ -195,12 +202,13 @@ public void acceptsYamlWithAllCommands() throws Exception {
@Test
public void getExistAssets() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"friends:",
" - jeff/test",
"assets:",
" settings.xml: \"jeff/test#exist.txt\""
- )
+ ).asString()
);
final Map map = new GithubProfile(repo).assets();
MatcherAssert.assertThat(
@@ -216,12 +224,13 @@ public void getExistAssets() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectGetAssetWithNotExistFile() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"friends:",
" - jeff/test",
"assets:",
" settings.xml: \"jeff/test#something.txt\""
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -233,12 +242,13 @@ public void rejectGetAssetWithNotExistFile() throws Exception {
@Test(expected = IllegalArgumentException.class)
public void rejectGetAssetWithWrongRepo() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"friends:",
" - jeff/test",
"assets:",
" settings.xml: \"jeff/fail#exist.txt\""
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -250,12 +260,13 @@ public void rejectGetAssetWithWrongRepo() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectGetAssetWithNoFriendUser() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"friends:",
" - zheus/test",
"assets:",
" settings.xml: \"jeff/test#exist.txt\""
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -267,10 +278,11 @@ public void rejectGetAssetWithNoFriendUser() throws Exception {
@Test(expected = Profile.ConfigException.class)
public void rejectGetAssetWithNoFriends() throws Exception {
final Repo repo = GithubProfileValidationTest.repo(
- Joiner.on('\n').join(
+ new JoinedText(
+ "\n",
"assets:",
" settings.xml: \"jeff/test#exist.txt\""
- )
+ ).asString()
);
new GithubProfile(repo).assets();
}
@@ -290,7 +302,10 @@ private static Repo repo(final String yaml) throws IOException {
Json.createObjectBuilder()
.add("path", ".rultor.yml")
.add("message", "just test")
- .add("content", Base64.encodeBase64String(yaml.getBytes()))
+ .add(
+ "content",
+ Base64.getEncoder().encodeToString(yaml.getBytes())
+ )
.build()
);
repo.contents().create(