Skip to content

Commit

Permalink
[hotfix] Migrate ReadableWritableConfigurationTest to Junit5 and AssertJ
Browse files Browse the repository at this point in the history
  • Loading branch information
JunRuiLee authored and zhuzhurk committed Nov 30, 2023
1 parent c3db044 commit 20339ea
Showing 1 changed file with 13 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,13 @@
package org.apache.flink.configuration;

import org.apache.flink.api.java.tuple.Tuple2;
import org.apache.flink.testutils.junit.extensions.parameterized.Parameter;
import org.apache.flink.testutils.junit.extensions.parameterized.ParameterizedTestExtension;
import org.apache.flink.testutils.junit.extensions.parameterized.Parameters;
import org.apache.flink.util.Preconditions;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.jupiter.api.TestTemplate;
import org.junit.jupiter.api.extension.ExtendWith;

import java.time.Duration;
import java.util.Arrays;
Expand Down Expand Up @@ -52,9 +54,10 @@
* ReadableConfig#getOptional(ConfigOption)}.
* </ol>
*/
@RunWith(Parameterized.class)
@ExtendWith(ParameterizedTestExtension.class)
public class ReadableWritableConfigurationTest {
@Parameterized.Parameters(name = "{0}")

@Parameters(name = "{0}")
public static Collection<TestSpec<?>> getSpecs() {
return Arrays.asList(
new TestSpec<>(ConfigOptions.key("int").intType().defaultValue(-1))
Expand Down Expand Up @@ -135,9 +138,9 @@ private static Map<String, String> asMap(List<Tuple2<String, String>> entries) {
return entries.stream().collect(Collectors.toMap(t -> t.f0, t -> t.f1));
}

@Parameterized.Parameter public TestSpec<?> testSpec;
@Parameter public TestSpec<?> testSpec;

@Test
@TestTemplate
public void testGetOptionalFromObject() {
Configuration configuration = new Configuration();
testSpec.setValue(configuration);
Expand All @@ -146,7 +149,7 @@ public void testGetOptionalFromObject() {
assertThat(optional.get(), equalTo(testSpec.getValue()));
}

@Test
@TestTemplate
public void testGetOptionalFromString() {
ConfigOption<?> option = testSpec.getOption();
Configuration configuration = new Configuration();
Expand All @@ -156,7 +159,7 @@ public void testGetOptionalFromString() {
assertThat(optional.get(), equalTo(testSpec.getValue()));
}

@Test
@TestTemplate
public void testGetDefaultValue() {
Configuration configuration = new Configuration();

Expand All @@ -165,7 +168,7 @@ public void testGetDefaultValue() {
assertThat(value, equalTo(option.defaultValue()));
}

@Test
@TestTemplate
@SuppressWarnings("unchecked")
public void testGetOptionalDefaultValueOverride() {
ReadableConfig configuration = new Configuration();
Expand Down

0 comments on commit 20339ea

Please sign in to comment.