-
Notifications
You must be signed in to change notification settings - Fork 30
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #667 from KyleAure/657-more-QBN-fixes
Add test case for custom entity types and fix query methods for validation
- Loading branch information
Showing
16 changed files
with
497 additions
and
164 deletions.
There are no files selected for viewing
50 changes: 50 additions & 0 deletions
50
tck/src/main/java/ee/jakarta/tck/data/common/cdi/AddressBook.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* | ||
* Copyright (c) 2024 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.common.cdi; | ||
|
||
import static jakarta.data.repository.By.ID; | ||
|
||
import java.util.List; | ||
import java.util.UUID; | ||
|
||
import jakarta.data.repository.By; | ||
import jakarta.data.repository.DataRepository; | ||
import jakarta.data.repository.Delete; | ||
import jakarta.data.repository.Find; | ||
import jakarta.data.repository.Repository; | ||
|
||
/** | ||
* An AddressBook repository for testing. | ||
* | ||
* Uses the AddressRecord with the {@code @EntityDefining} annotation {@code TCKEntity} | ||
* to ensure the mock Jakarta Data provider from this TCK implements this repository interface. | ||
* | ||
* @see ee.jakarta.tck.data.common.cdi.DirectoryRepository | ||
*/ | ||
@Repository | ||
public interface AddressBook extends DataRepository<AddressRecord, UUID> { | ||
|
||
public static final String ADDRESS_PROVIDER = "ADDRESS_PROVIDER"; | ||
|
||
@Find | ||
List<AddressRecord> findById(List<UUID> ids); | ||
|
||
@Delete | ||
void deleteById(@By(ID) UUID id); | ||
|
||
@PutTCKLifecyleMethod | ||
AddressRecord putAddress(AddressRecord address); | ||
} |
28 changes: 28 additions & 0 deletions
28
tck/src/main/java/ee/jakarta/tck/data/common/cdi/AddressRecord.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) 2024 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.common.cdi; | ||
|
||
import java.util.UUID; | ||
|
||
/** | ||
* A test entity that will be persisted to a repository. | ||
* Uses the custom {@code @TCKEntity} annotation. | ||
* | ||
* @see ee.jakarta.tck.data.common.cdi.TCKEntity | ||
*/ | ||
@TCKEntity | ||
public record AddressRecord(UUID id, int house, String street, String city, String state, long zipCode) { | ||
} |
53 changes: 53 additions & 0 deletions
53
tck/src/main/java/ee/jakarta/tck/data/common/cdi/AddressRepository.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (c) 2023, 2024 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.common.cdi; | ||
|
||
import java.util.HashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.UUID; | ||
import java.util.stream.Collectors; | ||
|
||
/** | ||
* An implementation of the AddressBook repository interface. | ||
* Implementation is backed by an in-memory HashMap. | ||
*/ | ||
public class AddressRepository implements AddressBook { | ||
|
||
private Map<UUID, AddressRecord> data = new HashMap<UUID, AddressRecord>(); | ||
|
||
public AddressRepository() { | ||
} | ||
|
||
@Override | ||
public List<AddressRecord> findById(List<UUID> ids) { | ||
return data.values() | ||
.stream() | ||
.filter(a -> ids.contains(a.id())) | ||
.collect(Collectors.toList()); | ||
} | ||
|
||
@Override | ||
public void deleteById(UUID id) { | ||
data.remove(id); | ||
} | ||
|
||
@Override | ||
public AddressRecord putAddress(AddressRecord address) { | ||
return data.put(address.id(), address); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
15 changes: 15 additions & 0 deletions
15
tck/src/main/java/ee/jakarta/tck/data/common/cdi/PutTCKLifecyleMethod.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.