use of org.mockito.verification.VerificationMode in project riposte by Nike-Inc.
the class NonblockingEndpointExecutionHandlerTest method doChannelRead_performs_endpoint_timing_span_annotations_depending_on_tracing_config.
@UseDataProvider("endpointTimingScenarioDataProvider")
@Test
public void doChannelRead_performs_endpoint_timing_span_annotations_depending_on_tracing_config(EndpointTimingScenario scenario) {
// given
Span spanMock = mock(Span.class);
Tracer.getInstance().registerWithThread(new ArrayDeque<>(Collections.singleton(spanMock)));
assertThat(Tracer.getInstance().getCurrentSpan()).isEqualTo(spanMock);
// Internal Tracer stuff
verify(spanMock).getTraceId();
TracingState tracingStateForTest = TracingState.getCurrentThreadTracingState();
doReturn(tracingStateForTest.getLeft()).when(stateMock).getDistributedTraceStack();
doReturn(tracingStateForTest.getRight()).when(stateMock).getLoggerMdcContextMap();
doReturn(scenario.addStartAnnotation).when(taggingStrategySpy).shouldAddEndpointStartAnnotation();
doReturn(scenario.startAnnotationName).when(taggingStrategySpy).endpointStartAnnotationName();
doReturn(scenario.addFinishAnnotation).when(taggingStrategySpy).shouldAddEndpointFinishAnnotation();
doReturn(scenario.finishAnnotationName).when(taggingStrategySpy).endpointFinishAnnotationName();
// when
handlerSpy.doChannelRead(ctxMock, msg);
// then
{
VerificationMode startAnnotationVerification = (scenario.addStartAnnotation) ? times(1) : never();
verify(spanMock, startAnnotationVerification).addTimestampedAnnotationForCurrentTime(scenario.startAnnotationName);
// Internal Tracer stuff
verify(spanMock, atLeastOnce()).getTraceId();
verifyNoMoreInteractions(spanMock);
}
// and when
futureThatWillBeAttachedToSpy.complete(mock(ResponseInfo.class));
// then
{
VerificationMode finishAnnotationVerification = (scenario.addFinishAnnotation) ? times(1) : never();
verify(spanMock, finishAnnotationVerification).addTimestampedAnnotationForCurrentTime(scenario.finishAnnotationName);
verifyNoMoreInteractions(spanMock);
}
}
use of org.mockito.verification.VerificationMode in project robozonky by RoboZonky.
the class SellingTest method saleMade.
private void saleMade(final boolean isDryRun) {
final Investment i = mockInvestment();
final Zonky zonky = mockApi();
final Portfolio portfolio = new Portfolio(Collections.singleton(i), mockBalance(zonky));
new Selling(ALL_ACCEPTING, isDryRun).accept(portfolio, mockAuthentication(zonky));
final List<Event> e = getNewEvents();
assertThat(e).hasSize(5);
assertSoftly(softly -> {
softly.assertThat(e.get(0)).isInstanceOf(SellingStartedEvent.class);
softly.assertThat(e.get(1)).isInstanceOf(SaleRecommendedEvent.class);
softly.assertThat(e.get(2)).isInstanceOf(SaleRequestedEvent.class);
softly.assertThat(e.get(3)).isInstanceOf(SaleOfferedEvent.class);
softly.assertThat(e.get(4)).isInstanceOf(SellingCompletedEvent.class);
});
final VerificationMode m = isDryRun ? never() : times(1);
assertThat(i.isOnSmp()).isTrue();
verify(zonky, m).sell(argThat(inv -> i.getLoanId() == inv.getLoanId()));
}
use of org.mockito.verification.VerificationMode in project motech by motech.
the class TaskServiceImplTest method captureTask.
private Task captureTask(boolean fromUpdate, VerificationMode verificationMode) {
VerificationMode mode = (verificationMode == null) ? times(1) : verificationMode;
ArgumentCaptor<Task> taskCaptor = ArgumentCaptor.forClass(Task.class);
if (fromUpdate) {
verify(tasksDataService, mode).update(taskCaptor.capture());
} else {
verify(tasksDataService, mode).create(taskCaptor.capture());
}
return taskCaptor.getValue();
}
use of org.mockito.verification.VerificationMode in project kie-wb-common by kiegroup.
the class FormEditorPresenterTest method testOnSyncPalette.
private void testOnSyncPalette(boolean noContext) {
loadContent();
VerificationMode count = times(1);
if (noContext) {
when(editorHelper.getContent()).thenReturn(null);
count = never();
}
FormEditorPresenter presenterSpy = spy(presenter);
String formId = presenterSpy.getFormDefinition().getId();
presenterSpy.onSyncPalette(formId);
Collection<FieldDefinition> availableFieldsValues = editorHelper.getAvailableFields().values();
verify(presenterSpy, count).removeAllDraggableGroupComponent(presenter.getFormDefinition().getFields());
verify(presenterSpy, count).removeAllDraggableGroupComponent(availableFieldsValues);
verify(presenterSpy, count).addAllDraggableGroupComponent(availableFieldsValues);
}
use of org.mockito.verification.VerificationMode in project mockito by mockito.
the class VerificationListenerCallBackTest method should_call_single_listener_on_verify.
@Test
public void should_call_single_listener_on_verify() throws NoSuchMethodException {
// given
RememberingListener listener = new RememberingListener();
MockitoFramework mockitoFramework = Mockito.framework();
mockitoFramework.addListener(listener);
Method invocationWanted = Foo.class.getDeclaredMethod("doSomething", String.class);
Foo foo = mock(Foo.class);
// when
VerificationMode never = never();
verify(foo, never).doSomething("");
// then
assertThat(listener).is(notifiedFor(foo, never, invocationWanted));
}
Aggregations