Skip to content

Commit

Permalink
Merge branch '__rultor'
Browse files Browse the repository at this point in the history
  • Loading branch information
rultor committed Jan 16, 2019
2 parents 210c7ef + d79debe commit 8b06862
Show file tree
Hide file tree
Showing 8 changed files with 36 additions and 31 deletions.
4 changes: 2 additions & 2 deletions src/test/java/org/takes/facets/auth/IdentityTest.java
Expand Up @@ -25,7 +25,7 @@

import java.io.IOException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
Expand All @@ -42,7 +42,7 @@ public final class IdentityTest {
public void equalsToItself() throws IOException {
MatcherAssert.assertThat(
Identity.ANONYMOUS,
Matchers.equalTo(Identity.ANONYMOUS)
new IsEqual<>(Identity.ANONYMOUS)
);
}

Expand Down
18 changes: 9 additions & 9 deletions src/test/java/org/takes/facets/auth/PsAllTest.java
Expand Up @@ -28,7 +28,7 @@
import java.util.Arrays;
import java.util.Collections;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.junit.Test;
import org.takes.Response;
import org.takes.rq.RqFake;
Expand All @@ -51,7 +51,7 @@ public void thereShouldBeAtLeastOnePass() throws Exception {
new ArrayList<Pass>(0),
0
).enter(new RqFake()).has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -66,7 +66,7 @@ public void indexMustBeNonNegative() throws Exception {
Collections.singletonList(new PsFake(true)),
-1
).enter(new RqFake()).has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -84,7 +84,7 @@ public void indexMustBeSmallEnough() throws Exception {
),
2
).enter(new RqFake()).has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -99,7 +99,7 @@ public void testOneSuccessfull() throws Exception {
Collections.singletonList(new PsFake(true)),
0
).enter(new RqFake()).has(),
Matchers.is(true)
new IsEqual<>(true)
);
}

Expand All @@ -114,7 +114,7 @@ public void testOneFail() throws Exception {
Collections.singletonList(new PsFake(false)),
0
).enter(new RqFake()).has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -139,7 +139,7 @@ public void testSuccessfullIdx() throws Exception {
),
Tv.THREE
).enter(request).get().urn(),
Matchers.equalTo(resulting.enter(request).get().urn())
new IsEqual<>(resulting.enter(request).get().urn())
);
}

Expand All @@ -159,7 +159,7 @@ public void testFail() throws Exception {
),
1
).enter(new RqFake()).has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -179,7 +179,7 @@ public void exits() throws Exception {
),
1
).exit(response, exiting.enter(new RqFake()).get()),
Matchers.equalTo(response)
new IsEqual<>(response)
);
}
}
16 changes: 8 additions & 8 deletions src/test/java/org/takes/facets/auth/PsBasicDefaultTest.java
Expand Up @@ -25,7 +25,7 @@

import java.net.URLEncoder;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.junit.Test;

/**
Expand Down Expand Up @@ -53,7 +53,7 @@ public void acceptsCorrectLoginPasswordPair() throws Exception {
)
.get()
.urn(),
Matchers.equalTo("urn:foo:robert")
new IsEqual<>("urn:foo:robert")
);
}

Expand All @@ -75,7 +75,7 @@ public void supportsBothKindsOfSpace() throws Exception {
"hey you"
)
.has(),
Matchers.is(true)
new IsEqual<>(true)
);
MatcherAssert.assertThat(
new PsBasic.Default(
Expand All @@ -88,7 +88,7 @@ public void supportsBothKindsOfSpace() throws Exception {
"hey me"
)
.has(),
Matchers.is(true)
new IsEqual<>(true)
);
}

Expand All @@ -109,7 +109,7 @@ public void supportsUsersWithSpacesInTheirNames() throws Exception {
"qwer"
)
.has(),
Matchers.is(true)
new IsEqual<>(true)
);
}

Expand All @@ -135,7 +135,7 @@ public void supportsUrlencodedUrns() throws Exception {
)
.get()
.urn(),
Matchers.is(urn)
new IsEqual<>(urn)
);
}

Expand All @@ -154,7 +154,7 @@ public void rejectsIncorrectPassword() throws Exception {
)
.enter("charlie", "wrongpassword")
.has(),
Matchers.is(false)
new IsEqual<>(false)
);
}

Expand All @@ -173,7 +173,7 @@ public void rejectsIncorrectLogin() throws Exception {
)
.enter("mike", "anything")
.has(),
Matchers.is(false)
new IsEqual<>(false)
);
}
}
7 changes: 4 additions & 3 deletions src/test/java/org/takes/facets/auth/PsChainTest.java
Expand Up @@ -25,7 +25,8 @@

import java.io.IOException;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.StringContains;
import org.junit.Test;
import org.takes.rq.RqFake;
import org.takes.rs.RsEmpty;
Expand All @@ -47,7 +48,7 @@ public void chainExecutionTest() throws IOException {
new PsLogout(),
new PsFake(true)
).enter(new RqFake()).get(),
Matchers.is(Identity.ANONYMOUS)
new IsEqual<>(Identity.ANONYMOUS)
);
}

Expand All @@ -62,7 +63,7 @@ public void exitChainTest() throws IOException {
new PsFake(true)
).exit(new RsEmpty(), Identity.ANONYMOUS)
.head().iterator().next(),
Matchers.containsString("HTTP/1.1 200 O")
new StringContains("HTTP/1.1 200 O")
);
}
}
10 changes: 7 additions & 3 deletions src/test/java/org/takes/facets/hamcrest/HmBodyTest.java
Expand Up @@ -26,9 +26,9 @@

import java.util.Collections;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.StringDescription;
import org.hamcrest.core.IsEqual;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.takes.Body;
import org.takes.Request;
Expand Down Expand Up @@ -66,7 +66,7 @@ public void testsBodyValuesAreDifferent() {
Collections.<String>emptyList(),
"this"
),
Matchers.not(new HmBody<>("that"))
new IsNot<>(new HmBody<>("that"))
);
}

Expand All @@ -85,14 +85,18 @@ public void describesMismatchInReadableWay() {
matcher.describeMismatchSafely(request, description);
MatcherAssert.assertThat(
description.toString(),
Matchers.equalTo(
new IsEqual<>(
"body was: [111, 116, 104, 101, 114]"
)
);
}

/**
* HmBody can describe in readable way.
* @todo #893:30min Continue removing static class Matchers. Use the
* classes IdentityTest.java, PsAllTest.java, PsBasicDefaultTest.java,
* PsChainTest.java, HmBodyTest.java, HmRqTextBodyTest.java,
* HmRsStatusTest.java, and HmRsTextBodyTest.java as an example.
*/
@Test
public void describeToInReadableWay() {
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/takes/facets/hamcrest/HmRqTextBodyTest.java
Expand Up @@ -25,7 +25,7 @@

import java.util.Collections;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.takes.rq.RqFake;

Expand Down Expand Up @@ -61,7 +61,7 @@ public void testsBodyValueDoesNotContainsText() {
Collections.<String>emptyList(),
"some"
),
Matchers.not(new HmRqTextBody("other"))
new IsNot<>(new HmRqTextBody("other"))
);
}
}
4 changes: 2 additions & 2 deletions src/test/java/org/takes/facets/hamcrest/HmRsStatusTest.java
Expand Up @@ -26,7 +26,7 @@
import java.io.IOException;
import java.net.HttpURLConnection;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.takes.rq.RqFake;
import org.takes.tk.TkEmpty;
Expand Down Expand Up @@ -62,7 +62,7 @@ public void testsStatusOk() throws IOException {
public void testsStatusNotFound() throws IOException {
MatcherAssert.assertThat(
new TkHtml("<html><body/></html>").act(new RqFake()),
Matchers.not(
new IsNot<>(
new HmRsStatus(
HttpURLConnection.HTTP_NOT_FOUND
)
Expand Down
4 changes: 2 additions & 2 deletions src/test/java/org/takes/facets/hamcrest/HmRsTextBodyTest.java
Expand Up @@ -24,7 +24,7 @@
package org.takes.facets.hamcrest;

import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
import org.hamcrest.core.IsNot;
import org.junit.Test;
import org.takes.rs.RsWithBody;

Expand Down Expand Up @@ -54,7 +54,7 @@ public void testsBodyValueContainsText() {
public void testsBodyValueDoesNotContainsText() {
MatcherAssert.assertThat(
new RsWithBody("Some response"),
Matchers.not(new HmRsTextBody("expected something else"))
new IsNot<>(new HmRsTextBody("expected something else"))
);
}
}

1 comment on commit 8b06862

@0pdd
Copy link
Collaborator

@0pdd 0pdd commented on 8b06862 Jan 16, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Puzzle 893-3412ae8c discovered in src/test/java/org/takes/facets/hamcrest/HmBodyTest.java and submitted as #948. Please, remember that the puzzle was not necessarily added in this particular commit. Maybe it was added earlier, but we discovered it only now.

Please sign in to comment.