Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Mar 29, 2021
2 parents 047fb51 + 0bf6c79 commit 3e37919
Show file tree
Hide file tree
Showing 12 changed files with 142 additions and 208 deletions.
12 changes: 6 additions & 6 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -131,12 +131,12 @@ The MIT License (MIT)
<artifactId>junit</artifactId>
<version>4.13</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
<version>1.3</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.hamcrest</groupId>
<artifactId>hamcrest-core</artifactId>
</exclusion>
</exclusions>
</dependency>
</dependencies>
<build>
Expand Down
13 changes: 4 additions & 9 deletions src/test/java/org/cactoos/bytes/BytesOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@
import org.cactoos.io.Sticky;
import org.cactoos.iterable.Endless;
import org.cactoos.iterable.HeadOf;
import org.cactoos.iterable.IterableOf;
import org.cactoos.iterable.IterableOfBytes;
import org.cactoos.iterator.IteratorOfBytes;
import org.cactoos.text.Concatenated;
Expand Down Expand Up @@ -89,10 +88,8 @@ void readsInputIntoBytes() throws Exception {
)
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hello, "),
new EndsWith("друг!")
)
new StartsWith("Hello, "),
new EndsWith("друг!")
)
).affirm();
}
Expand Down Expand Up @@ -130,10 +127,8 @@ void readsInputIntoBytesWithSmallBuffer() throws Exception {
)
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hello,"),
new EndsWith("товарищ!")
)
new StartsWith("Hello,"),
new EndsWith("товарищ!")
)
).affirm();
}
Expand Down
13 changes: 4 additions & 9 deletions src/test/java/org/cactoos/bytes/InputAsBytesTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
import org.cactoos.io.SlowInputStream;
import org.cactoos.iterable.Endless;
import org.cactoos.iterable.HeadOf;
import org.cactoos.iterable.IterableOf;
import org.cactoos.text.TextOf;
import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsEqual;
Expand Down Expand Up @@ -98,10 +97,8 @@ void readsInputIntoBytes() throws Exception {
StandardCharsets.UTF_8
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hello, "),
new EndsWith("друг!")
)
new StartsWith("Hello, "),
new EndsWith("друг!")
)
).affirm();
}
Expand All @@ -122,10 +119,8 @@ void readsInputIntoBytesWithSmallBuffer() throws Exception {
StandardCharsets.UTF_8
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hello,"),
new EndsWith("товарищ!")
)
new StartsWith("Hello,"),
new EndsWith("товарищ!")
)
).affirm();
}
Expand Down
16 changes: 4 additions & 12 deletions src/test/java/org/cactoos/collection/BehavesAsCollection.java
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.collection.IsCollectionWithSize;
import org.hamcrest.collection.IsEmptyCollection;
import org.hamcrest.core.IsCollectionContaining;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasValues;
import org.llorllale.cactoos.matchers.Verifies;

/**
Expand Down Expand Up @@ -65,11 +65,7 @@ public boolean matchesSafely(final Collection<E> col) {
new Assertion<>(
"Must contain item",
col,
new IsCollectionContaining<>(
new IsEqual<>(
this.sample
)
)
new HasValues<>(this.sample)
).affirm();
new Assertion<>(
"Must not be empty",
Expand All @@ -90,18 +86,14 @@ public boolean matchesSafely(final Collection<E> col) {
new ListOf<>(
(E[]) col.toArray()
),
new IsCollectionContaining<>(
new IsEqual<>(this.sample)
)
new HasValues<>(this.sample)
).affirm();
final E[] array = (E[]) new Object[col.size()];
col.toArray(array);
new Assertion<>(
"Array from collection must contain item",
new ListOf<>(array),
new IsCollectionContaining<>(
new IsEqual<>(this.sample)
)
new HasValues<>(this.sample)
).affirm();
new Assertion<>(
"Must contain list with the item",
Expand Down
31 changes: 10 additions & 21 deletions src/test/java/org/cactoos/io/InputOfTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@
import javax.net.ssl.TrustManager;
import javax.net.ssl.X509TrustManager;
import org.cactoos.bytes.BytesOf;
import org.cactoos.iterable.IterableOf;
import org.cactoos.text.TextOf;
import org.hamcrest.core.AllOf;
import org.hamcrest.core.IsEqual;
Expand Down Expand Up @@ -180,10 +179,8 @@ void readsStringIntoBytes() throws Exception {
StandardCharsets.UTF_8
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hello, "),
new EndsWith("друг!")
)
new StartsWith("Hello, "),
new EndsWith("друг!")
)
).affirm();
}
Expand All @@ -203,10 +200,8 @@ void readsStringBuilder() throws Exception {
)
),
new AllOf<>(
new IterableOf<>(
new StartsWith(starts),
new EndsWith(ends)
)
new StartsWith(starts),
new EndsWith(ends)
)
).affirm();
}
Expand All @@ -226,10 +221,8 @@ void readsStringBuffer() throws Exception {
)
),
new AllOf<>(
new IterableOf<>(
new StartsWith(starts),
new EndsWith(ends)
)
new StartsWith(starts),
new EndsWith(ends)
)
).affirm();
}
Expand All @@ -247,10 +240,8 @@ void readsArrayOfChars() throws Exception {
)
),
new AllOf<>(
new IterableOf<>(
new StartsWith("Hold "),
new EndsWith("infinity")
)
new StartsWith("Hold "),
new EndsWith("infinity")
)
).affirm();
}
Expand All @@ -272,10 +263,8 @@ void readsEncodedArrayOfChars() throws Exception {
StandardCharsets.UTF_8
),
new AllOf<>(
new IterableOf<>(
new StartsWith("O que sera"),
new EndsWith(" que sera")
)
new StartsWith("O que sera"),
new EndsWith(" que sera")
)
).affirm();
}
Expand Down
35 changes: 16 additions & 19 deletions src/test/java/org/cactoos/map/BehavesAsMap.java
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,10 @@

import java.util.Map;
import org.hamcrest.Description;
import org.hamcrest.MatcherAssert;
import org.hamcrest.TypeSafeMatcher;
import org.hamcrest.collection.IsMapContaining;
import org.hamcrest.core.IsCollectionContaining;
import org.hamcrest.core.IsEqual;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.HasEntry;
import org.llorllale.cactoos.matchers.HasValues;

/**
* Matcher for collection.
Expand Down Expand Up @@ -62,25 +61,23 @@ public BehavesAsMap(final K akey, final V val) {
}

@Override
@SuppressWarnings("unchecked")
public boolean matchesSafely(final Map<K, V> map) {
MatcherAssert.assertThat(
"Doesn't contain the key",
new Assertion<>(
"Must contain the key/value entry",
map,
new IsMapContaining<>(
new IsEqual<>(this.key),
new IsEqual<>(this.value)
)
);
MatcherAssert.assertThat(
"Doesn't contain the key in #keySet()",
new HasEntry<>(this.key, this.value)
).affirm();
new Assertion<>(
"Must contain the key in #keySet()",
map.keySet(),
new IsCollectionContaining<>(new IsEqual<>(this.key))
);
MatcherAssert.assertThat(
"Doesn't contain the value in #values()",
new HasValues<>(this.key)
).affirm();
new Assertion<>(
"Must contain the value in #values()",
map.values(),
new IsCollectionContaining<>(new IsEqual<>(this.value))
);
new HasValues<>(this.value)
).affirm();
return true;
}

Expand Down
Loading

0 comments on commit 3e37919

Please sign in to comment.