Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#1 Coverage is too low #15

Merged
merged 2 commits into from
May 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,6 @@
</excludes>
</configuration>
</plugin>
<!--
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
Expand Down Expand Up @@ -176,7 +175,6 @@
</execution>
</executions>
</plugin>
-->
</plugins>
</build>
</profile>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public final class MatcherOf<T> extends TypeSafeMatcher<T> {
* @param proc The func
*/
public MatcherOf(final Proc<T> proc) {
this(new FuncOf<>(proc));
this(new FuncOf<>(proc, true));
}

/**
Expand Down
51 changes: 51 additions & 0 deletions src/test/java/org/llorllale/cactoos/matchers/FuncAppliesTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/**
* The MIT License (MIT)
*
* Copyright (c) for portions of project cactoos-matchers are held by
* Yegor Bugayenko, 2017-2018, as part of project cactoos.
* All other copyright for project cactoos-matchers are held by
* George Aristy, 2018.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.llorllale.cactoos.matchers;

import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
* Test case for {@link org.llorllale.cactoos.matchers.FuncApplies}.
*
* @author Alexander Menshikov ([email protected])
* @version $Id$
* @since 1.0
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class FuncAppliesTest {
@Test
public void matchFuncs() {
final FuncApplies<Integer, Integer> matcher = new FuncApplies<>(1, 1);
MatcherAssert.assertThat(
"Can't match equaled values",
matcher.matchesSafely(x -> x),
new IsEqual<>(true)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,13 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.matchers;
package org.llorllale.cactoos.matchers;

import org.cactoos.Input;
import org.cactoos.io.InputOf;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.llorllale.cactoos.matchers.InputHasContent;

/**
* Test case for {@link org.llorllale.cactoos.matchers.InputHasContent}.
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
/**
* The MIT License (MIT)
*
* Copyright (c) for portions of project cactoos-matchers are held by
* Yegor Bugayenko, 2017-2018, as part of project cactoos.
* All other copyright for project cactoos-matchers are held by
* George Aristy, 2018.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.llorllale.cactoos.matchers;

import java.util.ConcurrentModificationException;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ThreadLocalRandom;
import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
* Test case for {@link org.llorllale.cactoos.matchers.RunsInThreads}.
*
* @author Alexander Menshikov ([email protected])
* @version $Id$
* @since 1.0
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class RunsInThreadsTest {

@Test
public void matchPositive() {
final RunsInThreads<Map<Integer, Integer>> matcher =
new RunsInThreads<>(new ConcurrentHashMap<>());
MatcherAssert.assertThat(
"Can't concurrently modify ConcurrentHashMap",
matcher.matchesSafely(RunsInThreadsTest::modify),
new IsEqual<>(true)
);
}

@Test
public void matchNegative() {
final RunsInThreads<Map<Integer, Integer>> matcher =
new RunsInThreads<>(new HashMap<>());
MatcherAssert.assertThat(
"Can concurrently modify HashMap",
matcher.matchesSafely(RunsInThreadsTest::modify),
new IsEqual<>(false)
);
}

/**
* Check possibility of concurrent modification.
*
* @param map Tested map.
* @return Return {@code true} if the map can be concurrently modified.
*/
private static boolean modify(final Map<Integer, Integer> map) {
boolean flag = true;
try {
for (final Map.Entry<Integer, Integer> entry : map.entrySet()) {
if (entry.getKey() == null || entry.getValue() == null) {
flag = false;
break;
}
}
if (flag) {
//@checkstyle MagicNumberCheck (1 line)
for (int count = 0; count < 100; ++count) {
map.put(
ThreadLocalRandom.current().nextInt(),
ThreadLocalRandom.current().nextInt()
);
}
}
} catch (final ConcurrentModificationException ignored) {
flag = false;
}
return flag;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* The MIT License (MIT)
*
* Copyright (c) for portions of project cactoos-matchers are held by
* Yegor Bugayenko, 2017-2018, as part of project cactoos.
* All other copyright for project cactoos-matchers are held by
* George Aristy, 2018.
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included
* in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.llorllale.cactoos.matchers;

import org.hamcrest.MatcherAssert;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
* Test case for {@link org.llorllale.cactoos.matchers.ScalarHasValue}.
*
* @author Alexander Menshikov ([email protected])
* @version $Id$
* @since 1.0
* @checkstyle JavadocMethodCheck (500 lines)
*/
public final class ScalarHasValueTest {

@Test
public void matchPositive() {
final ScalarHasValue<Integer> matcher = new ScalarHasValue<>(1);
MatcherAssert.assertThat(
"Can't match equaled values",
matcher.matchesSafely(() -> 1),
new IsEqual<>(true)
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.matchers;
package org.llorllale.cactoos.matchers;

import java.io.ByteArrayOutputStream;
import org.cactoos.io.OutputTo;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package org.cactoos.matchers;
package org.llorllale.cactoos.matchers;

import org.cactoos.io.InputOf;
import org.cactoos.io.Md5DigestOf;
Expand All @@ -34,7 +34,6 @@
import org.hamcrest.StringDescription;
import org.hamcrest.core.StringContains;
import org.junit.Test;
import org.llorllale.cactoos.matchers.TextHasString;

/**
* Test case for {@link TextHasString}.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,4 @@
* @version $Id$
* @since 0.1
*/
package org.cactoos.matchers;
package org.llorllale.cactoos.matchers;