Skip to content

Commit

Permalink
Fixing NodeDefinitionTest tests: correcting expectations for allowed …
Browse files Browse the repository at this point in the history
…types of referenced resources.
  • Loading branch information
piotrszul committed Jan 6, 2025
1 parent f736aa6 commit 0df2b8b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package au.csiro.pathling.fhirpath.definition;

import jakarta.annotation.Nonnull;
import lombok.Value;
import org.hl7.fhir.r4.model.Enumerations.ResourceType;
import java.util.Collections;
import java.util.Optional;
Expand Down Expand Up @@ -59,10 +60,11 @@ public Optional<ResourceType> asSingleResourceType() {
/**
* Represents a set of declared resource types.
*/
@Value
class DeclaredResourceTypes implements ResourceTypeSet {

@Nonnull
private final Set<ResourceType> resourceTypes;
Set<ResourceType> resourceTypes;

private DeclaredResourceTypes(@Nonnull final Set<ResourceType> resourceTypes) {
if (resourceTypes.isEmpty()) {
Expand Down Expand Up @@ -124,4 +126,17 @@ static ResourceTypeSet of(@Nonnull final Set<ResourceType> resourceTypes) {
return new DeclaredResourceTypes(resourceTypes);
}


/**
* Creates a new {@link ResourceTypeSet} from the given resource types. The set must not be
* empty.
*
* @param resourceTypes The resource types
* @return A new {@link ResourceTypeSet} instance
*/
static ResourceTypeSet of(@Nonnull final ResourceType... resourceTypes) {
return new DeclaredResourceTypes(Set.of(resourceTypes));
}


}
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void testReferenceInChoiceValue() {
"Reference")
.orElseThrow();
assertInstanceOf(ReferenceDefinition.class, referenceDefinition);
assertEquals(Set.of(ResourceType.MEDICATION),
assertEquals(ResourceTypeSet.of(ResourceType.MEDICATION),
((ReferenceDefinition) referenceDefinition).getReferenceTypes());
assertEquals("medicationReference", referenceDefinition.getElementName());
}
Expand All @@ -70,6 +70,7 @@ void testReferenceInExtensionValue() {
.orElseThrow();
assertInstanceOf(ReferenceDefinition.class, referenceDefinition);
assertEquals("valueReference", referenceDefinition.getElementName());
System.out.println(((ReferenceDefinition) referenceDefinition).getReferenceTypes());
assertEquals(ResourceTypeSet.allResourceTypes(),
((ReferenceDefinition) referenceDefinition).getReferenceTypes());
}
}

0 comments on commit 0df2b8b

Please sign in to comment.