2323 */
2424package org .cactoos .io ;
2525
26- import java .io .DataInputStream ;
2726import java .io .IOException ;
28- import org .cactoos .bytes .HexOf ;
2927import org .cactoos .iterable .IterableOf ;
30- import org .cactoos .text .TextOf ;
31- import org .hamcrest .core .IsEqual ;
3228import org .junit .Test ;
3329import org .llorllale .cactoos .matchers .Assertion ;
34- import org .llorllale .cactoos .matchers .TextHasString ;
30+ import org .llorllale .cactoos .matchers .InputHasContent ;
3531
3632/**
3733 * Unit tests for {@link Joined}.
@@ -47,14 +43,12 @@ public final class JoinedTest {
4743 public void joinsOk () {
4844 new Assertion <>(
4945 "Cannot properly join inputs" ,
50- () -> new TextOf (
51- new Joined (
52- new InputOf ("first" ),
53- new InputOf ("second" ),
54- new InputOf ("third" )
55- )
46+ () -> new Joined (
47+ new InputOf ("first" ),
48+ new InputOf ("second" ),
49+ new InputOf ("third" )
5650 ),
57- new TextHasString ("firstsecondthird" )
51+ new InputHasContent ("firstsecondthird" )
5852 ).affirm ();
5953 }
6054
@@ -65,55 +59,14 @@ public void joinsOk() {
6559 public void fromIterable () {
6660 new Assertion <>(
6761 "Can't join iterable of inputs" ,
68- () -> new TextOf (
69- new Joined (
70- new IterableOf <>(
71- new InputOf ("ab" ),
72- new InputOf ("cde" ),
73- new InputOf ("fghi" )
74- )
75- )
76- ),
77- new TextHasString ("abcdefghi" )
78- ).affirm ();
79- }
80-
81- /**
82- * Must join inputs of the iterable bytes.
83- * @checkstyle MagicNumberCheck (20 lines)
84- * @throws Exception If an error occurs
85- */
86- @ Test
87- public void fromIterableInputOfBytes () throws Exception {
88- final byte [] result = new byte [6 ];
89- new DataInputStream (
90- new Joined (
62+ () -> new Joined (
9163 new IterableOf <>(
92- new InputOf (
93- new BytesOf (
94- (byte ) 202 ,
95- (byte ) 254 ,
96- (byte ) 186 ,
97- (byte ) 190
98- )
99- ),
100- new InputOf (
101- new BytesOf (
102- (byte ) 222 ,
103- (byte ) 173
104- )
105- )
64+ new InputOf ("ab" ),
65+ new InputOf ("cde" ),
66+ new InputOf ("fghi" )
10667 )
107- ).stream ()
108- ).readFully (result );
109- new Assertion <>(
110- "The merged stream does not equal to the expected sum of 2" ,
111- () -> result ,
112- new IsEqual <>(
113- new HexOf (
114- new TextOf ("CAFEBABEDEAD" )
115- ).asBytes ()
116- )
68+ ),
69+ new InputHasContent ("abcdefghi" )
11770 ).affirm ();
11871 }
11972}
0 commit comments