From 48461ed6cc86333c7bd414537089b27d09cb7400 Mon Sep 17 00:00:00 2001 From: Dhawal Kapil Date: Tue, 26 Jul 2022 18:38:10 +0530 Subject: [PATCH] JAVA-13628 Minor upgrades --- .../MockitoVerifyExamplesUnitTest.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java b/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java index f138256e72..c3c5758950 100644 --- a/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java +++ b/testing-modules/mockito-simple/src/test/java/com/baeldung/mockito/MockitoVerifyExamplesUnitTest.java @@ -1,6 +1,17 @@ package com.baeldung.mockito; -import com.google.common.collect.Lists; +import static org.assertj.core.api.Assertions.assertThat; +import static org.mockito.ArgumentMatchers.anyString; +import static org.mockito.Mockito.atLeast; +import static org.mockito.Mockito.atMost; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.never; +import static org.mockito.Mockito.times; +import static org.mockito.Mockito.verify; +import static org.mockito.Mockito.verifyNoInteractions; +import static org.mockito.Mockito.verifyNoMoreInteractions; + +import java.util.List; import org.junit.Test; import org.mockito.ArgumentCaptor; @@ -8,11 +19,7 @@ import org.mockito.InOrder; import org.mockito.Mockito; import org.mockito.exceptions.verification.NoInteractionsWanted; -import java.util.List; - -import static org.hamcrest.Matchers.hasItem; -import static org.junit.Assert.assertThat; -import static org.mockito.Mockito.*; +import com.google.common.collect.Lists; public class MockitoVerifyExamplesUnitTest { @@ -108,10 +115,12 @@ public class MockitoVerifyExamplesUnitTest { public final void whenVerifyingAnInteractionWithArgumentCapture_thenCorrect() { final List mockedList = mock(MyList.class); mockedList.addAll(Lists.newArrayList("someElement")); - final ArgumentCaptor argumentCaptor = ArgumentCaptor.forClass(List.class); + + final ArgumentCaptor> argumentCaptor = ArgumentCaptor.forClass(List.class); verify(mockedList).addAll(argumentCaptor.capture()); - final List capturedArgument = argumentCaptor.>getValue(); - assertThat(capturedArgument, hasItem("someElement")); + + final List capturedArgument = argumentCaptor.getValue(); + assertThat(capturedArgument).contains("someElement"); } }