/** MkAnswerMatchers can match MkAnswer body bytes. */ @Test public void canMatchBodyBytes() { final byte[] body = {0x01, 0x45, 0x21}; final MkAnswer query = Mockito.mock(MkAnswer.class); Mockito.doReturn(body).when(query).bodyBytes(); MatcherAssert.assertThat(query, MkAnswerMatchers.hasBodyBytes(Matchers.is(body))); }
/** MkAnswerMatchers should be able to match MkAnswer body. */ @Test public void canMatchBody() { final String body = "Hello \u20ac!"; final MkAnswer query = Mockito.mock(MkAnswer.class); Mockito.doReturn(body).when(query).body(); MatcherAssert.assertThat(query, MkAnswerMatchers.hasBody(Matchers.is(body))); }
/** MkAnswerMatchers should be able to match MkAnswer header. */ @Test public void canMatchHeader() { final String header = "Content-Type"; final String value = "application/json"; final MkAnswer query = Mockito.mock(MkAnswer.class); Mockito.doReturn(Collections.singletonMap(header, Collections.singletonList(value))) .when(query) .headers(); MatcherAssert.assertThat(query, MkAnswerMatchers.hasHeader(header, Matchers.contains(value))); }