Skip to content

Commit

Permalink
(#1434) Some more forbidden APIs
Browse files Browse the repository at this point in the history
  • Loading branch information
victornoel committed May 2, 2021
1 parent f999c06 commit 15d32b0
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 22 deletions.
6 changes: 4 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ The MIT License (MIT)
-->
<includes>
<include>org/cactoos/bytes/*.class</include>
<include>org/cactoos/map/*.class</include>
<include>org/cactoos/time/*.class</include>
<include>org/cactoos/collection/*.class</include>
<include>org/cactoos/experimental/*.class</include>
<include>org/cactoos/func/*.class</include>
<include>org/cactoos/io/*.class</include>
<include>org/cactoos/proc/*.class</include>
<include>org/cactoos/set/*.class</include>
<include>org/cactoos/test/*.class</include>
<include>org/cactoos/time/*.class</include>
</includes>
</configuration>
<executions>
Expand Down
29 changes: 17 additions & 12 deletions src/test/java/org/cactoos/proc/RepeatedProcTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,21 +26,20 @@
import java.util.concurrent.atomic.AtomicInteger;
import org.cactoos.Proc;
import org.hamcrest.core.IsEqual;
import org.junit.Assert;
import org.junit.Test;
import org.junit.jupiter.api.Test;
import org.llorllale.cactoos.matchers.Assertion;
import org.llorllale.cactoos.matchers.Throws;

/**
* Test case for {@link RepeatedProc}.
*
* @since 0.49.2
* @checkstyle MagicNumberCheck (100 line)
* @checkstyle JavadocMethodCheck (100 lines)
*/
public final class RepeatedProcTest {
final class RepeatedProcTest {

@Test
public void runsProcMultipleTimes() throws Exception {
void runsProcMultipleTimes() throws Exception {
final AtomicInteger atom = new AtomicInteger();
final Proc<AtomicInteger> func = new RepeatedProc<>(
AtomicInteger::getAndIncrement,
Expand All @@ -54,12 +53,18 @@ public void runsProcMultipleTimes() throws Exception {
);
}

@Test(expected = IllegalArgumentException.class)
public void throwsIfZero() throws Exception {
final Proc<Object> func = new RepeatedProc<>(
obj -> Assert.fail("unexpected"),
0
);
func.exec(new Object());
@Test
void throwsIfZero() throws Exception {
new Assertion<>(
"Must throw if zero",
() -> {
new RepeatedProc<>(
obj -> { },
0
).exec(new Object());
return "discarded";
},
new Throws<>(IllegalArgumentException.class)
).affirm();
}
}
13 changes: 5 additions & 8 deletions src/test/resources/forbidden-apis.txt
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
@defaultMessage Do not use static methods
@defaultMessage Do not use static methods, please use cactoos-matchers Assertion instead
org.hamcrest.Matchers

@defaultMessage Please specify failure reason
org.hamcrest.MatcherAssert#assertThat(java.lang.Object, org.hamcrest.Matcher)

@defaultMessage Please specify failure reason
org.junit.Assert#assertThat(java.lang.Object, org.hamcrest.Matcher)
org.junit.jupiter.api.Assertions
org.junit.Assert
org.hamcrest.MatcherAssert

@defaultMessage Please avoid using static methods.
java.util.Collections#unmodifiableList(java.util.List)
java.util.Collections#unmodifiableList(java.util.List)

0 comments on commit 15d32b0

Please sign in to comment.