Skip to content

Commit

Permalink
use MethodSource instead of FieldSource
Browse files Browse the repository at this point in the history
  • Loading branch information
miklcct committed Dec 12, 2024
1 parent b667e96 commit d12373f
Showing 1 changed file with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,29 @@
import static org.opentripplanner.utils.color.ColorUtils.computeBrightness;

import java.awt.Color;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.FieldSource;
import org.junit.jupiter.params.provider.MethodSource;

public class ColorUtilsTest {

static final Arguments[] brightnessExpectations = {
arguments(Color.black, Brightness.DARK),
arguments(Color.green, Brightness.LIGHT),
arguments(Color.blue, Brightness.DARK),
arguments(Color.red, Brightness.LIGHT),
arguments(Color.yellow, Brightness.LIGHT),
arguments(Color.white, Brightness.LIGHT),
arguments(Color.pink, Brightness.LIGHT),
arguments(Color.orange, Brightness.LIGHT),
arguments(Color.cyan, Brightness.LIGHT),
};
private static Stream<Arguments> brightnessExpectations() {
return Stream.of(
arguments(Color.black, Brightness.DARK),
arguments(Color.green, Brightness.LIGHT),
arguments(Color.blue, Brightness.DARK),
arguments(Color.red, Brightness.LIGHT),
arguments(Color.yellow, Brightness.LIGHT),
arguments(Color.white, Brightness.LIGHT),
arguments(Color.pink, Brightness.LIGHT),
arguments(Color.orange, Brightness.LIGHT),
arguments(Color.cyan, Brightness.LIGHT)
);
}

@ParameterizedTest
@FieldSource("brightnessExpectations")
@MethodSource("brightnessExpectations")
void testBrightness(Color color, Brightness brightness) {
assertEquals(computeBrightness(color), brightness);
}
Expand Down

0 comments on commit d12373f

Please sign in to comment.