### Question:
UriContainsStringPredicate implements Predicate<HttpRequest> { @Override public boolean test(HttpRequest httpRequest) { return httpRequest.getUri().contains(stringToBeContained); } UriContainsStringPredicate(String stringToBeContained); @Override boolean test(HttpRequest httpRequest);  }### Answer:
@Test public void ifContainsSubmitUrlThenEventIsSubmitted() { String url = SUBMIT_EVENT_URL + "ico"; HttpRequest httpRequest = mock(HttpRequest.class); when(httpRequest.getUri()).thenReturn(url); UriContainsStringPredicate uriContainsStringPredicate = new UriContainsStringPredicate(SUBMIT_EVENT_URL); assertTrue(uriContainsStringPredicate.test(httpRequest)); }
@Test public void ifDoesNotContainSubmitUrlThenEventIsNotSubmitted() { String url = "http: HttpRequest httpRequest = mock(HttpRequest.class); when(httpRequest.getUri()).thenReturn(url); UriContainsStringPredicate uriContainsStringPredicate = new UriContainsStringPredicate(SUBMIT_EVENT_URL); assertFalse(uriContainsStringPredicate.test(httpRequest)); }