Skip to content

Commit

Permalink
Addresses comments from code review.
Browse files Browse the repository at this point in the history
* Makes a method name change.
* asserts that exception strings in the RequiredFilterValuesTest are as expected.
  • Loading branch information
eibakke committed Nov 27, 2024
1 parent 81980ba commit a621865
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ public static GraphQLFieldDefinition createQuery(GraphQLOutputType datedServiceJ
"privateCodes",
environment.<List<String>>getArgument("privateCodes")
);
var operatingDays = FilterValues.ofEmptyIsInvalid(
var operatingDays = FilterValues.ofRequired(
"operatingDays",
environment.<List<LocalDate>>getArgument("operatingDays")
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public static <E> FilterValues<E> ofEmptyIsEverything(
* @param values - The {@link Collection} of filter values.
* @return RequiredFilterValues
*/
public static <E> RequiredFilterValues<E> ofEmptyIsInvalid(
public static <E> RequiredFilterValues<E> ofRequired(
String name,
@Nullable Collection<E> values
) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,22 +9,24 @@ class RequiredFilterValuesTest {

@Test
void testEmptyIsInvalid() {
assertThrows(
IllegalArgumentException e = assertThrows(
IllegalArgumentException.class,
() -> {
FilterValues.ofEmptyIsInvalid("empty", List.of());
FilterValues.ofRequired("empty", List.of());
}
);
assertEquals("Filter empty values must not be empty.", e.getMessage());
}

@Test
void testNullIsInvalid() {
List<String> nullList = null;
assertThrows(
IllegalArgumentException e = assertThrows(
IllegalArgumentException.class,
() -> {
FilterValues.ofEmptyIsInvalid("null", nullList);
FilterValues.ofRequired("null", nullList);
}
);
assertEquals("Filter null values must not be empty.", e.getMessage());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void setup() {
@Test
void testMatchOperatingDays() {
TripOnServiceDateRequest request = TripOnServiceDateRequest
.of(FilterValues.ofEmptyIsInvalid("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.build();

Matcher<TripOnServiceDate> matcher = TripOnServiceDateMatcherFactory.of(request);
Expand All @@ -116,7 +116,7 @@ void testMatchOperatingDays() {
@Test
void testMatchMultiple() {
TripOnServiceDateRequest request = TripOnServiceDateRequest
.of(FilterValues.ofEmptyIsInvalid("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.withAgencies(
FilterValues.ofEmptyIsEverything("agencies", List.of(new FeedScopedId("F", "RUT:1")))
)
Expand All @@ -141,7 +141,7 @@ void testMatchMultiple() {
@Test
void testMatchMultipleServiceJourneyMatchers() {
TripOnServiceDateRequest request = TripOnServiceDateRequest
.of(FilterValues.ofEmptyIsInvalid("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.of(FilterValues.ofRequired("serviceDates", List.of(LocalDate.of(2024, 2, 22))))
.withAgencies(
FilterValues.ofEmptyIsEverything(
"agencies",
Expand Down

0 comments on commit a621865

Please sign in to comment.