Replace @MethodSource with @FieldSource
This commit is contained in:
@@ -24,16 +24,15 @@ import notion.api.v1.model.databases.query.filter.condition.NumberFilter;
|
||||
import notion.api.v1.model.databases.query.filter.condition.SelectFilter;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.FieldSource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.function.Supplier;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static org.springframework.batch.extensions.notion.Filter.where;
|
||||
import static java.util.function.Function.identity;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
import static org.springframework.batch.extensions.notion.Filter.where;
|
||||
|
||||
/**
|
||||
* @author Stefano Cordio
|
||||
@@ -41,7 +40,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
class FilterTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource({ "propertyFilters", "compoundFilters", "nestedFilters" })
|
||||
@FieldSource({ "PROPERTY_FILTERS", "COMPOUND_FILTERS", "NESTED_FILTERS" })
|
||||
void toQueryTopLevelFilter(Filter underTest, QueryTopLevelFilter expected) {
|
||||
// WHEN
|
||||
QueryTopLevelFilter result = underTest.toQueryTopLevelFilter();
|
||||
@@ -49,478 +48,462 @@ class FilterTests {
|
||||
then(result).usingRecursiveComparison().isEqualTo(expected);
|
||||
}
|
||||
|
||||
static Stream<Arguments> propertyFilters() {
|
||||
return Stream.of( //
|
||||
checkboxFilters(), //
|
||||
multiSelectFilters(), //
|
||||
numberFilters(), //
|
||||
selectFilters()) //
|
||||
.flatMap(identity());
|
||||
}
|
||||
|
||||
static Stream<Arguments> checkboxFilters() {
|
||||
return Stream.of(true, false)
|
||||
.flatMap(value -> Stream.of( //
|
||||
arguments( //
|
||||
where().checkbox("property").isEqualTo(value), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(value);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().checkbox("property").isNotEqualTo(value), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(value);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}))));
|
||||
}
|
||||
|
||||
static Stream<Arguments> multiSelectFilters() {
|
||||
return Stream.of( //
|
||||
static final List<Arguments> CHECKBOX_FILTERS = Stream.of(true, false)
|
||||
.flatMap(value -> Stream.of( //
|
||||
arguments( //
|
||||
where().multiSelect("property").contains("value"), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setContains("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").doesNotContain("value"), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setDoesNotContain("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
}
|
||||
|
||||
static Stream<Arguments> numberFilters() {
|
||||
return Stream.of( //
|
||||
arguments( //
|
||||
where().number("property").isEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setEquals(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isNotEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setDoesNotEqual(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isGreaterThan(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setGreaterThan(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isGreaterThanOrEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setGreaterThanOrEqualTo(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isLessThan(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setLessThan(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isLessThanOrEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setLessThanOrEqualTo(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
}
|
||||
|
||||
static Stream<Arguments> selectFilters() {
|
||||
return Stream.of( //
|
||||
arguments( //
|
||||
where().select("property").isEqualTo("value"), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEquals("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isNotEqualTo("value"), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setDoesNotEqual("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
}
|
||||
|
||||
static Stream<Arguments> compoundFilters() {
|
||||
return Stream.of(andFilters(), orFilters()).flatMap(identity());
|
||||
}
|
||||
|
||||
static Stream<Arguments> andFilters() {
|
||||
return Stream.of( //
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and().select("another").isNotEmpty(), //
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and(where().select("another").isNotEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and(where().select("another").isNotEmpty())
|
||||
.and().checkbox("one-more").isNotEqualTo(true)
|
||||
.and(where().select("another-more").isEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
}
|
||||
|
||||
static Stream<Arguments> orFilters() {
|
||||
return Stream.of( //
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or().select("another").isNotEmpty(),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or(where().select("another").isNotEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or(where().select("another").isNotEmpty())
|
||||
.or().checkbox("one-more").isNotEqualTo(true)
|
||||
.or(where().select("another-more").isEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
}
|
||||
|
||||
static Stream<Arguments> nestedFilters() {
|
||||
return Stream.of( //
|
||||
arguments( // @formatter:off
|
||||
where(where().checkbox("active").isEqualTo(true)),
|
||||
// @formatter:on
|
||||
where().checkbox("property").isEqualTo(value), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
checkboxFilter.setEquals(value);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(true)
|
||||
.and(where().select("another").isEmpty().or().select("another").isEqualTo("value")),
|
||||
// @formatter:on
|
||||
arguments( //
|
||||
where().checkbox("property").isNotEqualTo(value), //
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(value);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}))))
|
||||
.toList();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CompoundFilter innerFilter = new CompoundFilter();
|
||||
static final List<Arguments> MULTI_SELECT_FILTERS = List.of( //
|
||||
arguments( //
|
||||
where().multiSelect("property").contains("value"), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setContains("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").doesNotContain("value"), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setDoesNotContain("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().multiSelect("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
MultiSelectFilter multiSelectFilter = new MultiSelectFilter();
|
||||
multiSelectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setMultiSelect(multiSelectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
innerFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEquals("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
static final List<Arguments> NUMBER_FILTERS = List.of( //
|
||||
arguments( //
|
||||
where().number("property").isEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setEquals(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isNotEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setDoesNotEqual(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isGreaterThan(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setGreaterThan(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isGreaterThanOrEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setGreaterThanOrEqualTo(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isLessThan(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setLessThan(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isLessThanOrEqualTo(42), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setLessThanOrEqualTo(42);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().number("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
NumberFilter numberFilter = new NumberFilter();
|
||||
numberFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setNumber(numberFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return innerFilter;
|
||||
})));
|
||||
static final List<Arguments> SELECT_FILTERS = List.of( //
|
||||
arguments( //
|
||||
where().select("property").isEqualTo("value"), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEquals("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isNotEqualTo("value"), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setDoesNotEqual("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isEmpty(), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( //
|
||||
where().select("property").isNotEmpty(), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("property");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where(where().checkbox("active").isEqualTo(false)
|
||||
.or().select("another").isNotEmpty())
|
||||
.and().select("one-more").isEmpty(),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
static final List<Arguments> PROPERTY_FILTERS = Stream.of( //
|
||||
CHECKBOX_FILTERS, //
|
||||
MULTI_SELECT_FILTERS, //
|
||||
NUMBER_FILTERS, //
|
||||
SELECT_FILTERS) //
|
||||
.flatMap(List::stream)
|
||||
.toList();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CompoundFilter innerFilter = new CompoundFilter();
|
||||
static final List<Arguments> AND_FILTERS = List.of( //
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and().select("another").isNotEmpty(), //
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
innerFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return innerFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and(where().select("another").isNotEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
}
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.and(where().select("another").isNotEmpty())
|
||||
.and().checkbox("one-more").isNotEqualTo(true)
|
||||
.and(where().select("another-more").isEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
|
||||
static final List<Arguments> OR_FILTERS = List.of( //
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or().select("another").isNotEmpty(),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or(where().select("another").isNotEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(false)
|
||||
.or(where().select("another").isNotEmpty())
|
||||
.or().checkbox("one-more").isNotEqualTo(true)
|
||||
.or(where().select("another-more").isEmpty()),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setDoesNotEqual(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
|
||||
static final List<Arguments> COMPOUND_FILTERS = Stream.of(AND_FILTERS, OR_FILTERS).flatMap(List::stream).toList();
|
||||
|
||||
static final List<Arguments> NESTED_FILTERS = List.of( //
|
||||
arguments( // @formatter:off
|
||||
where(where().checkbox("active").isEqualTo(true)),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where().checkbox("active").isEqualTo(true)
|
||||
.and(where().select("another").isEmpty().or().select("another").isEqualTo("value")),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
CompoundFilter innerFilter = new CompoundFilter();
|
||||
|
||||
innerFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEquals("value");
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return innerFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})),
|
||||
arguments( // @formatter:off
|
||||
where(where().checkbox("active").isEqualTo(false)
|
||||
.or().select("another").isNotEmpty())
|
||||
.and().select("one-more").isEmpty(),
|
||||
// @formatter:on
|
||||
supply(() -> {
|
||||
CompoundFilter compoundFilter = new CompoundFilter();
|
||||
|
||||
compoundFilter.setAnd(List.of( //
|
||||
supply(() -> {
|
||||
CompoundFilter innerFilter = new CompoundFilter();
|
||||
|
||||
innerFilter.setOr(List.of( //
|
||||
supply(() -> {
|
||||
CheckboxFilter checkboxFilter = new CheckboxFilter();
|
||||
checkboxFilter.setEquals(false);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("active");
|
||||
propertyFilter.setCheckbox(checkboxFilter);
|
||||
return propertyFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setNotEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("another");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return innerFilter;
|
||||
}), //
|
||||
supply(() -> {
|
||||
SelectFilter selectFilter = new SelectFilter();
|
||||
selectFilter.setEmpty(true);
|
||||
PropertyFilter propertyFilter = new PropertyFilter("one-more");
|
||||
propertyFilter.setSelect(selectFilter);
|
||||
return propertyFilter;
|
||||
})));
|
||||
|
||||
return compoundFilter;
|
||||
})));
|
||||
|
||||
private static <T> T supply(Supplier<T> supplier) {
|
||||
return supplier.get();
|
||||
|
||||
@@ -20,14 +20,10 @@ import notion.api.v1.model.databases.query.sort.QuerySortDirection;
|
||||
import notion.api.v1.model.databases.query.sort.QuerySortTimestamp;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.FieldSource;
|
||||
|
||||
import java.util.stream.Stream;
|
||||
import java.util.List;
|
||||
|
||||
import static org.springframework.batch.extensions.notion.Sort.Direction.ASCENDING;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Direction.DESCENDING;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Timestamp.CREATED_TIME;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Timestamp.LAST_EDITED_TIME;
|
||||
import static notion.api.v1.model.databases.query.sort.QuerySortDirection.Ascending;
|
||||
import static notion.api.v1.model.databases.query.sort.QuerySortDirection.Descending;
|
||||
import static notion.api.v1.model.databases.query.sort.QuerySortTimestamp.CreatedTime;
|
||||
@@ -35,6 +31,10 @@ import static notion.api.v1.model.databases.query.sort.QuerySortTimestamp.LastEd
|
||||
import static org.assertj.core.api.BDDAssertions.from;
|
||||
import static org.assertj.core.api.BDDAssertions.then;
|
||||
import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Direction.ASCENDING;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Direction.DESCENDING;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Timestamp.CREATED_TIME;
|
||||
import static org.springframework.batch.extensions.notion.Sort.Timestamp.LAST_EDITED_TIME;
|
||||
|
||||
/**
|
||||
* @author Stefano Cordio
|
||||
@@ -42,7 +42,7 @@ import static org.junit.jupiter.params.provider.Arguments.arguments;
|
||||
class SortTests {
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
@FieldSource
|
||||
void toQuerySort(Sort underTest, String property, QuerySortTimestamp timestamp, QuerySortDirection direction) {
|
||||
// WHEN
|
||||
QuerySort result = underTest.toQuerySort();
|
||||
@@ -53,21 +53,19 @@ class SortTests {
|
||||
.returns(timestamp, from(QuerySort::getTimestamp));
|
||||
}
|
||||
|
||||
static Stream<Arguments> toQuerySort() {
|
||||
return Stream.of( //
|
||||
arguments(Sort.by("property"), "property", null, Ascending),
|
||||
arguments(Sort.by("property", ASCENDING), "property", null, Ascending),
|
||||
arguments(Sort.by("property", DESCENDING), "property", null, Descending),
|
||||
arguments(Sort.by(CREATED_TIME), null, CreatedTime, Ascending),
|
||||
arguments(Sort.by(CREATED_TIME, ASCENDING), null, CreatedTime, Ascending),
|
||||
arguments(Sort.by(CREATED_TIME, DESCENDING), null, CreatedTime, Descending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME), null, LastEditedTime, Ascending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, ASCENDING), null, LastEditedTime, Ascending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, DESCENDING), null, LastEditedTime, Descending));
|
||||
}
|
||||
static List<Arguments> toQuerySort = List.of( //
|
||||
arguments(Sort.by("property"), "property", null, Ascending),
|
||||
arguments(Sort.by("property", ASCENDING), "property", null, Ascending),
|
||||
arguments(Sort.by("property", DESCENDING), "property", null, Descending),
|
||||
arguments(Sort.by(CREATED_TIME), null, CreatedTime, Ascending),
|
||||
arguments(Sort.by(CREATED_TIME, ASCENDING), null, CreatedTime, Ascending),
|
||||
arguments(Sort.by(CREATED_TIME, DESCENDING), null, CreatedTime, Descending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME), null, LastEditedTime, Ascending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, ASCENDING), null, LastEditedTime, Ascending),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, DESCENDING), null, LastEditedTime, Descending));
|
||||
|
||||
@ParameterizedTest
|
||||
@MethodSource
|
||||
@FieldSource
|
||||
void testToString(Sort underTest, String expected) {
|
||||
// WHEN
|
||||
String result = underTest.toString();
|
||||
@@ -75,17 +73,15 @@ class SortTests {
|
||||
then(result).isEqualTo(expected);
|
||||
}
|
||||
|
||||
static Stream<Arguments> testToString() {
|
||||
return Stream.of( //
|
||||
arguments(Sort.by("property"), "property: ASCENDING"),
|
||||
arguments(Sort.by("property", ASCENDING), "property: ASCENDING"),
|
||||
arguments(Sort.by("property", DESCENDING), "property: DESCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME), "CREATED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME, ASCENDING), "CREATED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME, DESCENDING), "CREATED_TIME: DESCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME), "LAST_EDITED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, ASCENDING), "LAST_EDITED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, DESCENDING), "LAST_EDITED_TIME: DESCENDING"));
|
||||
}
|
||||
static List<Arguments> testToString = List.of( //
|
||||
arguments(Sort.by("property"), "property: ASCENDING"),
|
||||
arguments(Sort.by("property", ASCENDING), "property: ASCENDING"),
|
||||
arguments(Sort.by("property", DESCENDING), "property: DESCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME), "CREATED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME, ASCENDING), "CREATED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(CREATED_TIME, DESCENDING), "CREATED_TIME: DESCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME), "LAST_EDITED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, ASCENDING), "LAST_EDITED_TIME: ASCENDING"),
|
||||
arguments(Sort.by(LAST_EDITED_TIME, DESCENDING), "LAST_EDITED_TIME: DESCENDING"));
|
||||
|
||||
}
|
||||
|
||||
@@ -15,11 +15,11 @@
|
||||
*/
|
||||
package org.springframework.batch.extensions.notion.mapping;
|
||||
|
||||
import org.junit.jupiter.params.provider.MethodSource;
|
||||
import org.junit.jupiter.params.provider.FieldSource;
|
||||
|
||||
import java.lang.annotation.Retention;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
|
||||
@@ -29,31 +29,27 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
class TestData {
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@MethodSource("org.springframework.batch.extensions.notion.mapping.TestData#all_properties")
|
||||
@FieldSource("org.springframework.batch.extensions.notion.mapping.TestData#ALL_PROPERTIES")
|
||||
@interface AllPropertiesSource {
|
||||
|
||||
}
|
||||
|
||||
static Stream<Map<String, String>> all_properties() {
|
||||
return Stream.of(
|
||||
// FIXME not working with BeanWrapperPropertyMapper
|
||||
// Map.of("FIELD1", "Value1", "FIELD2", "Value2"), //
|
||||
Map.of("Field1", "Value1", "Field2", "Value2"), //
|
||||
Map.of("field1", "Value1", "field2", "Value2"));
|
||||
}
|
||||
static final List<Map<String, String>> ALL_PROPERTIES = List.of(
|
||||
// FIXME not working with BeanWrapperPropertyMapper
|
||||
// Map.of("FIELD1", "Value1", "FIELD2", "Value2"), //
|
||||
Map.of("Field1", "Value1", "Field2", "Value2"), //
|
||||
Map.of("field1", "Value1", "field2", "Value2"));
|
||||
|
||||
@Retention(RUNTIME)
|
||||
@MethodSource("org.springframework.batch.extensions.notion.mapping.TestData#partial_properties")
|
||||
@FieldSource("org.springframework.batch.extensions.notion.mapping.TestData#PARTIAL_PROPERTIES")
|
||||
@interface PartialPropertiesSource {
|
||||
|
||||
}
|
||||
|
||||
static Stream<Map<String, String>> partial_properties() {
|
||||
return Stream.of(
|
||||
// FIXME not working with BeanWrapperPropertyMapper
|
||||
// Map.of("FIELD1", "Value1"), //
|
||||
Map.of("Field1", "Value1"), //
|
||||
Map.of("field1", "Value1"));
|
||||
}
|
||||
static final List<Map<String, String>> PARTIAL_PROPERTIES = List.of(
|
||||
// FIXME not working with BeanWrapperPropertyMapper
|
||||
// Map.of("FIELD1", "Value1"), //
|
||||
Map.of("Field1", "Value1"), //
|
||||
Map.of("field1", "Value1"));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user