Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Further refactoring of CDI tests #711

Merged
merged 1 commit into from
Apr 18, 2024
Merged
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

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.common.cdi;
package ee.jakarta.tck.data.core.cdi;

import static jakarta.data.repository.By.ID;

Expand All @@ -30,21 +30,15 @@
* 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
* to ensure no Jakarta Data provider implements this repository interface.
*/
@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);

}
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,15 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.common.cdi;
package ee.jakarta.tck.data.core.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
* @see ee.jakarta.tck.data.core.cdi.TCKEntity
*/
@TCKEntity
public record AddressRecord(UUID id, int house, String street, String city, String state, long zipCode) {
Expand Down
52 changes: 52 additions & 0 deletions tck/src/main/java/ee/jakarta/tck/data/core/cdi/CDITests.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/*
* 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.core.cdi;

import static org.junit.jupiter.api.Assertions.assertTrue;

import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.spec.WebArchive;

import ee.jakarta.tck.data.framework.junit.anno.AnyEntity;
import ee.jakarta.tck.data.framework.junit.anno.Assertion;
import ee.jakarta.tck.data.framework.junit.anno.CDIRequired;
import ee.jakarta.tck.data.framework.junit.anno.Core;
import jakarta.enterprise.inject.spi.CDI;

@Core
@AnyEntity
@CDIRequired
public class CDITests {

@Deployment
public static WebArchive createDeployment() {
return ShrinkWrap.create(WebArchive.class)
.addPackage(CDITests.class.getPackage());
}

@Assertion(id = "640", strategy = "Verifies that another Jakarta Data Provider does not attempt to "
+ "implement the Dictonary repository based on provider attribute.")
public void testDataRepositoryHonorsProviderAttribute() {
assertTrue(CDI.current().select(Directory.class).isUnsatisfied());
}

@Assertion(id = "640", strategy = "Verifies that another Jakarta Data Provider does not attempt to "
+ "implement the Address repository based on the EntityDefining annotation.")
public void testDataRepositoryHonorsEntityDefiningAnnotation() {
assertTrue(CDI.current().select(AddressBook.class).isUnsatisfied());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
*
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
*/
package ee.jakarta.tck.data.common.cdi;
package ee.jakarta.tck.data.core.cdi;

import static jakarta.data.repository.By.ID;

Expand All @@ -27,23 +27,19 @@
/**
* A Directory repository for testing.
*
* Uses the 'provider' attribute to ensure the mock Jakarta Data provider
* from the TCK implements this repository interface.
*
* @see ee.jakarta.tck.data.common.cdi.DirectoryRepository
* Uses the 'provider' attribute to ensure that no Jakarta Data provider
* implements this repository interface.
*/
@Repository(provider = Directory.PERSON_PROVIDER)
public interface Directory extends DataRepository<Person, Long> {

//Self referencing provider so that this repository can be used for both WEB and CORE tests
public static final String PERSON_PROVIDER = "PERSON_PROVIDER";
// A string that is unique enough not to be used by any
// Jakarta Data provider attempting to run this TCK.
public static final String PERSON_PROVIDER = "cb4d43ac-477a-4634-b3ee-a9ce81ea1801";

List<Person> findByIdInOrderByAgeDesc(List<Long> ids);

@Delete
void deleteById(@By(ID) Long id);

@PutTCKLifecyleMethod
Person putPerson(Person person);

}
Loading