44 */
55package org .cactoos .scalar ;
66
7- import java .util .List ;
87import java .util .ArrayList ;
8+ import java .util .List ;
99import org .cactoos .Func ;
1010import org .cactoos .Proc ;
1111import org .cactoos .Scalar ;
2828 */
2929final class WildcardSemanticsTest {
3030
31+ /**
32+ * Test string constant.
33+ */
34+ private static final String HELLO = "hello" ;
35+
3136 @ Test
3237 void scalarOfAcceptsCovariantFunc () {
3338 final Func <Object , String > func = input -> input .toString ();
@@ -41,9 +46,9 @@ void scalarOfAcceptsCovariantFunc() {
4146
4247 @ Test
4348 void scalarOfAcceptsContravariantProc () {
44- final List <String > result = new ArrayList <>();
49+ final List <String > result = new ArrayList <>(1 );
4550 final Proc <Object > proc = input -> result .add (input .toString ());
46- final String input = "hello" ;
51+ final String input = WildcardSemanticsTest . HELLO ;
4752 final String expected = "world" ;
4853 new Assertion <>(
4954 "ScalarOf must accept contravariant processor" ,
@@ -54,7 +59,7 @@ void scalarOfAcceptsContravariantProc() {
5459
5560 @ Test
5661 void mappedAcceptsCovariantScalar () {
57- final Scalar <String > scalar = () -> "hello" ;
62+ final Scalar <String > scalar = () -> WildcardSemanticsTest . HELLO ;
5863 final Func <Object , Text > func = input -> new Upper (new TextOf (input .toString ()));
5964 new Assertion <>(
6065 "Mapped must accept covariant scalar" ,
@@ -65,7 +70,7 @@ void mappedAcceptsCovariantScalar() {
6570
6671 @ Test
6772 void mappedAcceptsContravariantFunc () {
68- final Scalar <String > scalar = () -> "hello" ;
73+ final Scalar <String > scalar = () -> WildcardSemanticsTest . HELLO ;
6974 final Func <CharSequence , Text > func = input -> new Upper (new TextOf (input .toString ()));
7075 new Assertion <>(
7176 "Mapped must accept contravariant function" ,
@@ -77,7 +82,7 @@ void mappedAcceptsContravariantFunc() {
7782 @ Test
7883 void andAcceptsContravariantFunc () {
7984 final Func <CharSequence , Boolean > func = input -> input .length () > 0 ;
80- final String [] inputs = {"hello" , "world" };
85+ final String [] inputs = {WildcardSemanticsTest . HELLO , "world" };
8186 new Assertion <>(
8287 "And must accept contravariant function" ,
8388 new And (func , inputs ),
@@ -88,7 +93,7 @@ void andAcceptsContravariantFunc() {
8893 @ Test
8994 void andAcceptsCovariantIterable () {
9095 final Func <CharSequence , Boolean > func = input -> input .length () > 0 ;
91- final IterableOf <String > inputs = new IterableOf <>("hello" , "world" );
96+ final IterableOf <String > inputs = new IterableOf <>(WildcardSemanticsTest . HELLO , "world" );
9297 new Assertion <>(
9398 "And must accept covariant iterable" ,
9499 new And (func , inputs ),
@@ -99,7 +104,7 @@ void andAcceptsCovariantIterable() {
99104 @ Test
100105 void orAcceptsContravariantFunc () {
101106 final Func <CharSequence , Boolean > func = input -> input .length () > 5 ;
102- final String [] inputs = {"hi" , "hello" };
107+ final String [] inputs = {"hi" , WildcardSemanticsTest . HELLO };
103108 new Assertion <>(
104109 "Or must accept contravariant function" ,
105110 new Or (func , inputs ),
@@ -110,7 +115,7 @@ void orAcceptsContravariantFunc() {
110115 @ Test
111116 void orAcceptsCovariantIterable () {
112117 final Func <CharSequence , Boolean > func = input -> input .length () > 3 ;
113- final IterableOf <String > inputs = new IterableOf <>("hi" , "hello" );
118+ final IterableOf <String > inputs = new IterableOf <>("hi" , WildcardSemanticsTest . HELLO );
114119 new Assertion <>(
115120 "Or must accept covariant iterable" ,
116121 new Or (func , inputs ),
@@ -139,4 +144,4 @@ void scalarWithFallbackAcceptsCovariantScalar() {
139144 ).affirm ();
140145 }
141146
142- }
147+ }
0 commit comments