Test fixes

This commit is contained in:
jamesagnew 2020-04-09 10:34:18 -04:00
parent 2a43aa3b6c
commit 879fbb0bf8
9 changed files with 18 additions and 17 deletions

View File

@ -161,7 +161,7 @@ public class LenientErrorHandler extends BaseErrorHandler implements IParserErro
@Override
public void extensionContainsValueAndNestedExtensions(IParseLocation theLocation) {
if (myLogErrors) {
ourLog.warn("Extension contains both a value and nested extensions: {}", describeLocation(theLocation));
ourLog.warn("{}Extension contains both a value and nested extensions", describeLocation(theLocation));
}
}

View File

@ -1282,7 +1282,7 @@ class ParserState<T> {
if ("value".equals(theName)) {
if ("".equals(theValue)) {
ParseLocation location = ParseLocation.fromElementName(myChildName);
myErrorHandler.invalidValue(location, theValue, "Attribute value for element must not be empty (\"\")");
myErrorHandler.invalidValue(location, theValue, "Attribute value must not be empty (\"\")");
} else {
try {
myInstance.setValueAsString(theValue);

View File

@ -86,7 +86,7 @@ public class StrictErrorHandler extends BaseErrorHandler implements IParserError
@Override
public void extensionContainsValueAndNestedExtensions(IParseLocation theLocation) {
throw new DataFormatException(describeLocation(theLocation) + "Extension contains both a value and nested extensions: " + theLocation);
throw new DataFormatException(describeLocation(theLocation) + "Extension contains both a value and nested extensions");
}
}

View File

@ -13,6 +13,7 @@ import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertThat;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Matchers.eq;
import static org.mockito.Matchers.isNull;
import static org.mockito.Mockito.mock;
@ -1098,8 +1099,8 @@ public class JsonParserDstu2_1Test {
assertEquals(null, parsed.getGenderElement().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(IParseLocation.class), eq(""), msgCaptor.capture());
assertEquals("Attribute values must not be empty (\"\")", msgCaptor.getValue());
verify(errorHandler, times(1)).invalidValue(any(IParseLocation.class), eq(""), msgCaptor.capture());
assertEquals("Attribute value must not be empty (\"\")", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);
assertEquals("{\"resourceType\":\"Patient\"}", encoded);
@ -1118,7 +1119,7 @@ public class JsonParserDstu2_1Test {
assertEquals("foo", parsed.getGenderElement().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(IParseLocation.class), eq("foo"), msgCaptor.capture());
verify(errorHandler, times(1)).invalidValue(any(IParseLocation.class), eq("foo"), msgCaptor.capture());
assertEquals("Unknown AdministrativeGender code 'foo'", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);
@ -1138,7 +1139,7 @@ public class JsonParserDstu2_1Test {
assertEquals("foo", parsed.getValueDateTimeType().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(IParseLocation.class), eq("foo"), msgCaptor.capture());
verify(errorHandler, times(1)).invalidValue(any(IParseLocation.class), eq("foo"), msgCaptor.capture());
assertEquals("Invalid date/time format: \"foo\"", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);

View File

@ -2379,7 +2379,7 @@ public class XmlParserDstu2_1Test {
p.parseResource(resource);
fail();
} catch (DataFormatException e) {
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: Invalid attribute value \"1\": Invalid boolean string: '1'", e.getMessage());
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: [element=\"active\"] Invalid attribute value \"1\": Invalid boolean string: '1'", e.getMessage());
}
LenientErrorHandler errorHandler = new LenientErrorHandler();

View File

@ -82,7 +82,7 @@ public class ResourceValidatorDstu2Test {
parser.parseResource(encoded);
fail();
} catch (DataFormatException e) {
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: Invalid attribute value \"2000-15-31\": Invalid date/time format: \"2000-15-31\"", e.getMessage());
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: [element=\"birthDate\"] Invalid attribute value \"2000-15-31\": Invalid date/time format: \"2000-15-31\"", e.getMessage());
}
}

View File

@ -1504,7 +1504,7 @@ public class JsonParserDstu3Test {
assertEquals("foo", parsed.getValueDateTimeType().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(), eq("foo"), msgCaptor.capture());
verify(errorHandler, times(1)).invalidValue(any(), eq("foo"), msgCaptor.capture());
assertEquals("Invalid date/time format: \"foo\"", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);
@ -1536,8 +1536,8 @@ public class JsonParserDstu3Test {
assertEquals(null, parsed.getGenderElement().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(), eq(""), msgCaptor.capture());
assertEquals("Attribute values must not be empty (\"\")", msgCaptor.getValue());
verify(errorHandler, times(1)).invalidValue(any(), eq(""), msgCaptor.capture());
assertEquals("Attribute value must not be empty (\"\")", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);
assertEquals("{\"resourceType\":\"Patient\"}", encoded);
@ -1556,7 +1556,7 @@ public class JsonParserDstu3Test {
assertEquals("foo", parsed.getGenderElement().getValueAsString());
ArgumentCaptor<String> msgCaptor = ArgumentCaptor.forClass(String.class);
verify(errorHandler, times(1)).invalidValue(isNull(), eq("foo"), msgCaptor.capture());
verify(errorHandler, times(1)).invalidValue(any(), eq("foo"), msgCaptor.capture());
assertEquals("Unknown AdministrativeGender code 'foo'", msgCaptor.getValue());
String encoded = ourCtx.newJsonParser().encodeResourceToString(parsed);

View File

@ -1542,7 +1542,7 @@ public class XmlParserDstu3Test {
parser.encodeResourceToString(p);
fail();
} catch (DataFormatException e) {
assertEquals("Extension contains both a value and nested extensions: Patient(res).extension", e.getMessage());
assertEquals("[element=\"Patient(res).extension\"] Extension contains both a value and nested extensions: [element=\"Patient(res).extension\"]", e.getMessage());
}
}
@ -3119,7 +3119,7 @@ public class XmlParserDstu3Test {
p.parseResource(resource);
fail();
} catch (DataFormatException e) {
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: Invalid attribute value \"1\": Invalid boolean string: '1'", e.getMessage());
assertEquals("DataFormatException at [[row,col {unknown-source}]: [2,4]]: [element=\"active\"] Invalid attribute value \"1\": Invalid boolean string: '1'", e.getMessage());
}
LenientErrorHandler errorHandler = new LenientErrorHandler();

View File

@ -350,7 +350,7 @@ public class JsonParserR4Test extends BaseTest {
parser.encodeResourceToString(p);
fail();
} catch (DataFormatException e) {
assertEquals("Extension contains both a value and nested extensions: Patient(res).extension", e.getMessage());
assertEquals("[element=\"Patient(res).extension\"] Extension contains both a value and nested extensions", e.getMessage());
}
}
@ -590,7 +590,7 @@ public class JsonParserR4Test extends BaseTest {
jsonParser.parseResource(Patient.class, input);
fail();
} catch (DataFormatException e) {
assertEquals("[element=\"value\"] Invalid attribute value \"\": Attribute value for element must not be empty (\"\")", e.getMessage());
assertEquals("[element=\"value\"] Invalid attribute value \"\": Attribute value must not be empty (\"\")", e.getMessage());
}
}