Search in sources :

Example 1 with DatastoreKey

use of org.datanucleus.tests.annotations.Datastore.DatastoreKey in project tests by datanucleus.

the class DataNucleusTestWatcher method filterDatastores.

private void filterDatastores(Class<?> testClass) {
    List<DatastoreKey> filterDatastores = findAnnotationAtMethodOrClass(Datastore.class, description, testClass).map(annotation -> asList(annotation.value())).orElse(emptyList());
    if (!filterDatastores.isEmpty()) {
        String datastoreKey = JDOPersistenceTestCase.storeMgr.getStoreManagerKey();
        DatastoreKey currentDatastore = DatastoreKey.valueOf(datastoreKey.toUpperCase());
        DatastoreKey vendorIdDatastore = JDOPersistenceTestCase.vendorID == null ? null : DatastoreKey.valueOf(JDOPersistenceTestCase.vendorID.toUpperCase());
        Assume.assumeTrue(filterDatastores.stream().anyMatch(filter -> filter.equals(currentDatastore) || filter.equals(vendorIdDatastore)));
    }
}
Also used : Datastore(org.datanucleus.tests.annotations.Datastore) Collections.emptyList(java.util.Collections.emptyList) Description(org.junit.runner.Description) AssertionFailedError(junit.framework.AssertionFailedError) Mode(org.datanucleus.tests.annotations.TransactionMode.Mode) TestWatcher(org.junit.rules.TestWatcher) List(java.util.List) NucleusLogger(org.datanucleus.util.NucleusLogger) Arrays.asList(java.util.Arrays.asList) OPTIMISTIC(org.datanucleus.tests.annotations.TransactionMode.Mode.OPTIMISTIC) Annotation(java.lang.annotation.Annotation) Optional(java.util.Optional) DatastoreKey(org.datanucleus.tests.annotations.Datastore.DatastoreKey) Assume(org.junit.Assume) PESSIMISTIC(org.datanucleus.tests.annotations.TransactionMode.Mode.PESSIMISTIC) TransactionMode(org.datanucleus.tests.annotations.TransactionMode) DatastoreKey(org.datanucleus.tests.annotations.Datastore.DatastoreKey)

Aggregations

Annotation (java.lang.annotation.Annotation)1 Arrays.asList (java.util.Arrays.asList)1 Collections.emptyList (java.util.Collections.emptyList)1 List (java.util.List)1 Optional (java.util.Optional)1 AssertionFailedError (junit.framework.AssertionFailedError)1 Datastore (org.datanucleus.tests.annotations.Datastore)1 DatastoreKey (org.datanucleus.tests.annotations.Datastore.DatastoreKey)1 TransactionMode (org.datanucleus.tests.annotations.TransactionMode)1 Mode (org.datanucleus.tests.annotations.TransactionMode.Mode)1 OPTIMISTIC (org.datanucleus.tests.annotations.TransactionMode.Mode.OPTIMISTIC)1 PESSIMISTIC (org.datanucleus.tests.annotations.TransactionMode.Mode.PESSIMISTIC)1 NucleusLogger (org.datanucleus.util.NucleusLogger)1 Assume (org.junit.Assume)1 TestWatcher (org.junit.rules.TestWatcher)1 Description (org.junit.runner.Description)1