Merge branch 'master' of github.com:jamesagnew/hapi-fhir
This commit is contained in:
commit
c0d125f288
|
@ -30,13 +30,16 @@ import ca.uhn.fhir.model.base.resource.BaseOperationOutcome;
|
|||
*/
|
||||
public class ValidationResult {
|
||||
private BaseOperationOutcome myOperationOutcome;
|
||||
private boolean isSuccessful;
|
||||
|
||||
private ValidationResult(BaseOperationOutcome myOperationOutcome) {
|
||||
private ValidationResult(BaseOperationOutcome myOperationOutcome, boolean isSuccessful) {
|
||||
this.myOperationOutcome = myOperationOutcome;
|
||||
this.isSuccessful = isSuccessful;
|
||||
}
|
||||
|
||||
public static ValidationResult valueOf(BaseOperationOutcome myOperationOutcome) {
|
||||
return new ValidationResult(myOperationOutcome);
|
||||
boolean noIssues = myOperationOutcome == null || myOperationOutcome.getIssue().isEmpty();
|
||||
return new ValidationResult(myOperationOutcome, noIssues);
|
||||
}
|
||||
|
||||
public BaseOperationOutcome getOperationOutcome() {
|
||||
|
@ -47,6 +50,7 @@ public class ValidationResult {
|
|||
public String toString() {
|
||||
return "ValidationResult{" +
|
||||
"myOperationOutcome=" + myOperationOutcome +
|
||||
", isSuccessful=" + isSuccessful +
|
||||
", description='" + toDescription() + '\'' +
|
||||
'}';
|
||||
}
|
||||
|
@ -67,6 +71,6 @@ public class ValidationResult {
|
|||
* @return true if the validation was successful
|
||||
*/
|
||||
public boolean isSuccessful() {
|
||||
return myOperationOutcome == null || myOperationOutcome.getIssue().isEmpty();
|
||||
return isSuccessful;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,18 +1,19 @@
|
|||
package ca.uhn.fhir.model.primitive;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import org.apache.commons.lang3.time.FastDateFormat;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import ca.uhn.fhir.model.api.TemporalPrecisionEnum;
|
||||
import ca.uhn.fhir.parser.DataFormatException;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertNull;
|
||||
|
||||
public class BaseDateTimeDtTest {
|
||||
private SimpleDateFormat myDateInstantParser;
|
||||
|
@ -39,7 +40,7 @@ public class BaseDateTimeDtTest {
|
|||
Date instant = myDateInstantParser.parse("2001-02-03 13:01:02.555");
|
||||
for (FastDateFormat next : BaseDateTimeDt.getFormatters()) {
|
||||
|
||||
GregorianCalendar cal = new GregorianCalendar(TimeZone.getTimeZone("EST"));
|
||||
Calendar cal = Calendar.getInstance();
|
||||
cal.setTime(instant);
|
||||
String value = next.format(cal);
|
||||
ourLog.info("String: {}", value);
|
||||
|
|
|
@ -2,7 +2,6 @@ package ca.uhn.fhir.validation;
|
|||
|
||||
import ca.uhn.fhir.model.base.resource.BaseOperationOutcome.BaseIssue;
|
||||
import ca.uhn.fhir.model.dstu.resource.OperationOutcome;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.List;
|
||||
|
@ -45,4 +44,17 @@ public class ValidationResultTest {
|
|||
|
||||
assertThat("ValidationResult#toString should contain the issue description", result.toString(), containsString(errorMessage));
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
Test for https://github.com/jamesagnew/hapi-fhir/issues/51
|
||||
*/
|
||||
@Test
|
||||
public void toString_ShouldNotCauseResultToBecomeFailure() {
|
||||
OperationOutcome operationOutcome = new OperationOutcome();
|
||||
ValidationResult result = ValidationResult.valueOf(operationOutcome);
|
||||
assertEquals(true, result.isSuccessful());
|
||||
// need to call toString to make sure any unwanted side effects are generated
|
||||
@SuppressWarnings("UnusedDeclaration") String unused = result.toString();
|
||||
assertEquals(true, result.isSuccessful());
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue