Introduce new validator cliContext option disableDefaultResourceFetcher (#1526)
* introduce new cliContext option doNotFetchUnknownProfiles * rename parameter to disable-default-resource-fetcher * missed renaming a couple items * review feedback
This commit is contained in:
parent
7761be6197
commit
f1096a8ebd
|
@ -56,6 +56,8 @@ public class CliContext {
|
||||||
private HtmlInMarkdownCheck htmlInMarkdownCheck = HtmlInMarkdownCheck.WARNING;
|
private HtmlInMarkdownCheck htmlInMarkdownCheck = HtmlInMarkdownCheck.WARNING;
|
||||||
@JsonProperty("allowDoubleQuotesInFHIRPath")
|
@JsonProperty("allowDoubleQuotesInFHIRPath")
|
||||||
private boolean allowDoubleQuotesInFHIRPath = false;
|
private boolean allowDoubleQuotesInFHIRPath = false;
|
||||||
|
@JsonProperty("disableDefaultResourceFetcher")
|
||||||
|
private boolean disableDefaultResourceFetcher = false;
|
||||||
@JsonProperty("checkIPSCodes")
|
@JsonProperty("checkIPSCodes")
|
||||||
private boolean checkIPSCodes;
|
private boolean checkIPSCodes;
|
||||||
@JsonProperty("langTransform")
|
@JsonProperty("langTransform")
|
||||||
|
@ -328,6 +330,17 @@ public class CliContext {
|
||||||
this.allowDoubleQuotesInFHIRPath = allowDoubleQuotesInFHIRPath;
|
this.allowDoubleQuotesInFHIRPath = allowDoubleQuotesInFHIRPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@JsonProperty("disableDefaultResourceFetcher")
|
||||||
|
public boolean isDisableDefaultResourceFetcher() {
|
||||||
|
return disableDefaultResourceFetcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonProperty("disableDefaultResourceFetcher")
|
||||||
|
public CliContext setDisableDefaultResourceFetcher(boolean disableDefaultResourceFetcher) {
|
||||||
|
this.disableDefaultResourceFetcher = disableDefaultResourceFetcher;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
@JsonProperty("checkIPSCodes")
|
@JsonProperty("checkIPSCodes")
|
||||||
public boolean isCheckIPSCodes() {
|
public boolean isCheckIPSCodes() {
|
||||||
return checkIPSCodes;
|
return checkIPSCodes;
|
||||||
|
|
|
@ -524,9 +524,11 @@ public class ValidationService {
|
||||||
validationEngine.setForPublication(cliContext.isForPublication());
|
validationEngine.setForPublication(cliContext.isForPublication());
|
||||||
validationEngine.setShowTimes(cliContext.isShowTimes());
|
validationEngine.setShowTimes(cliContext.isShowTimes());
|
||||||
validationEngine.setAllowExampleUrls(cliContext.isAllowExampleUrls());
|
validationEngine.setAllowExampleUrls(cliContext.isAllowExampleUrls());
|
||||||
|
if (!cliContext.isDisableDefaultResourceFetcher()) {
|
||||||
StandAloneValidatorFetcher fetcher = new StandAloneValidatorFetcher(validationEngine.getPcm(), validationEngine.getContext(), validationEngine);
|
StandAloneValidatorFetcher fetcher = new StandAloneValidatorFetcher(validationEngine.getPcm(), validationEngine.getContext(), validationEngine);
|
||||||
validationEngine.setFetcher(fetcher);
|
validationEngine.setFetcher(fetcher);
|
||||||
validationEngine.getContext().setLocator(fetcher);
|
validationEngine.getContext().setLocator(fetcher);
|
||||||
|
}
|
||||||
validationEngine.getBundleValidationRules().addAll(cliContext.getBundleValidationRules());
|
validationEngine.getBundleValidationRules().addAll(cliContext.getBundleValidationRules());
|
||||||
validationEngine.setJurisdiction(CodeSystemUtilities.readCoding(cliContext.getJurisdiction()));
|
validationEngine.setJurisdiction(CodeSystemUtilities.readCoding(cliContext.getJurisdiction()));
|
||||||
TerminologyCache.setNoCaching(cliContext.isNoInternalCaching());
|
TerminologyCache.setNoCaching(cliContext.isNoInternalCaching());
|
||||||
|
|
|
@ -89,6 +89,7 @@ public class Params {
|
||||||
public static final String SRC_LANG = "-src-lang";
|
public static final String SRC_LANG = "-src-lang";
|
||||||
public static final String TGT_LANG = "-tgt-lang";
|
public static final String TGT_LANG = "-tgt-lang";
|
||||||
public static final String ALLOW_DOUBLE_QUOTES = "-allow-double-quotes-in-fhirpath";
|
public static final String ALLOW_DOUBLE_QUOTES = "-allow-double-quotes-in-fhirpath";
|
||||||
|
public static final String DISABLE_DEFAULT_RESOURCE_FETCHER = "-disable-default-resource-fetcher";
|
||||||
public static final String CHECK_IPS_CODES = "-check-ips-codes";
|
public static final String CHECK_IPS_CODES = "-check-ips-codes";
|
||||||
public static final String BEST_PRACTICE = "-best-practice";
|
public static final String BEST_PRACTICE = "-best-practice";
|
||||||
|
|
||||||
|
@ -270,6 +271,8 @@ public class Params {
|
||||||
cliContext.setNoExtensibleBindingMessages(true);
|
cliContext.setNoExtensibleBindingMessages(true);
|
||||||
} else if (args[i].equals(ALLOW_DOUBLE_QUOTES)) {
|
} else if (args[i].equals(ALLOW_DOUBLE_QUOTES)) {
|
||||||
cliContext.setAllowDoubleQuotesInFHIRPath(true);
|
cliContext.setAllowDoubleQuotesInFHIRPath(true);
|
||||||
|
} else if (args[i].equals(DISABLE_DEFAULT_RESOURCE_FETCHER)) {
|
||||||
|
cliContext.setDisableDefaultResourceFetcher(true);
|
||||||
} else if (args[i].equals(CHECK_IPS_CODES)) {
|
} else if (args[i].equals(CHECK_IPS_CODES)) {
|
||||||
cliContext.setCheckIPSCodes(true);
|
cliContext.setCheckIPSCodes(true);
|
||||||
} else if (args[i].equals(NO_UNICODE_BIDI_CONTROL_CHARS)) {
|
} else if (args[i].equals(NO_UNICODE_BIDI_CONTROL_CHARS)) {
|
||||||
|
|
|
@ -10,8 +10,10 @@ import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.ArgumentMatchers.endsWith;
|
import static org.mockito.ArgumentMatchers.endsWith;
|
||||||
import static org.mockito.ArgumentMatchers.eq;
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.ArgumentMatchers.isNull;
|
import static org.mockito.ArgumentMatchers.isNull;
|
||||||
|
import static org.mockito.ArgumentMatchers.notNull;
|
||||||
import static org.mockito.ArgumentMatchers.startsWith;
|
import static org.mockito.ArgumentMatchers.startsWith;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
|
import static org.mockito.Mockito.never;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
|
|
||||||
|
@ -236,17 +238,43 @@ class ValidationServiceTest {
|
||||||
*/
|
*/
|
||||||
@Test
|
@Test
|
||||||
public void buildValidationEngineTest() throws IOException, URISyntaxException {
|
public void buildValidationEngineTest() throws IOException, URISyntaxException {
|
||||||
|
final TimeTracker timeTracker = mock(TimeTracker.class);
|
||||||
final org.hl7.fhir.utilities.TimeTracker timeTracker = mock(org.hl7.fhir.utilities.TimeTracker.class);
|
|
||||||
|
|
||||||
final SimpleWorkerContext workerContext = mock(SimpleWorkerContext.class);
|
final SimpleWorkerContext workerContext = mock(SimpleWorkerContext.class);
|
||||||
|
|
||||||
final ValidationEngine validationEngine = mock(ValidationEngine.class);
|
final ValidationEngine mockValidationEngine = mock(ValidationEngine.class);
|
||||||
when(validationEngine.getContext()).thenReturn(workerContext);
|
when(mockValidationEngine.getContext()).thenReturn(workerContext);
|
||||||
|
|
||||||
final ValidationEngine.ValidationEngineBuilder validationEngineBuilder = mock(ValidationEngine.ValidationEngineBuilder.class);;
|
final ValidationEngine.ValidationEngineBuilder mockValidationEngineBuilder = mock(ValidationEngine.ValidationEngineBuilder.class);;
|
||||||
|
final ValidationService validationService = createFakeValidationService(mockValidationEngineBuilder, mockValidationEngine);
|
||||||
|
|
||||||
final ValidationService validationService = new ValidationService() {
|
CliContext cliContext = new CliContext();
|
||||||
|
validationService.buildValidationEngine(cliContext, null, timeTracker);
|
||||||
|
|
||||||
|
verify(mockValidationEngine).setFetcher(notNull());
|
||||||
|
verify(mockValidationEngineBuilder).withUserAgent(eq("fhir/validator/" + VersionUtil.getVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void buildValidationEngineDisableDefaultResourceFetcherTest() throws IOException, URISyntaxException {
|
||||||
|
final TimeTracker timeTracker = mock(TimeTracker.class);
|
||||||
|
final SimpleWorkerContext workerContext = mock(SimpleWorkerContext.class);
|
||||||
|
|
||||||
|
final ValidationEngine mockValidationEngine = mock(ValidationEngine.class);
|
||||||
|
when(mockValidationEngine.getContext()).thenReturn(workerContext);
|
||||||
|
|
||||||
|
final ValidationEngine.ValidationEngineBuilder mockValidationEngineBuilder = mock(ValidationEngine.ValidationEngineBuilder.class);;
|
||||||
|
final ValidationService validationService = createFakeValidationService(mockValidationEngineBuilder, mockValidationEngine);
|
||||||
|
|
||||||
|
CliContext cliContext = new CliContext();
|
||||||
|
cliContext.setDisableDefaultResourceFetcher(true);
|
||||||
|
validationService.buildValidationEngine(cliContext, null, timeTracker);
|
||||||
|
|
||||||
|
verify(mockValidationEngine, never()).setFetcher(any());
|
||||||
|
verify(mockValidationEngineBuilder).withUserAgent(eq("fhir/validator/" + VersionUtil.getVersion()));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static ValidationService createFakeValidationService(ValidationEngine.ValidationEngineBuilder validationEngineBuilder, ValidationEngine validationEngine) {
|
||||||
|
return new ValidationService() {
|
||||||
@Override
|
@Override
|
||||||
protected ValidationEngine.ValidationEngineBuilder getValidationEngineBuilder() {
|
protected ValidationEngine.ValidationEngineBuilder getValidationEngineBuilder() {
|
||||||
when(validationEngineBuilder.withTHO(anyBoolean())).thenReturn(validationEngineBuilder);
|
when(validationEngineBuilder.withTHO(anyBoolean())).thenReturn(validationEngineBuilder);
|
||||||
|
@ -268,11 +296,5 @@ class ValidationServiceTest {
|
||||||
//Don't care. Do nothing.
|
//Don't care. Do nothing.
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
CliContext cliContext = new CliContext();
|
|
||||||
|
|
||||||
validationService.buildValidationEngine(cliContext, null, timeTracker);
|
|
||||||
|
|
||||||
verify(validationEngineBuilder).withUserAgent(eq("fhir/validator/" + VersionUtil.getVersion()));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue