Skip to content

Commit

Permalink
Fixes duplicate search param definition in DefaultCapabilities.json (#…
Browse files Browse the repository at this point in the history
…172)

* Fixes #165
  • Loading branch information
brendankowitz authored Nov 6, 2018
1 parent 1c837da commit 67dfe76
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,22 @@ public void GivenACapabilityStatement_WhenSupportingSearchParamConfiguringWrongS
Assert.Throws<UnsupportedConfigurationException>(() => supported.Intersect(configured, strictConfig: true));
}

[Fact]
public void GivenACapabilityStatement_WhenSupportingSearchParamConfiguringDuplicateSearchParams_ThenNotSupportedExceptionIsThrown()
{
var supported = GetMockedListedCapabilityStatement();
supported.TryAddSearchParams(ResourceType.Account, GetSearchParamCollection());

var configured = CapabilityStatementMock.GetMockedCapabilityStatement();
CapabilityStatementMock.SetupMockResource(configured, ResourceType.Account, null, new List<SearchParamComponent>
{
new SearchParamComponent { Type = SearchParamType.String, Name = "name" },
new SearchParamComponent { Type = SearchParamType.String, Name = "name" },
});

Assert.Throws<UnsupportedConfigurationException>(() => supported.Intersect(configured, strictConfig: true));
}

[Fact]
public void GivenACapabilityStatement_WhenSupportingSearchParamConfiguringSearchParam_ThenResultIsCorrectlyIntersected()
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -325,6 +325,11 @@ private static List<TElement> IntersectList<TElement, TProperty>(this IEnumerabl
issues.Add(string.Format(CultureInfo.InvariantCulture, Core.Resources.InvalidListConfigSetting, fieldName));
}

if (config.Select(selector).GroupBy(x => x).Any(x => x.Count() > 1))
{
issues.Add(string.Format(CultureInfo.InvariantCulture, Core.Resources.InvalidListConfigDuplicateItem, fieldName));
}

return config.ToList();
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13367,12 +13367,6 @@
"type": "date",
"documentation": "The time during which the questionnaire is intended to be in use"
},
{
"name": "code",
"definition": "http://hl7.org/fhir/SearchParameter/Questionnaire-code",
"type": "token",
"documentation": "A code that corresponds to one of its items in the questionnaire"
},
{
"name": "jurisdiction",
"definition": "http://hl7.org/fhir/SearchParameter/Questionnaire-jurisdiction",
Expand Down
9 changes: 9 additions & 0 deletions src/Microsoft.Health.Fhir.Core/Resources.Designer.cs

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 4 additions & 1 deletion src/Microsoft.Health.Fhir.Core/Resources.resx
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,9 @@
<data name="InvalidEnumConfigSetting" xml:space="preserve">
<value>Field '{0}' with value '{1}' is not supported. Please select from the following list of supported capabilities: [{2}]."</value>
</data>
<data name="InvalidListConfigDuplicateItem" xml:space="preserve">
<value>A duplicate value was found for field '{0}'. Please check your configured options.</value>
</data>
<data name="InvalidListConfigSetting" xml:space="preserve">
<value>Unsupported values for field '{0}' were selected. Please check your configured options.</value>
</data>
Expand Down Expand Up @@ -289,4 +292,4 @@
<data name="WeakETagFormatRequired" xml:space="preserve">
<value>WeakETag must be in the weak ETag format</value>
</data>
</root>
</root>

0 comments on commit 67dfe76

Please sign in to comment.