Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jan 27, 2019
2 parents ab8f142 + 5feae8c commit 0314962
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 16 deletions.
18 changes: 14 additions & 4 deletions src/main/java/org/cactoos/io/Joined.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,15 +40,25 @@ public final class Joined implements Input {
*/
private final Iterable<Input> inputs;

/**
* Ctor.
* @param ipts Iterable of inputs
*/
public Joined(final Iterable<Input> ipts) {
this.inputs = ipts;
}

/**
* Ctor.
* @param first First input
* @param rest The rest
* @param rest The other inputs
*/
public Joined(final Input first, final Input... rest) {
this.inputs = new org.cactoos.iterable.Joined<>(
first,
new IterableOf<>(rest)
this(
new org.cactoos.iterable.Joined<>(
first,
new IterableOf<>(rest)
)
);
}

Expand Down
41 changes: 29 additions & 12 deletions src/test/java/org/cactoos/io/JoinedTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,49 @@
package org.cactoos.io;

import java.io.IOException;
import org.cactoos.text.TextOf;
import org.hamcrest.MatcherAssert;
import org.cactoos.iterable.IterableOf;
import org.junit.Test;
import org.llorllale.cactoos.matchers.TextHasString;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.InputHasContent;

/**
* Unit tests for {@link Joined}.
* @since 0.36
* @checkstyle ClassDataAbstractionCouplingCheck (500 lines)
*/
public final class JoinedTest {
/**
* Must join inputs in the given order.
* @throws IOException If an error occurs
*/
@Test
public void joinsOk() throws IOException {
MatcherAssert.assertThat(
public void joinsOk() {
new Assertion<>(
"Cannot properly join inputs",
new TextOf(
new Joined(
new InputOf("first"),
new InputOf("second"),
new InputOf("third")
() -> new Joined(
new InputOf("first"),
new InputOf("second"),
new InputOf("third")
),
new InputHasContent("firstsecondthird")
).affirm();
}

/**
* Must join inputs of the iterable in the given order.
*/
@Test
public void fromIterable() {
new Assertion<>(
"Can't join iterable of inputs",
() -> new Joined(
new IterableOf<>(
new InputOf("ab"),
new InputOf("cde"),
new InputOf("fghi")
)
),
new TextHasString("firstsecondthird")
);
new InputHasContent("abcdefghi")
).affirm();
}
}

0 comments on commit 0314962

Please sign in to comment.