TIL that anyString() wont match nulls in Mockito, but any() will

This commit is contained in:
Tadgh 2021-08-19 15:15:51 -04:00
parent ac31c4e7a1
commit 77c99e47c1
2 changed files with 4 additions and 6 deletions

View File

@ -779,7 +779,5 @@ public class FhirResourceDaoR4VersionedReferenceTest extends BaseJpaR4Test {
assertEquals(observationId.getValue(), resources.get(0).getIdElement().getValue());
assertEquals(patientId.withVersion("2").getValue(), resources.get(1).getIdElement().getValue());
}
}
}

View File

@ -428,13 +428,13 @@ public class FhirInstanceValidatorR5Test {
String input = IOUtils.toString(FhirInstanceValidator.class.getResourceAsStream("/vitals.json"), Charsets.UTF_8);
IResourceValidator.IValidatorResourceFetcher resourceFetcher = mock(IResourceValidator.IValidatorResourceFetcher.class);
when(resourceFetcher.validationPolicy(any(), anyString(), anyString(), anyString())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS);
when(resourceFetcher.validationPolicy(any(), any(), any(), any())).thenReturn(IResourceValidator.ReferenceValidationPolicy.CHECK_TYPE_IF_EXISTS);
myInstanceVal.setValidatorResourceFetcher(resourceFetcher);
myVal.validateWithResult(input);
verify(resourceFetcher, times(13)).resolveURL(any(), anyString(), anyString(), anyString(), anyString());
verify(resourceFetcher, times(4)).validationPolicy(any(), anyString(), anyString(), anyString());
verify(resourceFetcher, times(3)).fetch(any(), anyString(), anyString());
verify(resourceFetcher, times(13)).resolveURL(any(), any(), anyString(), anyString(), anyString());
verify(resourceFetcher, times(4)).validationPolicy(any(), any(), anyString(), anyString());
verify(resourceFetcher, times(3)).fetch(any(), any(), anyString());
}
@Test