Search in sources :

Example 1 with SubText

use of org.cactoos.text.SubText in project cactoos by yegor256.

the class SolidMapTest method mapsEmptyIterableWithKeyFuncAndValueFunc.

@Test
public void mapsEmptyIterableWithKeyFuncAndValueFunc() {
    final SolidMap<String, String> map = new SolidMap<>(key -> new SubText(new TextOf(key), 0, 1).asString(), value -> new UpperText(new TextOf(value)).asString(), new IterableOf<String>());
    MatcherAssert.assertThat("Empty Iterable cannot be accepted for key and value mapping", map, new MatcherOf<>(m -> m.size() == 0));
}
Also used : UpperText(org.cactoos.text.UpperText) MatcherAssert(org.hamcrest.MatcherAssert) Map(java.util.Map) IterableOf(org.cactoos.iterable.IterableOf) Matchers(org.hamcrest.Matchers) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test) SubText(org.cactoos.text.SubText) Scalar(org.cactoos.Scalar) MatcherOf(org.cactoos.matchers.MatcherOf) RunsInThreads(org.cactoos.matchers.RunsInThreads) UpperText(org.cactoos.text.UpperText) SubText(org.cactoos.text.SubText) TextOf(org.cactoos.text.TextOf) Test(org.junit.Test)

Example 2 with SubText

use of org.cactoos.text.SubText in project cactoos by yegor256.

the class SolidMapTest method mapsIterableWithKeyFuncAndValueFunc.

@Test
public void mapsIterableWithKeyFuncAndValueFunc() {
    final SolidMap<String, String> map = new SolidMap<>(key -> new SubText(new TextOf(key), 0, 1).asString(), value -> new UpperText(new TextOf(value)).asString(), new IterableOf<>("aa", "bb"));
    MatcherAssert.assertThat("Functions are not applied to key and value", map, Matchers.allOf(Matchers.hasEntry(Matchers.equalTo("a"), Matchers.equalTo("AA")), Matchers.hasEntry(Matchers.equalTo("b"), Matchers.equalTo("BB")), new MatcherOf<>(m -> m.size() == 2)));
}
Also used : UpperText(org.cactoos.text.UpperText) SubText(org.cactoos.text.SubText) TextOf(org.cactoos.text.TextOf) MatcherOf(org.cactoos.matchers.MatcherOf) Test(org.junit.Test)

Aggregations

MatcherOf (org.cactoos.matchers.MatcherOf)2 SubText (org.cactoos.text.SubText)2 TextOf (org.cactoos.text.TextOf)2 UpperText (org.cactoos.text.UpperText)2 Test (org.junit.Test)2 Map (java.util.Map)1 Scalar (org.cactoos.Scalar)1 IterableOf (org.cactoos.iterable.IterableOf)1 RunsInThreads (org.cactoos.matchers.RunsInThreads)1 MatcherAssert (org.hamcrest.MatcherAssert)1 Matchers (org.hamcrest.Matchers)1