Skip to content
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: 1 addition & 1 deletion contrib-http-framework/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,12 @@
package org.forgerock.http.filter;

import static org.forgerock.util.promise.Promises.newResultPromise;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import static org.mockito.MockitoAnnotations.initMocks;

Expand Down Expand Up @@ -65,7 +65,7 @@ public void shouldExecuteTheDelegatedFilter() throws Exception {
@Test
public void shouldSkipTheDelegatedFilter() throws Exception {
new ConditionalFilter(delegate, false).filter(context, request, next);
verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
verify(next).handle(eq(context), eq(request));
}

Expand All @@ -79,15 +79,15 @@ public void shouldEvaluateTheConditionForEveryRequest() throws Exception {
// First time the function evaluates to false
filter.filter(context, request, next);

verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
verify(next).handle(eq(context), eq(request));

// Second time the function evaluates to true
reset(delegate, next);
filter.filter(context, request, next);

verify(delegate).filter(eq(context), eq(request), eq(next));
verifyZeroInteractions(next);
verifyNoMoreInteractions(next);
}

@Test
Expand All @@ -99,7 +99,7 @@ public void shouldSkipTheDelegatedFilterInCaseOfException() throws Exception {

filter.filter(context, request, next);

verifyZeroInteractions(delegate);
verifyNoMoreInteractions(delegate);
verify(next).handle(eq(context), eq(request));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.forgerock.util.time.Duration.duration;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
import static org.forgerock.http.protocol.Responses.newInternalServerError;
import static org.forgerock.util.promise.Promises.newResultPromise;
import static org.forgerock.util.time.Duration.duration;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyString;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import java.util.concurrent.CountDownLatch;
Expand Down Expand Up @@ -93,7 +93,7 @@ public Promise<ThrottlingRate, Exception> lookup(Context context, Request reques

// Then
verify(handler).handle(eq(context), eq(request));
verifyZeroInteractions(throttlingStrategy);
verifyNoMoreInteractions(throttlingStrategy);
}

@Test
Expand Down Expand Up @@ -183,7 +183,7 @@ public void run() {
Response response = filter.filter(new RootContext(), new Request(), spiedHandler).get();

// The throttling strategy refuses it so the handler does not have to be called and must return a 429.
verifyZeroInteractions(spiedHandler);
verifyNoMoreInteractions(spiedHandler);
assertThat(response.getStatus()).isEqualTo(Status.TOO_MANY_REQUESTS);
assertThat(response.getHeaders().getFirst("Retry-After")).isEqualTo("1");
} finally {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
import static org.forgerock.util.time.Duration.UNLIMITED;
import static org.forgerock.util.time.Duration.ZERO;
import static org.forgerock.util.time.Duration.duration;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyLong;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyLong;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;

Expand Down
2 changes: 1 addition & 1 deletion openig-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-all</artifactId>
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
<dependency>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.forgerock.http.protocol.Response.newResponsePromise;
import static org.forgerock.http.protocol.Status.TEAPOT;
import static org.forgerock.json.JsonValue.json;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.when;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.forgerock.openig.decoration.capture.CapturePoint.FILTERED_RESPONSE;
import static org.forgerock.openig.decoration.capture.CapturePoint.REQUEST;
import static org.forgerock.openig.decoration.capture.CapturePoint.RESPONSE;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -68,7 +68,7 @@ public Promise<Response, NeverThrowsException> filter(final Context context,
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
response = new Response(Status.OK);
when(terminal.handle(any(Context.class), any(Request.class)))
when(terminal.handle(any(Context.class), any()))
.thenReturn(Promises.<Response, NeverThrowsException>newResultPromise(response));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
import static org.forgerock.openig.decoration.capture.CapturePoint.FILTERED_RESPONSE;
import static org.forgerock.openig.decoration.capture.CapturePoint.REQUEST;
import static org.forgerock.openig.decoration.capture.CapturePoint.RESPONSE;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
Expand Down Expand Up @@ -57,7 +57,7 @@ public class CaptureHandlerTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
response = new Response(Status.OK);
when(delegate.handle(any(Context.class), any(Request.class)))
when(delegate.handle(any(Context.class), any()))
.thenReturn(Promises.<Response, NeverThrowsException>newResultPromise(response));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

import static org.assertj.core.api.Assertions.*;
import static org.forgerock.json.JsonValue.*;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.*;

import org.forgerock.json.JsonValue;
Expand Down Expand Up @@ -50,7 +51,7 @@ public class GlobalDecoratorTest {
public void setUp() throws Exception {
MockitoAnnotations.initMocks(this);
when(context.getHeap()).thenReturn(heap);
when(decorator.accepts(any(Class.class))).thenReturn(true);
when(decorator.accepts(nullable(Class.class))).thenReturn(true);
}

@Test
Expand Down Expand Up @@ -89,7 +90,7 @@ public void shouldCallDecorators() throws Exception {
Object delegate = new Object();
globalDecorator.decorate(delegate, null, context);

verify(decorator, times(2)).decorate(anyObject(), captor.capture(), eq(context));
verify(decorator, times(2)).decorate(any(), captor.capture(), eq(context));
// Verify that the JSonValues are the one we're expecting
assertThat(captor.getAllValues().get(0).asString()).isEqualTo("value-1");
assertThat(captor.getAllValues().get(1).asString()).isEqualTo("value-2");
Expand All @@ -105,7 +106,7 @@ public void shouldIgnoreMissingDecorators() throws Exception {
Object delegate = new Object();
globalDecorator.decorate(delegate, null, context);

verify(decorator).decorate(anyObject(), captor.capture(), eq(context));
verify(decorator).decorate(any(), captor.capture(), eq(context));
// Verify that the JSonValues are the one we're expecting
assertThat(captor.getAllValues().get(0).asString()).isEqualTo("value-2");
}
Expand All @@ -115,15 +116,15 @@ public void shouldIgnoreIncompatibleDecorators() throws Exception {
when(heap.get("deco-1", Decorator.class)).thenReturn(decorator);
when(heap.get("deco-2", Decorator.class)).thenReturn(decorator);
// deco-1 will not accept the given type (the incompatible one)
when(decorator.accepts(any(Class.class))).thenReturn(false, true);
when(decorator.accepts(nullable(Class.class))).thenReturn(false, true);

JsonValue decorations = json(object(field("deco-1", "value-1"),
field("deco-2", "value-2")));
GlobalDecorator globalDecorator = new GlobalDecorator(null, decorations);
Object delegate = new Object();
globalDecorator.decorate(delegate, null, context);

verify(decorator).decorate(anyObject(), captor.capture(), eq(context));
verify(decorator).decorate(any(), captor.capture(), eq(context));
// Verify that the JSonValues are the one we're expecting
assertThat(captor.getAllValues().get(0).asString()).isEqualTo("value-2");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@

import static org.forgerock.json.JsonValue.*;
import static org.forgerock.openig.decoration.helper.LazyReference.*;
import static org.mockito.Mockito.*;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.forgerock.json.JsonValue;
import org.forgerock.openig.heap.Heap;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@
import static org.forgerock.openig.heap.Keys.CLIENT_HANDLER_HEAP_KEY;
import static org.forgerock.openig.heap.Keys.TEMPORARY_STORAGE_HEAP_KEY;
import static org.forgerock.util.Options.defaultOptions;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.MockitoAnnotations.initMocks;

import org.forgerock.http.Handler;
Expand Down Expand Up @@ -111,7 +111,7 @@ public void shouldContinueChainExecutionWhenConditionIsTrue() throws Exception {
final ConditionEnforcementFilter filter = new ConditionEnforcementFilter(Expression.valueOf("${true}",
Boolean.class));
filter.filter(context, null, next);
verify(next).handle(any(Context.class), any(Request.class));
verify(next).handle(any(Context.class), any());
}

@DataProvider
Expand All @@ -134,7 +134,7 @@ public void shouldReturnForbiddenAndBreakChainExecutionWhenConditionIsFalse(fina
// Then
assertThat(response.getStatus()).isEqualTo(FORBIDDEN);
assertThat(response.getCause()).isNull();
verifyZeroInteractions(next);
verifyNoMoreInteractions(next);
}

@Test(dataProvider = "conditionsEvaluatingToFalse")
Expand All @@ -147,7 +147,7 @@ public void shouldDelegateToFailureHandlerForInvalidOrEvaluatedToFalseConditions
// When
filter.filter(context, null, next);
// Then
verify(failureHandler).handle(any(Context.class), any(Request.class));
verify(failureHandler).handle(any(Context.class), any());
}

private HeapImpl buildDefaultHeap() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
import static org.forgerock.util.Options.defaultOptions;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;

import java.io.File;
import java.io.IOException;
Expand All @@ -44,10 +44,8 @@
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Set;
import javax.naming.InitialContext;
import javax.script.ScriptException;

Expand All @@ -61,11 +59,6 @@
import org.forgerock.http.session.Session;
import org.forgerock.http.session.SessionContext;
import org.forgerock.json.JsonValue;
import org.forgerock.opendj.ldap.Connections;
import org.forgerock.opendj.ldap.LDAPClientContext;
import org.forgerock.opendj.ldap.LDAPListener;
import org.forgerock.opendj.ldap.MemoryBackend;
import org.forgerock.opendj.ldif.LDIFEntryReader;
import org.forgerock.openig.config.Environment;
import org.forgerock.openig.config.env.DefaultEnvironment;
import org.forgerock.openig.filter.ScriptableFilter.Heaplet;
Expand Down Expand Up @@ -144,7 +137,7 @@ public void testBindingsArePresent() throws Exception {
final Handler handler = mock(Handler.class);
Response response = filter.filter(new RootContext(), new Request(), handler).get();
assertThat(response.getStatus()).isEqualTo(Status.OK);
verifyZeroInteractions(handler);
verifyNoMoreInteractions(handler);
}

@DataProvider
Expand Down Expand Up @@ -175,7 +168,7 @@ public void testConstructFromFile() throws Exception {
final Handler handler = mock(Handler.class);
Response response = filter.filter(new RootContext(), null, handler).get();
assertThat(response.getStatus()).isEqualTo(Status.OK);
verifyZeroInteractions(handler);
verifyNoMoreInteractions(handler);
}

@Test
Expand Down Expand Up @@ -253,7 +246,7 @@ public void testConstructFromString() throws Exception {

final Handler handler = mock(Handler.class);
Response response = filter.filter(new RootContext(), new Request(), handler).get();
verifyZeroInteractions(handler);
verifyNoMoreInteractions(handler);
assertThat(response.getStatus()).isEqualTo(Status.OK);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
import static org.forgerock.json.JsonValue.object;
import static org.forgerock.json.resource.Responses.newResourceResponse;
import static org.forgerock.services.context.ClientContext.buildExternalClientContext;
import static org.mockito.Matchers.any;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyZeroInteractions;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;

import java.util.Collections;
Expand Down Expand Up @@ -94,7 +94,7 @@ public void shouldNotSendAnAccessEventOnNullResponse() throws Exception {
request,
new ResponseHandler((Response) null)).get();

verifyZeroInteractions(reqHandler);
verifyNoMoreInteractions(reqHandler);
}

private void verifyAuditServiceCall(RequestHandler handler, Status status) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package org.forgerock.openig.filter;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.endsWith;
import static org.mockito.Matchers.eq;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.endsWith;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

import static org.assertj.core.api.Assertions.assertThat;
import static org.forgerock.http.protocol.Response.newResponsePromise;
import static org.mockito.Mockito.any;
import static org.mockito.ArgumentMatchers.nullable;
import static org.mockito.Mockito.when;

import org.forgerock.http.Handler;
Expand Down Expand Up @@ -53,7 +53,7 @@ public void setUp() throws Exception {
public void testDownstreamHandlerHasTheMessageDiagnosisContextCorrectlySet() throws Exception {
MdcRouteIdFilter filter = new MdcRouteIdFilter(ROUTE_NAME);

when(handler.handle(any(Context.class), any(Request.class)))
when(handler.handle(nullable(Context.class), nullable(Request.class)))
.then(new Answer<Promise<Response, NeverThrowsException>>() {
@Override
public Promise<Response, NeverThrowsException> answer(InvocationOnMock invocation) {
Expand Down
Loading