Add changelog. Address MR comments.
This commit is contained in:
parent
ee1f1fb5b8
commit
1e9163c636
|
@ -83,15 +83,15 @@ public class ValidationResult {
|
|||
|
||||
StringBuilder b = new StringBuilder(100 * myMessages.size());
|
||||
int shownMsgQty = Math.min(myErrorDisplayLimit, myMessages.size());
|
||||
|
||||
if (shownMsgQty < myMessages.size()) {
|
||||
b.append("(showing first ").append(shownMsgQty).append(" messages out of ")
|
||||
.append(myMessages.size()).append(" total)").append(ourNewLine);
|
||||
}
|
||||
|
||||
for (int i = 0; i < shownMsgQty; i++) {
|
||||
SingleValidationMessage nextMsg = myMessages.get(i);
|
||||
b.append(ourNewLine);
|
||||
if (i == 0) {
|
||||
if (shownMsgQty < myMessages.size()) {
|
||||
b.append("(showing first ").append(shownMsgQty).append(" messages out of ")
|
||||
.append(myMessages.size()).append(" total)").append(ourNewLine);
|
||||
}
|
||||
}
|
||||
if (nextMsg.getSeverity() != null) {
|
||||
b.append(nextMsg.getSeverity().name());
|
||||
b.append(" - ");
|
||||
|
|
|
@ -95,7 +95,7 @@ public abstract class BaseRequestGeneratingCommand extends BaseCommand {
|
|||
/**
|
||||
* @return Returns the optional pass-through header name and value
|
||||
*/
|
||||
protected Map<String, List<String>> getAndParseOptionHeadersPassthrough(
|
||||
private Map<String, List<String>> getAndParseOptionHeadersPassthrough(
|
||||
CommandLine theCommandLine, String theOptionName) throws ParseException {
|
||||
|
||||
if (! theCommandLine.hasOption(theOptionName)) {
|
||||
|
|
|
@ -1,23 +1,33 @@
|
|||
package ca.uhn.fhir.cli;
|
||||
|
||||
import ca.uhn.fhir.cli.BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.cli.CommandLine;
|
||||
import org.apache.commons.cli.Options;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.EnumSource;
|
||||
|
||||
import java.security.InvalidParameterException;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import static ca.uhn.fhir.cli.BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.BASIC_AUTH;
|
||||
import static ca.uhn.fhir.cli.BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.HEADER_PASSTHROUGH;
|
||||
import static ca.uhn.fhir.cli.BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.VERSION;
|
||||
import static ca.uhn.fhir.cli.BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.values;
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class BaseRequestGeneratingCommandTest {
|
||||
|
||||
private final BaseRequestGeneratingCommand tested = new BaseRequestGeneratingCommandChild();
|
||||
|
||||
private final List<BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions> allOptions =
|
||||
Arrays.asList(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.values());
|
||||
private final List<BaseRequestGeneratingCommandOptions> allOptions =
|
||||
Arrays.asList(values());
|
||||
|
||||
@Test
|
||||
void getOptions() {
|
||||
|
@ -31,70 +41,59 @@ class BaseRequestGeneratingCommandTest {
|
|||
assertTrue(options.hasShortOption(BaseRequestGeneratingCommand.HEADER_PASSTHROUGH));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSomeOptionsNoVersion() {
|
||||
Options options = tested.getSomeOptions(
|
||||
Collections.singleton(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.VERSION));
|
||||
assertEquals(5, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASE_URL_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASIC_AUTH_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BEARER_TOKEN_PARAM_NAME));
|
||||
assertTrue(options.hasShortOption(BaseCommand.VERBOSE_LOGGING_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseRequestGeneratingCommand.HEADER_PASSTHROUGH));
|
||||
@ParameterizedTest(name = "Excluding {0}")
|
||||
@EnumSource(value = BaseRequestGeneratingCommandOptions.class,
|
||||
names = {"VERSION", "BASE_URL", "BASIC_AUTH", "VERBOSE_LOGGING", "HEADER_PASSTHROUGH"})
|
||||
void getSomeOptionsExcludingOne(BaseRequestGeneratingCommandOptions excludedOption) {
|
||||
Collection<BaseRequestGeneratingCommandOptions> excludeOptions = Collections.singleton(excludedOption);
|
||||
|
||||
Options options = tested.getSomeOptions(excludeOptions);
|
||||
|
||||
// BASIC_AUTH exclusion excludes 2 options
|
||||
int expectedSize = excludedOption == BASIC_AUTH ? 4 : 5;
|
||||
assertEquals(expectedSize, options.getOptions().size());
|
||||
|
||||
assertFalse(options.hasShortOption(getOptionForExcludedOption(excludedOption)));
|
||||
if (excludedOption == BASIC_AUTH) {
|
||||
assertFalse(options.hasLongOption(BaseCommand.BEARER_TOKEN_PARAM_LONGOPT));
|
||||
}
|
||||
|
||||
Arrays.stream(values())
|
||||
.filter(excludeOptValue -> ! excludeOptValue.equals(excludedOption))
|
||||
.forEach(excludeOptValue -> {
|
||||
assertTrue(options.hasShortOption(getOptionForExcludedOption(excludeOptValue)));
|
||||
// BASIC_AUTH option carries additional BEARER_TOKEN option
|
||||
if (excludedOption != BASIC_AUTH) {
|
||||
assertTrue(options.hasLongOption(BaseCommand.BEARER_TOKEN_PARAM_LONGOPT));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSomeOptionsNoBaseUrl() {
|
||||
Options options = tested.getSomeOptions(
|
||||
Collections.singleton(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.BASE_URL));
|
||||
assertEquals(5, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.FHIR_VERSION_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASIC_AUTH_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BEARER_TOKEN_PARAM_NAME));
|
||||
assertTrue(options.hasShortOption(BaseCommand.VERBOSE_LOGGING_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseRequestGeneratingCommand.HEADER_PASSTHROUGH));
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSomeOptionsNoBasicAuth() {
|
||||
Options options = tested.getSomeOptions(
|
||||
Collections.singleton(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.BASIC_AUTH));
|
||||
assertEquals(4, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.FHIR_VERSION_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASE_URL_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.VERBOSE_LOGGING_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseRequestGeneratingCommand.HEADER_PASSTHROUGH));
|
||||
}
|
||||
private String getOptionForExcludedOption(BaseRequestGeneratingCommandOptions excludeOption) {
|
||||
switch (excludeOption) {
|
||||
case VERSION:
|
||||
return BaseCommand.FHIR_VERSION_PARAM;
|
||||
|
||||
@Test
|
||||
void getSomeOptionsNoVerboseLogging() {
|
||||
Options options = tested.getSomeOptions(
|
||||
Collections.singleton(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.VERBOSE_LOGGING));
|
||||
assertEquals(5, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.FHIR_VERSION_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASE_URL_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASIC_AUTH_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BEARER_TOKEN_PARAM_NAME));
|
||||
assertTrue(options.hasShortOption(BaseRequestGeneratingCommand.HEADER_PASSTHROUGH));
|
||||
}
|
||||
case BASE_URL:
|
||||
return BaseCommand.BASE_URL_PARAM;
|
||||
|
||||
@Test
|
||||
void getSomeOptionsNoHeaderPassthrough() {
|
||||
Options options = tested.getSomeOptions(
|
||||
Collections.singleton(BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.HEADER_PASSTHROUGH));
|
||||
assertEquals(5, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.FHIR_VERSION_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASE_URL_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASIC_AUTH_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BEARER_TOKEN_PARAM_NAME));
|
||||
assertTrue(options.hasShortOption(BaseCommand.VERBOSE_LOGGING_PARAM));
|
||||
case BASIC_AUTH:
|
||||
return BaseCommand.BASIC_AUTH_PARAM;
|
||||
|
||||
case VERBOSE_LOGGING:
|
||||
return BaseCommand.VERBOSE_LOGGING_PARAM;
|
||||
|
||||
case HEADER_PASSTHROUGH:
|
||||
return BaseRequestGeneratingCommand.HEADER_PASSTHROUGH;
|
||||
}
|
||||
throw new InvalidParameterException("unexpected exclude option " + excludeOption);
|
||||
}
|
||||
|
||||
@Test
|
||||
void getSomeOptionsExcludeTwo() {
|
||||
Options options = tested.getSomeOptions(Lists.newArrayList(
|
||||
BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.VERSION,
|
||||
BaseRequestGeneratingCommand.BaseRequestGeneratingCommandOptions.HEADER_PASSTHROUGH));
|
||||
Options options = tested.getSomeOptions(Lists.newArrayList(VERSION, HEADER_PASSTHROUGH));
|
||||
|
||||
assertEquals(4, options.getOptions().size());
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASE_URL_PARAM));
|
||||
assertTrue(options.hasShortOption(BaseCommand.BASIC_AUTH_PARAM));
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
type: add
|
||||
issue: 2777
|
||||
title: "Support for multiple header-passthrough option using <b>-hp</b> or <b>--header-passthrough</b>
|
||||
parameter has been added to hapi-fhir-cli commands: <b>example-data-uploader</b>, <b>export-conceptmap-to-csv</b>,
|
||||
<b>import-csv-to-conceptmap</b> and <b>upload-terminology</b>"
|
||||
|
Loading…
Reference in New Issue