diff --git a/api/src/main/java/jakarta/data/BasicRestriction.java b/api/src/main/java/jakarta/data/BasicRestriction.java index 0cc17338..d044da66 100644 --- a/api/src/main/java/jakarta/data/BasicRestriction.java +++ b/api/src/main/java/jakarta/data/BasicRestriction.java @@ -18,9 +18,9 @@ package jakarta.data; public interface BasicRestriction extends Restriction { - Operator comparison(); + String attribute(); - String field(); + Operator comparison(); @Override BasicRestriction negate(); diff --git a/api/src/main/java/jakarta/data/BasicRestrictionRecord.java b/api/src/main/java/jakarta/data/BasicRestrictionRecord.java index dfedc845..4667f9ce 100644 --- a/api/src/main/java/jakarta/data/BasicRestrictionRecord.java +++ b/api/src/main/java/jakarta/data/BasicRestrictionRecord.java @@ -24,18 +24,18 @@ import java.util.Objects; record BasicRestrictionRecord( - String field, + String attribute, Operator comparison, Object value) implements BasicRestriction { BasicRestrictionRecord { - Objects.requireNonNull(field, "Field must not be null"); + Objects.requireNonNull(attribute, "Attribute must not be null"); } @Override public BasicRestriction negate() { return new BasicRestrictionRecord<>( - field, + attribute, comparison.negate(), value); } diff --git a/api/src/main/java/jakarta/data/Restrict.java b/api/src/main/java/jakarta/data/Restrict.java index c9e402ad..9ba7dc49 100644 --- a/api/src/main/java/jakarta/data/Restrict.java +++ b/api/src/main/java/jakarta/data/Restrict.java @@ -53,83 +53,83 @@ public static Restriction any(Restriction... restrictions) { public static > Restriction between(V min, V max, - String field) { - return all(greaterThanEqual(min, field), - lessThanEqual(max, field)); + String attribute) { + return all(greaterThanEqual(min, attribute), + lessThanEqual(max, attribute)); } // TODO Need to think more about how to best cover negation of multiple // and then make negation of Single consistent with it - public static TextRestriction contains(String substring, String field) { + public static TextRestriction contains(String substring, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, true, substring, true); - return new TextRestrictionRecord<>(field, Operator.LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.LIKE, ESCAPED, pattern); } - public static TextRestriction endsWith(String suffix, String field) { + public static TextRestriction endsWith(String suffix, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, true, suffix, false); - return new TextRestrictionRecord<>(field, Operator.LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.LIKE, ESCAPED, pattern); } - public static Restriction equalTo(Object value, String field) { - return new BasicRestrictionRecord<>(field, Operator.EQUAL, value); + public static Restriction equalTo(Object value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.EQUAL, value); } - public static TextRestriction equalTo(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.EQUAL, value); + public static TextRestriction equalTo(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.EQUAL, value); } - public static > Restriction greaterThan(V value, String field) { - return new BasicRestrictionRecord<>(field, Operator.GREATER_THAN, value); + public static > Restriction greaterThan(V value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.GREATER_THAN, value); } - public static TextRestriction greaterThan(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.GREATER_THAN, value); + public static TextRestriction greaterThan(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.GREATER_THAN, value); } - public static > Restriction greaterThanEqual(V value, String field) { - return new BasicRestrictionRecord<>(field, Operator.GREATER_THAN_EQUAL, value); + public static > Restriction greaterThanEqual(V value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.GREATER_THAN_EQUAL, value); } - public static TextRestriction greaterThanEqual(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.GREATER_THAN_EQUAL, value); + public static TextRestriction greaterThanEqual(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.GREATER_THAN_EQUAL, value); } - public static Restriction in(Set values, String field) { - return new BasicRestrictionRecord<>(field, Operator.IN, values); + public static Restriction in(Set values, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.IN, values); } - public static > Restriction lessThan(V value, String field) { - return new BasicRestrictionRecord<>(field, Operator.LESS_THAN, value); + public static > Restriction lessThan(V value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.LESS_THAN, value); } - public static TextRestriction lessThan(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.LESS_THAN, value); + public static TextRestriction lessThan(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.LESS_THAN, value); } - public static > Restriction lessThanEqual(V value, String field) { - return new BasicRestrictionRecord<>(field, Operator.LESS_THAN_EQUAL, value); + public static > Restriction lessThanEqual(V value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.LESS_THAN_EQUAL, value); } - public static TextRestriction lessThanEqual(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.LESS_THAN_EQUAL, value); + public static TextRestriction lessThanEqual(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.LESS_THAN_EQUAL, value); } // TODO this would be possible if Pattern is added, but is it even useful? - //public static TextRestriction like(Pattern pattern, String field) { - // return new TextRestriction<>(field, Operator.LIKE, ESCAPED, pattern); + //public static TextRestriction like(Pattern pattern, String attribute) { + // return new TextRestriction<>(attribute, Operator.LIKE, ESCAPED, pattern); //} - public static TextRestriction like(String pattern, String field) { - return new TextRestrictionRecord<>(field, Operator.LIKE, pattern); + public static TextRestriction like(String pattern, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.LIKE, pattern); } public static TextRestriction like(String pattern, char charWildcard, char stringWildcard, - String field) { + String attribute) { String p = toLikeEscaped(charWildcard, stringWildcard, false, pattern, false); - return new TextRestrictionRecord<>(field, Operator.LIKE, ESCAPED, p); + return new TextRestrictionRecord<>(attribute, Operator.LIKE, ESCAPED, p); } // convenience method for those who would prefer to avoid .negate() @@ -138,48 +138,48 @@ public static Restriction not(Restriction restriction) { return restriction.negate(); } - public static Restriction notEqualTo(Object value, String field) { - return new BasicRestrictionRecord<>(field, Operator.NOT_EQUAL, value); + public static Restriction notEqualTo(Object value, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.NOT_EQUAL, value); } - public static TextRestriction notEqualTo(String value, String field) { - return new TextRestrictionRecord<>(field, Operator.NOT_EQUAL, value); + public static TextRestriction notEqualTo(String value, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.NOT_EQUAL, value); } - public static TextRestriction notContains(String substring, String field) { + public static TextRestriction notContains(String substring, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, true, substring, true); - return new TextRestrictionRecord<>(field, Operator.NOT_LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.NOT_LIKE, ESCAPED, pattern); } - public static TextRestriction notEndsWith(String suffix, String field) { + public static TextRestriction notEndsWith(String suffix, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, true, suffix, false); - return new TextRestrictionRecord<>(field, Operator.NOT_LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.NOT_LIKE, ESCAPED, pattern); } - public static Restriction notIn(Set values, String field) { - return new BasicRestrictionRecord<>(field, Operator.NOT_IN, values); + public static Restriction notIn(Set values, String attribute) { + return new BasicRestrictionRecord<>(attribute, Operator.NOT_IN, values); } - public static TextRestriction notLike(String pattern, String field) { - return new TextRestrictionRecord<>(field, Operator.NOT_LIKE, pattern); + public static TextRestriction notLike(String pattern, String attribute) { + return new TextRestrictionRecord<>(attribute, Operator.NOT_LIKE, pattern); } public static TextRestriction notLike(String pattern, char charWildcard, char stringWildcard, - String field) { + String attribute) { String p = toLikeEscaped(charWildcard, stringWildcard, false, pattern, false); - return new TextRestrictionRecord<>(field, Operator.NOT_LIKE, ESCAPED, p); + return new TextRestrictionRecord<>(attribute, Operator.NOT_LIKE, ESCAPED, p); } - public static TextRestriction notStartsWith(String prefix, String field) { + public static TextRestriction notStartsWith(String prefix, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, false, prefix, true); - return new TextRestrictionRecord<>(field, Operator.NOT_LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.NOT_LIKE, ESCAPED, pattern); } - public static TextRestriction startsWith(String prefix, String field) { + public static TextRestriction startsWith(String prefix, String attribute) { String pattern = toLikeEscaped(CHAR_WILDCARD, STRING_WILDCARD, false, prefix, true); - return new TextRestrictionRecord<>(field, Operator.LIKE, ESCAPED, pattern); + return new TextRestrictionRecord<>(attribute, Operator.LIKE, ESCAPED, pattern); } /** diff --git a/api/src/main/java/jakarta/data/TextRestrictionRecord.java b/api/src/main/java/jakarta/data/TextRestrictionRecord.java index c957860e..e8e25cd2 100644 --- a/api/src/main/java/jakarta/data/TextRestrictionRecord.java +++ b/api/src/main/java/jakarta/data/TextRestrictionRecord.java @@ -24,14 +24,14 @@ import java.util.Objects; record TextRestrictionRecord( - String field, + String attribute, Operator comparison, boolean isCaseSensitive, boolean isEscaped, String value) implements TextRestriction { TextRestrictionRecord { - Objects.requireNonNull(field, "Field must not be null"); + Objects.requireNonNull(attribute, "Attribute must not be null"); } TextRestrictionRecord(String field, Operator comparison, boolean escaped, String value) { @@ -44,14 +44,14 @@ record TextRestrictionRecord( @Override public TextRestriction ignoreCase() { - return new TextRestrictionRecord<>(field, comparison, false, isEscaped, value); + return new TextRestrictionRecord<>(attribute, comparison, false, isEscaped, value); } @Override public TextRestriction negate() { return new TextRestrictionRecord<>( - field, + attribute, comparison.negate(), isCaseSensitive, isEscaped, diff --git a/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java b/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java index e0c3c2c1..bd2e88be 100644 --- a/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java +++ b/api/src/test/java/jakarta/data/BasicRestrictionRecordTest.java @@ -33,7 +33,7 @@ void shouldCreateBasicRestrictionWithDefaultNegation() { BasicRestrictionRecord restriction = new BasicRestrictionRecord<>("title", Operator.EQUAL, "Java Guide"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.EQUAL); soft.assertThat(restriction.value()).isEqualTo("Java Guide"); }); @@ -46,7 +46,7 @@ void shouldCreateBasicRestrictionWithExplicitNegation() { .negate(); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_EQUAL); soft.assertThat(restriction.value()).isEqualTo("Java Guide"); }); @@ -58,7 +58,7 @@ void shouldCreateBasicRestrictionWithNullValue() { BasicRestrictionRecord restriction = new BasicRestrictionRecord<>("title", Operator.EQUAL, null); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.EQUAL); soft.assertThat(restriction.value()).isNull(); }); @@ -114,16 +114,16 @@ void shouldSupportNegatedRestrictionUsingDefaultConstructor() { (BasicRestriction) Restrict.notEqualTo((Object) "Unknown", "author"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(negatedRestriction.field()).isEqualTo("author"); + soft.assertThat(negatedRestriction.attribute()).isEqualTo("author"); soft.assertThat(negatedRestriction.comparison()).isEqualTo(Operator.NOT_EQUAL); soft.assertThat(negatedRestriction.value()).isEqualTo("Unknown"); }); } @Test - void shouldThrowExceptionWhenFieldIsNull() { + void shouldThrowExceptionWhenAttributeIsNull() { assertThatThrownBy(() -> new BasicRestrictionRecord<>(null, Operator.EQUAL, "testValue")) .isInstanceOf(NullPointerException.class) - .hasMessage("Field must not be null"); + .hasMessage("Attribute must not be null"); } } diff --git a/api/src/test/java/jakarta/data/RestrictTest.java b/api/src/test/java/jakarta/data/RestrictTest.java index 04113be8..8d458fc0 100644 --- a/api/src/test/java/jakarta/data/RestrictTest.java +++ b/api/src/test/java/jakarta/data/RestrictTest.java @@ -28,13 +28,13 @@ class RestrictTest { @Test void shouldCreateEqualToRestriction() { - Restriction restriction = Restrict.equalTo("value", "field"); + Restriction restriction = Restrict.equalTo("value", "attributeName"); assertThat(restriction).isInstanceOf(TextRestrictionRecord.class); TextRestrictionRecord basic = (TextRestrictionRecord) restriction; SoftAssertions.assertSoftly(soft -> { - soft.assertThat(basic.field()).isEqualTo("field"); + soft.assertThat(basic.attribute()).isEqualTo("attributeName"); soft.assertThat(basic.comparison()).isEqualTo(Operator.EQUAL); soft.assertThat(basic.value()).isEqualTo("value"); }); @@ -42,13 +42,13 @@ void shouldCreateEqualToRestriction() { @Test void shouldCreateNotEqualToRestriction() { - Restriction restriction = Restrict.notEqualTo("value", "field"); + Restriction restriction = Restrict.notEqualTo("value", "attributeName"); assertThat(restriction).isInstanceOf(TextRestrictionRecord.class); TextRestrictionRecord basic = (TextRestrictionRecord) restriction; SoftAssertions.assertSoftly(soft -> { - soft.assertThat(basic.field()).isEqualTo("field"); + soft.assertThat(basic.attribute()).isEqualTo("attributeName"); soft.assertThat(basic.comparison()).isEqualTo(Operator.NOT_EQUAL); soft.assertThat(basic.value()).isEqualTo("value"); }); @@ -56,8 +56,8 @@ void shouldCreateNotEqualToRestriction() { @Test void shouldCombineAllRestrictionsWithNegation() { - Restriction r1 = Restrict.notEqualTo("value1", "field1"); - Restriction r2 = Restrict.greaterThan(100, "field2"); + Restriction r1 = Restrict.notEqualTo("value1", "attributeName1"); + Restriction r2 = Restrict.greaterThan(100, "attributeName2"); Restriction combined = Restrict.all(r1, r2); @@ -73,10 +73,10 @@ void shouldCombineAllRestrictionsWithNegation() { @Test void shouldCreateContainsRestriction() { - TextRestriction restriction = Restrict.contains("substring", "field"); + TextRestriction restriction = Restrict.contains("substring", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(restriction.value()).isEqualTo("%substring%"); }); @@ -84,10 +84,10 @@ void shouldCreateContainsRestriction() { @Test void shouldCreateNegatedContainsRestriction() { - TextRestriction restriction = Restrict.notContains("substring", "field"); + TextRestriction restriction = Restrict.notContains("substring", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); soft.assertThat(restriction.value()).isEqualTo("%substring%"); }); @@ -95,10 +95,10 @@ void shouldCreateNegatedContainsRestriction() { @Test void shouldCreateStartsWithRestriction() { - TextRestriction restriction = Restrict.startsWith("prefix", "field"); + TextRestriction restriction = Restrict.startsWith("prefix", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(restriction.value()).isEqualTo("prefix%"); }); @@ -106,10 +106,10 @@ void shouldCreateStartsWithRestriction() { @Test void shouldCreateNegatedStartsWithRestriction() { - TextRestriction restriction = Restrict.notStartsWith("prefix", "field"); + TextRestriction restriction = Restrict.notStartsWith("prefix", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); soft.assertThat(restriction.value()).isEqualTo("prefix%"); }); @@ -117,10 +117,10 @@ void shouldCreateNegatedStartsWithRestriction() { @Test void shouldCreateEndsWithRestriction() { - TextRestriction restriction = Restrict.endsWith("suffix", "field"); + TextRestriction restriction = Restrict.endsWith("suffix", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(restriction.value()).isEqualTo("%suffix"); }); @@ -128,10 +128,10 @@ void shouldCreateEndsWithRestriction() { @Test void shouldCreateNegatedEndsWithRestriction() { - TextRestriction restriction = Restrict.notEndsWith("suffix", "field"); + TextRestriction restriction = Restrict.notEndsWith("suffix", "attributeName"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("field"); + soft.assertThat(restriction.attribute()).isEqualTo("attributeName"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); soft.assertThat(restriction.value()).isEqualTo("%suffix"); }); @@ -139,14 +139,14 @@ void shouldCreateNegatedEndsWithRestriction() { @Test void shouldEscapeToLikePatternCorrectly() { - String result = Restrict.endsWith("test_value", "fieldName").value(); + String result = Restrict.endsWith("test_value", "attributeName").value(); assertThat(result).isEqualTo("%test\\_value"); } @Test void shouldThrowExceptionForInvalidWildcard() { - assertThatThrownBy(() -> Restrict.like("pattern_value", '_', '_', "fieldName")) + assertThatThrownBy(() -> Restrict.like("pattern_value", '_', '_', "attributeName")) .isInstanceOf(IllegalArgumentException.class) .hasMessage("Cannot use the same character (_) for both types of wildcards."); } diff --git a/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java b/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java index 14b7f2b2..a0d799af 100644 --- a/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java +++ b/api/src/test/java/jakarta/data/TextRestrictionRecordTest.java @@ -36,7 +36,7 @@ void shouldCreateTextRestrictionWithDefaultValues() { ); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(restriction.value()).isEqualTo("%Java%"); soft.assertThat(restriction.isCaseSensitive()).isTrue(); @@ -53,7 +53,7 @@ void shouldCreateTextRestrictionWithExplicitNegation() { ); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); soft.assertThat(restriction.value()).isEqualTo("%Java%"); soft.assertThat(restriction.isCaseSensitive()).isTrue(); @@ -74,7 +74,7 @@ void shouldIgnoreCaseForTextRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(caseInsensitiveRestriction).isInstanceOf(TextRestrictionRecord.class); TextRestrictionRecord textRestriction = (TextRestrictionRecord) caseInsensitiveRestriction; - soft.assertThat(textRestriction.field()).isEqualTo("title"); + soft.assertThat(textRestriction.attribute()).isEqualTo("title"); soft.assertThat(textRestriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(textRestriction.value()).isEqualTo("%Java%"); soft.assertThat(textRestriction.isCaseSensitive()).isFalse(); @@ -92,7 +92,7 @@ void shouldCreateTextRestrictionWithEscapedValue() { ); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("title"); + soft.assertThat(restriction.attribute()).isEqualTo("title"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); soft.assertThat(restriction.value()).isEqualTo("%Java%"); soft.assertThat(restriction.isCaseSensitive()).isTrue(); @@ -149,7 +149,7 @@ void shouldSupportNegationForTextRestriction() { ); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("author"); + soft.assertThat(restriction.attribute()).isEqualTo("author"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_EQUAL); soft.assertThat(restriction.value()).isEqualTo("John Doe"); soft.assertThat(restriction.isCaseSensitive()).isTrue(); @@ -158,9 +158,9 @@ void shouldSupportNegationForTextRestriction() { } @Test - void shouldThrowExceptionWhenFieldIsNullInTextRestriction() { + void shouldThrowExceptionWhenAttributeIsNullInTextRestriction() { assertThatThrownBy(() -> new TextRestrictionRecord<>(null, Operator.LIKE, "testValue")) .isInstanceOf(NullPointerException.class) - .hasMessage("Field must not be null"); + .hasMessage("Attribute must not be null"); } } diff --git a/api/src/test/java/jakarta/data/metamodel/AttributeTest.java b/api/src/test/java/jakarta/data/metamodel/AttributeTest.java index e1a962b9..a109e1a9 100644 --- a/api/src/test/java/jakarta/data/metamodel/AttributeTest.java +++ b/api/src/test/java/jakarta/data/metamodel/AttributeTest.java @@ -37,7 +37,7 @@ void shouldCreateEqualToRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo("testValue"); soft.assertThat(basic.comparison()).isEqualTo(Operator.EQUAL); }); @@ -50,7 +50,7 @@ void shouldCreateNotEqualToRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo("testValue"); soft.assertThat(basic.comparison()).isEqualTo(Operator.NOT_EQUAL); }); @@ -63,7 +63,7 @@ void shouldCreateInRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(Set.of("value1", "value2")); soft.assertThat(basic.comparison()).isEqualTo(Operator.IN); }); @@ -83,7 +83,7 @@ void shouldCreateNotInRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(Set.of("value1", "value2")); soft.assertThat(basic.comparison()).isEqualTo(Operator.NOT_IN); }); @@ -103,7 +103,7 @@ void shouldCreateIsNullRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isNull(); soft.assertThat(basic.comparison()).isEqualTo(Operator.EQUAL); }); @@ -116,7 +116,7 @@ void shouldCreateNotNullRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isNull(); soft.assertThat(basic.comparison()).isEqualTo(Operator.NOT_EQUAL); }); diff --git a/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java b/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java index fcc204ce..a28f4c2b 100644 --- a/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java +++ b/api/src/test/java/jakarta/data/metamodel/SortableAttributeTest.java @@ -53,7 +53,7 @@ void shouldCreateGreaterThanRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(10); soft.assertThat(basic.comparison()).isEqualTo(Operator.GREATER_THAN); }); @@ -66,7 +66,7 @@ void shouldCreateGreaterThanEqualRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(10); soft.assertThat(basic.comparison()).isEqualTo(Operator.GREATER_THAN_EQUAL); }); @@ -79,7 +79,7 @@ void shouldCreateLessThanRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(10); soft.assertThat(basic.comparison()).isEqualTo(Operator.LESS_THAN); }); @@ -92,7 +92,7 @@ void shouldCreateLessThanOrEqualRestriction() { SoftAssertions.assertSoftly(soft -> { soft.assertThat(restriction).isInstanceOf(BasicRestriction.class); BasicRestriction basic = (BasicRestriction) restriction; - soft.assertThat(basic.field()).isEqualTo("testAttribute"); + soft.assertThat(basic.attribute()).isEqualTo("testAttribute"); soft.assertThat(basic.value()).isEqualTo(10); soft.assertThat(basic.comparison()).isEqualTo(Operator.LESS_THAN_EQUAL); }); @@ -111,14 +111,14 @@ void shouldCreateBetweenRestriction() { Restriction lowerBound = composite.restrictions().get(0); soft.assertThat(lowerBound).isInstanceOf(BasicRestriction.class); BasicRestriction lower = (BasicRestriction) lowerBound; - soft.assertThat(lower.field()).isEqualTo("testAttribute"); + soft.assertThat(lower.attribute()).isEqualTo("testAttribute"); soft.assertThat(lower.value()).isEqualTo(5); soft.assertThat(lower.comparison()).isEqualTo(Operator.GREATER_THAN_EQUAL); Restriction upperBound = composite.restrictions().get(1); soft.assertThat(upperBound).isInstanceOf(BasicRestriction.class); BasicRestriction upper = (BasicRestriction) upperBound; - soft.assertThat(upper.field()).isEqualTo("testAttribute"); + soft.assertThat(upper.attribute()).isEqualTo("testAttribute"); soft.assertThat(upper.value()).isEqualTo(15); soft.assertThat(upper.comparison()).isEqualTo(Operator.LESS_THAN_EQUAL); }); diff --git a/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java b/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java index 453f509d..1c9b24ab 100644 --- a/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java +++ b/api/src/test/java/jakarta/data/metamodel/TextAttributeTest.java @@ -58,7 +58,7 @@ void shouldCreateContainsRestriction() { TextRestriction restriction = testAttribute.contains("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%testValue%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); }); @@ -69,7 +69,7 @@ void shouldCreateStartsWithRestriction() { TextRestriction restriction = testAttribute.startsWith("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("testValue%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); }); @@ -80,7 +80,7 @@ void shouldCreateEndsWithRestriction() { TextRestriction restriction = testAttribute.endsWith("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%testValue"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); }); @@ -91,7 +91,7 @@ void shouldCreateLikeRestriction() { TextRestriction restriction = testAttribute.like("%test%"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%test%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.LIKE); }); @@ -102,7 +102,7 @@ void shouldCreateNotContainsRestriction() { TextRestriction restriction = testAttribute.notContains("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%testValue%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); }); @@ -113,7 +113,7 @@ void shouldCreateNotLikeRestriction() { TextRestriction restriction = testAttribute.notLike("%test%"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%test%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); }); @@ -124,7 +124,7 @@ void shouldCreateNotStartsWithRestriction() { TextRestriction restriction = testAttribute.notStartsWith("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("testValue%"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); }); @@ -135,7 +135,7 @@ void shouldCreateNotEndsWithRestriction() { TextRestriction restriction = testAttribute.notEndsWith("testValue"); SoftAssertions.assertSoftly(soft -> { - soft.assertThat(restriction.field()).isEqualTo("testAttribute"); + soft.assertThat(restriction.attribute()).isEqualTo("testAttribute"); soft.assertThat(restriction.value()).isEqualTo("%testValue"); soft.assertThat(restriction.comparison()).isEqualTo(Operator.NOT_LIKE); });