Code Monkey home page Code Monkey logo

cactoos-matchers's Introduction

Hi there ๐Ÿ‘‹

You might know me from My Blog, LinkedIn, Twitter, DZone, or several other places.

You've found my base of operations.

  • ๐Ÿ”ญ Iโ€™m currently helping organizations grow their expertise in Golang and Kubernetes to achieve scale
  • ๐ŸŒฑ Iโ€™m currently learning Kubernetes, Istio, and Google Cloud Platform (GCP)
  • ๐Ÿ’ฌ Ask me about OAuth2, OIDC, DIDComm, Verifiable Credentials, Golang, Kubernetes, Istio, and GCP

cactoos-matchers's People

Contributors

allcontributors[bot] avatar andreoss avatar borysfan avatar dgroup avatar fanifieiev avatar jsoroka avatar kokodyn avatar llorllale avatar paulodamaso avatar rultor avatar scristalli avatar sharpler avatar victornoel avatar vzurauskas avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

cactoos-matchers's Issues

TeeInputHasResult.java:46-48: Delete TeeInputHasResult...

The puzzle 58-b44e1a44 from #58 has to be resolved:

* @todo #58:30min Delete TeeInputHasResult from the library. It's too specific.
* Users should use InputHasContent instead. Should be moved to test packages
* in cactoos.

The puzzle was created by @rultor on 03-Jan-19.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Matcher to check that text has lines, independent to different OS

Now, when you want to check that text has specific lines you have to use something like

    @Test
    public void hasLines() {
        MatcherAssert.assertThat(
            new TextOf(....).asString(),
            Matchers.anyOf(
                // OSX, Linux
                Matchers.equalTo(
                    "Line A.\n\n" +
                        "Line B.\n" +

                        "Line N.\n\n]."
                ),
                // Windows
                Matchers.equalTo(
                    "Line A.\r\n\r\n" +
                        "Line B.\r\n" +
                          
                        "Line N.\r\n\r\n"
                )
            )
        );
    }

with text duplication which cause long tests.

InputHasContent.java:43-47: All the matchers should...

The puzzle 7-0cc4122b from #7 has to be resolved:

* @todo #7:30min All the matchers should implement describeMismatchSafely and
* their tests must verify that the implementation of the descriptions
* are satisfactory. The matchers should not expose publicly the xxxSafely
* method and the tests should rely on actual real use with assertThat.
* See ScalarHasValueTest for an example of a satisfactory result.

The puzzle was created by Victor Noรซl on 19-May-18.

Estimate: 30 minutes,

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Matcher to check by particular function that iterable has values - contains, endsWith, startsWith, non-null, etc

For example,

        MatcherAssert.assertThat(
            new ListOf<>("aA", "bB", "cC"),
            new HasValues<>("aA", "cC")
        );

        MatcherAssert.assertThat(
            new ListOf<>("aA", "bB", "cC"),
            new HasValues<>(
                expected -> expected.endsWith("A") || expected.endsWith("cC") 
            )
        );

        MatcherAssert.assertThat(
            new ListOf<>("aA", "bB", "cC"),
            new HasValues<>(
                expected -> expected.startsWith("a") || expected.startsWith("b")
            )
        );

Assertion.java:71-73: Replace all uses of...

The puzzle 18-b493cd89 from #18 has to be resolved:

* @todo #18:30min Replace all uses of MatcherAssert.assertThat() with
* Assertion, and ban all overloads of the former in forbidden-apis.txt.
* We should also look into banning common matchers like Matchers.is(), etc.

The puzzle was created by George Aristy on 08-Dec-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

TextMatcherEnvelope.java:39-42: Extends the envelope in...

The puzzle 16-acf734f9 from #16 has to be resolved:

* @todo #16:30min Extends the envelope in TextIs, TextHasString, StartsWith,
* EndsWith. Most of operations with text like startsWith, endsWith, contains,
* equals, etc has the same algorithm. There is only difference in the function
* which should be applied to text.

The puzzle was created by Yurii Dubinka on 08-Dec-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Matcher ScalarHasValue has to override describeMismatchSafely for better output

This ticket is moved from yegor256/cactoos#816

Currently, ScalarHasValue doesn't override method describeMismatchSafely that leads to the next problem:

final ScalarHasValue<String> matcher =
    new ScalarHasValue<>(new IsEqual<>("expected"));
final Scalar<String> scalar = new UncheckedScalar<>(() -> "actual");
final StringDescription description = new StringDescription();
matcher.describeMismatch(scalar, description);
System.out.println(description.toString());
// the out is:
// was <org.cactoos.scalar.UncheckedScalar@368239c8>
// how it should look like:
// was "actual"

so it prints an actual version incorrectly: default toString method is called for the Scalar.

Expected:

  • the value of scalar is printed as an actual value of matching.

What should be fixed

  • class ScalarHasValue has to override method describeMismatchSafely and convert Scalar to String properly.

HasSize matcher for Assertion in order to support the Collection and Iterable

Now hamcrest has 2 different matchers in order to check the size of the collection (which is iterable) and iterable. Sometimes you can't use them easily without static methods from org.hamcrest.Matchers:

  • org.hamcrest.Matchers#iterableWithSize(...)
  • org.hamcrest.Matchers#hasSize(...)

We are going to deprecate the static methods from Matchers thus we need to give an alternative to that behavior.

MatchesRegexTest.java:72-86: The TextMatcherEnvelope...

The puzzle 35-b5eec46c from #35 has to be resolved:

* @todo #35:30min The TextMatcherEnvelope should support the description
* for actual/expected values separately. For example, for now we are
* using single `TextMatcherEnvelope#TextMatcherEnvelope(Matcher, String)`
* description object which describe actual/expected objects and leads to
* uninformative message in case of failure of MatchesRegexp. For example
* <pre>{@code
* java.lang.AssertionError:
* Expected: Text matches "^.*know\sit\.$"
* but: Text matches "I'm simple."
* }</pre> Its better to have this error message
* <pre>{@code
* java.lang.AssertionError:
* Expected: Text matches "^.*know\sit\.$"
* but: Text is "I'm simple."
* }</pre>

The puzzle was created by Yurii Dubinka on 09-Dec-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

HasValuesTest.java:63-67: Matcher to test {@link...

The puzzle 32-59ea1519 from #32 has to be resolved:

* @todo #32:30m Matcher to test {@link org.hamcrest.Matcher} objects.
* In order to check the matchers we should verify that
* - error message is correct in case false status
* - the status of testing is correct itself.
* The possible name - {@code IsMatcherOf}.

The puzzle was created by rultor on 27-Nov-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

NotBlank.java:36-38: NotBlank should be changed to...

The puzzle 58-21ae45f3 from #58 has to be resolved:

* @todo #58:30min NotBlank should be changed to `IsBlank`. Users should
* be able to negate it by simply decorating it with `IsNot`. Update the
* README once done.

The puzzle was created by @rultor on 03-Jan-19.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Package `org.llorllale.cactoos.matchers` contains all matchers and should be split

In order to make the project more clear for understanding i propose to move the matchers to dedicated packages like:

  • org.llorllale.cactoos.matcher.text
  • org.llorllale.cactoos.matcher.collection
  • org.llorllale.cactoos.matcher.iterable
  • org.llorllale.cactoos.matcher.number
  • org.llorllale.cactoos.matcher.io
  • org.llorllale.cactoos.matcher.scalar
  • org.llorllale.cactoos.matcher.text
  • org.llorllale.cactoos.matcher.exception
  • etc

TextHasString is broken or misnamed

TextHasString default is behaving incorrectly, according to its name. I've received the following error when implementing a test class:

java.lang.AssertionError: 
Expected: Text with "text/plain"
     but: Text with "HTTP/1.1 200 OK\r\nContent-type: text/plain"

According to the class name, it's expected that this matcher asserts if there is any occurrence of the sample String in the text object; however it is expecting the exact match of the sample String and the text.

I see two solutions for this case:

  • Refactor TextHasString and change its default behavior, which uses IsEqual<> for comparing, when it should use StringContains;
  • Rename the class to something like TextIsString or TextEqualsString (but I don't know if it is worth just renaming; why don't just use IsEqual<> instead then?).

Extend AllOf in order to support varargs for Matchers

Now, if we want to use the org.hamcrest.core.AllOf we have to write something like

new AllOf<>(
    new IterableOf<>(
        new Matcher<>(
            ...
        ),
        new Matcher<>(
            ...
        ),
        new Matcher<>(
            ...
        )
    )
)

We can avoid it using Matchers.allOf(Matcher ...args), but its belongs to the lib hamcrest-all.
I propose to extend the AllOf in order to support the vararg ctor which allows us to avoid instantiation of iterable, and without unnecessary indents, we may write most matchers like:

new AllOf<>(
    new Matcher<>( ... ),
    new Matcher<>( ... ),
    new Matcher<>( ... )
)

Migrate from cactoos some matchers leftover in their test packages

We missed these matchers found only in cactoos test packages. We need to bring them over here:

  • BehavesAsCollection
  • BehavesAsList
  • BehavesAsMap
  • ClearDeletesAllValues
  • PutUpdatesValues
  • PutAllUpdatesValues
  • RemoveDeletesValues

We'll release 1.0 once this is complete.

HasLines doesn't explain the failed scenario properly

Today I found that HasLines

    @Test
    public void test(){
        MatcherAssert.assertThat(
            String.format("l1%nl2"),
            new HasLines("l1", "l3")
        );
    }

doesn't explain the failed scenario properly

java.lang.AssertionError: 
Expected: <org.cactoos.text.TextOf@3ab39c39>
     but: <org.cactoos.text.TextOf@2eee9593>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)

We need to call text.asString() instead of Text.toString().

Wrong ctor arg name and javadoc

ScalarHasValue has the following Ctor:

/**
* Ctor.
* @param text The text to match against
*/
public ScalarHasValue(final T text) {
this(new IsEqual<>(text));
}
/**
* Ctor.
* @param mtr Matcher of the text
*/
public ScalarHasValue(final Matcher<T> mtr) {
super();
this.matcher = mtr;
}

The javadoc speaks about text which is wrong. And so does the param in the first Ctor.
The scalar is generic and text is not an appropriate name.

I would suggest a more generic name like value.

Coverage is too low

Need to un-comment the jacoco configurations in the POM and make the following errors go away:

--- jacoco-maven-plugin:0.7.7.201606060606:check (jacoco-check) @ cactoos-matchers ---
Loading execution data file C:\dev\cactoos-matchers\target\jacoco.exec
Analyzed bundle 'cactoos-matchers' with 7 classes
Rule violated for bundle cactoos-matchers: instructions covered ratio is 0.00, but expected minimum is 0.61
Rule violated for bundle cactoos-matchers: lines covered ratio is 0.00, but expected minimum is 0.65
Rule violated for bundle cactoos-matchers: branches covered ratio is 0.00, but expected minimum is 0.65
Rule violated for bundle cactoos-matchers: complexity covered ratio is 0.00, but expected minimum is 0.57
Rule violated for bundle cactoos-matchers: methods covered ratio is 0.00, but expected minimum is 0.57

For starters, the CodeCov report from cactoos can be found here.

RunsInThreadsTest fails with ClassCastException ~10% of the time

On Fedora26, Oracle JDK8 u171 x64.

Looks like RunsInThreadTest assumes that concurrent modification of a HashMap only generates ConcurrentModificationException but actually one must not assume any particular exception type when there is more than one thread accessing the HashMap.

Tests run: 2, Failures: 0, Errors: 1, Skipped: 0, Time elapsed: 0.536 sec <<< FAILURE! - in org.llorllale.cactoos.matchers.RunsInThreadsTest
matchNegative(org.llorllale.cactoos.matchers.RunsInThreadsTest)  Time elapsed: 0.21 sec  <<< ERROR!
java.io.UncheckedIOException: java.io.IOException: java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
        at org.cactoos.scalar.UncheckedScalar.value(UncheckedScalar.java:60)
        at org.llorllale.cactoos.matchers.RunsInThreads.matchesSafely(RunsInThreads.java:109)
        at org.llorllale.cactoos.matchers.RunsInThreadsTest.matchNegative(RunsInThreadsTest.java:65)
        at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
        at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
        at java.lang.reflect.Method.invoke(Method.java:498)
        at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
        at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
        at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
        at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
        at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
        at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
        at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
        at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
        at java.util.concurrent.FutureTask.run(FutureTask.java:266)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
        at java.lang.Thread.run(Thread.java:748)
Caused by: java.io.IOException: java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
        at org.cactoos.func.UncheckedFunc.lambda$apply$0(UncheckedFunc.java:58)
        at org.cactoos.scalar.CheckedScalar.value(CheckedScalar.java:84)
        at org.cactoos.scalar.IoCheckedScalar.value(IoCheckedScalar.java:65)
        at org.cactoos.scalar.UncheckedScalar.value(UncheckedScalar.java:58)
        at org.cactoos.func.UncheckedFunc.apply(UncheckedFunc.java:59)
        at org.cactoos.scalar.CheckedScalar.wrappedException(CheckedScalar.java:108)
        at org.cactoos.scalar.CheckedScalar.value(CheckedScalar.java:93)
        at org.cactoos.scalar.IoCheckedScalar.value(IoCheckedScalar.java:65)
        at org.cactoos.scalar.UncheckedScalar.value(UncheckedScalar.java:58)
        ... 20 more
Caused by: java.util.concurrent.ExecutionException: java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
        at java.util.concurrent.FutureTask.report(FutureTask.java:122)
        at java.util.concurrent.FutureTask.get(FutureTask.java:192)
        at org.cactoos.scalar.And.lambda$null$0(And.java:111)
        at org.cactoos.scalar.And.value(And.java:137)
        at org.cactoos.scalar.And.value(And.java:61)
        at org.cactoos.scalar.CheckedScalar.value(CheckedScalar.java:84)
        ... 22 more
Caused by: java.lang.ClassCastException: java.util.HashMap$Node cannot be cast to java.util.HashMap$TreeNode
        at java.util.HashMap$TreeNode.moveRootToFront(HashMap.java:1832)
        at java.util.HashMap$TreeNode.putTreeVal(HashMap.java:2012)
        at java.util.HashMap.putVal(HashMap.java:638)
        at java.util.HashMap.put(HashMap.java:612)
        at org.llorllale.cactoos.matchers.RunsInThreadsTest.modify(RunsInThreadsTest.java:88)
        at org.llorllale.cactoos.matchers.RunsInThreads.lambda$matchesSafely$0(RunsInThreads.java:98)
        ... 4 more

HasValues.java:47-49: HasValuesMatching that accepts...

The puzzle 36-7ebfe74b from #36 has to be resolved:

* @todo #36:30min HasValuesMatching that accepts matching function.
* For example, the "non-null", "startWith", "endsWith", "greaterThan" etc.
* The HasValue matcher should work only with pre-defined set of expected items

The puzzle was created by Yurii Dubinka on 04-Dec-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

HasProperties matcher to check that java.util.Properties has particular entry(s)

In case of single property

      MatcherAssert.assertThat(
            "The 1st team has expected <team/1st/properties/1st> tag",
            new PropertiesOf<>(...),
            new HasProperties("the key", "the value")
      );

In case of multiple property it may looks like

      MatcherAssert.assertThat(
            "The 1st team has expected <team/1st/properties/1st> tag",
            new PropertiesOf<>(...),
            new HasProperties(MapEntry ...entries)
      );

Let's discuss the possiblity of this functionality.

Envelope for TypeSafeMatcher - reduce the code duplication within the matchers

TypeSafeMatcher was chosen as an example of how to easily implement hamcrest matcher, however, we have code duplication for each implementation of TypeSafeMatcher:

  • overriding of 3 methods match, describeTo, describeMismatch
  • for each of these methods, we need the fields in order to constructs the methods
  • most of these methods are operating with cactoos primitives, thus, we are using a lot of Unchecked implementations
  • when we were working on Text-based matchers we understood that something went wrong and implement the TextMatcherEnvelope. That was a good decision, but we need to extend it to the whole project. TextMatcherEnvelope should extend Envelope
  • envelope give a standard approach for matcher implementation, for example, the InputHasContent has no overridden describeMismatch method and this won't happen in case if the envelope was used. It similar to Assertion vsMatcherAssert.assertThat, when developers skipping the reason explanation of test (they can't do that using Assertion).

The envelope may look like

package org.llorllale.cactoos.matchers;

import org.cactoos.BiProc;
import org.cactoos.Func;
import org.cactoos.Proc;
import org.cactoos.func.UncheckedBiProc;
import org.cactoos.func.UncheckedFunc;
import org.cactoos.func.UncheckedProc;
import org.hamcrest.Description;
import org.hamcrest.Matcher;
import org.hamcrest.TypeSafeMatcher;

public class Envelope<T> extends TypeSafeMatcher<T> {

    private final Matcher<T> origin;

    public Envelope(
        final Func<T, Boolean> matches,
        final Proc<Description> describe,
        final BiProc<Description, T> mismatch
    ) {
        this(new TypeSafeMatcher<T>() {
                 @Override
                 public void describeTo(final Description description) {
                     new UncheckedProc<>(describe).exec(description);
                 }

                 @Override
                 protected boolean matchesSafely(final T o) {
                     return new UncheckedFunc<>(matches).apply(o);
                 }

                 @Override
                 protected final void describeMismatchSafely(
                     final T item, final Description desc) {
                    new UncheckedBiProc<>(mismatch).exec(desc, item);
                 }
             }
        );
    }

    public Envelope(final Matcher<T> origin) {
        this.origin = origin;
    }

    @Override
    protected final boolean matchesSafely(final T t) {
        return this.origin.matches(t);
    }

    @Override
    public final void describeTo(final Description desc) {
        this.origin.describeTo(desc);
    }

    @Override
    protected final void describeMismatchSafely(
        final T item, final Description desc) {
        this.origin.describeMismatch(item, desc);
    }
}

For example, the InputHasContent with envelope will became

public final class InputHasContent extends Envelope<Input> {

    /**
     * Ctor.
     * @param text The text to match against
     */
    public InputHasContent(final String text) {
        this(new TextOf(text));
    }

    /**
     * Ctor.
     * @param text The text to match against
     */
    public InputHasContent(final Text text) {
        this(new MatcherOf<>((String input) -> text.asString().equals(input)));
    }

    /**
     * Ctor.
     * @param mtr Matcher of the text
     */
    public InputHasContent(final Matcher<String> mtr) {
        super(
            input -> mtr.matches(new TextOf(input).asString()),
            desc -> {
                desc.appendText("Input with ").appendDescriptionOf(mtr);
            },
            (desc, input) -> desc.appendText("Input with ").appendValue(
                new TextOf(input).asString()
            )
        );
    }
}

which is much shorter than

public final class InputHasContent extends TypeSafeMatcher<Input> {

    /**
     * Matcher of the value.
     */
    private final Matcher<String> matcher;

    /**
     * Ctor.
     * @param text The text to match against
     */
    public InputHasContent(final String text) {
        this(new TextOf(text));
    }

    /**
     * Ctor.
     * @param text The text to match against
     */
    public InputHasContent(final Text text) {
        this(new MatcherOf<>((String input) -> text.asString().equals(input)));
    }

    /**
     * Ctor.
     * @param mtr Matcher of the text
     */
    public InputHasContent(final Matcher<String> mtr) {
        super();
        this.matcher = mtr;
    }

    @Override
    public boolean matchesSafely(final Input item) {
        return this.matcher.matches(
            new UncheckedText(
                new TextOf(item)
            ).asString()
        );
    }

    @Override
    public void describeTo(final Description description) {
        description.appendText("Input with ");
        description.appendDescriptionOf(this.matcher);
    }
}

Intermittent failure in RunsInThreadsTest.matchNegative

Log

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.168 sec <<< FAILURE! - in org.llorllale.cactoos.matchers.RunsInThreadsTest
matchNegative(org.llorllale.cactoos.matchers.RunsInThreadsTest)  Time elapsed: 0.167 sec  <<< FAILURE!
java.lang.AssertionError: 
Can concurrently modify HashMap
Expected: <false>
     but: was <true>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.llorllale.cactoos.matchers.RunsInThreadsTest.matchNegative(RunsInThreadsTest.java:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Assertion.java:74-77: Assertion relies on the operation...

The puzzle 18-a9679abd from #18 has to be resolved:

* @todo #18:30min Assertion relies on the operation under test to be idempotent
* in order to match "error matchers" such as `Throws` as expected. This may
* not be the case for all operations and could be a problem. Investigate if
* there's a way around/through this.

The puzzle was created by George Aristy on 08-Dec-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

HasEntry matcher to check that map has particular entry

Now when i need to write the unit test with java.util.Map i have to use something like

        MatcherAssert.assertThat(
            "The 1st team has expected <team/1st/properties/1st> tag",
            new MapOf<>(...),
            new IsMapContaining<>(
                new IsEqual<>("the key"),
                new IsEqual<>("the value")
            )
        );

and it would be more clear if we add a new matcher HasEntry like

       MatcherAssert.assertThat(
            "The 1st team has expected <team/1st/properties/1st> tag",
            new MapOf<>(...),
            new HasEntry<>("the key", "the value")
        );

The class may have 3 constructors:

  • HasEntry(key, value)
  • HasEntry(Map.Entry entry)
  • HasEntry(BiFunc<K,V,Boolean, String mismatch explanation))

Let's discuss the possiblity of this feature.

Upgrade qulice to 0.17.3

Shamelessly copied from yegor256/cactoos-http#49 :)

New qulice version brings following important changes:

  • removal of @author tag (it is prohibited now)
  • removal of @version tag (it is prohibited now)
  • license header should start with /* instead of /** - this will fix problem with IntelliJ reporting it as a javadoc that is not attached to any class
  • checkstyle validation performance improvement (speedup of ~ 10%)
  • And few minor formatting changes.

Please upgrade the qulice and fix the new problems found.

cactoos-matchers depends on cactoos which contains the matchers!

There is two thing really strange:

  1. cactoos-matchers relies on an old version of cactoos that currently contains the very same matchers
  2. if cactoos-matchers were relying on a newer version of cactoos, the latter would rely on cactoos-matchers: this is not very good architecturally speaking!

This should be fixed, I don't know how.

findbugs should be enabled in qulice

We should enable findbugs in qulice, there is no work to do, the build already passes with it currently.

Also there is a useless configuration property in qulice configuration too that could be removed.

Provide a way to test the stability/correctness of concurrency tests

During the implementation of yegor256/cactoos#968 I've started to think how to avoid the cases like #22.
Sometimes the test from #22 is failing, sometimes not and in order to prevent it again we can execute the fragile concurrent test(s) at least 20-50 times which can give us some level of confidence.

For example, junit 5 support such way

@RepeatedTest(10)
void repeatedTest() {
    // ...
}

As i understood we are not considering the upgrade to junit5 now, so i've googled a few approaches which may help (but review is required):

HasValues.java:64-66: Add the opportunity to print the...

The puzzle 32-2540e9c8 from #32 has to be resolved:

* @todo #32:30m Add the opportunity to print the exp values to the
* description in order to avoid abstract message like
* "The function applied to X,Y,Z is failed".

The puzzle was created by rultor on 27-Nov-18.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

Replace MatcherAssert.assertThat with 'new Assertion<>'

Let's add a substitute for MatcherAssert.assertThat, something like Assertion<T>:

new Assertion<>(
    "Collection cannot be empty",
    collection.size(),
    new IsNot<>(0)
).verify();    //might throw AssertionError

Note: ctor must have the reason text parameter

EndsWithTest.java:40-42: Ban all overloads of the former...

The puzzle 52-f2eb48e2 from #52 has to be resolved:

* @todo #52:30min Ban all overloads of the former in forbidden-apis.txt.
* We should also look into banning common static matchers like Matchers.is(),
* etc.

The puzzle was created by @dgroup on 15-Jan-19.

If you have any technical questions, don't ask me, submit new tickets instead. The task will be "done" when the problem is fixed and the text of the puzzle is removed from the source code. Here is more about PDD and about me.

org.llorllale.cactoos.matchers.RunsInThreadsTest.matchNegative(RunsInThreadsTest.java:61)

Observed in #48
https://travis-ci.org/llorllale/cactoos-matchers/builds/465352255?utm_source=github_status&utm_medium=notification

Tests run: 2, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.247 sec <<< FAILURE! - in org.llorllale.cactoos.matchers.RunsInThreadsTest
matchNegative(org.llorllale.cactoos.matchers.RunsInThreadsTest)  Time elapsed: 0.207 sec  <<< FAILURE!
java.lang.AssertionError: 
Can concurrently modify HashMap
Expected: <false>
     but: was <true>
	at org.hamcrest.MatcherAssert.assertThat(MatcherAssert.java:20)
	at org.llorllale.cactoos.matchers.RunsInThreadsTest.matchNegative(RunsInThreadsTest.java:61)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:498)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
	at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.apache.maven.surefire.junitcore.pc.Scheduler$1.run(Scheduler.java:393)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
	at java.util.concurrent.FutureTask.run(FutureTask.java:266)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
	at java.lang.Thread.run(Thread.java:748)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.