Skip to content

Commit

Permalink
add more tests for failure cases
Browse files Browse the repository at this point in the history
  • Loading branch information
md-at-slashwhy committed Jan 22, 2024
1 parent bc81e6b commit 9e793c0
Showing 1 changed file with 38 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,12 @@ public void shouldApplyHasConstraintsForObservationsBasedOnLaboratoryCategoryCor
new String[] { WRONG_UUID, ORDER_WITH_OBSERVATION_CATEGORY_PROCEDURE_UUID });
}

@Test
public void shouldApplyHasConstraintsForObservationsBasedOnUnknownCategoryCorrectly() {
runHasObservationBasedOnTest("category", "__UnknownCategory", new String[] {}, new String[] { WRONG_UUID,
ORDER_WITH_OBSERVATION_CATEGORY_PROCEDURE_UUID, ORDER_WITH_OBSERVATION_CATEGORY_LABORATORY_UUID });
}

@Test
public void shouldApplyHasConstraintsForObservationsBasedOnAnyDateCorrectly() {
runHasObservationBasedOnTest("date", null, new String[] { ORDER_WITH_OBSERVATION_CATEGORY_LABORATORY_UUID },
Expand Down Expand Up @@ -280,6 +286,38 @@ public void shouldApplyHasConstraintsForObservationsBasedOnSpecificPerformerCorr
new String[] { ORDER_WITH_PROVIDER_UUID }, new String[] { WRONG_UUID, ORDER_WITH_TEXT_VALUE_UUID });
}

@Test
public void shouldReturnNoResultsForInvalidSearchParameter() {
runHasObservationBasedOnTest("__NotPerformer", "3c08ebc2-6d9d-46c6-bdc4-e8a1871d7a7d", new String[] {},
new String[] { WRONG_UUID, ORDER_WITH_TEXT_VALUE_UUID, ORDER_WITH_PROVIDER_UUID });
}

@Test
public void shouldReturnNoResultsForMalformattedNumeric() {
runHasObservationBasedOnTest("value-quantity", "twelve", new String[] {},
new String[] { WRONG_UUID, ORDER_WITH_TEXT_VALUE_UUID, ORDER_WITH_NUMERIC_VALUE_UUID });
}

@Test
public void shouldReturnNoResultsForMalformattedDate() {
runHasObservationBasedOnTest("value-date", "yesterday", new String[] {},
new String[] { WRONG_UUID, ORDER_WITH_TEXT_VALUE_UUID, ORDER_WITH_NUMERIC_VALUE_UUID });
}

@Test
public void shouldReturnNoResultsForUnknownReferencesForHasSearch() {
HasOrListParam hasOrListParam = new HasOrListParam();
hasOrListParam.add(new HasParam("Observation", "__notBased-on", "status", null));
HasAndListParam hasAndListParam = new HasAndListParam();
hasAndListParam.addAnd(hasOrListParam);
SearchParameterMap theParams = new SearchParameterMap().addParameter(FhirConstants.HAS_SEARCH_HANDLER,
hasAndListParam);

List<TestOrder> results = dao.getSearchResults(theParams);

assertThat(results, notNullValue());
}

@Test
public void shouldReturnNoEntriesForUnsupportedSearchParameters() {
String[] unsupportedSearchParameters = { "focus", "derived-from", "method", "data-absent-reason", "device",
Expand Down

0 comments on commit 9e793c0

Please sign in to comment.