Final hamcrest conversions (#6015)
* wip * wip * revert' * Delete existing things * docs * removing last of hamcrest * removing last of hamcrest * manual fix * remove matchers used in awaitility * remove matchers used in awaitility * Final checkstyle removals * Disable suppression rule for mdm checkstyle * Fix some awaitility, remove dead matchers * manual fixes * manual fixes * filter all hamcrest mentions --------- Co-authored-by: Ken Stevens <khstevens@gmail.com>
This commit is contained in:
parent
47d6e357b6
commit
61b5103535
|
@ -23,9 +23,6 @@
|
|||
<suppress files="BaseMigrationTasks\.java" checks="AbstractClassName"/>
|
||||
<suppress files="BaseLoincTop2000LabResultsHandler\.java" checks="AbstractClassName"/>
|
||||
|
||||
<!-- TODO GGG Checkstyle MDM tests can currently use hamcrest until we fix em -->
|
||||
<suppress files=".*/mdm/.*" checks="RegexpSinglelineJava" id="NoHamcrestAssert"/>
|
||||
|
||||
<!-- Missing "Base" prefix suppressions -->
|
||||
<suppress files="ResourceMetadataKeyEnum\.java" checks="AbstractClassName"/>
|
||||
<suppress files="RequestDetails\.java" checks="AbstractClassName"/>
|
||||
|
|
|
@ -35,8 +35,8 @@
|
|||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="id" value="NoHamcrestAssert"/>
|
||||
<property name="format" value="org.hamcrest.MatcherAssert.assertThat"/>
|
||||
<property name="message" value="Incorrect assertThat import used: The "org.assertj.core.api.Assertions.assertThat" import should be used for tests"/>
|
||||
<property name="format" value="org.hamcrest."/>
|
||||
<property name="message" value="Incorrect matcher import used: The "org.assertj.core.api.Assertions.assertThat" import should be used for tests"/>
|
||||
</module>
|
||||
<module name="RegexpSinglelineJava">
|
||||
<property name="format" value="org\.jetbrains\.annotations\.NotNull"/>
|
||||
|
|
|
@ -9,9 +9,8 @@ import ca.uhn.fhir.test.utilities.docker.RequiresDocker;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeDiagnosingMatcher;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.assertj.core.api.AbstractIterableAssert;
|
||||
import org.hl7.fhir.instance.model.api.IBaseCoding;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
|
@ -33,6 +32,7 @@ import org.springframework.test.context.junit.jupiter.SpringExtension;
|
|||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.time.Instant;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
@ -91,9 +91,8 @@ public class ResourceProviderR4ElasticTest extends BaseResourceProviderR4Test {
|
|||
ourLog.info("testAutocompleteDirectionExisting {}", text);
|
||||
assertNotNull(valueSet);
|
||||
List<ValueSet.ValueSetExpansionContainsComponent> expansions = valueSet.getExpansion().getContains();
|
||||
// TODO CHECKSTYLE KHS
|
||||
// assertThat(expansions, hasItem(valueSetExpansionMatching(mean_blood_pressure)));
|
||||
// assertThat(expansions).doesNotContain(valueSetExpansionMatching(blood_count));
|
||||
ValueSetExpansionIterableAssert.assertThat(expansions).hasExpansionWithCoding(mean_blood_pressure);
|
||||
ValueSetExpansionIterableAssert.assertThat(expansions).doesNotHaveExpansionWithCoding(blood_count);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -110,19 +109,51 @@ public class ResourceProviderR4ElasticTest extends BaseResourceProviderR4Test {
|
|||
myObservationDao.create(observation, mySrd).getId().toUnqualifiedVersionless();
|
||||
}
|
||||
|
||||
public static Matcher<ValueSet.ValueSetExpansionContainsComponent> valueSetExpansionMatching(IBaseCoding theTarget) {
|
||||
return new TypeSafeDiagnosingMatcher<ValueSet.ValueSetExpansionContainsComponent>() {
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("ValueSetExpansionContainsComponent matching ").appendValue(theTarget.getSystem() + "|" + theTarget.getCode());
|
||||
}
|
||||
public static class ValueSetExpansionAssert extends AbstractAssert<ValueSetExpansionAssert, ValueSet.ValueSetExpansionContainsComponent> {
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(ValueSet.ValueSetExpansionContainsComponent theItem, Description mismatchDescription) {
|
||||
return Objects.equals(theItem.getSystem(), theTarget.getSystem()) &&
|
||||
Objects.equals(theItem.getCode(), theTarget.getCode());
|
||||
protected ValueSetExpansionAssert(ValueSet.ValueSetExpansionContainsComponent valueSetExpansionContainsComponent) {
|
||||
super(valueSetExpansionContainsComponent, ValueSetExpansionAssert.class);
|
||||
}
|
||||
}
|
||||
|
||||
public static class ValueSetExpansionIterableAssert extends AbstractIterableAssert<ValueSetExpansionIterableAssert, Collection<ValueSet.ValueSetExpansionContainsComponent>, ValueSet.ValueSetExpansionContainsComponent, ValueSetExpansionAssert> {
|
||||
protected ValueSetExpansionIterableAssert(Collection<ValueSet.ValueSetExpansionContainsComponent> actual) {
|
||||
super(actual, ValueSetExpansionIterableAssert.class);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ValueSetExpansionAssert toAssert(ValueSet.ValueSetExpansionContainsComponent value, String description) {
|
||||
return new ValueSetExpansionAssert(value).as(description);
|
||||
}
|
||||
|
||||
public static ValueSetExpansionIterableAssert assertThat(Collection<ValueSet.ValueSetExpansionContainsComponent> actual) {
|
||||
return new ValueSetExpansionIterableAssert(actual);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected ValueSetExpansionIterableAssert newAbstractIterableAssert(Iterable<? extends ValueSet.ValueSetExpansionContainsComponent> iterable) {
|
||||
return new ValueSetExpansionIterableAssert((Collection<ValueSet.ValueSetExpansionContainsComponent>) iterable);
|
||||
}
|
||||
|
||||
public ValueSetExpansionIterableAssert hasExpansionWithCoding(IBaseCoding theCoding) {
|
||||
String otherSystem = theCoding.getSystem();
|
||||
String otherCode = theCoding.getCode();
|
||||
boolean hasMatchingExpansion = actual.stream().anyMatch(item -> Objects.equals(item.getSystem(), otherSystem) && Objects.equals(item.getCode(), otherCode));
|
||||
if (!hasMatchingExpansion) {
|
||||
failWithMessage("Expansion list should contain an expansion with system " + otherSystem + " and code " + otherCode);
|
||||
}
|
||||
};
|
||||
return this;
|
||||
}
|
||||
|
||||
public ValueSetExpansionIterableAssert doesNotHaveExpansionWithCoding(IBaseCoding theCoding) {
|
||||
String otherSystem = theCoding.getSystem();
|
||||
String otherCode = theCoding.getCode();
|
||||
boolean hasMatchingExpansion = actual.stream().anyMatch(expansion -> Objects.equals(expansion.getCode(), otherCode) && Objects.equals(expansion.getSystem(), otherSystem));
|
||||
if (hasMatchingExpansion) {
|
||||
failWithMessage("Expected not to find a matching expansion, but we found one!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
@ -12,12 +12,7 @@ import ca.uhn.fhir.jpa.mdm.config.MdmSubmitterConfig;
|
|||
import ca.uhn.fhir.jpa.mdm.config.TestMdmConfigR4;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.jpa.mdm.helper.MdmLinkHelper;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsLinkedTo;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsMatchedToAGoldenResource;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsPossibleDuplicateOf;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsPossibleLinkedTo;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsPossibleMatchWith;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.IsSameGoldenResourceAs;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.GoldenResourceMatchingAssert;
|
||||
import ca.uhn.fhir.jpa.mdm.svc.MdmMatchLinkSvc;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
|
@ -45,8 +40,6 @@ import ca.uhn.fhir.rest.param.TokenParam;
|
|||
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails;
|
||||
import org.apache.commons.lang3.NotImplementedException;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.*;
|
||||
|
@ -159,6 +152,9 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test {
|
|||
myMdmLinkDaoSvc.save(theMdmLink);
|
||||
}
|
||||
|
||||
protected GoldenResourceMatchingAssert mdmAssertThat(IAnyResource theResource) {
|
||||
return GoldenResourceMatchingAssert.assertThat(theResource, myIdHelperService, myMdmLinkDaoSvc);
|
||||
}
|
||||
@Nonnull
|
||||
protected Patient createGoldenPatient() {
|
||||
return createPatient(new Patient(), true, false);
|
||||
|
@ -504,54 +500,6 @@ abstract public class BaseMdmR4Test extends BaseJpaR4Test {
|
|||
return thePractitioner;
|
||||
}
|
||||
|
||||
private Matcher<IAnyResource> wrapMatcherInTransaction(Supplier<Matcher<IAnyResource>> theFunction) {
|
||||
return new Matcher<IAnyResource>() {
|
||||
@Override
|
||||
public boolean matches(Object actual) {
|
||||
return runInTransaction(() -> theFunction.get().matches(actual));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeMismatch(Object actual, Description mismatchDescription) {
|
||||
runInTransaction(() -> theFunction.get().describeMismatch(actual, mismatchDescription));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void _dont_implement_Matcher___instead_extend_BaseMatcher_() {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
runInTransaction(() -> theFunction.get().describeTo(description));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> sameGoldenResourceAs(IAnyResource... theBaseResource) {
|
||||
return wrapMatcherInTransaction(() -> IsSameGoldenResourceAs.sameGoldenResourceAs(myIdHelperService, myMdmLinkDaoSvc, theBaseResource));
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> linkedTo(IAnyResource... theBaseResource) {
|
||||
return wrapMatcherInTransaction(() -> IsLinkedTo.linkedTo(myIdHelperService, myMdmLinkDaoSvc, theBaseResource));
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> possibleLinkedTo(IAnyResource... theBaseResource) {
|
||||
return wrapMatcherInTransaction(() -> IsPossibleLinkedTo.possibleLinkedTo(myIdHelperService, myMdmLinkDaoSvc, theBaseResource));
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> possibleMatchWith(IAnyResource... theBaseResource) {
|
||||
return wrapMatcherInTransaction(() -> IsPossibleMatchWith.possibleMatchWith(myIdHelperService, myMdmLinkDaoSvc, theBaseResource));
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> possibleDuplicateOf(IAnyResource... theBaseResource) {
|
||||
return wrapMatcherInTransaction(() -> IsPossibleDuplicateOf.possibleDuplicateOf(myIdHelperService, myMdmLinkDaoSvc, theBaseResource));
|
||||
}
|
||||
|
||||
protected Matcher<IAnyResource> matchedToAGoldenResource() {
|
||||
return wrapMatcherInTransaction(() -> IsMatchedToAGoldenResource.matchedToAGoldenResource(myIdHelperService, myMdmLinkDaoSvc));
|
||||
}
|
||||
|
||||
protected Patient getOnlyGoldenPatient() {
|
||||
List<IBaseResource> resources = getAllGoldenPatients();
|
||||
assertEquals(1, resources.size());
|
||||
|
|
|
@ -1,82 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
import ca.uhn.fhir.mdm.util.MdmResourceUtil;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public abstract class BaseGoldenResourceMatcher extends TypeSafeMatcher<IAnyResource> {
|
||||
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(BaseGoldenResourceMatcher.class);
|
||||
|
||||
protected IIdHelperService myIdHelperService;
|
||||
protected MdmLinkDaoSvc myMdmLinkDaoSvc;
|
||||
protected Collection<IAnyResource> myBaseResources;
|
||||
protected String myTargetType;
|
||||
|
||||
protected BaseGoldenResourceMatcher(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
myIdHelperService = theIdHelperService;
|
||||
myMdmLinkDaoSvc = theMdmLinkDaoSvc;
|
||||
myBaseResources = Arrays.stream(theBaseResource).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Nullable
|
||||
protected IResourcePersistentId getMatchedResourcePidFromResource(IAnyResource theResource) {
|
||||
IResourcePersistentId retval;
|
||||
|
||||
boolean isGoldenRecord = MdmResourceUtil.isMdmManaged(theResource);
|
||||
if (isGoldenRecord) {
|
||||
return myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theResource);
|
||||
}
|
||||
IMdmLink matchLink = getMatchedMdmLink(theResource);
|
||||
|
||||
if (matchLink == null) {
|
||||
return null;
|
||||
} else {
|
||||
retval = matchLink.getGoldenResourcePersistenceId();
|
||||
myTargetType = matchLink.getMdmSourceType();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected List<IResourcePersistentId> getPossibleMatchedGoldenResourcePidsFromTarget(IAnyResource theBaseResource) {
|
||||
return getMdmLinksForTarget(theBaseResource, MdmMatchResultEnum.POSSIBLE_MATCH)
|
||||
.stream()
|
||||
.map(IMdmLink::getGoldenResourcePersistenceId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
protected IMdmLink getMatchedMdmLink(IAnyResource thePatientOrPractitionerResource) {
|
||||
List<? extends IMdmLink> mdmLinks = getMdmLinksForTarget(thePatientOrPractitionerResource, MdmMatchResultEnum.MATCH);
|
||||
if (mdmLinks.size() == 0) {
|
||||
return null;
|
||||
} else if (mdmLinks.size() == 1) {
|
||||
return mdmLinks.get(0);
|
||||
} else {
|
||||
throw new IllegalStateException("Its illegal to have more than 1 match for a given target! we found " + mdmLinks.size() + " for resource with id: " + thePatientOrPractitionerResource.getIdElement().toUnqualifiedVersionless());
|
||||
}
|
||||
}
|
||||
|
||||
protected List<? extends IMdmLink> getMdmLinksForTarget(IAnyResource theTargetResource, MdmMatchResultEnum theMatchResult) {
|
||||
IResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTargetResource);
|
||||
List<? extends IMdmLink> matchLinkForTarget = myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(pidOrNull, theMatchResult);
|
||||
if (!matchLinkForTarget.isEmpty()) {
|
||||
return matchLinkForTarget;
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,215 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
import ca.uhn.fhir.mdm.util.MdmResourceUtil;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import jakarta.annotation.Nullable;
|
||||
import org.assertj.core.api.AbstractAssert;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Assertion class for asserting matching of golden resources.
|
||||
*/
|
||||
public class GoldenResourceMatchingAssert extends AbstractAssert<GoldenResourceMatchingAssert, IAnyResource> {
|
||||
|
||||
private IResourcePersistentId actualGoldenResourcePid;
|
||||
private IResourcePersistentId actualSourceResourcePid;
|
||||
private IIdHelperService myIdHelperService;
|
||||
private MdmLinkDaoSvc myMdmLinkDaoSvc;
|
||||
|
||||
protected GoldenResourceMatchingAssert(IAnyResource actual, IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
|
||||
super(actual, GoldenResourceMatchingAssert.class);
|
||||
myIdHelperService = theIdHelperService;
|
||||
myMdmLinkDaoSvc = theMdmLinkDaoSvc;
|
||||
actualGoldenResourcePid = getGoldenResourcePid(actual);
|
||||
actualSourceResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), actual);
|
||||
}
|
||||
|
||||
public static GoldenResourceMatchingAssert assertThat(IAnyResource actual, IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
|
||||
return new GoldenResourceMatchingAssert(actual, theIdHelperService, theMdmLinkDaoSvc);
|
||||
}
|
||||
|
||||
// Method to compare with another resource
|
||||
public GoldenResourceMatchingAssert is_MATCH_to(IAnyResource other) {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(other);
|
||||
if (!actualGoldenResourcePid.equals(otherGoldenPid)) {
|
||||
failWithActualExpectedAndMessage(actualGoldenResourcePid, otherGoldenPid, "Did not match golden resource pids!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert is_not_MATCH_to(IAnyResource other) {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(other);
|
||||
if (actualGoldenResourcePid != null && actualGoldenResourcePid.equals(otherGoldenPid)) {
|
||||
failWithActualExpectedAndMessage(actualGoldenResourcePid, otherGoldenPid, "Matched when it should not have!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public GoldenResourceMatchingAssert is_NO_MATCH_to(IAnyResource other) {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(other);
|
||||
if (actualGoldenResourcePid != null && actualGoldenResourcePid.equals(otherGoldenPid)) {
|
||||
failWithActualExpectedAndMessage(actualGoldenResourcePid, otherGoldenPid, "Both resources are linked to the same Golden pid!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert is_POSSIBLE_MATCH_to(IAnyResource other) {
|
||||
boolean possibleMatch = hasPossibleMatchWith(other);
|
||||
|
||||
if (!possibleMatch) {
|
||||
failWithMessage("No POSSIBLE_MATCH between these two resources.");
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
private boolean hasPossibleMatchWith(IAnyResource other) {
|
||||
IResourcePersistentId otherSourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), other);
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(other);
|
||||
|
||||
//Check for direct matches in either direction.
|
||||
// A POSSIBLE_MATCH -> B
|
||||
if (actualGoldenResourcePid != null) {
|
||||
Optional directForwardLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(actualGoldenResourcePid, otherSourcePid, MdmMatchResultEnum.POSSIBLE_MATCH);
|
||||
if (directForwardLink.isPresent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
// B -> POSSIBLE_MATCH -> A
|
||||
if (otherGoldenPid != null) {
|
||||
Optional directBackwardLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(otherGoldenPid, actualSourceResourcePid, MdmMatchResultEnum.POSSIBLE_MATCH);
|
||||
if (directBackwardLink.isPresent()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check for indirect possible matches, e.g.
|
||||
// A -> POSSIBLE_MATCH -> B
|
||||
// C -> POSSIBLE_MATCH -> B
|
||||
// this implies
|
||||
// A -> POSSIBLE_MATCH ->C
|
||||
|
||||
boolean possibleMatch = false;
|
||||
Set<IResourcePersistentId> goldenPids = new HashSet<>();
|
||||
List<? extends IMdmLink> possibleLinksForOther = myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(otherSourcePid, MdmMatchResultEnum.POSSIBLE_MATCH);
|
||||
Set<IResourcePersistentId> otherPossibles = possibleLinksForOther.stream().map(IMdmLink::getGoldenResourcePersistenceId).collect(Collectors.toSet());
|
||||
goldenPids.addAll(otherPossibles);
|
||||
|
||||
|
||||
// Compare and inflate with all possible matches from the actual. If we hit a collision, we know that the implies POSSIBLE_MATCH exists.
|
||||
List<? extends IMdmLink> possibleLinksForActual = myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(actualSourceResourcePid, MdmMatchResultEnum.POSSIBLE_MATCH);
|
||||
Set<IResourcePersistentId> actualPossiblePids = possibleLinksForActual.stream().map(IMdmLink::getGoldenResourcePersistenceId).collect(Collectors.toSet());
|
||||
possibleMatch = isPossibleMatch(actualPossiblePids, goldenPids, possibleMatch);
|
||||
return possibleMatch;
|
||||
}
|
||||
|
||||
private static boolean isPossibleMatch(Set<IResourcePersistentId> matchedPids, Set<IResourcePersistentId> goldenPids, boolean possibleMatch) {
|
||||
for (IResourcePersistentId pid : matchedPids) {
|
||||
if (goldenPids.contains(pid)) {
|
||||
return true;
|
||||
} else {
|
||||
goldenPids.add(pid);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean possibleDuplicateLinkExistsBetween(IResourcePersistentId goldenPid1, IResourcePersistentId goldenPid2) {
|
||||
Optional possibleForwardsLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(goldenPid1, goldenPid2, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
|
||||
Optional possibleBackwardsLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(goldenPid2, goldenPid1, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
|
||||
return possibleBackwardsLink.isPresent() || possibleForwardsLink.isPresent();
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert is_POSSIBLE_DUPLICATE_to(IAnyResource other) {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(other);
|
||||
if (actualGoldenResourcePid == null || otherGoldenPid == null) {
|
||||
failWithMessage("For a POSSIBLE_DUPLICATE, both resources must have a MATCH. This is not the case for these resources.");
|
||||
}
|
||||
boolean possibleDuplicateExists = possibleDuplicateLinkExistsBetween(actualGoldenResourcePid, otherGoldenPid);
|
||||
if (!possibleDuplicateExists) {
|
||||
failWithActualExpectedAndMessage("No POSSIBLE_DUPLICATE found between " + actualGoldenResourcePid + " and " + otherGoldenPid,
|
||||
"POSSIBLE_DUPLICATE found between " + actualGoldenResourcePid + " and " + otherGoldenPid,
|
||||
"No POSSIBLE_DUPLICATE links were found between golden resources");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@Nullable
|
||||
protected IResourcePersistentId getGoldenResourcePid(IAnyResource theResource) {
|
||||
IResourcePersistentId retval;
|
||||
|
||||
boolean isGoldenRecord = MdmResourceUtil.isMdmManaged(theResource);
|
||||
if (isGoldenRecord) {
|
||||
return myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theResource);
|
||||
}
|
||||
IMdmLink matchLink = getMatchedMdmLink(theResource);
|
||||
|
||||
if (matchLink == null) {
|
||||
return null;
|
||||
} else {
|
||||
retval = matchLink.getGoldenResourcePersistenceId();
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
protected IMdmLink getMatchedMdmLink(IAnyResource thePatientOrPractitionerResource) {
|
||||
List<? extends IMdmLink> mdmLinks = getMdmLinksForTarget(thePatientOrPractitionerResource, MdmMatchResultEnum.MATCH);
|
||||
if (mdmLinks.size() == 0) {
|
||||
return null;
|
||||
} else if (mdmLinks.size() == 1) {
|
||||
return mdmLinks.get(0);
|
||||
} else {
|
||||
throw new IllegalStateException("Its illegal to have more than 1 match for a given target! we found " + mdmLinks.size() + " for resource with id: " + thePatientOrPractitionerResource.getIdElement().toUnqualifiedVersionless());
|
||||
}
|
||||
}
|
||||
|
||||
protected List<? extends IMdmLink> getMdmLinksForTarget(IAnyResource theTargetResource, MdmMatchResultEnum theMatchResult) {
|
||||
IResourcePersistentId pidOrNull = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theTargetResource);
|
||||
List<? extends IMdmLink> matchLinkForTarget = myMdmLinkDaoSvc.getMdmLinksBySourcePidAndMatchResult(pidOrNull, theMatchResult);
|
||||
if (!matchLinkForTarget.isEmpty()) {
|
||||
return matchLinkForTarget;
|
||||
} else {
|
||||
return new ArrayList<>();
|
||||
}
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert hasGoldenResourceMatch() {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(actual);
|
||||
if (otherGoldenPid == null) {
|
||||
failWithMessage("Expected resource to be matched to a golden resource. Found no such matches. ");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert doesNotHaveGoldenResourceMatch() {
|
||||
IResourcePersistentId otherGoldenPid = getGoldenResourcePid(actual);
|
||||
if (otherGoldenPid != null) {
|
||||
failWithMessage("Expected resource to have no golden resource match, but it did.");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
|
||||
public GoldenResourceMatchingAssert is_not_POSSIBLE_DUPLICATE_to(IAnyResource other) {
|
||||
IResourcePersistentId otherGoldenResourcePid = getGoldenResourcePid(other);
|
||||
boolean possibleDuplicateExists = possibleDuplicateLinkExistsBetween(actualGoldenResourcePid, otherGoldenResourcePid);
|
||||
if (possibleDuplicateExists) {
|
||||
failWithMessage("Possible duplicate exists between both resources!");
|
||||
}
|
||||
return this;
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A Matcher which allows us to check that a target patient/practitioner at a given link level.
|
||||
* is linked to a set of patients/practitioners via a golden resource.
|
||||
*/
|
||||
public class IsLinkedTo extends BaseGoldenResourceMatcher {
|
||||
|
||||
private List<IResourcePersistentId> baseResourceGoldenResourcePids;
|
||||
private IResourcePersistentId incomingResourceGoldenResourcePid;
|
||||
|
||||
protected IsLinkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theIncomingResource) {
|
||||
incomingResourceGoldenResourcePid = getMatchedResourcePidFromResource(theIncomingResource);
|
||||
|
||||
//OK, lets grab all the golden resource pids of the resources passed in via the constructor.
|
||||
baseResourceGoldenResourcePids = myBaseResources.stream()
|
||||
.map(this::getMatchedResourcePidFromResource)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//The resources are linked if all golden resource pids match the incoming golden resource pid.
|
||||
return baseResourceGoldenResourcePids.stream()
|
||||
.allMatch(pid -> pid.equals(incomingResourceGoldenResourcePid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> linkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
return new IsLinkedTo(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
}
|
|
@ -1,38 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
public class IsMatchedToAGoldenResource extends TypeSafeMatcher<IAnyResource> {
|
||||
|
||||
private final IIdHelperService myIdHelperService;
|
||||
private final MdmLinkDaoSvc myMdmLinkDaoSvc;
|
||||
|
||||
public IsMatchedToAGoldenResource(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
|
||||
myIdHelperService = theIdHelperService;
|
||||
myMdmLinkDaoSvc = theMdmLinkDaoSvc;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theIncomingResource) {
|
||||
Optional<? extends IMdmLink> matchedLinkForTargetPid = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theIncomingResource));
|
||||
return matchedLinkForTargetPid.isPresent();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
theDescription.appendText("target was not linked to a Golden Resource.");
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> matchedToAGoldenResource(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc) {
|
||||
return new IsMatchedToAGoldenResource(theIdHelperService, theMdmLinkDaoSvc);
|
||||
}
|
||||
}
|
|
@ -1,62 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IsPossibleDuplicateOf extends BaseGoldenResourceMatcher {
|
||||
|
||||
/**
|
||||
* Matcher with tells us if there is an MdmLink with between these two resources that are considered POSSIBLE DUPLICATE.
|
||||
* For use only on GoldenResource.
|
||||
*/
|
||||
private IResourcePersistentId incomingGoldenResourcePid;
|
||||
|
||||
protected IsPossibleDuplicateOf(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theIncomingResource) {
|
||||
incomingGoldenResourcePid = getMatchedResourcePidFromResource(theIncomingResource);
|
||||
|
||||
List<IResourcePersistentId> goldenResourcePidsToMatch = myBaseResources.stream()
|
||||
.map(this::getMatchedResourcePidFromResource)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
//Returns true if there is a POSSIBLE_DUPLICATE between the incoming resource, and all of the resources passed in via the constructor.
|
||||
return goldenResourcePidsToMatch.stream()
|
||||
.map(baseResourcePid -> {
|
||||
Optional<? extends IMdmLink> duplicateLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(baseResourcePid, incomingGoldenResourcePid, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
|
||||
if (!duplicateLink.isPresent()) {
|
||||
duplicateLink = myMdmLinkDaoSvc.getMdmLinksByGoldenResourcePidSourcePidAndMatchResult(incomingGoldenResourcePid, baseResourcePid, MdmMatchResultEnum.POSSIBLE_DUPLICATE);
|
||||
}
|
||||
return duplicateLink;
|
||||
}).allMatch(Optional::isPresent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
theDescription.appendText("Resource was not duplicate of Resource/" + incomingGoldenResourcePid);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void describeMismatchSafely(IAnyResource item, Description mismatchDescription) {
|
||||
super.describeMismatchSafely(item, mismatchDescription);
|
||||
mismatchDescription.appendText("No MdmLink With POSSIBLE_DUPLICATE was found");
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> possibleDuplicateOf(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
return new IsPossibleDuplicateOf(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* A Matcher which allows us to check that a target resource at a given link level
|
||||
* is linked to a set of target resources via a golden resource.
|
||||
*/
|
||||
public class IsPossibleLinkedTo extends BaseGoldenResourceMatcher {
|
||||
|
||||
private List<IResourcePersistentId> baseResourceGoldenResourcePids;
|
||||
private IResourcePersistentId incomingResourceGoldenResourcePid;
|
||||
|
||||
protected IsPossibleLinkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theTargetResources) {
|
||||
super(theIdHelperService, theMdmLinkDaoSvc, theTargetResources);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theGoldenResource) {
|
||||
incomingResourceGoldenResourcePid = myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), theGoldenResource);
|
||||
|
||||
//OK, lets grab all the golden resource pids of the resources passed in via the constructor.
|
||||
baseResourceGoldenResourcePids = myBaseResources.stream()
|
||||
.flatMap(iBaseResource -> getPossibleMatchedGoldenResourcePidsFromTarget(iBaseResource).stream())
|
||||
.collect(Collectors.toList());
|
||||
|
||||
//The resources are linked if all golden resource pids match the incoming golden resource pid.
|
||||
return baseResourceGoldenResourcePids.stream()
|
||||
.allMatch(pid -> pid.equals(incomingResourceGoldenResourcePid));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> possibleLinkedTo(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
return new IsPossibleLinkedTo(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
}
|
|
@ -1,61 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Matcher with tells us if there is an MdmLink with between these two resources that are considered POSSIBLE_MATCH
|
||||
*/
|
||||
public class IsPossibleMatchWith extends BaseGoldenResourceMatcher {
|
||||
|
||||
protected IsPossibleMatchWith(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theIncomingResource) {
|
||||
List<? extends IMdmLink> mdmLinks = getMdmLinksForTarget(theIncomingResource, MdmMatchResultEnum.POSSIBLE_MATCH);
|
||||
|
||||
List<IResourcePersistentId> goldenResourcePidsToMatch = myBaseResources.stream()
|
||||
.map(this::getMatchedResourcePidFromResource)
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (goldenResourcePidsToMatch.isEmpty()) {
|
||||
goldenResourcePidsToMatch = myBaseResources.stream()
|
||||
.flatMap(iBaseResource -> getPossibleMatchedGoldenResourcePidsFromTarget(iBaseResource).stream())
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<IResourcePersistentId> mdmLinkGoldenResourcePids = mdmLinks
|
||||
.stream().map(IMdmLink::getGoldenResourcePersistenceId)
|
||||
.collect(Collectors.toList());
|
||||
|
||||
return mdmLinkGoldenResourcePids.containsAll(goldenResourcePidsToMatch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
theDescription.appendText(" no link found with POSSIBLE_MATCH to the requested PIDS");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void describeMismatchSafely(IAnyResource item, Description mismatchDescription) {
|
||||
super.describeMismatchSafely(item, mismatchDescription);
|
||||
mismatchDescription.appendText("No MDM Link With POSSIBLE_MATCH was found");
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> possibleMatchWith(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
return new IsPossibleMatchWith(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
package ca.uhn.fhir.jpa.mdm.matcher;
|
||||
|
||||
import ca.uhn.fhir.jpa.api.svc.IIdHelperService;
|
||||
import ca.uhn.fhir.jpa.mdm.dao.MdmLinkDaoSvc;
|
||||
import ca.uhn.fhir.rest.api.server.storage.IResourcePersistentId;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class IsSameGoldenResourceAs extends BaseGoldenResourceMatcher {
|
||||
|
||||
private List<IResourcePersistentId> goldenResourcePidsToMatch;
|
||||
private IResourcePersistentId incomingGoldenResourcePid;
|
||||
|
||||
public IsSameGoldenResourceAs(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
super(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(IAnyResource theIncomingResource) {
|
||||
incomingGoldenResourcePid = getMatchedResourcePidFromResource(theIncomingResource);
|
||||
goldenResourcePidsToMatch = myBaseResources.stream().map(this::getMatchedResourcePidFromResource).collect(Collectors.toList());
|
||||
boolean allToCheckAreSame = goldenResourcePidsToMatch.stream().allMatch(pid -> pid.equals(goldenResourcePidsToMatch.get(0)));
|
||||
if (!allToCheckAreSame) {
|
||||
throw new IllegalStateException("You wanted to do a source resource comparison, but the pool of source resources you submitted for checking don't match! We won't even check the incoming source resource against them.");
|
||||
}
|
||||
return goldenResourcePidsToMatch.contains(incomingGoldenResourcePid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void describeTo(Description theDescription) {
|
||||
theDescription.appendText(String.format(" %s linked to source resource %s/%s", myTargetType, myTargetType, goldenResourcePidsToMatch));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void describeMismatchSafely(IAnyResource item, Description mismatchDescription) {
|
||||
super.describeMismatchSafely(item, mismatchDescription);
|
||||
mismatchDescription.appendText(String.format(" was actually linked to %s/%s", myTargetType, incomingGoldenResourcePid));
|
||||
}
|
||||
|
||||
public static Matcher<IAnyResource> sameGoldenResourceAs(IIdHelperService theIdHelperService, MdmLinkDaoSvc theMdmLinkDaoSvc, IAnyResource... theBaseResource) {
|
||||
return new IsSameGoldenResourceAs(theIdHelperService, theMdmLinkDaoSvc, theBaseResource);
|
||||
}
|
||||
}
|
|
@ -1,9 +1,11 @@
|
|||
package ca.uhn.fhir.jpa.mdm.provider;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ca.uhn.fhir.i18n.Msg;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.entity.MdmLink;
|
||||
import ca.uhn.fhir.jpa.entity.PartitionEntity;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.GoldenResourceMatchingAssert;
|
||||
import ca.uhn.fhir.jpa.model.config.PartitionSettings;
|
||||
import ca.uhn.fhir.mdm.api.MdmLinkSourceEnum;
|
||||
import ca.uhn.fhir.mdm.api.MdmMatchResultEnum;
|
||||
|
@ -20,16 +22,11 @@ import org.junit.jupiter.api.Test;
|
|||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.endsWith;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
//TODO GGG Convert this to assertJ
|
||||
public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
||||
|
||||
private Patient myFromGoldenPatient;
|
||||
|
@ -88,7 +85,7 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
assertFalse(MdmResourceUtil.isGoldenRecordRedirected(mergedSourcePatient));
|
||||
|
||||
assertEquals(myToGoldenPatient.getIdElement(), mergedSourcePatient.getIdElement());
|
||||
assertThat(mergedSourcePatient, is(sameGoldenResourceAs(myToGoldenPatient)));
|
||||
GoldenResourceMatchingAssert.assertThat(mergedSourcePatient, myIdHelperService, myMdmLinkDaoSvc).is_MATCH_to(myToGoldenPatient);
|
||||
assertEquals(1, getAllRedirectedGoldenPatients().size());
|
||||
assertEquals(1, getAllGoldenPatients().size());
|
||||
|
||||
|
@ -99,10 +96,10 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
|
||||
//TODO GGG eventually this will need to check a redirect... this is a hack which doesnt work
|
||||
// Optional<Identifier> redirect = fromSourcePatient.getIdentifier().stream().filter(theIdentifier -> theIdentifier.getSystem().equals("REDIRECT")).findFirst();
|
||||
// assertThat(redirect.get().getValue(), is(equalTo(myToSourcePatient.getIdElement().toUnqualified().getValue())));
|
||||
// assertThat(redirect.get().getValue()).isEqualTo(myToSourcePatient.getIdElement().toUnqualified().getValue());
|
||||
|
||||
List<MdmLink> links = (List<MdmLink>) myMdmLinkDaoSvc.findMdmLinksBySourceResource(myToGoldenPatient);
|
||||
assertThat(links, hasSize(1));
|
||||
assertThat(links).hasSize(1);
|
||||
|
||||
MdmLink link = links.get(0);
|
||||
assertEquals(link.getSourcePid(), myToGoldenPatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
|
||||
|
@ -131,13 +128,13 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
assertFalse(MdmResourceUtil.isGoldenRecordRedirected(mergedSourcePatient));
|
||||
|
||||
assertEquals(toGoldenPatient.getIdElement(), mergedSourcePatient.getIdElement());
|
||||
assertThat(mergedSourcePatient, is(sameGoldenResourceAs(toGoldenPatient)));
|
||||
mdmAssertThat(mergedSourcePatient).is_MATCH_to(toGoldenPatient);
|
||||
assertEquals(1, getAllRedirectedGoldenPatients().size());
|
||||
// 2 from the set-up and only one from this test should be golden resource
|
||||
assertEquals(3, getAllGoldenPatients().size());
|
||||
|
||||
List<MdmLink> links = (List<MdmLink>) myMdmLinkDaoSvc.findMdmLinksBySourceResource(toGoldenPatient);
|
||||
assertThat(links, hasSize(1));
|
||||
assertThat(links).hasSize(1);
|
||||
|
||||
MdmLink link = links.get(0);
|
||||
assertEquals(link.getSourcePid(), toGoldenPatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
|
||||
|
@ -163,7 +160,7 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
myMdmProvider.mergeGoldenResources(fromGoldenPatientId, toGoldenPatientId, null, myRequestDetails);
|
||||
fail();
|
||||
} catch (InvalidRequestException e) {
|
||||
assertThat(e.getMessage(), endsWith("This operation is only available for resources on the same partition."));
|
||||
assertThat(e.getMessage()).endsWith("This operation is only available for resources on the same partition.");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -178,7 +175,7 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
patient, myRequestDetails);
|
||||
|
||||
assertEquals(myToGoldenPatient.getIdElement(), mergedSourcePatient.getIdElement());
|
||||
assertThat(mergedSourcePatient, is(sameGoldenResourceAs(myToGoldenPatient)));
|
||||
mdmAssertThat(mergedSourcePatient).is_MATCH_to(myToGoldenPatient);
|
||||
assertEquals(1, getAllRedirectedGoldenPatients().size());
|
||||
assertEquals(1, getAllGoldenPatients().size());
|
||||
|
||||
|
@ -187,7 +184,7 @@ public class MdmProviderMergeGoldenResourcesR4Test extends BaseProviderR4Test {
|
|||
assertTrue(MdmResourceUtil.isGoldenRecordRedirected(fromSourcePatient));
|
||||
|
||||
List<MdmLink> links = (List<MdmLink>) myMdmLinkDaoSvc.findMdmLinksBySourceResource(myToGoldenPatient);
|
||||
assertThat(links, hasSize(1));
|
||||
assertThat(links).hasSize(1);
|
||||
|
||||
MdmLink link = links.get(0);
|
||||
assertEquals(link.getSourcePid(), myToGoldenPatient.getIdElement().toUnqualifiedVersionless().getIdPartAsLong());
|
||||
|
|
|
@ -18,6 +18,7 @@ import ca.uhn.fhir.mdm.model.MdmTransactionContext;
|
|||
import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
||||
import ca.uhn.fhir.rest.server.TransactionLogMessages;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.GoldenResourceMatchingAssert;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Address;
|
||||
import org.hl7.fhir.r4.model.DateType;
|
||||
|
@ -95,8 +96,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test {
|
|||
Patient mergedGoldenPatient = mergeGoldenPatients();
|
||||
|
||||
assertEquals(myToGoldenPatient.getIdElement(), mergedGoldenPatient.getIdElement());
|
||||
// TODO CHECKSTYLE KHS restore
|
||||
// assertThat(mergedGoldenPatient).is(sameGoldenResourceAs(mergedGoldenPatient));
|
||||
GoldenResourceMatchingAssert.assertThat(mergedGoldenPatient, myIdHelperService, myMdmLinkDaoSvc).is_MATCH_to(mergedGoldenPatient);
|
||||
assertThat(getAllGoldenPatients()).hasSize(1);
|
||||
assertThat(getAllRedirectedGoldenPatients()).hasSize(1);
|
||||
}
|
||||
|
@ -242,8 +242,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test {
|
|||
Patient mergedGoldenPatient = mergeGoldenPatients();
|
||||
List<MdmLink> links = getNonRedirectLinksByGoldenResource(mergedGoldenPatient);
|
||||
assertThat(links).hasSize(1);
|
||||
// TODO CHECKSTYLE KHS restore
|
||||
// assertThat(mergedGoldenPatient, possibleLinkedTo(myTargetPatient1));
|
||||
GoldenResourceMatchingAssert.assertThat(mergedGoldenPatient, myIdHelperService, myMdmLinkDaoSvc).is_POSSIBLE_MATCH_to(myTargetPatient1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -253,8 +252,7 @@ public class MdmGoldenResourceMergerSvcTest extends BaseMdmR4Test {
|
|||
Patient mergedSourcePatient = mergeGoldenPatients();
|
||||
List<MdmLink> links = getNonRedirectLinksByGoldenResource(mergedSourcePatient);
|
||||
assertThat(links).hasSize(1);
|
||||
// TODO CHECKSTYLE KHS restore
|
||||
// assertThat(mergedSourcePatient, possibleLinkedTo(myTargetPatient1));
|
||||
GoldenResourceMatchingAssert.assertThat(mergedSourcePatient, myIdHelperService, myMdmLinkDaoSvc).is_POSSIBLE_MATCH_to(myTargetPatient1);
|
||||
}
|
||||
|
||||
private Patient mergeGoldenResources(Patient theFrom, Patient theTo) {
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.mdm.svc;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.entity.MdmLink;
|
||||
import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
|
||||
|
@ -22,12 +23,6 @@ import java.util.stream.Stream;
|
|||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.MATCH;
|
||||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.POSSIBLE_DUPLICATE;
|
||||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.POSSIBLE_MATCH;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.in;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.slf4j.LoggerFactory.getLogger;
|
||||
|
||||
@TestPropertySource(properties = {
|
||||
|
@ -64,7 +59,7 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchVector(null, 6L);
|
||||
|
||||
//We want to make sure the patients were linked to the same GoldenResource.
|
||||
assertThat(patient, is(sameGoldenResourceAs(janePatient)));
|
||||
mdmAssertThat(patient).is_MATCH_to(janePatient);
|
||||
|
||||
Patient sourcePatient = (Patient) getGoldenResourceFromTargetResource(patient);
|
||||
|
||||
|
@ -72,17 +67,17 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
|
||||
//The collision should have kept the old identifier
|
||||
Identifier firstIdentifier = identifier.get(0);
|
||||
assertThat(firstIdentifier.getSystem(), is(equalTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM)));
|
||||
assertThat(firstIdentifier.getValue(), is(equalTo(foundHapiEid)));
|
||||
assertThat(firstIdentifier.getSystem()).isEqualTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM);
|
||||
assertThat(firstIdentifier.getValue()).isEqualTo(foundHapiEid);
|
||||
|
||||
//The collision should have added a new identifier with the external system.
|
||||
Identifier secondIdentifier = identifier.get(1);
|
||||
assertThat(secondIdentifier.getSystem(), is(equalTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"))));
|
||||
assertThat(secondIdentifier.getValue(), is(equalTo("12345")));
|
||||
assertThat(secondIdentifier.getSystem()).isEqualTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"));
|
||||
assertThat(secondIdentifier.getValue()).isEqualTo("12345");
|
||||
|
||||
Identifier thirdIdentifier = identifier.get(2);
|
||||
assertThat(thirdIdentifier.getSystem(), is(equalTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"))));
|
||||
assertThat(thirdIdentifier.getValue(), is(equalTo("67890")));
|
||||
assertThat(thirdIdentifier.getSystem()).isEqualTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"));
|
||||
assertThat(thirdIdentifier.getValue()).isEqualTo("67890");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -111,14 +106,14 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchScore(1.0, 1.0);
|
||||
assertLinksMatchVector(null, null);
|
||||
|
||||
assertThat(patient1, is(sameGoldenResourceAs(patient2)));
|
||||
mdmAssertThat(patient1).is_MATCH_to(patient2);
|
||||
|
||||
clearExternalEIDs(patient2);
|
||||
addExternalEID(patient2, "id_6");
|
||||
|
||||
//At this point, there should be 5 EIDs on the GoldenResource
|
||||
Patient patientFromTarget = (Patient) getGoldenResourceFromTargetResource(patient2);
|
||||
assertThat(patientFromTarget.getIdentifier(), hasSize(5));
|
||||
assertThat(patientFromTarget.getIdentifier()).hasSize(5);
|
||||
|
||||
ourLog.info("About to update patient...");
|
||||
updatePatientAndUpdateLinks(patient2);
|
||||
|
@ -128,10 +123,10 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchScore(1.0, 1.0);
|
||||
assertLinksMatchVector(null, null);
|
||||
|
||||
assertThat(patient1, is(sameGoldenResourceAs(patient2)));
|
||||
mdmAssertThat(patient1).is_MATCH_to(patient2);
|
||||
|
||||
patientFromTarget = (Patient) getGoldenResourceFromTargetResource(patient2);
|
||||
assertThat(patientFromTarget.getIdentifier(), hasSize(6));
|
||||
assertThat(patientFromTarget.getIdentifier()).hasSize(6);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -157,7 +152,7 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchVector(null, null, null);
|
||||
|
||||
List<MdmLink> possibleDuplicates = (List<MdmLink>) myMdmLinkDaoSvc.getPossibleDuplicates();
|
||||
assertThat(possibleDuplicates, hasSize(1));
|
||||
assertThat(possibleDuplicates).hasSize(1);
|
||||
|
||||
Patient finalPatient1 = patient1;
|
||||
Patient finalPatient2 = patient2;
|
||||
|
@ -167,8 +162,8 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
|
||||
//The two GoldenResources related to the patients should both show up in the only existing POSSIBLE_DUPLICATE MdmLink.
|
||||
MdmLink mdmLink = possibleDuplicates.get(0);
|
||||
assertThat(mdmLink.getGoldenResourcePersistenceId(), is(in(duplicatePids)));
|
||||
assertThat(mdmLink.getSourcePersistenceId(), is(in(duplicatePids)));
|
||||
assertThat(mdmLink.getGoldenResourcePersistenceId()).isIn(duplicatePids);
|
||||
assertThat(mdmLink.getSourcePersistenceId()).isIn(duplicatePids);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -204,7 +199,7 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchVector(null, null, null);
|
||||
|
||||
//Now, Patient 2 and 3 are linked, and the GoldenResource has 2 eids.
|
||||
assertThat(patient2, is(sameGoldenResourceAs(patient3)));
|
||||
mdmAssertThat(patient2).is_MATCH_to(patient3);
|
||||
|
||||
//Now lets change one of the EIDs on the second patient to one that matches our original patient.
|
||||
//This should create a situation in which the incoming EIDs are matched to _two_ different GoldenResources. In this case, we want to
|
||||
|
@ -220,12 +215,12 @@ public class MdmMatchLinkSvcMultipleEidModeTest extends BaseMdmR4Test {
|
|||
assertLinksMatchScore(1.0, 1.0, 1.0, 1.0, null);
|
||||
assertLinksMatchVector(null, null, null, null, null);
|
||||
|
||||
assertThat(patient2, is(not(matchedToAGoldenResource())));
|
||||
assertThat(patient2, is(possibleMatchWith(patient1)));
|
||||
assertThat(patient2, is(possibleMatchWith(patient3)));
|
||||
mdmAssertThat(patient2).doesNotHaveGoldenResourceMatch();
|
||||
mdmAssertThat(patient2).is_POSSIBLE_MATCH_to(patient1);
|
||||
mdmAssertThat(patient2).is_POSSIBLE_MATCH_to(patient3);
|
||||
|
||||
List<MdmLink> possibleDuplicates = (List<MdmLink>) myMdmLinkDaoSvc.getPossibleDuplicates();
|
||||
assertThat(possibleDuplicates, hasSize(1));
|
||||
assertThat(patient3, is(possibleDuplicateOf(patient1)));
|
||||
assertThat(possibleDuplicates).hasSize(1);
|
||||
mdmAssertThat(patient3).is_POSSIBLE_DUPLICATE_to(patient1);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package ca.uhn.fhir.jpa.mdm.svc;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||
import ca.uhn.fhir.jpa.api.model.DaoMethodOutcome;
|
||||
import ca.uhn.fhir.jpa.entity.MdmLink;
|
||||
import ca.uhn.fhir.jpa.mdm.BaseMdmR4Test;
|
||||
import ca.uhn.fhir.jpa.mdm.config.BaseTestMdmConfig;
|
||||
import ca.uhn.fhir.jpa.mdm.config.BlockListConfig;
|
||||
import ca.uhn.fhir.jpa.mdm.helper.testmodels.MDMState;
|
||||
import ca.uhn.fhir.jpa.mdm.matcher.GoldenResourceMatchingAssert;
|
||||
import ca.uhn.fhir.jpa.model.dao.JpaPid;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.mdm.api.IMdmLink;
|
||||
|
@ -59,14 +59,6 @@ import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.MATCH;
|
|||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.NO_MATCH;
|
||||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.POSSIBLE_DUPLICATE;
|
||||
import static ca.uhn.fhir.mdm.api.MdmMatchResultEnum.POSSIBLE_MATCH;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
import static org.hamcrest.Matchers.blankOrNullString;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.hamcrest.Matchers.equalToIgnoringCase;
|
||||
import static org.hamcrest.Matchers.hasSize;
|
||||
import static org.hamcrest.Matchers.in;
|
||||
import static org.hamcrest.Matchers.is;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -183,7 +175,7 @@ public class MdmMatchLinkSvcTest {
|
|||
|
||||
assertLinkCount(2);
|
||||
|
||||
assertThat(patient1, is(not(sameGoldenResourceAs(patient2))));
|
||||
mdmAssertThat(patient1).is_not_MATCH_to(patient2);
|
||||
|
||||
assertLinksMatchResult(MATCH, MATCH);
|
||||
assertLinksCreatedNewResource(true, true);
|
||||
|
@ -200,7 +192,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient patient2 = createPatientAndUpdateLinks(buildJanePatient());
|
||||
assertLinkCount(2);
|
||||
|
||||
assertThat(patient1, is(sameGoldenResourceAs(patient2)));
|
||||
mdmAssertThat(patient1).is_MATCH_to(patient2);
|
||||
assertLinksMatchResult(MATCH, MATCH);
|
||||
assertLinksCreatedNewResource(true, false);
|
||||
assertLinksMatchedByEid(false, false);
|
||||
|
@ -211,7 +203,7 @@ public class MdmMatchLinkSvcTest {
|
|||
@Test
|
||||
public void testWhenMatchOccursOnGoldenResourceThatHasBeenManuallyNOMATCHedThatItIsBlocked() {
|
||||
Patient originalJane = createPatientAndUpdateLinks(buildJanePatient());
|
||||
IAnyResource janeGoldenResource = getGoldenResourceFromTargetResource(originalJane);
|
||||
Patient janeGoldenResource = getGoldenResourceFromTargetResource(originalJane);
|
||||
|
||||
//Create a manual NO_MATCH between janeGoldenResource and unmatchedJane.
|
||||
Patient unmatchedJane = createPatient(buildJanePatient());
|
||||
|
@ -220,8 +212,8 @@ public class MdmMatchLinkSvcTest {
|
|||
//rerun MDM rules against unmatchedJane.
|
||||
myMdmMatchLinkSvc.updateMdmLinksForMdmSource(unmatchedJane, createContextForCreate("Patient"));
|
||||
|
||||
assertThat(unmatchedJane, is(not(sameGoldenResourceAs(janeGoldenResource))));
|
||||
assertThat(unmatchedJane, is(not(linkedTo(originalJane))));
|
||||
mdmAssertThat(unmatchedJane).is_not_MATCH_to(janeGoldenResource);
|
||||
mdmAssertThat(unmatchedJane).is_not_MATCH_to(originalJane);
|
||||
|
||||
assertLinksMatchResult(MATCH, NO_MATCH, MATCH);
|
||||
assertLinksCreatedNewResource(true, false, true);
|
||||
|
@ -244,7 +236,7 @@ public class MdmMatchLinkSvcTest {
|
|||
|
||||
//Then: The secondary jane should link to the first jane.
|
||||
myMdmMatchLinkSvc.updateMdmLinksForMdmSource(resource, buildUpdateResourceMdmTransactionContext());
|
||||
assertThat(secondaryJane, is(sameGoldenResourceAs(jane)));
|
||||
mdmAssertThat(secondaryJane).is_MATCH_to(goldenJane);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -252,7 +244,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient originalJane = createPatientAndUpdateLinks(buildJanePatient());
|
||||
|
||||
IBundleProvider search = myPatientDao.search(buildGoldenRecordSearchParameterMap());
|
||||
IAnyResource janeGoldenResource = (IAnyResource) search.getResources(0, 1).get(0);
|
||||
Patient janeGoldenResource = (Patient) search.getResources(0, 1).get(0);
|
||||
|
||||
Patient unmatchedPatient = createPatient(buildJanePatient());
|
||||
|
||||
|
@ -264,8 +256,8 @@ public class MdmMatchLinkSvcTest {
|
|||
//should cause a whole new GoldenResource to be created.
|
||||
myMdmMatchLinkSvc.updateMdmLinksForMdmSource(unmatchedPatient, createContextForCreate("Patient"));
|
||||
|
||||
assertThat(unmatchedPatient, is(not(sameGoldenResourceAs(janeGoldenResource))));
|
||||
assertThat(unmatchedPatient, is(not(linkedTo(originalJane))));
|
||||
GoldenResourceMatchingAssert.assertThat(unmatchedPatient, myIdHelperService, myMdmLinkDaoSvc).is_not_MATCH_to(janeGoldenResource);
|
||||
GoldenResourceMatchingAssert.assertThat(unmatchedPatient, myIdHelperService, myMdmLinkDaoSvc).is_not_MATCH_to(originalJane);
|
||||
|
||||
assertLinksMatchResult(MATCH, NO_MATCH, MATCH);
|
||||
assertLinksCreatedNewResource(true, false, true);
|
||||
|
@ -281,13 +273,13 @@ public class MdmMatchLinkSvcTest {
|
|||
janePatient = createPatientAndUpdateLinks(janePatient);
|
||||
|
||||
Optional<? extends IMdmLink> mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(JpaPid.fromId(janePatient.getIdElement().getIdPartAsLong()));
|
||||
assertThat(mdmLink.isPresent(), is(true));
|
||||
assertTrue(mdmLink.isPresent());
|
||||
|
||||
Patient patient = getTargetResourceFromMdmLink(mdmLink.get(), "Patient");
|
||||
List<CanonicalEID> externalEid = myEidHelper.getExternalEid(patient);
|
||||
|
||||
assertThat(externalEid.get(0).getSystem(), is(equalTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"))));
|
||||
assertThat(externalEid.get(0).getValue(), is(equalTo(sampleEID)));
|
||||
assertThat(externalEid.get(0).getSystem()).isEqualTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"));
|
||||
assertThat(externalEid.get(0).getValue()).isEqualTo(sampleEID);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -297,8 +289,8 @@ public class MdmMatchLinkSvcTest {
|
|||
|
||||
Patient targetPatient = getTargetResourceFromMdmLink(mdmLink, "Patient");
|
||||
Identifier identifierFirstRep = targetPatient.getIdentifierFirstRep();
|
||||
assertThat(identifierFirstRep.getSystem(), is(equalTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM)));
|
||||
assertThat(identifierFirstRep.getValue(), not(blankOrNullString()));
|
||||
assertThat(identifierFirstRep.getSystem()).isEqualTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM);
|
||||
assertThat(identifierFirstRep.getValue()).isNotBlank();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -308,20 +300,20 @@ public class MdmMatchLinkSvcTest {
|
|||
Optional<? extends IMdmLink> mdmLink = myMdmLinkDaoSvc.getMatchedLinkForSourcePid(JpaPid.fromId(patient.getIdElement().getIdPartAsLong()));
|
||||
Patient read = getTargetResourceFromMdmLink(mdmLink.get(), "Patient");
|
||||
|
||||
assertThat(read.getNameFirstRep().getFamily(), is(equalTo(patient.getNameFirstRep().getFamily())));
|
||||
assertThat(read.getNameFirstRep().getGivenAsSingleString(), is(equalTo(patient.getNameFirstRep().getGivenAsSingleString())));
|
||||
assertThat(read.getBirthDateElement().toHumanDisplay(), is(equalTo(patient.getBirthDateElement().toHumanDisplay())));
|
||||
assertThat(read.getTelecomFirstRep().getValue(), is(equalTo(patient.getTelecomFirstRep().getValue())));
|
||||
assertThat(read.getPhoto().size(), is(equalTo(patient.getPhoto().size())));
|
||||
assertThat(read.getPhotoFirstRep().getData(), is(equalTo(patient.getPhotoFirstRep().getData())));
|
||||
assertThat(read.getGender(), is(equalTo(patient.getGender())));
|
||||
assertThat(read.getNameFirstRep().getFamily()).isEqualTo(patient.getNameFirstRep().getFamily());
|
||||
assertThat(read.getNameFirstRep().getGivenAsSingleString()).isEqualTo(patient.getNameFirstRep().getGivenAsSingleString());
|
||||
assertThat(read.getBirthDateElement().toHumanDisplay()).isEqualTo(patient.getBirthDateElement().toHumanDisplay());
|
||||
assertThat(read.getTelecomFirstRep().getValue()).isEqualTo(patient.getTelecomFirstRep().getValue());
|
||||
assertThat(read.getPhoto().size()).isEqualTo(patient.getPhoto().size());
|
||||
assertThat(read.getPhotoFirstRep().getData()).isEqualTo(patient.getPhotoFirstRep().getData());
|
||||
assertThat(read.getGender()).isEqualTo(patient.getGender());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testPatientMatchingAnotherPatientLinksToSameGoldenResource() {
|
||||
Patient janePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
Patient sameJanePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
assertThat(janePatient, is(sameGoldenResourceAs(sameJanePatient)));
|
||||
mdmAssertThat(janePatient).is_MATCH_to(sameJanePatient);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -338,7 +330,7 @@ public class MdmMatchLinkSvcTest {
|
|||
createPatientAndUpdateLinks(janePatient);
|
||||
|
||||
//We want to make sure the patients were linked to the same Golden Resource.
|
||||
assertThat(patient, is(sameGoldenResourceAs(janePatient)));
|
||||
mdmAssertThat(patient).is_MATCH_to(janePatient);
|
||||
|
||||
Patient sourcePatient = getGoldenResourceFromTargetResource(patient);
|
||||
|
||||
|
@ -346,13 +338,13 @@ public class MdmMatchLinkSvcTest {
|
|||
|
||||
//The collision should have kept the old identifier
|
||||
Identifier firstIdentifier = identifier.get(0);
|
||||
assertThat(firstIdentifier.getSystem(), is(equalTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM)));
|
||||
assertThat(firstIdentifier.getValue(), is(equalTo(foundHapiEid)));
|
||||
assertThat(firstIdentifier.getSystem()).isEqualTo(MdmConstants.HAPI_ENTERPRISE_IDENTIFIER_SYSTEM);
|
||||
assertThat(firstIdentifier.getValue()).isEqualTo(foundHapiEid);
|
||||
|
||||
//The collision should have added a new identifier with the external system.
|
||||
Identifier secondIdentifier = identifier.get(1);
|
||||
assertThat(secondIdentifier.getSystem(), is(equalTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"))));
|
||||
assertThat(secondIdentifier.getValue(), is(equalTo("12345")));
|
||||
assertThat(secondIdentifier.getSystem()).isEqualTo(myMdmSettings.getMdmRules().getEnterpriseEIDSystemForResourceType("Patient"));
|
||||
assertThat(secondIdentifier.getValue()).isEqualTo("12345");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -365,7 +357,7 @@ public class MdmMatchLinkSvcTest {
|
|||
patient2 = addExternalEID(patient2, "uniqueid");
|
||||
createPatientAndUpdateLinks(patient2);
|
||||
|
||||
assertThat(patient1, is(sameGoldenResourceAs(patient2)));
|
||||
mdmAssertThat(patient1).is_MATCH_to(patient2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -382,7 +374,7 @@ public class MdmMatchLinkSvcTest {
|
|||
addExternalEID(patient2, "id_1");
|
||||
createPatientAndUpdateLinks(patient2);
|
||||
|
||||
assertThat(patient1, is(sameGoldenResourceAs(patient2)));
|
||||
mdmAssertThat(patient1).is_MATCH_to(patient2);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -395,7 +387,7 @@ public class MdmMatchLinkSvcTest {
|
|||
patient2 = createPatientAndUpdateLinks(patient2);
|
||||
|
||||
List<MdmLink> possibleDuplicates = (List<MdmLink>) myMdmLinkDaoSvc.getPossibleDuplicates();
|
||||
assertThat(possibleDuplicates, hasSize(1));
|
||||
assertThat(possibleDuplicates).hasSize(1);
|
||||
|
||||
Patient finalPatient1 = patient1;
|
||||
Patient finalPatient2 = patient2;
|
||||
|
@ -405,8 +397,8 @@ public class MdmMatchLinkSvcTest {
|
|||
|
||||
//The two GoldenResources related to the patients should both show up in the only existing POSSIBLE_DUPLICATE MdmLink.
|
||||
MdmLink mdmLink = possibleDuplicates.get(0);
|
||||
assertThat(mdmLink.getGoldenResourcePersistenceId(), is(in(duplicatePids)));
|
||||
assertThat(mdmLink.getSourcePersistenceId(), is(in(duplicatePids)));
|
||||
assertThat(mdmLink.getGoldenResourcePersistenceId()).isIn(duplicatePids);
|
||||
assertThat(mdmLink.getSourcePersistenceId()).isIn(duplicatePids);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -425,7 +417,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Practitioner janePractitioner = createPractitionerAndUpdateLinks(buildJanePractitioner());
|
||||
|
||||
assertLinkCount(2);
|
||||
assertThat(janePatient, is(not(sameGoldenResourceAs(janePractitioner))));
|
||||
mdmAssertThat(janePatient).is_not_MATCH_to(janePractitioner);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -434,7 +426,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Practitioner anotherJanePractitioner = createPractitionerAndUpdateLinks(buildJanePractitioner());
|
||||
|
||||
assertLinkCount(2);
|
||||
assertThat(anotherJanePractitioner, is(sameGoldenResourceAs(janePractitioner)));
|
||||
mdmAssertThat(anotherJanePractitioner).is_MATCH_to(janePractitioner);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -446,7 +438,7 @@ public class MdmMatchLinkSvcTest {
|
|||
assertLinkCount(0);
|
||||
Patient janePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
assertLinkCount(1);
|
||||
assertThat(janePatient, is(matchedToAGoldenResource()));
|
||||
mdmAssertThat(janePatient).hasGoldenResourceMatch();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -459,11 +451,14 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient janePatient2 = createPatientAndUpdateLinks(buildJanePatient());
|
||||
|
||||
assertLinkCount(2);
|
||||
assertThat(janePatient, is(sameGoldenResourceAs(janePatient2)));
|
||||
mdmAssertThat(janePatient).is_MATCH_to(janePatient2);
|
||||
|
||||
|
||||
Patient incomingJanePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
assertThat(incomingJanePatient, is(sameGoldenResourceAs(janePatient, janePatient2)));
|
||||
assertThat(incomingJanePatient, is(linkedTo(janePatient, janePatient2)));
|
||||
mdmAssertThat(incomingJanePatient)
|
||||
.is_MATCH_to(janePatient)
|
||||
.is_MATCH_to(janePatient2);
|
||||
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -483,20 +478,22 @@ public class MdmMatchLinkSvcTest {
|
|||
myMdmSurvivorshipService
|
||||
);
|
||||
myMdmLinkSvc.updateLink(goldenResource, janePatient2, MdmMatchOutcome.NEW_GOLDEN_RESOURCE_MATCH, MdmLinkSourceEnum.AUTO, createContextForCreate("Patient"));
|
||||
assertThat(janePatient, is(not(sameGoldenResourceAs(janePatient2))));
|
||||
mdmAssertThat(janePatient).is_not_MATCH_to(janePatient2);
|
||||
|
||||
//In theory, this will match both GoldenResources!
|
||||
Patient incomingJanePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
|
||||
//There should now be a single POSSIBLE_DUPLICATE link with
|
||||
assertThat(janePatient, is(possibleDuplicateOf(janePatient2)));
|
||||
mdmAssertThat(janePatient).is_POSSIBLE_DUPLICATE_to(janePatient2);
|
||||
|
||||
//There should now be 2 POSSIBLE_MATCH links with this goldenResource.
|
||||
assertThat(incomingJanePatient, is(possibleMatchWith(janePatient, janePatient2)));
|
||||
mdmAssertThat(incomingJanePatient)
|
||||
.is_POSSIBLE_MATCH_to(janePatient)
|
||||
.is_POSSIBLE_MATCH_to(janePatient2);
|
||||
|
||||
//Ensure there is no successful MATCH links for incomingJanePatient
|
||||
Optional<? extends IMdmLink> matchedLinkForTargetPid = runInTransaction(() -> myMdmLinkDaoSvc.getMatchedLinkForSourcePid(myIdHelperService.getPidOrNull(RequestPartitionId.allPartitions(), incomingJanePatient)));
|
||||
assertThat(matchedLinkForTargetPid.isPresent(), is(false));
|
||||
assertThat(matchedLinkForTargetPid.isPresent()).isEqualTo(false);
|
||||
|
||||
logAllLinks();
|
||||
assertLinksMatchResult(MATCH, MATCH, POSSIBLE_MATCH, POSSIBLE_MATCH, POSSIBLE_DUPLICATE);
|
||||
|
@ -513,19 +510,19 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient patient = buildJanePatient();
|
||||
patient.getNameFirstRep().setFamily("familyone");
|
||||
patient = createPatientAndUpdateLinks(patient);
|
||||
assertThat(patient, is(sameGoldenResourceAs(patient)));
|
||||
mdmAssertThat(patient).is_MATCH_to(patient);
|
||||
|
||||
Patient patient2 = buildJanePatient();
|
||||
patient2.getNameFirstRep().setFamily("pleasedonotmatchatall");
|
||||
patient2 = createPatientAndUpdateLinks(patient2);
|
||||
assertThat(patient2, is(possibleMatchWith(patient)));
|
||||
mdmAssertThat(patient2).is_POSSIBLE_MATCH_to(patient);
|
||||
|
||||
Patient patient3 = buildJanePatient();
|
||||
patient3.getNameFirstRep().setFamily("pleasedonotmatchatall");
|
||||
patient3 = createPatientAndUpdateLinks(patient3);
|
||||
|
||||
assertThat(patient3, is(possibleMatchWith(patient2)));
|
||||
assertThat(patient3, is(possibleMatchWith(patient)));
|
||||
mdmAssertThat(patient3).is_POSSIBLE_MATCH_to(patient2);
|
||||
mdmAssertThat(patient3).is_POSSIBLE_MATCH_to(patient);
|
||||
|
||||
IBundleProvider bundle = myPatientDao.search(buildGoldenRecordSearchParameterMap());
|
||||
assertEquals(1, bundle.size());
|
||||
|
@ -549,7 +546,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient patient = buildJanePatient();
|
||||
patient.getNameFirstRep().setFamily("familyone");
|
||||
patient = createPatientAndUpdateLinks(patient);
|
||||
assertThat(patient, is(sameGoldenResourceAs(patient)));
|
||||
mdmAssertThat(patient).is_MATCH_to(patient);
|
||||
|
||||
Patient patient2 = buildJanePatient();
|
||||
patient2.getNameFirstRep().setFamily("pleasedonotmatchatall");
|
||||
|
@ -559,9 +556,9 @@ public class MdmMatchLinkSvcTest {
|
|||
patient3.getNameFirstRep().setFamily("familyone");
|
||||
patient3 = createPatientAndUpdateLinks(patient3);
|
||||
|
||||
assertThat(patient2, is(not(sameGoldenResourceAs(patient))));
|
||||
assertThat(patient2, is(possibleMatchWith(patient)));
|
||||
assertThat(patient3, is(sameGoldenResourceAs(patient)));
|
||||
mdmAssertThat(patient2).is_not_MATCH_to(patient);
|
||||
mdmAssertThat(patient2).is_POSSIBLE_MATCH_to(patient);
|
||||
mdmAssertThat(patient3).is_MATCH_to(patient);
|
||||
}
|
||||
|
||||
|
||||
|
@ -571,15 +568,14 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient patient = buildJanePatient();
|
||||
patient.getNameFirstRep().setFamily("familyone");
|
||||
patient = createPatientAndUpdateLinks(patient);
|
||||
assertThat(patient, is(sameGoldenResourceAs(patient)));
|
||||
mdmAssertThat(patient).is_MATCH_to(patient);
|
||||
|
||||
Patient patient2 = buildJanePatient();
|
||||
patient2.getNameFirstRep().setFamily("pleasedonotmatchatall");
|
||||
patient2 = createPatientAndUpdateLinks(patient2);
|
||||
|
||||
assertThat(patient2, is(not(sameGoldenResourceAs(patient))));
|
||||
assertThat(patient2, is(not(linkedTo(patient))));
|
||||
assertThat(patient2, is(possibleMatchWith(patient)));
|
||||
mdmAssertThat(patient2).is_not_MATCH_to(patient);
|
||||
mdmAssertThat(patient2).is_POSSIBLE_MATCH_to(patient);
|
||||
|
||||
patient2.getNameFirstRep().setFamily(patient.getNameFirstRep().getFamily());
|
||||
|
||||
|
@ -587,8 +583,7 @@ public class MdmMatchLinkSvcTest {
|
|||
updatePatientAndUpdateLinks(patient2);
|
||||
|
||||
// validate
|
||||
assertThat(patient2, is(linkedTo(patient)));
|
||||
assertThat(patient2, is(sameGoldenResourceAs(patient)));
|
||||
mdmAssertThat(patient2).is_MATCH_to(patient);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -606,7 +601,7 @@ public class MdmMatchLinkSvcTest {
|
|||
assertFalse(myEidHelper.getHapiEid(janeGoldenResourcePatient).isEmpty());
|
||||
|
||||
// original checks - verifies that EIDs are assigned
|
||||
assertThat("Resource must not be identical", janePatient != janeGoldenResourcePatient);
|
||||
assertThat(janePatient != janeGoldenResourcePatient).as("Resource must not be identical").isTrue();
|
||||
assertFalse(janePatient.getIdentifier().isEmpty());
|
||||
assertFalse(janeGoldenResourcePatient.getIdentifier().isEmpty());
|
||||
|
||||
|
@ -629,13 +624,13 @@ public class MdmMatchLinkSvcTest {
|
|||
patient1.setId(janePatient.getId());
|
||||
Patient janePaulPatient = updatePatientAndUpdateLinks(patient1);
|
||||
|
||||
assertThat(janeSourcePatient, is(sameGoldenResourceAs(janePaulPatient)));
|
||||
mdmAssertThat(janeSourcePatient).is_MATCH_to(janePaulPatient);
|
||||
|
||||
//Ensure the related GoldenResource was updated with new info.
|
||||
Patient sourcePatientFromTarget = getGoldenResourceFromTargetResource(janePaulPatient);
|
||||
HumanName nameFirstRep = sourcePatientFromTarget.getNameFirstRep();
|
||||
|
||||
assertThat(nameFirstRep.getGivenAsSingleString(), is(equalToIgnoringCase("paul")));
|
||||
assertThat(nameFirstRep.getGivenAsSingleString()).isEqualToIgnoringCase("paul");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -647,7 +642,7 @@ public class MdmMatchLinkSvcTest {
|
|||
paul = createPatientAndUpdateLinks(paul);
|
||||
|
||||
Patient sourcePatientFromTarget = getGoldenResourceFromTargetResource(paul);
|
||||
assertThat(sourcePatientFromTarget.getBirthDateElement().getValueAsString(), is(incorrectBirthdate));
|
||||
assertThat(sourcePatientFromTarget.getBirthDateElement().getValueAsString()).isEqualTo(incorrectBirthdate);
|
||||
|
||||
String correctBirthdate = "1990-06-28";
|
||||
paul.getBirthDateElement().setValueAsString(correctBirthdate);
|
||||
|
@ -655,7 +650,7 @@ public class MdmMatchLinkSvcTest {
|
|||
paul = updatePatientAndUpdateLinks(paul);
|
||||
|
||||
sourcePatientFromTarget = getGoldenResourceFromTargetResource(paul);
|
||||
assertThat(sourcePatientFromTarget.getBirthDateElement().getValueAsString(), is(equalTo(correctBirthdate)));
|
||||
assertThat(sourcePatientFromTarget.getBirthDateElement().getValueAsString()).isEqualTo(correctBirthdate);
|
||||
assertLinkCount(1);
|
||||
}
|
||||
|
||||
|
@ -672,8 +667,8 @@ public class MdmMatchLinkSvcTest {
|
|||
addExternalEID(paul, EID_2);
|
||||
updatePatientAndUpdateLinks(paul);
|
||||
|
||||
assertThat(originalJaneGolden, is(possibleDuplicateOf(originalPaulGolden)));
|
||||
assertThat(jane, is(sameGoldenResourceAs(paul)));
|
||||
mdmAssertThat(originalJaneGolden).is_POSSIBLE_DUPLICATE_to(originalPaulGolden);
|
||||
mdmAssertThat(jane).is_MATCH_to(paul);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -702,8 +697,8 @@ public class MdmMatchLinkSvcTest {
|
|||
updatePatientAndUpdateLinks(paul);
|
||||
|
||||
// verify
|
||||
assertThat(originalJaneGolden, is(not(possibleDuplicateOf(originalPaulGolden))));
|
||||
assertThat(jane, is(sameGoldenResourceAs(paul)));
|
||||
mdmAssertThat(originalJaneGolden).is_not_POSSIBLE_DUPLICATE_to(originalPaulGolden);
|
||||
mdmAssertThat(jane).is_MATCH_to(paul);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -713,7 +708,7 @@ public class MdmMatchLinkSvcTest {
|
|||
Patient originalPaulGolden = getGoldenResourceFromTargetResource(paul);
|
||||
|
||||
String oldEid = myEidHelper.getExternalEid(originalPaulGolden).get(0).getValue();
|
||||
assertThat(oldEid, is(equalTo(EID_1)));
|
||||
assertThat(oldEid).isEqualTo(EID_1);
|
||||
|
||||
clearExternalEIDs(paul);
|
||||
addExternalEID(paul, EID_2);
|
||||
|
@ -722,14 +717,14 @@ public class MdmMatchLinkSvcTest {
|
|||
assertNoDuplicates();
|
||||
|
||||
Patient newlyFoundPaulPatient = getGoldenResourceFromTargetResource(paul);
|
||||
assertThat(originalPaulGolden, is(sameGoldenResourceAs(newlyFoundPaulPatient)));
|
||||
mdmAssertThat(originalPaulGolden).is_MATCH_to(newlyFoundPaulPatient);
|
||||
String newEid = myEidHelper.getExternalEid(newlyFoundPaulPatient).get(0).getValue();
|
||||
assertThat(newEid, is(equalTo(EID_2)));
|
||||
assertThat(newEid).isEqualTo(EID_2);
|
||||
}
|
||||
|
||||
private void assertNoDuplicates() {
|
||||
List<MdmLink> possibleDuplicates = (List<MdmLink>) myMdmLinkDaoSvc.getPossibleDuplicates();
|
||||
assertThat(possibleDuplicates, hasSize(0));
|
||||
assertThat(possibleDuplicates).hasSize(0);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -748,7 +743,7 @@ public class MdmMatchLinkSvcTest {
|
|||
patient3 = createPatientAndUpdateLinks(patient3);
|
||||
|
||||
//Now, Patient 2 and 3 are linked, and the GoldenResource has 2 eids.
|
||||
assertThat(patient2, is(sameGoldenResourceAs(patient3)));
|
||||
mdmAssertThat(patient2).is_MATCH_to(patient3);
|
||||
assertNoDuplicates();
|
||||
// GoldenResource A -> {P1}
|
||||
// GoldenResource B -> {P2, P3}
|
||||
|
@ -761,11 +756,11 @@ public class MdmMatchLinkSvcTest {
|
|||
// GoldenResource B -> {P3}
|
||||
// Possible duplicates A<->B
|
||||
|
||||
assertThat(patient2, is(sameGoldenResourceAs(patient1)));
|
||||
mdmAssertThat(patient2).is_MATCH_to(patient1);
|
||||
|
||||
List<MdmLink> possibleDuplicates = (List<MdmLink>) myMdmLinkDaoSvc.getPossibleDuplicates();
|
||||
assertThat(possibleDuplicates, hasSize(1));
|
||||
assertThat(patient3, is(possibleDuplicateOf(patient1)));
|
||||
assertThat(possibleDuplicates).hasSize(1);
|
||||
mdmAssertThat(patient3).is_POSSIBLE_DUPLICATE_to(patient1);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -782,16 +777,16 @@ public class MdmMatchLinkSvcTest {
|
|||
);
|
||||
myMdmLinkSvc.updateLink(goldenResource, janePatient2, MdmMatchOutcome.NEW_GOLDEN_RESOURCE_MATCH,
|
||||
MdmLinkSourceEnum.AUTO, createContextForCreate("Patient"));
|
||||
assertThat(janePatient, is(not(sameGoldenResourceAs(janePatient2))));
|
||||
mdmAssertThat(janePatient).is_not_MATCH_to(janePatient2);
|
||||
|
||||
//In theory, this will match both GoldenResources!
|
||||
Patient incomingJanePatient = createPatientAndUpdateLinks(buildJanePatient());
|
||||
|
||||
//There should now be a single POSSIBLE_DUPLICATE link with
|
||||
assertThat(janePatient, is(possibleDuplicateOf(janePatient2)));
|
||||
mdmAssertThat(janePatient).is_POSSIBLE_DUPLICATE_to(janePatient2);
|
||||
|
||||
//There should now be 2 POSSIBLE_MATCH links with this goldenResource.
|
||||
assertThat(incomingJanePatient, is(possibleMatchWith(janePatient, janePatient2)));
|
||||
mdmAssertThat(incomingJanePatient).is_POSSIBLE_MATCH_to(janePatient).is_POSSIBLE_MATCH_to(janePatient2);
|
||||
|
||||
// Ensure both links are POSSIBLE_MATCH and both have a score value
|
||||
List<? extends IMdmLink> janetPatientLinks = runInTransaction(() -> myMdmLinkDaoSvc.findMdmLinksBySourceResource(incomingJanePatient));
|
||||
|
|
|
@ -78,8 +78,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.ResourceVersionConflictException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import org.apache.commons.lang3.RandomStringUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
|
|
@ -1868,8 +1868,8 @@ public class FhirSystemDaoDstu2Test extends BaseJpaDstu2SystemTest {
|
|||
// assertTrue(o1.getId().getValue(), o1.getId().getIdPart().matches("^[0-9]+$"));
|
||||
// assertTrue(o2.getId().getValue(), o2.getId().getIdPart().matches("^[0-9]+$"));
|
||||
//
|
||||
// assertThat(o1.getSubject().getReference().getValue(), endsWith("Patient/" + p1.getId().getIdPart()));
|
||||
// assertThat(o2.getSubject().getReference().getValue(), endsWith("Patient/" + p1.getId().getIdPart()));
|
||||
// assertThat(o1.getSubject().getReference().getValue()).endsWith("Patient/" + p1.getId().getIdPart());
|
||||
// assertThat(o2.getSubject().getReference().getValue()).endsWith("Patient/" + p1.getId().getIdPart());
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
|
|
@ -1349,7 +1349,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
// ourLog.info(output);
|
||||
// List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(pId, cId));
|
||||
// assertThat(ids).contains(pId, cId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
@ -1363,7 +1363,7 @@ public class ResourceProviderDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
// ourLog.info(output);
|
||||
// List<IdDt> ids = toIdListUnqualifiedVersionless(myFhirCtx.newXmlParser().parseBundle(output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(cId, pId, oId));
|
||||
// assertThat(ids).contains(cId, pId, oId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
|
|
@ -30,7 +30,6 @@ import ca.uhn.fhir.rest.server.IPagingProvider;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceGoneException;
|
||||
import ca.uhn.fhir.system.HapiSystemProperties;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -324,7 +323,7 @@ public class SearchCoordinatorSvcImplTest extends BaseSearchSvc {
|
|||
|
||||
ourLog.info("Registering the first search");
|
||||
new Thread(() -> mySvc.registerSearch(myCallingDao, params, "Patient", new CacheControlDirective(), null, RequestPartitionId.allPartitions())).start();
|
||||
await().until(iter::getCountReturned, Matchers.greaterThan(0));
|
||||
await().untilAsserted(() -> assertThat(iter.getCountReturned()).isGreaterThan(0));
|
||||
|
||||
String searchId = mySvc.getActiveSearchIds().iterator().next();
|
||||
CountDownLatch completionLatch = new CountDownLatch(1);
|
||||
|
|
|
@ -19,7 +19,6 @@ import ca.uhn.fhir.rest.server.mail.MailSvc;
|
|||
import com.icegreen.greenmail.junit5.GreenMailExtension;
|
||||
import com.icegreen.greenmail.util.GreenMailUtil;
|
||||
import com.icegreen.greenmail.util.ServerSetupTest;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
@ -123,11 +122,11 @@ public class EmailSubscriptionDstu2Test extends BaseResourceProviderDstu2Test {
|
|||
|
||||
Subscription subscription1 = createSubscription(criteria1, payload, "to1@example.com,to2@example.com");
|
||||
mySubscriptionTestUtil.waitForQueueToDrain();
|
||||
await().until(() -> mySubscriptionRegistry.get(subscription1.getIdElement().getIdPart()), Matchers.not(Matchers.nullValue()));
|
||||
await().untilAsserted(() -> assertThat(mySubscriptionRegistry.get(subscription1.getIdElement().getIdPart())).isNotNull());
|
||||
mySubscriptionTestUtil.setEmailSender(subscription1.getIdElement(), new EmailSenderImpl(withMailService()));
|
||||
assertThat(Arrays.asList(ourGreenMail.getReceivedMessages())).isEmpty();
|
||||
|
||||
Observation observation1 = sendObservation(code, "SNOMED-CT");
|
||||
sendObservation(code, "SNOMED-CT");
|
||||
|
||||
assertTrue(ourGreenMail.waitForIncomingEmail(10000, 1));
|
||||
|
||||
|
|
|
@ -66,7 +66,7 @@ public class FhirResourceDaoDstu3SearchFtTest extends BaseJpaDstu3Test {
|
|||
//
|
||||
// map = new SearchParameterMap();
|
||||
// map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), empty());
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map))).isEmpty();
|
||||
//
|
||||
// map = new SearchParameterMap();
|
||||
// map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
|
||||
|
|
|
@ -1972,7 +1972,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
// ourLog.info(output);
|
||||
// List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(pId, cId));
|
||||
// assertThat(ids).contains(pId, cId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
@ -1986,7 +1986,7 @@ public class ResourceProviderDstu3Test extends BaseResourceProviderDstu3Test {
|
|||
// ourLog.info(output);
|
||||
// List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(cId, pId, oId));
|
||||
// assertThat(ids).contains(cId, pId, oId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
|
|
@ -29,7 +29,6 @@ import ca.uhn.fhir.rest.api.server.RequestDetails;
|
|||
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
|
||||
import ca.uhn.fhir.test.utilities.ITestDataBuilder;
|
||||
import ca.uhn.fhir.util.BundleBuilder;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
|
|
|
@ -49,7 +49,6 @@ import ca.uhn.fhir.test.utilities.server.HashMapResourceProviderExtension;
|
|||
import ca.uhn.fhir.test.utilities.server.RestfulServerExtension;
|
||||
import ca.uhn.fhir.util.BundleBuilder;
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
|
|
|
@ -31,8 +31,6 @@ import java.util.List;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hl7.fhir.r4.model.Observation.SP_VALUE_QUANTITY;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
|
@ -80,7 +78,7 @@ public class FhirResourceDaoR4SearchFtTest extends BaseJpaR4Test {
|
|||
//
|
||||
// map = new SearchParameterMap();
|
||||
// map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map)), empty());
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(map))).isEmpty();
|
||||
//
|
||||
// map = new SearchParameterMap();
|
||||
// map.add(Observation.SP_CODE, new TokenParam(null, "blood").setModifier(TokenParamModifier.TEXT));
|
||||
|
@ -148,7 +146,7 @@ public class FhirResourceDaoR4SearchFtTest extends BaseJpaR4Test {
|
|||
// contains doesn't work
|
||||
// map = new SearchParameterMap();
|
||||
// map.add(Observation.SP_VALUE_STRING, new StringParam("sure").setContains(true));
|
||||
// assertThat("contains matches internal fragment", toUnqualifiedVersionlessIdValues(myObservationDao.search(map)), containsInAnyOrder(toValues(id1, id2)));
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myObservationDao.search(map))).as("contains matches internal fragment").containsExactlyInAnyOrder(toValues(id1, id2));
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1180,7 +1180,7 @@ public class FhirResourceDaoR4SearchNoFtTest extends BaseJpaR4Test {
|
|||
// params = new SearchParameterMap();
|
||||
// params.setLoadSynchronous(true);
|
||||
// params.add("_has", new HasParam("Observation", "subject", "device.identifier", "urn:system|DEVICEID"));
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params)), contains(pid0.getValue()));
|
||||
// assertThat(toUnqualifiedVersionlessIdValues(myPatientDao.search(params))).contains(pid0.getValue());
|
||||
|
||||
// No targets exist
|
||||
params = new SearchParameterMap();
|
||||
|
|
|
@ -71,7 +71,6 @@ import static org.apache.commons.lang3.StringUtils.leftPad;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
|
|
@ -9,7 +9,6 @@ import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
|||
import ca.uhn.fhir.rest.param.StringParam;
|
||||
import ca.uhn.fhir.rest.param.TokenParam;
|
||||
import ca.uhn.fhir.rest.param.UriParam;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.SearchParameter;
|
||||
|
|
|
@ -4,7 +4,6 @@ import static org.junit.jupiter.api.Assertions.assertEquals;
|
|||
import ca.uhn.fhir.jpa.model.util.JpaConstants;
|
||||
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -7,7 +7,6 @@ import ca.uhn.fhir.jpa.entity.TermValueSet;
|
|||
import ca.uhn.fhir.jpa.model.entity.ResourceTable;
|
||||
import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
||||
import ca.uhn.fhir.jpa.util.ValueSetTestUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.r4.model.CodeSystem;
|
||||
import org.hl7.fhir.r4.model.ValueSet;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -62,7 +62,7 @@ public class FhirResourceDaoSearchListTest extends BaseJpaR4Test {
|
|||
for(IIdType patientId: theExpectedPatientIds) {
|
||||
assertThat(ids).contains(patientId);
|
||||
|
||||
//assertThat(patientId, contains(ids));
|
||||
//assertThat(patientId).contains(ids);
|
||||
}
|
||||
// assert ids equal pid1 and pid2
|
||||
}
|
||||
|
|
|
@ -40,7 +40,6 @@ import ca.uhn.fhir.rest.server.interceptor.auth.RuleBuilder;
|
|||
import ca.uhn.fhir.util.BundleBuilder;
|
||||
import ca.uhn.fhir.util.ClasspathUtil;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.AllergyIntolerance;
|
||||
|
@ -4777,8 +4776,8 @@ public class FhirSystemDaoR4Test extends BaseJpaR4SystemTest {
|
|||
// assertTrue(o1.getId().getValue(), o1.getId().getIdPart().matches("^[0-9]+$"));
|
||||
// assertTrue(o2.getId().getValue(), o2.getId().getIdPart().matches("^[0-9]+$"));
|
||||
//
|
||||
// assertThat(o1.getSubject().getReference().getValue(), endsWith("Patient/" + p1.getId().getIdPart()));
|
||||
// assertThat(o2.getSubject().getReference().getValue(), endsWith("Patient/" + p1.getId().getIdPart()));
|
||||
// assertThat(o1.getSubject().getReference().getValue()).endsWith("Patient/" + p1.getId().getIdPart());
|
||||
// assertThat(o2.getSubject().getReference().getValue()).endsWith("Patient/" + p1.getId().getIdPart());
|
||||
//
|
||||
// }
|
||||
//
|
||||
|
|
|
@ -49,7 +49,6 @@ import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
|||
import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException;
|
||||
import ca.uhn.fhir.util.BundleBuilder;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IAnyResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
|
|
@ -28,7 +28,6 @@ import ca.uhn.fhir.util.HapiExtensions;
|
|||
import com.google.common.collect.Sets;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
|
|
|
@ -14,7 +14,6 @@ import ca.uhn.fhir.rest.server.interceptor.ResponseTerminologyTranslationInterce
|
|||
import ca.uhn.fhir.util.Batch2JobDefinitionConstants;
|
||||
import ca.uhn.fhir.util.JsonUtil;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Binary;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
|
|
|
@ -8,7 +8,6 @@ import ca.uhn.fhir.jpa.test.BaseJpaR4Test;
|
|||
import ca.uhn.fhir.test.utilities.ProxyUtil;
|
||||
import ca.uhn.fhir.util.ClasspathUtil;
|
||||
import ca.uhn.fhir.util.JsonUtil;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.slf4j.Logger;
|
||||
|
|
|
@ -27,11 +27,11 @@ import java.util.concurrent.ExecutorService;
|
|||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Predicate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
@SuppressWarnings("Duplicates")
|
||||
|
@ -155,22 +155,20 @@ public class ResourceProviderConcurrencyR4Test extends BaseResourceProviderR4Tes
|
|||
}
|
||||
|
||||
ourLog.info("About to wait for FAMILY3 to complete");
|
||||
await().until(() -> {
|
||||
ourLog.info("Received names: {}", myReceivedNames);
|
||||
return myReceivedNames;
|
||||
}, contains("FAMILY3"));
|
||||
await().untilAsserted(() -> assertThat(myReceivedNames).contains("FAMILY3"));
|
||||
ourLog.info("Got FAMILY3");
|
||||
|
||||
searchBlockingInterceptorFamily1.getLatch().countDown();
|
||||
|
||||
ourLog.info("About to wait for FAMILY1 to complete");
|
||||
await().until(() -> myReceivedNames, contains("FAMILY3", "FAMILY1", "FAMILY1"));
|
||||
await().untilAsserted(() -> assertThat(myReceivedNames).containsOnly("FAMILY3", "FAMILY1","FAMILY1"));
|
||||
ourLog.info("Got FAMILY1");
|
||||
|
||||
assertEquals(1, searchBlockingInterceptorFamily1.getHits());
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Interceptor
|
||||
public static class SearchBlockingInterceptor {
|
||||
|
||||
|
|
|
@ -60,7 +60,6 @@ import static org.apache.commons.lang3.time.DateUtils.MILLIS_PER_SECOND;
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
|
@ -249,7 +248,7 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|||
await()
|
||||
.atMost(60, TimeUnit.SECONDS)
|
||||
.pollInterval(1, TimeUnit.SECONDS)
|
||||
.until(()->{
|
||||
.untilAsserted(()-> {
|
||||
Bundle observations = myClient
|
||||
.search()
|
||||
.forResource("Observation")
|
||||
|
@ -258,9 +257,8 @@ public class ResourceProviderInterceptorR4Test extends BaseResourceProviderR4Tes
|
|||
.cacheControl(CacheControlDirective.noCache())
|
||||
.execute();
|
||||
ourLog.info("Have {} observations", observations.getEntry().size());
|
||||
return observations.getEntry().size();
|
||||
},
|
||||
equalTo(1));
|
||||
assertThat(observations.getEntry()).hasSize(1);
|
||||
});
|
||||
|
||||
} finally {
|
||||
myServer.getRestfulServer().unregisterInterceptor(interceptor);
|
||||
|
|
|
@ -10,7 +10,6 @@ import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test;
|
|||
import ca.uhn.fhir.model.api.StorageResponseCodeEnum;
|
||||
import ca.uhn.fhir.rest.api.PreferReturnEnum;
|
||||
import ca.uhn.fhir.util.BundleBuilder;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hl7.fhir.r4.model.BooleanType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.CodeType;
|
||||
|
@ -248,8 +247,7 @@ public class ResourceProviderMeaningfulOutcomeMessageR4Test extends BaseResource
|
|||
.execute();
|
||||
ourLog.debug("Create {}", myFhirContext.newJsonParser().setPrettyPrint(true).encodeResourceToString(output));
|
||||
OperationOutcome oo = (OperationOutcome) output.getEntry().get(0).getResponse().getOutcome();
|
||||
// TODO CHECKSTYLE KHS restore this
|
||||
// assertThat(oo.getIssueFirstRep().getDiagnostics()).matches("Successfully conditionally created resource \".*\". No existing resources matched URL \"Patient\\?active=true\". Took [0-9]+ms.");
|
||||
assertThat(oo.getIssueFirstRep().getDiagnostics()).matches("Successfully conditionally created resource \".*\". No existing resources matched URL \"Patient\\?active=true\". Took [0-9]+ms.");
|
||||
assertEquals(StorageResponseCodeEnum.SUCCESSFUL_CREATE_NO_CONDITIONAL_MATCH.name(), oo.getIssueFirstRep().getDetails().getCodingFirstRep().getCode());
|
||||
assertEquals(StorageResponseCodeEnum.SYSTEM, oo.getIssueFirstRep().getDetails().getCodingFirstRep().getSystem());
|
||||
|
||||
|
|
|
@ -3,8 +3,6 @@ package ca.uhn.fhir.jpa.provider.r4;
|
|||
import ca.uhn.fhir.jpa.api.dao.DaoRegistry;
|
||||
import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test;
|
||||
import ca.uhn.fhir.rest.server.exceptions.ResourceNotFoundException;
|
||||
import org.hamcrest.CoreMatchers;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.hl7.fhir.r4.model.Practitioner;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -797,7 +797,7 @@ public class ResourceProviderR4EverythingTest extends BaseResourceProviderR4Test
|
|||
// ourLog.info(output);
|
||||
// List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(pId, cId));
|
||||
// assertThat(ids).contains(pId, cId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
@ -811,7 +811,7 @@ public class ResourceProviderR4EverythingTest extends BaseResourceProviderR4Test
|
|||
// ourLog.info(output);
|
||||
// List<IIdType> ids = toUnqualifiedVersionlessIds(myFhirCtx.newXmlParser().parseResource(Bundle.class, output));
|
||||
// ourLog.info(ids.toString());
|
||||
// assertThat(ids, contains(cId, pId, oId));
|
||||
// assertThat(ids).contains(cId, pId, oId);
|
||||
// } finally {
|
||||
// response.close();
|
||||
// }
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.provider.r4;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ca.uhn.fhir.jpa.provider.BaseResourceProviderR4Test;
|
||||
import ca.uhn.fhir.jpa.searchparam.SearchParameterMap;
|
||||
import ca.uhn.fhir.rest.api.server.IBundleProvider;
|
||||
|
@ -7,7 +8,6 @@ import ca.uhn.fhir.rest.api.server.SystemRequestDetails;
|
|||
import ca.uhn.fhir.rest.client.api.IGenericClient;
|
||||
import ca.uhn.fhir.rest.param.HasParam;
|
||||
import ca.uhn.fhir.rest.server.exceptions.InvalidRequestException;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.CarePlan;
|
||||
|
@ -35,7 +35,6 @@ import org.junit.jupiter.params.provider.ValueSource;
|
|||
|
||||
import java.util.List;
|
||||
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertThrows;
|
||||
|
||||
|
@ -442,7 +441,7 @@ public class ResourceProviderR4SearchVariousScenariosTest extends BaseResourcePr
|
|||
.map(Resource::getIdPart)
|
||||
.toList();
|
||||
|
||||
MatcherAssert.assertThat(theReason, actualIdsInOrder, contains(theExpectedIdsInOrder));
|
||||
assertThat(actualIdsInOrder).as(theReason).contains(theExpectedIdsInOrder);
|
||||
}
|
||||
|
||||
private void runAndAssert(String theQueryString) {
|
||||
|
|
|
@ -9,7 +9,6 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
import ca.uhn.fhir.rest.server.interceptor.ResponseHighlighterInterceptor;
|
||||
import ca.uhn.fhir.util.ClasspathUtil;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.CapabilityStatement;
|
||||
import org.hl7.fhir.r4.model.Enumerations;
|
||||
|
|
|
@ -49,7 +49,6 @@ import ca.uhn.fhir.util.MetaTagSorterAlphabetical;
|
|||
import ca.uhn.fhir.util.StopWatch;
|
||||
import ca.uhn.fhir.validation.IInstanceValidatorModule;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hibernate.internal.SessionImpl;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
|
|
@ -24,7 +24,6 @@ import com.google.common.collect.Sets;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
|
|
@ -40,7 +40,6 @@ import static ca.uhn.fhir.batch2.jobs.termcodesystem.TermCodeSystemJobConfig.TER
|
|||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.equalTo;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
|
|
@ -12,7 +12,6 @@ import com.google.common.base.Charsets;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r4b.model.Bundle;
|
||||
import org.hl7.fhir.r4b.model.Bundle.BundleEntryComponent;
|
||||
|
|
|
@ -17,7 +17,6 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.hl7.fhir.r5.model.Bundle;
|
||||
import org.hl7.fhir.r5.model.Bundle.BundleEntryComponent;
|
||||
|
|
|
@ -33,8 +33,6 @@ import ca.uhn.fhir.rest.server.IRestfulServerDefaults;
|
|||
import ca.uhn.fhir.rest.server.method.SortParameter;
|
||||
import ca.uhn.fhir.rest.server.util.ISearchParamRegistry;
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
@ -48,11 +46,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.apache.commons.lang3.ArrayUtils.EMPTY_STRING_ARRAY;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.hamcrest.Matchers.containsInAnyOrder;
|
||||
import static org.hamcrest.Matchers.everyItem;
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
import static org.hamcrest.Matchers.in;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.mockito.Mockito.doReturn;
|
||||
import static org.mockito.Mockito.mock;
|
||||
import static org.mockito.Mockito.spy;
|
||||
|
@ -105,7 +98,7 @@ public class TestDaoSearch {
|
|||
* @param theIds the resource ids to expect.
|
||||
*/
|
||||
public void assertSearchFinds(String theReason, String theQueryUrl, String... theIds) {
|
||||
assertSearchResultIds(theQueryUrl, theReason, hasItems(theIds));
|
||||
assertSearchResultIds(theQueryUrl, theReason, theIds);
|
||||
}
|
||||
|
||||
public void assertSearchFinds(String theReason, String theQueryUrl, List<String> theIds) {
|
||||
|
@ -121,7 +114,7 @@ public class TestDaoSearch {
|
|||
public void assertSearchFinds(String theReason, String theQueryUrl, IIdType... theIds) {
|
||||
String[] bareIds = idTypeToIdParts(theIds);
|
||||
|
||||
assertSearchResultIds(theQueryUrl, theReason, hasItems(bareIds));
|
||||
assertSearchResultIds(theQueryUrl, theReason, bareIds);
|
||||
}
|
||||
|
||||
public void assertSearchFindsInOrder(String theReason, String theQueryUrl, String... theIds) {
|
||||
|
@ -135,20 +128,17 @@ public class TestDaoSearch {
|
|||
}
|
||||
|
||||
public void assertSearchFindsOnly(String theReason, String theQueryUrl, String... theIds) {
|
||||
assertSearchIdsMatch(theReason, theQueryUrl, containsInAnyOrder(theIds));
|
||||
assertSearchIdsMatch(theReason, theQueryUrl, theIds);
|
||||
}
|
||||
|
||||
public void assertSearchIdsMatch(
|
||||
String theReason, String theQueryUrl, Matcher<? super Iterable<String>> theMatchers) {
|
||||
public void assertSearchIdsMatch(String theReason, String theQueryUrl, String... theIds) {
|
||||
List<String> ids = searchForIds(theQueryUrl);
|
||||
|
||||
MatcherAssert.assertThat(theReason, ids, theMatchers);
|
||||
assertThat(ids).as(theReason).containsExactlyInAnyOrder(theIds);
|
||||
}
|
||||
|
||||
public void assertSearchResultIds(String theQueryUrl, String theReason, Matcher<Iterable<String>> matcher) {
|
||||
public void assertSearchResultIds(String theQueryUrl, String theReason, String... theExpectedIds) {
|
||||
List<String> ids = searchForIds(theQueryUrl);
|
||||
|
||||
MatcherAssert.assertThat(theReason, ids, matcher);
|
||||
assertThat(ids).as(theReason).contains(theExpectedIds);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -159,8 +149,7 @@ public class TestDaoSearch {
|
|||
*/
|
||||
public void assertSearchNotFound(String theReason, String theQueryUrl, IIdType... theIds) {
|
||||
List<String> ids = searchForIds(theQueryUrl);
|
||||
|
||||
MatcherAssert.assertThat(theReason, ids, everyItem(not(in(idTypeToIdParts(theIds)))));
|
||||
assertThat(ids).as(theReason).doesNotContain(idTypeToIdParts(theIds));
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -31,8 +31,6 @@ import java.util.concurrent.atomic.AtomicInteger;
|
|||
import static ca.uhn.fhir.util.TestUtil.sleepAtLeast;
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.greaterThan;
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.jupiter.api.Assertions.fail;
|
||||
|
||||
@ContextConfiguration(classes = SchedulerServiceImplTest.TestConfiguration.class)
|
||||
|
@ -59,8 +57,7 @@ public class SchedulerServiceImplTest {
|
|||
|
||||
StopWatch sw = new StopWatch();
|
||||
mySvc.scheduleLocalJob(100, def);
|
||||
|
||||
await().until(CountingJob.ourCount::get, greaterThan(5));
|
||||
await().until(CountingJob.ourCount::get, count -> count > 5);
|
||||
|
||||
ourLog.info("Fired {} times in {}", CountingJob.ourCount, sw);
|
||||
assertThat(sw.getMillis()).isGreaterThan(500L);
|
||||
|
@ -77,8 +74,7 @@ public class SchedulerServiceImplTest {
|
|||
for (int i = 0; i < 20; ++i) {
|
||||
mySvc.triggerLocalJobImmediately(def);
|
||||
}
|
||||
|
||||
await().until(CountingJob.ourCount::get, greaterThan(25));
|
||||
await().until(CountingJob.ourCount::get, count -> count > 25);
|
||||
|
||||
ourLog.info("Fired {} times in {}", CountingJob.ourCount, sw);
|
||||
assertThat(sw.getMillis()).isGreaterThan(500L);
|
||||
|
@ -106,7 +102,7 @@ public class SchedulerServiceImplTest {
|
|||
StopWatch sw = new StopWatch();
|
||||
mySvc.scheduleLocalJob(100, def);
|
||||
|
||||
await().until(CountingJob.ourCount::get, greaterThan(5));
|
||||
await().until(CountingJob.ourCount::get, count -> count > 5);
|
||||
|
||||
ourLog.info("Fired {} times in {}", CountingJob.ourCount, sw);
|
||||
assertThat(sw.getMillis()).isGreaterThan(0L);
|
||||
|
@ -121,7 +117,7 @@ public class SchedulerServiceImplTest {
|
|||
StopWatch sw = new StopWatch();
|
||||
mySvc.scheduleLocalJob(100, def);
|
||||
|
||||
await().until(CountingJob.ourCount::get, greaterThan(5));
|
||||
await().until(CountingJob.ourCount::get, count -> count > 5);
|
||||
|
||||
ourLog.info("Fired {} times in {}", CountingJob.ourCount, sw);
|
||||
assertThat(sw.getMillis()).isGreaterThan(3000L);
|
||||
|
@ -138,7 +134,7 @@ public class SchedulerServiceImplTest {
|
|||
mySvc.triggerLocalJobImmediately(def);
|
||||
mySvc.triggerLocalJobImmediately(def);
|
||||
|
||||
await().until(CountingJob.ourCount::get, greaterThan(5));
|
||||
await().until(CountingJob.ourCount::get, count -> count > 5);
|
||||
|
||||
ourLog.info("Fired {} times in {}", CountingJob.ourCount, sw);
|
||||
assertThat(sw.getMillis()).isGreaterThan(3000L);
|
||||
|
@ -160,7 +156,7 @@ public class SchedulerServiceImplTest {
|
|||
|
||||
ourLog.info("Fired {} times", CountingIntervalJob.ourCount);
|
||||
|
||||
await().until(() -> CountingIntervalJob.ourCount, greaterThanOrEqualTo(2));
|
||||
await().until(() -> CountingIntervalJob.ourCount, count -> count >= 2);
|
||||
assertThat(CountingIntervalJob.ourCount).isLessThan(6);
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.jpa.search.builder.predicate;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.context.RuntimeSearchParam;
|
||||
import ca.uhn.fhir.interceptor.model.RequestPartitionId;
|
||||
|
@ -16,8 +17,6 @@ import com.healthmarketscience.sqlbuilder.InCondition;
|
|||
import com.healthmarketscience.sqlbuilder.dbspec.basic.DbSchema;
|
||||
import com.healthmarketscience.sqlbuilder.dbspec.basic.DbSpec;
|
||||
import com.healthmarketscience.sqlbuilder.dbspec.basic.DbTable;
|
||||
import org.hamcrest.MatcherAssert;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
@ -114,7 +113,7 @@ public class ResourceLinkPredicateBuilderTest {
|
|||
when(mockSearchParam.getPathsSplit()).thenReturn(List.of("Patient.given", "Bundle.composition.subject", "Bundle.type"));
|
||||
when(mySearchParamRegistry.getActiveSearchParam(resourceType, paramName)).thenReturn(mockSearchParam);
|
||||
List<String> result = myResourceLinkPredicateBuilder.createResourceLinkPaths(resourceType, paramName, List.of());
|
||||
MatcherAssert.assertThat(result, Matchers.containsInAnyOrder("Bundle.composition.subject", "Bundle.type"));
|
||||
assertThat(result).containsExactlyInAnyOrder("Bundle.composition.subject", "Bundle.type");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -122,7 +121,7 @@ public class ResourceLinkPredicateBuilderTest {
|
|||
String paramName = "param.name";
|
||||
String resourceType = "Bundle";
|
||||
List<String> result = myResourceLinkPredicateBuilder.createResourceLinkPaths(resourceType, paramName, List.of());
|
||||
MatcherAssert.assertThat(result, Matchers.empty());
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -138,7 +137,7 @@ public class ResourceLinkPredicateBuilderTest {
|
|||
when(patientIdentifierSP.getPathsSplit()).thenReturn(List.of("Patient.identifier"));
|
||||
when(mySearchParamRegistry.getActiveSearchParam("Patient", "identifier")).thenReturn(patientIdentifierSP);
|
||||
List<String> result = myResourceLinkPredicateBuilder.createResourceLinkPaths(resourceType, paramName, List.of());
|
||||
MatcherAssert.assertThat(result, Matchers.containsInAnyOrder("Observation.subject.identifier"));
|
||||
assertThat(result).containsExactlyInAnyOrder("Observation.subject.identifier");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -165,7 +164,7 @@ public class ResourceLinkPredicateBuilderTest {
|
|||
when(mySearchParamRegistry.getActiveSearchParam("Organization", "identifier")).thenReturn(organizationIdentifierSP);
|
||||
|
||||
List<String> result = myResourceLinkPredicateBuilder.createResourceLinkPaths(resourceType, paramName, List.of("Patient", "Organization"));
|
||||
MatcherAssert.assertThat(result, Matchers.containsInAnyOrder("Observation.subject.managingOrganization.identifier"));
|
||||
assertThat(result).containsExactlyInAnyOrder("Observation.subject.managingOrganization.identifier");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -178,6 +177,6 @@ public class ResourceLinkPredicateBuilderTest {
|
|||
when(observationSubjectSP.getTargets()).thenReturn(Set.of("Patient"));
|
||||
when(mySearchParamRegistry.getActiveSearchParam("Observation", "subject")).thenReturn(observationSubjectSP);
|
||||
List<String> result = myResourceLinkPredicateBuilder.createResourceLinkPaths(resourceType, paramName, List.of("Group"));
|
||||
MatcherAssert.assertThat(result, Matchers.empty());
|
||||
assertThat(result).isEmpty();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -18,8 +18,6 @@ import net.sf.json.JSON;
|
|||
import net.sf.json.JSONSerializer;
|
||||
import net.sf.json.JsonConfig;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.dstu2016may.model.Address.AddressUse;
|
||||
import org.hl7.fhir.dstu2016may.model.Address.AddressUseEnumFactory;
|
||||
import org.hl7.fhir.dstu2016may.model.AuditEvent;
|
||||
|
|
|
@ -8,7 +8,6 @@ import ca.uhn.fhir.rest.annotation.Operation;
|
|||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.dstu2016may.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
|
|
@ -20,7 +20,6 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
|
|||
import ca.uhn.fhir.model.primitive.StringDt;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
|
@ -58,7 +58,6 @@ import net.sf.json.JSON;
|
|||
import net.sf.json.JSONSerializer;
|
||||
import net.sf.json.JsonConfig;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -19,7 +19,6 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
|
@ -46,7 +46,6 @@ import java.util.Set;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
|
@ -92,7 +91,15 @@ public class InterceptorUserDataMapDstu2Test {
|
|||
assertEquals(400, status.getStatusLine().getStatusCode());
|
||||
}
|
||||
|
||||
await().until(() -> myMapCheckMethods, contains("incomingRequestPostProcessed", "incomingRequestPreHandled", "preProcessOutgoingException", "handleException", "processingCompleted"));
|
||||
await().untilAsserted(() ->
|
||||
assertThat(myMapCheckMethods).containsExactly(
|
||||
"incomingRequestPostProcessed",
|
||||
"incomingRequestPreHandled",
|
||||
"preProcessOutgoingException",
|
||||
"handleException",
|
||||
"processingCompleted"
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -104,7 +111,7 @@ public class InterceptorUserDataMapDstu2Test {
|
|||
|
||||
String response = IOUtils.toString(status.getEntity().getContent(), StandardCharsets.UTF_8);
|
||||
assertThat(response).contains("\"id\":\"1\"");
|
||||
await().until(() -> myMapCheckMethods, contains("incomingRequestPostProcessed", "incomingRequestPreHandled", "outgoingResponse", "processingCompletedNormally", "processingCompleted"));
|
||||
await().untilAsserted(() -> assertThat(myMapCheckMethods).contains("incomingRequestPostProcessed", "incomingRequestPreHandled", "outgoingResponse", "processingCompletedNormally", "processingCompleted"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -33,7 +33,6 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -8,7 +8,6 @@ import ca.uhn.fhir.rest.annotation.Operation;
|
|||
import ca.uhn.fhir.rest.annotation.OperationParam;
|
||||
import ca.uhn.fhir.rest.annotation.Read;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.dstu3.model.Patient;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package ca.uhn.fhir.util;
|
||||
|
||||
import ca.uhn.fhir.context.FhirContext;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.dstu3.model.Parameters;
|
||||
import org.hl7.fhir.dstu3.model.StringType;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
|
|
@ -11,7 +11,6 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
import ca.uhn.fhir.util.TestUtil;
|
||||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import org.apache.commons.lang3.time.FastDateFormat;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.junit.jupiter.api.AfterAll;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
|
@ -12,9 +12,6 @@ import ca.uhn.fhir.rest.api.Constants;
|
|||
import net.sf.json.JSON;
|
||||
import net.sf.json.JSONSerializer;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.core.IsNot;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu2.model.Address;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUse;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory;
|
||||
|
|
|
@ -15,7 +15,6 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.dstu2.model.Patient;
|
||||
import org.junit.jupiter.api.BeforeAll;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
|
|
|
@ -3,7 +3,6 @@ package ca.uhn.fhir.narrative;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import ca.uhn.fhir.util.TestUtil;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.r4.model.CodeableConcept;
|
||||
import org.hl7.fhir.r4.model.Coding;
|
||||
import org.hl7.fhir.r4.model.DateTimeType;
|
||||
|
|
|
@ -57,8 +57,6 @@ import org.apache.http.client.methods.HttpPut;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.core.StringEndsWith;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
|
|
|
@ -16,7 +16,6 @@ import org.apache.http.client.HttpClient;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
|
|
|
@ -48,7 +48,6 @@ import org.apache.http.client.methods.HttpPut;
|
|||
import org.apache.http.client.methods.HttpUriRequest;
|
||||
import org.apache.http.message.BasicHeader;
|
||||
import org.apache.http.message.BasicStatusLine;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.instance.model.api.IBaseBundle;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.instance.model.api.IPrimitiveType;
|
||||
|
|
|
@ -34,7 +34,6 @@ import java.util.concurrent.TimeUnit;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.notNullValue;
|
||||
|
||||
public class BlockingContentR4Test {
|
||||
|
||||
|
@ -94,7 +93,7 @@ public class BlockingContentR4Test {
|
|||
try (CloseableHttpResponse resp = client.execute(post)) {
|
||||
ourLog.info(Arrays.asList(resp.getAllHeaders()).toString().replace(", ", "\n"));
|
||||
ourLog.info(resp.toString());
|
||||
await().until(()->myServerException, notNullValue());
|
||||
await().until(()->myServerException != null);
|
||||
}
|
||||
|
||||
assertThat(myServerException.toString()).contains("Idle timeout expired");
|
||||
|
|
|
@ -19,7 +19,6 @@ import java.util.stream.Collectors;
|
|||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import static org.awaitility.Awaitility.await;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
|
||||
public class CapabilityStatementCacheR4Test {
|
||||
|
@ -47,7 +46,9 @@ public class CapabilityStatementCacheR4Test {
|
|||
// Shut down the server
|
||||
myServerExtension.stopServer();
|
||||
|
||||
await().until(() -> Thread.getAllStackTraces().keySet().stream().map(t -> t.getName()).filter(t -> t.startsWith(ConformanceMethodBinding.CACHE_THREAD_PREFIX)).sorted().collect(Collectors.toList()), empty());
|
||||
await().until(() -> Thread.getAllStackTraces().keySet().stream()
|
||||
.map(Thread::getName)
|
||||
.noneMatch(t -> t.startsWith(ConformanceMethodBinding.CACHE_THREAD_PREFIX)));
|
||||
}
|
||||
|
||||
private static class MyCapabilityStatementProvider extends ServerCapabilityStatementProvider {
|
||||
|
|
|
@ -18,8 +18,6 @@ import org.apache.commons.io.IOUtils;
|
|||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.core.IsEqual;
|
||||
import org.hamcrest.core.StringStartsWith;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.HumanName;
|
||||
|
|
|
@ -75,7 +75,7 @@ public class PreferTest {
|
|||
|
||||
assertEquals(Constants.STATUS_HTTP_201_CREATED, status.getStatusLine().getStatusCode());
|
||||
assertThat(responseContent).isNullOrEmpty();
|
||||
// assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue(), not(containsString("fhir")));
|
||||
// assertThat(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE).getValue()).doesNotContain("fhir");
|
||||
assertNull(status.getFirstHeader(Constants.HEADER_CONTENT_TYPE));
|
||||
assertEquals(ourServer.getBaseUrl() + "/Patient/001/_history/002", status.getFirstHeader("location").getValue());
|
||||
assertEquals(ourServer.getBaseUrl() + "/Patient/001/_history/002", status.getFirstHeader("content-location").getValue());
|
||||
|
|
|
@ -19,7 +19,6 @@ import ca.uhn.fhir.test.utilities.server.MockServletUtil;
|
|||
import com.google.common.collect.Lists;
|
||||
import jakarta.servlet.ServletException;
|
||||
import jakarta.servlet.http.HttpServletRequest;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.instance.model.api.IBaseResource;
|
||||
import org.hl7.fhir.r4.model.DateType;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
|
|
|
@ -21,7 +21,6 @@ import com.google.common.base.Charsets;
|
|||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.http.HttpResponse;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.r4.model.IdType;
|
||||
import org.hl7.fhir.r4.model.OperationOutcome;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
|
|
|
@ -50,6 +50,7 @@
|
|||
<version>${fhir_core_version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- Logging -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
|
|
|
@ -1,157 +0,0 @@
|
|||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR Test Utilities
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.test.util;
|
||||
|
||||
import ca.uhn.fhir.model.api.IModelJson;
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.hamcrest.Description;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.TypeSafeMatcher;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.beans.BeanInfo;
|
||||
import java.beans.FeatureDescriptor;
|
||||
import java.beans.IntrospectionException;
|
||||
import java.beans.Introspector;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.hamcrest.Matchers.hasItems;
|
||||
|
||||
@Deprecated
|
||||
/**
|
||||
* @deprecated convert usages to HasGetterOrSetterForAllJsonFieldsAssert
|
||||
*/
|
||||
public class HasGetterOrSetterForAllJsonFields extends TypeSafeMatcher<Class<? extends IModelJson>> {
|
||||
private static final Logger ourLog = LoggerFactory.getLogger(HasGetterOrSetterForAllJsonFields.class);
|
||||
|
||||
@Override
|
||||
public void describeTo(Description description) {
|
||||
description.appendText("All @JsonProperty annotated fields have getters and setters.");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(Class<? extends IModelJson> item) {
|
||||
List<String> jsonPropertyFields = getJsonPropertyFields(item);
|
||||
Matcher<Iterable<Object>> matcher = hasItems(jsonPropertyFields.toArray());
|
||||
List<String> properties = getProperties(item);
|
||||
ourLog.info("{}: testing {} @JsonProperty fields", item.getSimpleName(), jsonPropertyFields.size());
|
||||
return matcher.matches(properties);
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private List<String> getJsonPropertyFields(Class<? extends IModelJson> item) {
|
||||
List<Field> fields = new ArrayList<>();
|
||||
|
||||
populateFields(fields, item);
|
||||
|
||||
return fields.stream()
|
||||
.filter(this::isJsonProperty)
|
||||
.filter(this::isNotCollection)
|
||||
.filter(this::isNotMap)
|
||||
.map(Field::getName)
|
||||
.map(this::stripPrefix)
|
||||
.map(this::stripUnderscoreSuffix)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private boolean isNotCollection(Field theField) {
|
||||
return !Collection.class.isAssignableFrom(theField.getType());
|
||||
}
|
||||
|
||||
private boolean isNotMap(Field theField) {
|
||||
return !Map.class.isAssignableFrom(theField.getType());
|
||||
}
|
||||
|
||||
private boolean isJsonProperty(Field theField) {
|
||||
if (!theField.isAnnotationPresent(JsonProperty.class)) {
|
||||
return false;
|
||||
}
|
||||
Schema apiModelProperty = theField.getAnnotation(Schema.class);
|
||||
if (apiModelProperty != null && apiModelProperty.accessMode() == Schema.AccessMode.READ_ONLY) {
|
||||
return false;
|
||||
}
|
||||
return apiModelProperty == null || !apiModelProperty.hidden();
|
||||
}
|
||||
|
||||
private String stripPrefix(String theFieldName) {
|
||||
if (theFieldName.startsWith("my")) {
|
||||
return theFieldName.substring(2, 3).toLowerCase() + theFieldName.substring(3);
|
||||
}
|
||||
return theFieldName;
|
||||
}
|
||||
|
||||
private String stripUnderscoreSuffix(String theFieldName) {
|
||||
if (theFieldName.endsWith("_")) {
|
||||
return theFieldName.substring(0, theFieldName.length() - 1);
|
||||
}
|
||||
return theFieldName;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void describeMismatchSafely(Class<? extends IModelJson> item, Description mismatchDescription) {
|
||||
mismatchDescription.appendText(" for class ").appendText(item.getName()).appendText(", ");
|
||||
List<String> jsonFields = getJsonPropertyFields(item);
|
||||
Matcher<Iterable<Object>> matcher = hasItems(jsonFields.toArray());
|
||||
List<String> properties = getProperties(item);
|
||||
matcher.describeMismatch(properties, mismatchDescription);
|
||||
mismatchDescription.appendText("\n All non-collection @JsonProperty fields: " + String.join(", ", jsonFields));
|
||||
mismatchDescription.appendText("\n Have get/set methods for: " + String.join(", ", properties));
|
||||
}
|
||||
|
||||
private List<String> getProperties(Class<? extends IModelJson> item) {
|
||||
try {
|
||||
BeanInfo beanInfo = Introspector.getBeanInfo(item);
|
||||
return Arrays.stream(beanInfo.getPropertyDescriptors())
|
||||
.map(FeatureDescriptor::getName)
|
||||
.filter(name -> !"class".equals(name))
|
||||
.map(this::lowerCaseFirstLetter)
|
||||
.sorted()
|
||||
.collect(Collectors.toList());
|
||||
} catch (IntrospectionException e) {
|
||||
throw new AssertionError("Unable to introspect " + item.getName(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private String lowerCaseFirstLetter(String thePropertyName) {
|
||||
return thePropertyName.substring(0, 1).toLowerCase() + thePropertyName.substring(1);
|
||||
}
|
||||
|
||||
private static void populateFields(List<Field> theFields, Class<?> theItem) {
|
||||
theFields.addAll(Arrays.asList(theItem.getDeclaredFields()));
|
||||
|
||||
if (theItem.getSuperclass() != null) {
|
||||
populateFields(theFields, theItem.getSuperclass());
|
||||
}
|
||||
}
|
||||
|
||||
public static HasGetterOrSetterForAllJsonFields hasGetterOrSetterForAllJsonFields() {
|
||||
return new HasGetterOrSetterForAllJsonFields();
|
||||
}
|
||||
}
|
|
@ -27,7 +27,4 @@ public class LogEventAssert extends AbstractAssert<LogEventAssert, ILoggingEvent
|
|||
protected LogEventAssert(ILoggingEvent actual) {
|
||||
super(actual, LogEventAssert.class);
|
||||
}
|
||||
|
||||
// Example of a custom assertion for a single LogEvent
|
||||
// You can add methods for specific assertions here
|
||||
}
|
||||
|
|
|
@ -1,197 +0,0 @@
|
|||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR Test Utilities
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.test.util;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.Logger;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.junit.jupiter.api.extension.AfterEachCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeEachCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* Test helper to collect logback lines.
|
||||
* The empty constructor will capture all log events, or you can name a log root to limit the noise.
|
||||
* @deprecated use {@link LogbackTestExtension}
|
||||
*/
|
||||
@Deprecated
|
||||
public class LogbackCaptureTestExtension implements BeforeEachCallback, AfterEachCallback {
|
||||
private final Logger myLogger;
|
||||
private final Level myLevel;
|
||||
private ListAppender<ILoggingEvent> myListAppender = null;
|
||||
private Level mySavedLevel;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param theLogger the log to capture
|
||||
*/
|
||||
public LogbackCaptureTestExtension(Logger theLogger) {
|
||||
myLogger = theLogger;
|
||||
myLevel = null;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param theLogger the log to capture
|
||||
* @param theTestLogLevel the log Level to set on the target logger for the duration of the test
|
||||
*/
|
||||
public LogbackCaptureTestExtension(Logger theLogger, Level theTestLogLevel) {
|
||||
myLogger = theLogger;
|
||||
myLevel = theTestLogLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param theLoggerName the log name to capture
|
||||
*/
|
||||
public LogbackCaptureTestExtension(String theLoggerName) {
|
||||
this((Logger) LoggerFactory.getLogger(theLoggerName));
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture the root logger - all lines.
|
||||
*/
|
||||
public LogbackCaptureTestExtension() {
|
||||
this(org.slf4j.Logger.ROOT_LOGGER_NAME);
|
||||
}
|
||||
|
||||
public LogbackCaptureTestExtension(String theLoggerName, Level theLevel) {
|
||||
this((Logger) LoggerFactory.getLogger(theLoggerName), theLevel);
|
||||
}
|
||||
|
||||
public LogbackCaptureTestExtension(Class<?> theClass) {
|
||||
this(theClass.getName());
|
||||
}
|
||||
|
||||
public LogbackCaptureTestExtension(Class<?> theClass, Level theLevel) {
|
||||
this(theClass.getName(), theLevel);
|
||||
}
|
||||
|
||||
public LogbackCaptureTestExtension(org.slf4j.Logger theLogger) {
|
||||
this((Logger) theLogger);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy to avoid concurrent modification errors.
|
||||
* @return A copy of the log events so far.
|
||||
*/
|
||||
public java.util.List<ILoggingEvent> getLogEvents() {
|
||||
// copy to avoid concurrent mod errors
|
||||
return new ArrayList<>(myListAppender.list);
|
||||
}
|
||||
|
||||
/** Clear accumulated log events. */
|
||||
public void clearEvents() {
|
||||
myListAppender.list.clear();
|
||||
}
|
||||
|
||||
public ListAppender<ILoggingEvent> getAppender() {
|
||||
return myListAppender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeEach(ExtensionContext context) throws Exception {
|
||||
setUp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Guts of beforeEach exposed for manual lifecycle.
|
||||
*/
|
||||
public void setUp() {
|
||||
setUp(myLevel);
|
||||
}
|
||||
|
||||
/**
|
||||
* Guts of beforeEach exposed for manual lifecycle.
|
||||
*/
|
||||
public void setUp(Level theLevel) {
|
||||
myListAppender = new ListAppender<>();
|
||||
myListAppender.start();
|
||||
myLogger.addAppender(myListAppender);
|
||||
if (theLevel != null) {
|
||||
mySavedLevel = myLogger.getLevel();
|
||||
myLogger.setLevel(theLevel);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterEach(ExtensionContext context) throws Exception {
|
||||
myLogger.detachAppender(myListAppender);
|
||||
myListAppender.stop();
|
||||
if (myLevel != null) {
|
||||
myLogger.setLevel(mySavedLevel);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithMessageEqualTo(String theMessageText){
|
||||
return filterLoggingEventsWithPredicate(loggingEvent -> loggingEvent.getFormattedMessage().equals(theMessageText));
|
||||
}
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithMessageContaining(String theMessageText){
|
||||
return filterLoggingEventsWithPredicate(loggingEvent -> loggingEvent.getFormattedMessage().contains(theMessageText));
|
||||
}
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithPredicate(Predicate<ILoggingEvent> theLoggingEventPredicate){
|
||||
return getLogEvents()
|
||||
.stream()
|
||||
.filter(theLoggingEventPredicate)
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the log messages from the logging events.
|
||||
* @return a copy of the List of log messages
|
||||
*
|
||||
*/
|
||||
@Nonnull
|
||||
public List<String> getLogMessages() {
|
||||
return getLogEvents().stream().map(ILoggingEvent::getMessage).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
// Hamcrest matcher support
|
||||
public static Matcher<ILoggingEvent> eventWithLevelAndMessageContains(@Nonnull Level theLevel, @Nonnull String thePartialMessage) {
|
||||
return new LogbackEventMatcher(theLevel, thePartialMessage);
|
||||
}
|
||||
|
||||
public static Matcher<ILoggingEvent> eventWithLevel(@Nonnull Level theLevel) {
|
||||
return new LogbackEventMatcher(theLevel, null);
|
||||
}
|
||||
|
||||
public static Matcher<ILoggingEvent> eventWithMessageContains(@Nonnull String thePartialMessage) {
|
||||
return new LogbackEventMatcher(null, thePartialMessage);
|
||||
}
|
||||
|
||||
public static Matcher<ILoggingEvent> eventWithLevelAndMessageAndThrew(@Nonnull Level theLevel,
|
||||
@Nonnull String thePartialMessage,
|
||||
@Nonnull String theThrown)
|
||||
{
|
||||
return new LogbackEventMatcher(theLevel, thePartialMessage, theThrown);
|
||||
}
|
||||
|
||||
}
|
|
@ -1,83 +0,0 @@
|
|||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR Test Utilities
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.test.util;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import org.hamcrest.CustomTypeSafeMatcher;
|
||||
|
||||
import jakarta.annotation.Nonnull;
|
||||
import jakarta.annotation.Nullable;
|
||||
|
||||
/**
|
||||
* A Hamcrest matcher for junit assertions.
|
||||
* Matches on level, partial message, and/or a portion of the message contained by a throwable, if present.
|
||||
* @deprecated use {@link LogbackEventAssert}
|
||||
*/
|
||||
@Deprecated
|
||||
public class LogbackEventMatcher extends CustomTypeSafeMatcher<ILoggingEvent> {
|
||||
@Nullable
|
||||
private final Level myLevel;
|
||||
@Nullable
|
||||
private final String myLogMessage;
|
||||
@Nullable
|
||||
private final String myThrownMessage;
|
||||
|
||||
public LogbackEventMatcher(@Nullable Level theLevel, @Nullable String thePartialString) {
|
||||
this("log event", theLevel, thePartialString, null);
|
||||
}
|
||||
|
||||
public LogbackEventMatcher(@Nullable Level theLevel, @Nullable String thePartialString, @Nullable String theThrownMessage) {
|
||||
this("log event", theLevel, thePartialString, theThrownMessage);
|
||||
}
|
||||
|
||||
private LogbackEventMatcher(@Nonnull String description, Level theLevel,
|
||||
String thePartialString, String theThrownMessage)
|
||||
{
|
||||
super(makeDescription(description, theLevel, thePartialString, theThrownMessage));
|
||||
myLevel = theLevel;
|
||||
myLogMessage = thePartialString;
|
||||
myThrownMessage = theThrownMessage;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
private static String makeDescription(String description, Level theLevel, String thePartialString, String theThrownMessage) {
|
||||
String msg = description;
|
||||
if (theLevel != null) {
|
||||
msg = msg + " with level at least " + theLevel;
|
||||
}
|
||||
if (thePartialString != null) {
|
||||
msg = msg + " containing string \"" + thePartialString + "\"";
|
||||
|
||||
}
|
||||
if (thePartialString != null) {
|
||||
msg = msg + " and throwable with error message containing string \"" + theThrownMessage + "\"";
|
||||
|
||||
}
|
||||
return msg;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean matchesSafely(ILoggingEvent item) {
|
||||
return (myLevel == null || item.getLevel().isGreaterOrEqual(myLevel)) &&
|
||||
(myLogMessage == null || item.getFormattedMessage().contains(myLogMessage)) &&
|
||||
(myThrownMessage == null || item.getThrowableProxy() == null || item.getThrowableProxy().getMessage().contains(myThrownMessage));
|
||||
}
|
||||
}
|
|
@ -1,116 +0,0 @@
|
|||
/*-
|
||||
* #%L
|
||||
* HAPI FHIR Test Utilities
|
||||
* %%
|
||||
* Copyright (C) 2014 - 2024 Smile CDR, Inc.
|
||||
* %%
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* #L%
|
||||
*/
|
||||
package ca.uhn.test.util;
|
||||
|
||||
import ch.qos.logback.classic.Level;
|
||||
import ch.qos.logback.classic.filter.ThresholdFilter;
|
||||
import ch.qos.logback.classic.spi.ILoggingEvent;
|
||||
import ch.qos.logback.core.read.ListAppender;
|
||||
import jakarta.annotation.Nonnull;
|
||||
import org.junit.jupiter.api.extension.AfterAllCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeAllCallback;
|
||||
import org.junit.jupiter.api.extension.ExtensionContext;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.slf4j.Logger.ROOT_LOGGER_NAME;
|
||||
|
||||
/**
|
||||
* This is a static wrapper around LogbackTestExtension for use in IT tests when you need to assert on App
|
||||
* startup log entries
|
||||
* @deprecated use {@link StaticLogbackTestExtension}
|
||||
*/
|
||||
@Deprecated
|
||||
public class StaticLogbackCaptureTestExtension implements BeforeAllCallback, AfterAllCallback {
|
||||
private final LogbackCaptureTestExtension myLogbackCaptureTestExtension;
|
||||
|
||||
public StaticLogbackCaptureTestExtension(LogbackCaptureTestExtension theLogbackCaptureTestExtension) {
|
||||
myLogbackCaptureTestExtension = theLogbackCaptureTestExtension;
|
||||
}
|
||||
|
||||
public StaticLogbackCaptureTestExtension() {
|
||||
myLogbackCaptureTestExtension = new LogbackCaptureTestExtension();
|
||||
}
|
||||
|
||||
public static StaticLogbackCaptureTestExtension withThreshold(Level theLevel) {
|
||||
LogbackCaptureTestExtension logbackCaptureTestExtension = new LogbackCaptureTestExtension();
|
||||
logbackCaptureTestExtension.setUp(theLevel);
|
||||
ThresholdFilter thresholdFilter = new ThresholdFilter();
|
||||
thresholdFilter.setLevel(theLevel.levelStr);
|
||||
logbackCaptureTestExtension.getAppender().addFilter(thresholdFilter);
|
||||
|
||||
return new StaticLogbackCaptureTestExtension(logbackCaptureTestExtension);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void beforeAll(ExtensionContext theExtensionContext) throws Exception {
|
||||
if (myLogbackCaptureTestExtension.getAppender() == null) {
|
||||
myLogbackCaptureTestExtension.beforeEach(theExtensionContext);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterAll(ExtensionContext theExtensionContext) throws Exception {
|
||||
myLogbackCaptureTestExtension.afterEach(theExtensionContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a copy to avoid concurrent modification errors.
|
||||
* @return A copy of the log events so far.
|
||||
*/
|
||||
public java.util.List<ILoggingEvent> getLogEvents() {
|
||||
return myLogbackCaptureTestExtension.getLogEvents();
|
||||
}
|
||||
|
||||
/** Clear accumulated log events. */
|
||||
public void clearEvents() {
|
||||
myLogbackCaptureTestExtension.clearEvents();
|
||||
}
|
||||
|
||||
public ListAppender<ILoggingEvent> getAppender() {
|
||||
return myLogbackCaptureTestExtension.getAppender();
|
||||
}
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithMessageEqualTo(String theMessageText){
|
||||
return myLogbackCaptureTestExtension.filterLoggingEventsWithMessageEqualTo(theMessageText);
|
||||
}
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithMessageContaining(String theMessageText){
|
||||
return myLogbackCaptureTestExtension.filterLoggingEventsWithMessageContaining(theMessageText);
|
||||
}
|
||||
|
||||
public List<ILoggingEvent> filterLoggingEventsWithPredicate(Predicate<ILoggingEvent> theLoggingEventPredicate){
|
||||
return myLogbackCaptureTestExtension.filterLoggingEventsWithPredicate(theLoggingEventPredicate);
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the log messages from the logging events.
|
||||
* @return a copy of the List of log messages
|
||||
*
|
||||
*/
|
||||
@Nonnull
|
||||
public List<String> getLogMessages() {
|
||||
return myLogbackCaptureTestExtension.getLogMessages();
|
||||
}
|
||||
|
||||
}
|
|
@ -31,7 +31,6 @@ import org.apache.http.client.methods.HttpGet;
|
|||
import org.apache.http.client.methods.HttpPost;
|
||||
import org.apache.http.entity.ContentType;
|
||||
import org.apache.http.entity.StringEntity;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
|
|
|
@ -24,7 +24,6 @@ import org.apache.http.HttpResponse;
|
|||
import org.apache.http.client.methods.CloseableHttpResponse;
|
||||
import org.apache.http.client.methods.HttpDelete;
|
||||
import org.apache.http.client.methods.HttpGet;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu3.model.Enumerations.AdministrativeGender;
|
||||
import org.hl7.fhir.dstu3.model.IdType;
|
||||
|
|
|
@ -12,7 +12,6 @@ import ca.uhn.fhir.validation.SchemaBaseValidator;
|
|||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
|
||||
import org.hl7.fhir.dstu2016may.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu2016may.model.Coding;
|
||||
|
|
|
@ -18,7 +18,6 @@ import ca.uhn.fhir.validation.ValidationResult;
|
|||
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.Validate;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.common.hapi.validation.support.PrePopulatedValidationSupport;
|
||||
import org.hl7.fhir.common.hapi.validation.support.ValidationSupportChain;
|
||||
import org.hl7.fhir.common.hapi.validation.validator.FhirInstanceValidator;
|
||||
|
|
|
@ -33,9 +33,6 @@ import ca.uhn.fhir.validation.ValidationFailureException;
|
|||
import ca.uhn.fhir.validation.ValidationResult;
|
||||
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
import org.ops4j.pax.exam.Configuration;
|
||||
|
@ -47,8 +44,6 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_VALIDATION_DSTU2;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.tests.integration.karaf.dstu21;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
|
@ -13,8 +14,6 @@ import ca.uhn.fhir.parser.IParser;
|
|||
import ca.uhn.fhir.parser.LenientErrorHandler;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.dstu2016may.model.Conformance;
|
||||
import org.hl7.fhir.dstu2016may.model.PrimitiveType;
|
||||
import org.hl7.fhir.instance.model.api.IIdType;
|
||||
|
@ -30,10 +29,6 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_DSTU2_1;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
|
@ -668,7 +663,7 @@ public class JsonParserDstu2_1Test {
|
|||
|
||||
assertNull(ourCtx.newJsonParser().getStripVersionsFromReferences());
|
||||
assertTrue(ourCtx.getParserOptions().isStripVersionsFromReferences());
|
||||
assertThat(ourCtx.getParserOptions().getDontStripVersionsFromReferencesAtPaths(), empty());
|
||||
assertThat(ourCtx.getParserOptions().getDontStripVersionsFromReferencesAtPaths()).isEmpty();
|
||||
|
||||
org.hl7.fhir.dstu2016may.model.Patient p = new org.hl7.fhir.dstu2016may.model.Patient();
|
||||
p.setManagingOrganization(new org.hl7.fhir.dstu2016may.model.Reference("http://foo.com/Organization/2/_history/1"));
|
||||
|
@ -1033,7 +1028,7 @@ public class JsonParserDstu2_1Test {
|
|||
|
||||
assertThat(ourCtx.newJsonParser().encodeResourceToString(p)).containsSubsequence("123", "ABC"));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p)).contains("ABC"));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p), not(containsString("123")));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p)).doesNotContain("123");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1157,8 +1152,8 @@ public class JsonParserDstu2_1Test {
|
|||
assertEquals("654321", res.getIdentifier().get(0).getValue());
|
||||
assertEquals(true, res.getActive());
|
||||
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre(), contains("identifier comment 1", "identifier comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre(), contains("use comment 1", "use comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre()).contains("identifier comment 1", "identifier comment 2");
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre()).contains("use comment 1", "use comment 2");
|
||||
|
||||
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(res);
|
||||
ourLog.info(encoded);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.tests.integration.karaf.dstu21;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
@ -15,10 +16,6 @@ import ca.uhn.fhir.parser.LenientErrorHandler;
|
|||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu2016may.model.Address;
|
||||
import org.hl7.fhir.dstu2016may.model.Appointment;
|
||||
import org.hl7.fhir.dstu2016may.model.AuditEvent;
|
||||
|
@ -75,10 +72,6 @@ import org.xmlunit.diff.ElementSelectors;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_DSTU2_1;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
@ -723,7 +716,7 @@ public class XmlParserDstu2_1Test {
|
|||
//@formatter:on
|
||||
|
||||
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
||||
assertThat(parsed.getMeta().getProfile(), empty());
|
||||
assertThat(parsed.getMeta().getProfile()).isEmpty();
|
||||
|
||||
List<Coding> tagList = parsed.getMeta().getTag();
|
||||
assertEquals(2, tagList.size());
|
||||
|
@ -1673,7 +1666,7 @@ public class XmlParserDstu2_1Test {
|
|||
|
||||
assertThat(ourCtx.newXmlParser().encodeResourceToString(p)).containsSubsequence("123", "ABC"));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p)).contains("ABC"));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p), not(containsString("123")));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p)).doesNotContain("123");
|
||||
}
|
||||
|
||||
|
||||
|
@ -1717,10 +1710,10 @@ public class XmlParserDstu2_1Test {
|
|||
assertEquals("654321", res.getIdentifier().get(0).getValue());
|
||||
assertEquals(true, res.getActive());
|
||||
|
||||
assertThat(res.getIdElement().getFormatCommentsPre(), contains("pre resource comment"));
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre(), contains("identifier comment 1", "identifier comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre(), contains("use comment 1", "use comment 2"));
|
||||
assertThat(res.getActiveElement().getFormatCommentsPost(), contains("post resource comment"));
|
||||
assertThat(res.getIdElement().getFormatCommentsPre()).contains("pre resource comment");
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre()).contains("identifier comment 1", "identifier comment 2");
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre()).contains("use comment 1", "use comment 2");
|
||||
assertThat(res.getActiveElement().getFormatCommentsPost()).contains("post resource comment");
|
||||
|
||||
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(res);
|
||||
ourLog.info(encoded);
|
||||
|
|
|
@ -12,11 +12,6 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.IsNot;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu2.model.Address;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUse;
|
||||
import org.hl7.fhir.dstu2.model.Address.AddressUseEnumFactory;
|
||||
|
@ -65,8 +60,6 @@ import org.xml.sax.SAXException;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_HL7ORG_DSTU2;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
|
|
@ -17,11 +17,6 @@ import ca.uhn.fhir.parser.DataFormatException;
|
|||
import ca.uhn.fhir.parser.IParser;
|
||||
import ca.uhn.fhir.rest.api.Constants;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.IsNot;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu2.model.Address;
|
||||
import org.hl7.fhir.dstu2.model.CodeableConcept;
|
||||
import org.hl7.fhir.dstu2.model.Composition;
|
||||
|
@ -58,8 +53,6 @@ import org.xmlunit.diff.ElementSelectors;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_HL7ORG_DSTU2;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.tests.integration.karaf.dstu3;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.math.BigDecimal;
|
||||
|
@ -14,8 +15,6 @@ import ca.uhn.fhir.parser.IParser;
|
|||
import ca.uhn.fhir.parser.LenientErrorHandler;
|
||||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hl7.fhir.dstu3.model.AuditEvent;
|
||||
import org.hl7.fhir.dstu3.model.Basic;
|
||||
import org.hl7.fhir.dstu3.model.Binary;
|
||||
|
@ -62,10 +61,6 @@ import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_DSTU3
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.apache.commons.lang3.StringUtils.countMatches;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
@ -871,7 +866,7 @@ public class Dstu3JsonParserTest {
|
|||
|
||||
assertNull(ourCtx.newJsonParser().getStripVersionsFromReferences());
|
||||
assertTrue(ourCtx.getParserOptions().isStripVersionsFromReferences());
|
||||
assertThat(ourCtx.getParserOptions().getDontStripVersionsFromReferencesAtPaths(), empty());
|
||||
assertThat(ourCtx.getParserOptions().getDontStripVersionsFromReferencesAtPaths()).isEmpty();
|
||||
|
||||
Patient p = new Patient();
|
||||
p.setManagingOrganization(new Reference("http://foo.com/Organization/2/_history/1"));
|
||||
|
@ -1264,7 +1259,7 @@ public class Dstu3JsonParserTest {
|
|||
|
||||
assertThat(ourCtx.newJsonParser().encodeResourceToString(p)).containsSubsequence("123", "ABC"));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p)).contains("ABC"));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p), not(containsString("123")));
|
||||
assertThat(ourCtx.newJsonParser().setOmitResourceId(true).encodeResourceToString(p)).doesNotContain("123");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -1430,8 +1425,8 @@ public class Dstu3JsonParserTest {
|
|||
assertEquals("654321", res.getIdentifier().get(0).getValue());
|
||||
assertEquals(true, res.getActive());
|
||||
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre(), contains("identifier comment 1", "identifier comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre(), contains("use comment 1", "use comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre()).contains("identifier comment 1", "identifier comment 2");
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre()).contains("use comment 1", "use comment 2");
|
||||
|
||||
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(res);
|
||||
ourLog.info(encoded);
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
package ca.uhn.fhir.tests.integration.karaf.dstu3;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
import java.io.IOException;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
|
@ -20,10 +21,6 @@ import com.google.common.collect.Sets;
|
|||
import org.apache.commons.io.FileUtils;
|
||||
import org.apache.commons.io.IOUtils;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.hamcrest.Matcher;
|
||||
import org.hamcrest.Matchers;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hamcrest.text.StringContainsInOrder;
|
||||
import org.hl7.fhir.dstu3.model.Address;
|
||||
import org.hl7.fhir.dstu3.model.AllergyIntolerance;
|
||||
import org.hl7.fhir.dstu3.model.Annotation;
|
||||
|
@ -94,11 +91,6 @@ import org.xmlunit.diff.ElementSelectors;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_DSTU3;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.contains;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.Matchers.empty;
|
||||
import static org.hamcrest.Matchers.not;
|
||||
import static org.hamcrest.Matchers.startsWith;
|
||||
import static org.junit.jupiter.api.Assertions.assertArrayEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
|
@ -831,7 +823,7 @@ public class Dstu3XmlParserTest {
|
|||
"</Patient>"));
|
||||
|
||||
Patient parsed = ourCtx.newXmlParser().parseResource(Patient.class, enc);
|
||||
assertThat(parsed.getMeta().getProfile(), empty());
|
||||
assertThat(parsed.getMeta().getProfile()).isEmpty();
|
||||
|
||||
List<Coding> tagList = parsed.getMeta().getTag();
|
||||
assertEquals(2, tagList.size());
|
||||
|
@ -2085,7 +2077,7 @@ public class Dstu3XmlParserTest {
|
|||
|
||||
assertThat(ourCtx.newXmlParser().encodeResourceToString(p)).containsSubsequence("123", "ABC"));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p)).contains("ABC"));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p), not(containsString("123")));
|
||||
assertThat(ourCtx.newXmlParser().setOmitResourceId(true).encodeResourceToString(p)).doesNotContain("123");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -2167,10 +2159,10 @@ public class Dstu3XmlParserTest {
|
|||
assertEquals("654321", res.getIdentifier().get(0).getValue());
|
||||
assertEquals(true, res.getActive());
|
||||
|
||||
assertThat(res.getIdElement().getFormatCommentsPre(), contains("pre resource comment"));
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre(), contains("identifier comment 1", "identifier comment 2"));
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre(), contains("use comment 1", "use comment 2"));
|
||||
assertThat(res.getActiveElement().getFormatCommentsPost(), contains("post resource comment"));
|
||||
assertThat(res.getIdElement().getFormatCommentsPre()).contains("pre resource comment");
|
||||
assertThat(res.getIdentifier().get(0).getFormatCommentsPre()).contains("identifier comment 1", "identifier comment 2");
|
||||
assertThat(res.getIdentifier().get(0).getUseElement().getFormatCommentsPre()).contains("use comment 1", "use comment 2");
|
||||
assertThat(res.getActiveElement().getFormatCommentsPost()).contains("post resource comment");
|
||||
|
||||
String encoded = ourCtx.newJsonParser().setPrettyPrint(true).encodeResourceToString(res);
|
||||
ourLog.info(encoded);
|
||||
|
|
|
@ -8,7 +8,6 @@ import ca.uhn.fhir.parser.IParser;
|
|||
import ca.uhn.fhir.parser.StrictErrorHandler;
|
||||
import ca.uhn.fhir.tests.integration.karaf.ValidationConstants;
|
||||
import ca.uhn.fhir.validation.schematron.SchematronBaseValidator;
|
||||
import org.hamcrest.core.StringContains;
|
||||
import org.hl7.fhir.r5.hapi.validation.FhirInstanceValidator;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
|
|
|
@ -19,8 +19,6 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_R4;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.hamcrest.core.IsNot.not;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
|
|
|
@ -6,7 +6,6 @@ import java.util.Set;
|
|||
import ca.uhn.fhir.context.FhirContext;
|
||||
import ca.uhn.fhir.parser.IParser;
|
||||
import com.google.common.collect.Sets;
|
||||
import org.hamcrest.core.IsNot;
|
||||
import org.hl7.fhir.r4.model.Bundle;
|
||||
import org.hl7.fhir.r4.model.Patient;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
@ -20,7 +19,6 @@ import org.ops4j.pax.exam.spi.reactors.PerClass;
|
|||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.HAPI_FHIR_R4;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.KARAF;
|
||||
import static ca.uhn.fhir.tests.integration.karaf.PaxExamOptions.WRAP;
|
||||
import static org.hamcrest.Matchers.containsString;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.ops4j.pax.exam.CoreOptions.mavenBundle;
|
||||
|
|
Loading…
Reference in New Issue