diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java index 3b8fec3f5d7..8664331dc2c 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4InterceptorTest.java @@ -5,6 +5,7 @@ import ca.uhn.fhir.jpa.dao.DeleteMethodOutcome; import ca.uhn.fhir.rest.api.server.RequestDetails; import ca.uhn.fhir.rest.server.interceptor.IServerOperationInterceptor; import ca.uhn.fhir.rest.server.interceptor.ServerOperationInterceptorAdapter; +import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; import ca.uhn.fhir.util.TestUtil; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -567,8 +568,8 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test { @Test public void testServerOperationPreDelete() { - doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourcePreDelete(any(RequestDetails.class), any(IBaseResource.class)); - doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourceDeleted(any(RequestDetails.class), any(IBaseResource.class)); + doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourcePreDelete(nullable(ServletRequestDetails.class), any(Patient.class)); + doAnswer(new MyOneResourceAnswer()).when(myJpaInterceptor).resourceDeleted(nullable(ServletRequestDetails.class), any(Patient.class)); Patient p = new Patient(); p.setActive(false); @@ -578,8 +579,8 @@ public class FhirResourceDaoR4InterceptorTest extends BaseJpaR4Test { myPatientDao.delete(id); InOrder inorder = inOrder(myJpaInterceptor); - inorder.verify(myJpaInterceptor, times(1)).resourcePreDelete(any(RequestDetails.class), any(IBaseResource.class)); - inorder.verify(myJpaInterceptor, times(1)).resourceDeleted(any(RequestDetails.class), any(IBaseResource.class)); + inorder.verify(myJpaInterceptor, times(1)).resourcePreDelete(nullable(ServletRequestDetails.class), any(Patient.class)); + inorder.verify(myJpaInterceptor, times(1)).resourceDeleted(nullable(ServletRequestDetails.class), any(Patient.class)); // resourcePreDelete assertEquals(idPart, myIds.get(0).getIdPart()); assertEquals("1", myIds.get(0).getVersionIdPart()); diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java index 9126cec246a..df9fe378a08 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/SearchCoordinatorSvcImplTest.java @@ -31,7 +31,7 @@ import org.mockito.Captor; import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.invocation.InvocationOnMock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.MockitoJUnitRunner; import org.mockito.stubbing.Answer; import org.springframework.data.domain.Page; import org.springframework.data.domain.PageImpl; @@ -143,8 +143,6 @@ public class SearchCoordinatorSvcImplTest { Iterator iter = new FailAfterNIterator(new SlowIterator(pids.iterator(), 2), 300); when(mySearchBuider.createQuery(Mockito.same(params), any(String.class))).thenReturn(iter); - doAnswer(loadPids()).when(mySearchBuider).loadResourcesByPid(any(List.class), any(List.class), any(Set.class), anyBoolean(), any(EntityManager.class), any(FhirContext.class), same(myCallingDao)); - IBundleProvider result = mySvc.registerSearch(myCallingDao, params, "Patient", new CacheControlDirective()); assertNotNull(result.getUuid()); assertEquals(null, result.size()); diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java index c8dd5e99539..75a548bc53b 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/dstu3/hapi/validation/FhirInstanceValidatorDstu3Test.java @@ -37,6 +37,7 @@ import java.util.zip.GZIPInputStream; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -48,6 +49,7 @@ public class FhirInstanceValidatorDstu3Test { private static FhirContext ourCtx = FhirContext.forDstu3(); @Rule public TestRule watcher = new TestWatcher() { + @Override protected void starting(Description description) { ourLog.info("Starting test: " + description.getMethodName()); } @@ -84,19 +86,19 @@ public class FhirInstanceValidatorDstu3Test { myValidConcepts = new ArrayList<>(); - when(myMockSupport.expandValueSet(any(FhirContext.class), any(ConceptSetComponent.class))).thenAnswer(new Answer() { + when(myMockSupport.expandValueSet(any(FhirContext.class), nullable(ConceptSetComponent.class))).thenAnswer(new Answer() { @Override public ValueSetExpansionComponent answer(InvocationOnMock theInvocation) { ConceptSetComponent arg = (ConceptSetComponent) theInvocation.getArguments()[0]; ValueSetExpansionComponent retVal = mySupportedCodeSystemsForExpansion.get(arg.getSystem()); if (retVal == null) { - retVal = myDefaultValidationSupport.expandValueSet(any(FhirContext.class), arg); + retVal = myDefaultValidationSupport.expandValueSet(nullable(FhirContext.class), arg); } ourLog.debug("expandValueSet({}) : {}", new Object[] {theInvocation.getArguments()[0], retVal}); return retVal; } }); - when(myMockSupport.isCodeSystemSupported(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.isCodeSystemSupported(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public Boolean answer(InvocationOnMock theInvocation) { boolean retVal = myValidSystems.contains(theInvocation.getArguments()[1]); @@ -104,7 +106,7 @@ public class FhirInstanceValidatorDstu3Test { return retVal; } }); - when(myMockSupport.fetchResource(any(FhirContext.class), any(Class.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchResource(nullable(FhirContext.class), nullable(Class.class), nullable(String.class))).thenAnswer(new Answer() { @Override public IBaseResource answer(InvocationOnMock theInvocation) throws Throwable { IBaseResource retVal = null; @@ -134,7 +136,7 @@ public class FhirInstanceValidatorDstu3Test { return retVal; } }); - when(myMockSupport.validateCode(any(FhirContext.class), any(String.class), any(String.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.validateCode(nullable(FhirContext.class), nullable(String.class), nullable(String.class), nullable(String.class))).thenAnswer(new Answer() { @Override public CodeValidationResult answer(InvocationOnMock theInvocation) { FhirContext ctx = (FhirContext) theInvocation.getArguments()[0]; @@ -150,7 +152,7 @@ public class FhirInstanceValidatorDstu3Test { return retVal; } }); - when(myMockSupport.fetchCodeSystem(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchCodeSystem(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public CodeSystem answer(InvocationOnMock theInvocation) { CodeSystem retVal = myDefaultValidationSupport.fetchCodeSystem((FhirContext) theInvocation.getArguments()[0], (String) theInvocation.getArguments()[1]); @@ -161,7 +163,7 @@ public class FhirInstanceValidatorDstu3Test { myStructureDefinitions = new HashMap<>(); myValueSets = new HashMap<>(); myCodeSystems = new HashMap<>(); - when(myMockSupport.fetchStructureDefinition(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchStructureDefinition(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public StructureDefinition answer(InvocationOnMock theInvocation) { String url = (String) theInvocation.getArguments()[1]; @@ -173,7 +175,7 @@ public class FhirInstanceValidatorDstu3Test { return retVal; } }); - when(myMockSupport.fetchAllStructureDefinitions(any(FhirContext.class))).thenAnswer(new Answer>() { + when(myMockSupport.fetchAllStructureDefinitions(nullable(FhirContext.class))).thenAnswer(new Answer>() { @Override public List answer(InvocationOnMock theInvocation) { List retVal = myDefaultValidationSupport.fetchAllStructureDefinitions((FhirContext) theInvocation.getArguments()[0]); diff --git a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java index ad6ba758608..0ae6332859d 100644 --- a/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java +++ b/hapi-fhir-validation/src/test/java/org/hl7/fhir/r4/validation/FhirInstanceValidatorR4Test.java @@ -43,6 +43,7 @@ import java.util.zip.GZIPInputStream; import static org.hamcrest.Matchers.*; import static org.junit.Assert.*; +import static org.mockito.ArgumentMatchers.nullable; import static org.mockito.Matchers.any; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; @@ -102,19 +103,19 @@ public class FhirInstanceValidatorR4Test { myValidConcepts = new ArrayList<>(); - when(myMockSupport.expandValueSet(any(FhirContext.class), any(ConceptSetComponent.class))).thenAnswer(new Answer() { + when(myMockSupport.expandValueSet(nullable(FhirContext.class), nullable(ConceptSetComponent.class))).thenAnswer(new Answer() { @Override public ValueSetExpansionComponent answer(InvocationOnMock theInvocation) throws Throwable { ConceptSetComponent arg = (ConceptSetComponent) theInvocation.getArguments()[ 0 ]; ValueSetExpansionComponent retVal = mySupportedCodeSystemsForExpansion.get(arg.getSystem()); if (retVal == null) { - retVal = myDefaultValidationSupport.expandValueSet(any(FhirContext.class), arg); + retVal = myDefaultValidationSupport.expandValueSet(nullable(FhirContext.class), arg); } ourLog.debug("expandValueSet({}) : {}", new Object[] {theInvocation.getArguments()[ 0 ], retVal}); return retVal; } }); - when(myMockSupport.isCodeSystemSupported(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.isCodeSystemSupported(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public Boolean answer(InvocationOnMock theInvocation) throws Throwable { boolean retVal = myValidSystems.contains(theInvocation.getArguments()[ 1 ]); @@ -122,7 +123,7 @@ public class FhirInstanceValidatorR4Test { return retVal; } }); - when(myMockSupport.fetchResource(any(FhirContext.class), any(Class.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchResource(nullable(FhirContext.class), nullable(Class.class), nullable(String.class))).thenAnswer(new Answer() { @Override public IBaseResource answer(InvocationOnMock theInvocation) throws Throwable { IBaseResource retVal; @@ -136,7 +137,7 @@ public class FhirInstanceValidatorR4Test { return retVal; } }); - when(myMockSupport.validateCode(any(FhirContext.class), any(String.class), any(String.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.validateCode(nullable(FhirContext.class), nullable(String.class), nullable(String.class), nullable(String.class))).thenAnswer(new Answer() { @Override public CodeValidationResult answer(InvocationOnMock theInvocation) throws Throwable { FhirContext ctx = (FhirContext) theInvocation.getArguments()[ 0 ]; @@ -152,7 +153,7 @@ public class FhirInstanceValidatorR4Test { return retVal; } }); - when(myMockSupport.fetchCodeSystem(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchCodeSystem(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public CodeSystem answer(InvocationOnMock theInvocation) throws Throwable { CodeSystem retVal = myDefaultValidationSupport.fetchCodeSystem((FhirContext) theInvocation.getArguments()[ 0 ], (String) theInvocation.getArguments()[ 1 ]); @@ -160,7 +161,7 @@ public class FhirInstanceValidatorR4Test { return retVal; } }); - when(myMockSupport.fetchStructureDefinition(any(FhirContext.class), any(String.class))).thenAnswer(new Answer() { + when(myMockSupport.fetchStructureDefinition(nullable(FhirContext.class), nullable(String.class))).thenAnswer(new Answer() { @Override public StructureDefinition answer(InvocationOnMock theInvocation) throws Throwable { StructureDefinition retVal = myDefaultValidationSupport.fetchStructureDefinition((FhirContext) theInvocation.getArguments()[ 0 ], (String) theInvocation.getArguments()[ 1 ]); @@ -168,7 +169,7 @@ public class FhirInstanceValidatorR4Test { return retVal; } }); - when(myMockSupport.fetchAllStructureDefinitions(any(FhirContext.class))).thenAnswer(new Answer>() { + when(myMockSupport.fetchAllStructureDefinitions(nullable(FhirContext.class))).thenAnswer(new Answer>() { @Override public List answer(InvocationOnMock theInvocation) throws Throwable { List retVal = myDefaultValidationSupport.fetchAllStructureDefinitions((FhirContext) theInvocation.getArguments()[ 0 ]);