Skip to content

Commit

Permalink
[hotfix][docs] Clean up deprecation/unused warnings in tests for Conf…
Browse files Browse the repository at this point in the history
…igOptionsDocGenerator
  • Loading branch information
StephanEwen committed Feb 3, 2020
1 parent 4c21029 commit 2ce0409
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@
/**
* Tests for the {@link ConfigOptionsDocGenerator}.
*/
@SuppressWarnings("unused")
public class ConfigOptionsDocGeneratorTest {

@ClassRule
Expand All @@ -59,19 +60,21 @@ public class ConfigOptionsDocGeneratorTest {
static class TestConfigGroup {
public static ConfigOption<Integer> firstOption = ConfigOptions
.key("first.option.a")
.intType()
.defaultValue(2)
.withDescription("This is example description for the first option.");

public static ConfigOption<String> secondOption = ConfigOptions
.key("second.option.a")
.stringType()
.noDefaultValue()
.withDescription("This is long example description for the second option.");
}

private enum TestEnum {
VALUE_1,
VALUE_2,
VALUE_3;
VALUE_3
}

static class TypeTestConfigGroup {
Expand Down Expand Up @@ -209,34 +212,40 @@ static class TestConfigPrefix {
// should end up in the default group
public static ConfigOption<Integer> option1 = ConfigOptions
.key("a.option")
.intType()
.defaultValue(2);

// should end up in group1, perfect key-prefix match
public static ConfigOption<String> option2 = ConfigOptions
.key("a.b.option")
.stringType()
.noDefaultValue();

// should end up in group1, full key-prefix match
public static ConfigOption<Integer> option3 = ConfigOptions
.key("a.b.c.option")
.intType()
.defaultValue(2);

// should end up in group1, full key-prefix match for group 1, partial match for group 2
// checks that the generator remembers the last encountered root node
public static ConfigOption<Integer> option4 = ConfigOptions
.key("a.b.c.e.option")
.intType()
.defaultValue(2);

// should end up in the default group, since no group exists with prefix "a.c"
// checks that the generator does not ignore components (like ignoring "c" to find a match "a.b")
public static ConfigOption<String> option5 = ConfigOptions
.key("a.c.b.option")
.stringType()
.noDefaultValue();

// should end up in group2, full key-prefix match for group 2
// checks that the longest matching group is assigned
public static ConfigOption<Integer> option6 = ConfigOptions
.key("a.b.c.d.option")
.intType()
.defaultValue(2);
}

Expand Down Expand Up @@ -266,21 +275,25 @@ public void testLongestPrefixMatching() {
static class TestConfigMultipleSubGroup {
public static ConfigOption<Integer> firstOption = ConfigOptions
.key("first.option.a")
.intType()
.defaultValue(2)
.withDescription("This is example description for the first option.");

public static ConfigOption<String> secondOption = ConfigOptions
.key("second.option.a")
.stringType()
.noDefaultValue()
.withDescription("This is long example description for the second option.");

public static ConfigOption<Integer> thirdOption = ConfigOptions
.key("third.option.a")
.intType()
.defaultValue(2)
.withDescription("This is example description for the third option.");

public static ConfigOption<String> fourthOption = ConfigOptions
.key("fourth.option.a")
.stringType()
.noDefaultValue()
.withDescription("This is long example description for the fourth option.");
}
Expand Down Expand Up @@ -365,12 +378,14 @@ static class TestConfigGroupWithOverriddenDefault {
@Documentation.OverrideDefault("default_1")
public static ConfigOption<Integer> firstOption = ConfigOptions
.key("first.option.a")
.intType()
.defaultValue(2)
.withDescription("This is example description for the first option.");

@Documentation.OverrideDefault("default_2")
public static ConfigOption<String> secondOption = ConfigOptions
.key("second.option.a")
.stringType()
.noDefaultValue()
.withDescription("This is long example description for the second option.");
}
Expand Down Expand Up @@ -453,12 +468,14 @@ public void testCommonOptions() throws IOException, ClassNotFoundException {
static class TestConfigGroupWithExclusion {
public static ConfigOption<Integer> firstOption = ConfigOptions
.key("first.option.a")
.intType()
.defaultValue(2)
.withDescription("This is example description for the first option.");

@Documentation.ExcludeFromDocumentation
public static ConfigOption<String> excludedOption = ConfigOptions
.key("excluded.option.a")
.stringType()
.noDefaultValue()
.withDescription("This should not be documented.");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@
/**
* Collection of test {@link ConfigOptions ConfigOptions}.
*/
@SuppressWarnings("unused") // this class is only accessed reflectively
public class TestCommonOptions {

@Documentation.SectionOption(sections = {Documentation.SectionOption.SECTION_COMMON})
public static final ConfigOption<Integer> COMMON_OPTION = ConfigOptions
.key("first.option.a")
.intType()
.defaultValue(2)
.withDescription("This is the description for the common option.");

public static final ConfigOption<String> GENERIC_OPTION = ConfigOptions
.key("second.option.a")
.stringType()
.noDefaultValue()
.withDescription("This is the description for the generic option.");

Expand All @@ -43,6 +46,7 @@ public class TestCommonOptions {
position = 2)
public static final ConfigOption<Integer> COMMON_POSITIONED_OPTION = ConfigOptions
.key("third.option.a")
.intType()
.defaultValue(3)
.withDescription("This is the description for the positioned common option.");
}

0 comments on commit 2ce0409

Please sign in to comment.