Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.framework.junit.anno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.jupiter.api.Tag;

/**
* <p>Test classes that use annotation-defined query mechanisms:
* {@code @Query} (JDQL), {@code @Find} (with {@code @By} constraints),
* and built-in lifecycle/CRUD methods.</p>
*
* <p>These tests do not rely on query-by-method-name derivation.</p>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Tag("annotated")
public @interface Annotated {

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
/*
* Copyright (c) 2026 Contributors to the Eclipse Foundation
*
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
*
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the
* Eclipse Public License v. 2.0 are satisfied: GNU General Public License,
* version 2 with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.framework.junit.anno;

import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;

import org.junit.jupiter.api.Tag;

/**
* <p>Test classes that use query-by-method-name derivation,
* where repository methods like {@code findByNameEquals} or
* {@code countByIdLessThan} have their query logic inferred from
* the method name.</p>
*
* <p>Some implementations may require additional annotation
* processors to support this query mechanism.</p>
*/
@Target(ElementType.TYPE)
@Retention(RetentionPolicy.RUNTIME)
@Tag("query-by-method-name")
public @interface QueryByMethodName {

}
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,10 @@

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;

import jakarta.data.Limit;
import jakarta.data.Order;
import jakarta.data.Sort;
import jakarta.data.page.Page;
import jakarta.data.page.PageRequest;
import jakarta.data.repository.By;
import jakarta.data.repository.DataRepository;
import jakarta.data.repository.Find;
Expand All @@ -38,14 +34,11 @@
* from 0-256. This repository will be pre-populated at test startup and
* verified prior to running tests. This interface is required to inherit only
* from DataRepository in order to satisfy a TCK scenario.
* For query-by-method-name versions, see AsciiCharactersByName.
*/
@Repository
public interface AsciiCharacters extends DataRepository<AsciiCharacter, Long> {

long countByIdBetween(long minimum, long maximum);

boolean existsById(long id);

@Query("SELECT id WHERE id >= :inclusiveMin ORDER BY id ASC")
List<Long> withIdEqualOrAbove(long inclusiveMin, Limit limit);

Expand All @@ -62,9 +55,8 @@ public interface AsciiCharacters extends DataRepository<AsciiCharacter, Long> {
@Find(NaturalNumber.class)
Stream<CardinalNumber> cardinalNumberStream(long floorOfSquareRoot);

long countByHexadecimalNotNull();

boolean existsByThisCharacter(char ch);
@Query("SELECT COUNT(THIS) WHERE hexadecimal IS NOT NULL")
long countNonNullHex();

@Find
AsciiCharacter find(char thisCharacter);
Expand All @@ -73,29 +65,6 @@ public interface AsciiCharacters extends DataRepository<AsciiCharacter, Long> {
Optional<AsciiCharacter> find(@By("thisCharacter") char ch,
@By("hexadecimal") String hex);

List<AsciiCharacter> findByHexadecimalContainsAndIsControlNot(String substring, boolean isPrintable);

Stream<AsciiCharacter> findByHexadecimalIgnoreCaseBetweenAndHexadecimalNotIn(String minHex,
String maxHex,
Set<String> excludeHex,
Order<AsciiCharacter> sorts);

AsciiCharacter findByHexadecimalIgnoreCase(String hex);

Stream<AsciiCharacter> findByIdBetween(long minimum, long maximum, Sort<AsciiCharacter> sort);

AsciiCharacter findByIsControlTrueAndNumericValueBetween(int min, int max);

Optional<AsciiCharacter> findByNumericValue(int id);

Page<AsciiCharacter> findByNumericValueBetween(int min, int max, PageRequest pagination, Order<AsciiCharacter> order);

List<AsciiCharacter> findByNumericValueLessThanEqualAndNumericValueGreaterThanEqual(int max, int min);

AsciiCharacter[] findFirst3ByNumericValueGreaterThanEqualAndHexadecimalEndsWith(int minValue, String lastHexDigit, Sort<AsciiCharacter> sort);

Optional<AsciiCharacter> findFirstByHexadecimalStartsWithAndIsControlOrderByIdAsc(String firstHexDigit, boolean isControlChar);

@Query("select thisCharacter where hexadecimal like '4_'" +
" and hexadecimal not like '%0'" +
" and thisCharacter not in ('E', 'G')" +
Expand All @@ -109,11 +78,6 @@ Stream<AsciiCharacter> findByHexadecimalIgnoreCaseBetweenAndHexadecimalNotIn(Str
@Query("WHERE hexadecimal <> ' ORDER BY isn''t a keyword when inside a literal' AND hexadecimal IN ('4a', '4b', '4c', ?1)")
Stream<AsciiCharacter> jklOr(String hex);

default Stream<AsciiCharacter> retrieveAlphaNumericIn(long minId, long maxId) {
return findByIdBetween(minId, maxId, Sort.asc("id"))
.filter(c -> Character.isLetterOrDigit(c.getThisCharacter()));
}

@Query("SELECT thisCharacter ORDER BY id DESC")
Character[] reverseAlphabetic(Limit limit);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,6 @@ public void populationLogic(AsciiCharacters repo) {

@Override
public boolean isPopulated(AsciiCharacters repo) {
return repo.countByHexadecimalNotNull() == 127L;
return repo.countNonNullHex() == 127L;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,7 @@ List<Country> asLargeOrBigger(
List<Country> byCountryCodes(
@By(_Country.CODE) @Is(In.class) Collection<String> codes);

@Query("SELECT COUNT(THIS)")
long count();

@Find
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
import jakarta.data.Limit;
import jakarta.data.Order;
import jakarta.data.Sort;
import jakarta.data.page.CursoredPage;
import jakarta.data.page.Page;
import jakarta.data.page.PageRequest;
import jakarta.data.repository.BasicRepository;
Expand All @@ -35,21 +34,18 @@
import jakarta.data.repository.Query;
import jakarta.data.repository.Repository;
import jakarta.data.repository.Select;
import ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType;

/**
* This is a read only repository that represents the set of Natural Numbers from 1-100.
* This repository will be pre-populated at test startup and verified prior to running tests.
*
* TODO figure out a way to make this a ReadOnlyRepository instead.
*
* For query-by-method-name versions, see NaturalNumbersByName.
*/
@Repository
public interface NaturalNumbers extends BasicRepository<NaturalNumber, Long> {

long countByIdBetween(long minimum, long maximum);

boolean existsById(long id);

@Query("SELECT id WHERE id >= :inclusiveMin ORDER BY id ASC")
List<Long> withIdEqualOrAbove(long inclusiveMin, Limit limit);

Expand All @@ -73,39 +69,9 @@ Page<CardinalNumber> cardinalNumberPage(
@Query("FROM NaturalNumber WHERE floorOfSquareRoot=?1")
Stream<CardinalNumber> cardinalNumberStream(long sqrtFloor);

@Query("SELECT COUNT(THIS)")
long countAll();

CursoredPage<NaturalNumber> findByFloorOfSquareRootOrderByIdAsc(long sqrtFloor,
PageRequest pagination);

Stream<NaturalNumber> findByIdBetweenOrderByNumTypeOrdinalAsc(long minimum,
long maximum,
Order<NaturalNumber> sorts);

List<NaturalNumber> findByIdGreaterThanEqual(long minimum,
Limit limit,
Order<NaturalNumber> sorts);

NaturalNumber[] findByIdLessThan(long exclusiveMax, Sort<NaturalNumber> primarySort, Sort<NaturalNumber> secondarySort);

List<NaturalNumber> findByIdLessThanEqual(long maximum, Sort<?>... sorts);

Page<NaturalNumber> findByIdLessThanOrderByFloorOfSquareRootDesc(long exclusiveMax,
PageRequest pagination,
Order<NaturalNumber> order);

CursoredPage<NaturalNumber> findByNumTypeAndNumBitsRequiredLessThan(NumberType type,
short bitsUnder,
Order<NaturalNumber> order,
PageRequest pagination);

NaturalNumber[] findByNumTypeNot(NumberType notThisType, Limit limit, Order<NaturalNumber> sorts);

Page<NaturalNumber> findByNumTypeAndFloorOfSquareRootLessThanEqual(NumberType type,
long maxSqrtFloor,
PageRequest pagination,
Sort<NaturalNumber> sort);

@Find(AsciiCharacter.class)
// this is not the primary entity type
Optional<HexInfo> hexadecimalInfo(int numericValue);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,6 @@

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;

import ee.jakarta.tck.data.framework.read.only.NaturalNumber.NumberType;
import jakarta.data.Limit;
Expand All @@ -39,28 +37,13 @@
import jakarta.data.repository.Select;

/**
* This is a read only repository that shares the same data (and entity type)
* as the NaturalNumbers repository: the positive integers 1-100.
* This repository is pre-populated at test startup and verified prior to running tests.
* Annotation-based query repository for positive integers (1-100).
* Uses @Query and @Find annotations for query definitions.
* Shares the same data as NaturalNumbers repository.
* For query-by-method-name versions of these queries, see PositiveIntegersByName.
*/
@Repository
public interface PositiveIntegers extends BasicRepository<NaturalNumber, Long> {
long countByIdLessThan(long number);

boolean existsByIdGreaterThan(Long number);

CursoredPage<NaturalNumber> findByFloorOfSquareRootNotAndIdLessThanOrderByNumBitsRequiredDesc(long excludeSqrt,
long eclusiveMax,
PageRequest pagination,
Order<NaturalNumber> order);

List<NaturalNumber> findByIsOddTrueAndIdLessThanEqualOrderByIdDesc(long max);

List<NaturalNumber> findByIsOddFalseAndIdBetween(long min, long max);

Stream<NaturalNumber> findByNumTypeInOrderByIdAsc(Set<NumberType> types, Limit limit);

Stream<NaturalNumber> findByNumTypeOrFloorOfSquareRoot(NumberType type, long floor);

@Find
Page<NaturalNumber> findMatching(long floorOfSquareRoot, Short numBitsRequired, NumberType numType,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/**
* Copyright (c) 2026 Contributors to the Eclipse Foundation
* <p>
* This program and the accompanying materials are made available under the
* terms of the Eclipse Public License v. 2.0, which is available at
* http://www.eclipse.org/legal/epl-2.0.
* <p>
* This Source Code may also be made available under the following Secondary
* Licenses when the conditions for such availability set forth in the Eclipse
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
* with the GNU Classpath Exception, which is available at
* https://www.gnu.org/software/classpath/license.html.
* <p>
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.framework.read.only.qbmn;

import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;

import jakarta.data.Order;
import jakarta.data.Sort;
import jakarta.data.page.Page;
import jakarta.data.page.PageRequest;
import jakarta.data.repository.DataRepository;
import jakarta.data.repository.Repository;
import ee.jakarta.tck.data.framework.read.only.AsciiCharacter;

/**
* Query-by-method-name version of AsciiCharacters repository.
* This repository uses method name derivation for query logic.
*/
@Repository
public interface AsciiCharactersByName extends DataRepository<AsciiCharacter, Long> {

long countByIdBetween(long minimum, long maximum);

long countByHexadecimalNotNull();

boolean existsById(long id);

boolean existsByThisCharacter(char ch);

List<AsciiCharacter> findByHexadecimalContainsAndIsControlNot(String substring, boolean isPrintable);

Stream<AsciiCharacter> findByHexadecimalIgnoreCaseBetweenAndHexadecimalNotIn(String minHex,
String maxHex,
Set<String> excludeHex,
Order<AsciiCharacter> sorts);

AsciiCharacter findByHexadecimalIgnoreCase(String hex);

Stream<AsciiCharacter> findByIdBetween(long minimum, long maximum, Sort<AsciiCharacter> sort);

AsciiCharacter findByIsControlTrueAndNumericValueBetween(int min, int max);

Optional<AsciiCharacter> findByNumericValue(int id);

Page<AsciiCharacter> findByNumericValueBetween(int min, int max, PageRequest pagination, Order<AsciiCharacter> order);

List<AsciiCharacter> findByNumericValueLessThanEqualAndNumericValueGreaterThanEqual(int max, int min);

AsciiCharacter[] findFirst3ByNumericValueGreaterThanEqualAndHexadecimalEndsWith(int minValue, String lastHexDigit, Sort<AsciiCharacter> sort);

Optional<AsciiCharacter> findFirstByHexadecimalStartsWithAndIsControlOrderByIdAsc(String firstHexDigit, boolean isControlChar);

default Stream<AsciiCharacter> retrieveAlphaNumericIn(long minId, long maxId) {
return findByIdBetween(minId, maxId, Sort.asc("id"))
.filter(c -> Character.isLetterOrDigit(c.getThisCharacter()));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,12 @@
* <p>
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.framework.read.only;
package ee.jakarta.tck.data.framework.read.only.qbmn;

import java.util.List;
import java.util.Set;

import ee.jakarta.tck.data.framework.read.only.NaturalNumber;
import jakarta.data.repository.Delete;
import jakarta.data.repository.Insert;
import jakarta.data.repository.Repository;
Expand Down
Loading