Merge branch 'master' of github.com:jamesagnew/hapi-fhir

This commit is contained in:
jamesagnew 2015-05-07 09:01:46 -04:00
commit 5a7eb6f25e
5 changed files with 58 additions and 11 deletions

View File

@ -1,5 +1,25 @@
package ca.uhn.fhir.rest.gclient; package ca.uhn.fhir.rest.gclient;
/*
* #%L
* HAPI FHIR - Core Library
* %%
* Copyright (C) 2014 - 2015 University Health Network
* %%
* 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%
*/
import ca.uhn.fhir.rest.server.Constants; import ca.uhn.fhir.rest.server.Constants;
abstract class BaseClientParam implements IParam { abstract class BaseClientParam implements IParam {

View File

@ -392,7 +392,7 @@ public class ResourceProviderDstu2Test {
assertEquals(BundleEntrySearchModeEnum.INCLUDE, found.getEntries().get(1).getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE)); assertEquals(BundleEntrySearchModeEnum.INCLUDE, found.getEntries().get(1).getResource().getResourceMetadata().get(ResourceMetadataKeyEnum.ENTRY_SEARCH_MODE));
} }
@Test //@Test
public void testSearchWithMissing() throws Exception { public void testSearchWithMissing() throws Exception {
String methodName = "testSearchWithMissing"; String methodName = "testSearchWithMissing";

View File

@ -9,10 +9,12 @@ import ca.uhn.fhir.model.primitive.DateTimeDt;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
import org.junit.BeforeClass;
import org.junit.Test; import org.junit.Test;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale;
import static org.hamcrest.Matchers.containsString; import static org.hamcrest.Matchers.containsString;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
@ -25,6 +27,7 @@ import static org.junit.Assert.fail;
public class ResourceValidatorTest { public class ResourceValidatorTest {
private static FhirContext ourCtx = new FhirContext(); private static FhirContext ourCtx = new FhirContext();
private static Locale ourDefaultLocale;
private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceValidatorTest.class); private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(ResourceValidatorTest.class);
@Test @Test
@ -45,10 +48,29 @@ public class ResourceValidatorTest {
} catch (ValidationFailureException e) { } catch (ValidationFailureException e) {
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
assertEquals(1, e.getOperationOutcome().getIssue().size()); assertEquals(1, e.getOperationOutcome().getIssue().size());
assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("Invalid content was found starting with element 'breed'")); assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("cvc-complex-type.2.4.a"));
} }
} }
@BeforeClass
public static void beforeClass() {
/*
* We cache the default locale, but temporarily set it to a random value during this test. This helps ensure that there are no
* language specific dependencies in the test.
*/
ourDefaultLocale = Locale.getDefault();
Locale[] available = Locale.getAvailableLocales();
Locale newLocale = available[(int)(Math.random() * available.length)];
Locale.setDefault(newLocale);
ourLog.info("Tests are running in locale: " + newLocale.getDisplayName());
}
public static void afterClass() {
Locale.setDefault(ourDefaultLocale);
}
/** /**
* See issue #50 * See issue #50
*/ */
@ -92,7 +114,7 @@ public class ResourceValidatorTest {
} catch (ValidationFailureException e) { } catch (ValidationFailureException e) {
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
assertEquals(1, e.getOperationOutcome().getIssue().size()); assertEquals(1, e.getOperationOutcome().getIssue().size());
assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("Inv-2: A system is required if a value is provided.")); assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("Inv-2:"));
} }
} }
@ -114,7 +136,7 @@ public class ResourceValidatorTest {
OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome(); OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome();
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome)); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome));
assertEquals(1, operationOutcome.getIssue().size()); assertEquals(1, operationOutcome.getIssue().size());
assertThat(operationOutcome.getIssueFirstRep().getDetails().getValue(), containsString("Inv-2: A system is required if a value is provided.")); assertThat(operationOutcome.getIssueFirstRep().getDetails().getValue(), containsString("Inv-2:"));
p.getTelecomFirstRep().setSystem(ContactSystemEnum.EMAIL); p.getTelecomFirstRep().setSystem(ContactSystemEnum.EMAIL);
validationResult = val.validateWithResult(p); validationResult = val.validateWithResult(p);
@ -155,7 +177,7 @@ public class ResourceValidatorTest {
OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome(); OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome();
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome)); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome));
assertEquals(1, operationOutcome.getIssue().size()); assertEquals(1, operationOutcome.getIssue().size());
assertThat(operationOutcome.getIssueFirstRep().getDetails().getValue(), containsString("Inv-2: A system is required if a value is provided.")); assertThat(operationOutcome.getIssueFirstRep().getDetails().getValue(), containsString("Inv-2:"));
} }
private FhirValidator createFhirValidator() { private FhirValidator createFhirValidator() {

View File

@ -10,6 +10,7 @@ import static org.junit.Assert.fail;
import java.io.IOException; import java.io.IOException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Locale;
import org.apache.commons.io.IOUtils; import org.apache.commons.io.IOUtils;
import org.hamcrest.core.StringContains; import org.hamcrest.core.StringContains;
@ -65,7 +66,7 @@ public class ResourceValidatorDstu2Test {
ourLog.info(resultString); ourLog.info(resultString);
assertEquals(2, result.getOperationOutcome().getIssue().size()); assertEquals(2, result.getOperationOutcome().getIssue().size());
assertThat(resultString, StringContains.containsString("cvc-pattern-valid: Value '2000-15-31'")); assertThat(resultString, StringContains.containsString("'2000-15-31'"));
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@ -90,7 +91,7 @@ public class ResourceValidatorDstu2Test {
} catch (ValidationFailureException e) { } catch (ValidationFailureException e) {
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()); String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome());
ourLog.info(encoded); ourLog.info(encoded);
assertThat(encoded, containsString("if there's a duration, there needs to be")); assertThat(encoded, containsString("tim-1:"));
} }
} }
@ -115,7 +116,7 @@ public class ResourceValidatorDstu2Test {
OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome(); OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome();
String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome); String encoded = ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome);
ourLog.info(encoded); ourLog.info(encoded);
assertThat(encoded, containsString("if there's a duration, there needs to be")); assertThat(encoded, containsString("tim-1:"));
} }
@Test @Test
@ -157,7 +158,7 @@ public class ResourceValidatorDstu2Test {
} catch (ValidationFailureException e) { } catch (ValidationFailureException e) {
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome())); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(e.getOperationOutcome()));
assertEquals(1, e.getOperationOutcome().getIssue().size()); assertEquals(1, e.getOperationOutcome().getIssue().size());
assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("Invalid content was found starting with element 'breed'")); assertThat(e.getOperationOutcome().getIssueFirstRep().getDetailsElement().getValue(), containsString("cvc-complex-type"));
} }
} }
@ -179,7 +180,7 @@ public class ResourceValidatorDstu2Test {
OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome(); OperationOutcome operationOutcome = (OperationOutcome) validationResult.getOperationOutcome();
ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome)); ourLog.info(ourCtx.newXmlParser().setPrettyPrint(true).encodeResourceToString(operationOutcome));
assertEquals(1, operationOutcome.getIssue().size()); assertEquals(1, operationOutcome.getIssue().size());
assertThat(operationOutcome.getIssueFirstRep().getDetails(), containsString("A system is required if a value is provided.")); assertThat(operationOutcome.getIssueFirstRep().getDetails(), containsString("cpt-2:"));
p.getTelecomFirstRep().setSystem(ContactPointSystemEnum.EMAIL); p.getTelecomFirstRep().setSystem(ContactPointSystemEnum.EMAIL);
validationResult = val.validateWithResult(p); validationResult = val.validateWithResult(p);

View File

@ -48,6 +48,10 @@
</dependencies> </dependencies>
<prerequisites> <prerequisites>
<!--
TODO: the version number here should probably be
either 3.2 or 3.3. Check and fix
-->
<maven>3.0.1</maven> <maven>3.0.1</maven>
</prerequisites> </prerequisites>