Search in sources :

Example 1 with Arguments

use of org.junit.jupiter.params.provider.Arguments in project junit5 by junit-team.

the class ParameterizedTestExtensionTests method argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException.

@Test
void argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException() {
    ArgumentsProvider failingProvider = (context) -> {
        throw new FileNotFoundException("a message");
    };
    FileNotFoundException exception = assertThrows(FileNotFoundException.class, () -> arguments(failingProvider, null));
    assertEquals("a message", exception.getMessage());
}
Also used : Assertions.assertThrows(org.junit.jupiter.api.Assertions.assertThrows) ParameterizedTestExtension.arguments(org.junit.jupiter.params.ParameterizedTestExtension.arguments) Arrays(java.util.Arrays) Assertions.assertThat(org.assertj.core.api.Assertions.assertThat) JUnitException(org.junit.platform.commons.JUnitException) Set(java.util.Set) Lifecycle(org.junit.jupiter.api.TestInstance.Lifecycle) ExtensionContext(org.junit.jupiter.api.extension.ExtensionContext) Arguments(org.junit.jupiter.params.provider.Arguments) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.jupiter.api.Test) Stream(java.util.stream.Stream) Assertions.assertFalse(org.junit.jupiter.api.Assertions.assertFalse) TestTemplateInvocationContext(org.junit.jupiter.api.extension.TestTemplateInvocationContext) Assertions.assertTrue(org.junit.jupiter.api.Assertions.assertTrue) Map(java.util.Map) Optional(java.util.Optional) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) ArgumentsSource(org.junit.jupiter.params.provider.ArgumentsSource) Method(java.lang.reflect.Method) AnnotatedElement(java.lang.reflect.AnnotatedElement) ArgumentsProvider(org.junit.jupiter.params.provider.ArgumentsProvider) FileNotFoundException(java.io.FileNotFoundException) Test(org.junit.jupiter.api.Test)

Example 2 with Arguments

use of org.junit.jupiter.params.provider.Arguments in project kafka by apache.

the class MockProcessorContextStateStoreTest method parameters.

public static Stream<Arguments> parameters() {
    final List<Boolean> booleans = asList(true, false);
    final List<Arguments> values = new ArrayList<>();
    for (final Boolean timestamped : booleans) {
        for (final Boolean caching : booleans) {
            for (final Boolean logging : booleans) {
                final List<KeyValueBytesStoreSupplier> keyValueBytesStoreSuppliers = asList(Stores.inMemoryKeyValueStore("kv" + timestamped + caching + logging), Stores.persistentKeyValueStore("kv" + timestamped + caching + logging), Stores.persistentTimestampedKeyValueStore("kv" + timestamped + caching + logging));
                for (final KeyValueBytesStoreSupplier supplier : keyValueBytesStoreSuppliers) {
                    final StoreBuilder<? extends KeyValueStore<String, ?>> builder;
                    if (timestamped) {
                        builder = Stores.timestampedKeyValueStoreBuilder(supplier, Serdes.String(), Serdes.Long());
                    } else {
                        builder = Stores.keyValueStoreBuilder(supplier, Serdes.String(), Serdes.Long());
                    }
                    if (caching) {
                        builder.withCachingEnabled();
                    } else {
                        builder.withCachingDisabled();
                    }
                    if (logging) {
                        builder.withLoggingEnabled(Collections.emptyMap());
                    } else {
                        builder.withLoggingDisabled();
                    }
                    values.add(Arguments.of(builder, timestamped, caching, logging));
                }
            }
        }
    }
    for (final Boolean timestamped : booleans) {
        for (final Boolean caching : booleans) {
            for (final Boolean logging : booleans) {
                final List<WindowBytesStoreSupplier> windowBytesStoreSuppliers = asList(Stores.inMemoryWindowStore("w" + timestamped + caching + logging, Duration.ofSeconds(1), Duration.ofSeconds(1), false), Stores.persistentWindowStore("w" + timestamped + caching + logging, Duration.ofSeconds(1), Duration.ofSeconds(1), false), Stores.persistentTimestampedWindowStore("w" + timestamped + caching + logging, Duration.ofSeconds(1), Duration.ofSeconds(1), false));
                for (final WindowBytesStoreSupplier supplier : windowBytesStoreSuppliers) {
                    final StoreBuilder<? extends WindowStore<String, ?>> builder;
                    if (timestamped) {
                        builder = Stores.timestampedWindowStoreBuilder(supplier, Serdes.String(), Serdes.Long());
                    } else {
                        builder = Stores.windowStoreBuilder(supplier, Serdes.String(), Serdes.Long());
                    }
                    if (caching) {
                        builder.withCachingEnabled();
                    } else {
                        builder.withCachingDisabled();
                    }
                    if (logging) {
                        builder.withLoggingEnabled(Collections.emptyMap());
                    } else {
                        builder.withLoggingDisabled();
                    }
                    values.add(Arguments.of(builder, timestamped, caching, logging));
                }
            }
        }
    }
    for (final Boolean caching : booleans) {
        for (final Boolean logging : booleans) {
            final List<SessionBytesStoreSupplier> sessionBytesStoreSuppliers = asList(Stores.inMemorySessionStore("s" + caching + logging, Duration.ofSeconds(1)), Stores.persistentSessionStore("s" + caching + logging, Duration.ofSeconds(1)));
            for (final SessionBytesStoreSupplier supplier : sessionBytesStoreSuppliers) {
                final StoreBuilder<? extends SessionStore<String, ?>> builder = Stores.sessionStoreBuilder(supplier, Serdes.String(), Serdes.Long());
                if (caching) {
                    builder.withCachingEnabled();
                } else {
                    builder.withCachingDisabled();
                }
                if (logging) {
                    builder.withLoggingEnabled(Collections.emptyMap());
                } else {
                    builder.withLoggingDisabled();
                }
                values.add(Arguments.of(builder, false, caching, logging));
            }
        }
    }
    return values.stream();
}
Also used : WindowBytesStoreSupplier(org.apache.kafka.streams.state.WindowBytesStoreSupplier) SessionBytesStoreSupplier(org.apache.kafka.streams.state.SessionBytesStoreSupplier) Arguments(org.junit.jupiter.params.provider.Arguments) ArrayList(java.util.ArrayList) KeyValueBytesStoreSupplier(org.apache.kafka.streams.state.KeyValueBytesStoreSupplier)

Example 3 with Arguments

use of org.junit.jupiter.params.provider.Arguments in project zookeeper by apache.

the class UnifiedServerSocketTest method data.

public static Stream<Arguments> data() {
    ArrayList<Arguments> result = new ArrayList<>();
    int paramIndex = 0;
    for (X509KeyType caKeyType : X509KeyType.values()) {
        for (X509KeyType certKeyType : X509KeyType.values()) {
            for (Boolean hostnameVerification : new Boolean[] { true, false }) {
                result.add(Arguments.of(caKeyType, certKeyType, hostnameVerification, paramIndex++));
            }
        }
    }
    return result.stream();
}
Also used : X509KeyType(org.apache.zookeeper.common.X509KeyType) Arguments(org.junit.jupiter.params.provider.Arguments) ArrayList(java.util.ArrayList)

Example 4 with Arguments

use of org.junit.jupiter.params.provider.Arguments in project scylla by bptlab.

the class SeedProvider method provideArguments.

@Override
public Stream<? extends Arguments> provideArguments(ExtensionContext context) throws Exception {
    Random random = new Random();
    Long randomSeed = random.nextLong();
    List<Long> randomRun = new ArrayList<>();
    randomRun.add(randomSeed);
    return Stream.concat(Arrays.stream(seeds).boxed(), randomRun.stream()).map(Arguments::of);
}
Also used : Random(java.util.Random) ArrayList(java.util.ArrayList) Arguments(org.junit.jupiter.params.provider.Arguments)

Example 5 with Arguments

use of org.junit.jupiter.params.provider.Arguments in project janusgraph by JanusGraph.

the class IDAuthorityTest method configs.

public static Stream<Arguments> configs() {
    final List<Arguments> configurations = new ArrayList<>();
    ModifiableConfiguration c = getBasicConfig();
    configurations.add(arguments(checkAndReturnWriteConfiguration(c)));
    c = getBasicConfig();
    c.set(IDAUTHORITY_CAV_BITS, 9);
    c.set(IDAUTHORITY_CAV_TAG, 511);
    configurations.add(arguments(checkAndReturnWriteConfiguration(c)));
    c = getBasicConfig();
    c.set(IDAUTHORITY_CAV_RETRIES, 10);
    c.set(IDAUTHORITY_WAIT, Duration.ofMillis(10L));
    c.set(IDAUTHORITY_CAV_BITS, 7);
    // c.set(IDAUTHORITY_RANDOMIZE_UNIQUEID,true);
    c.set(IDAUTHORITY_CONFLICT_AVOIDANCE, ConflictAvoidanceMode.GLOBAL_AUTO);
    configurations.add(arguments(checkAndReturnWriteConfiguration(c)));
    return configurations.stream();
}
Also used : Arguments(org.junit.jupiter.params.provider.Arguments) ArrayList(java.util.ArrayList) ModifiableConfiguration(org.janusgraph.diskstorage.configuration.ModifiableConfiguration)

Aggregations

Arguments (org.junit.jupiter.params.provider.Arguments)12 ArrayList (java.util.ArrayList)9 Arrays (java.util.Arrays)3 Stream (java.util.stream.Stream)3 IOException (java.io.IOException)2 Method (java.lang.reflect.Method)2 List (java.util.List)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 RandomValues (com.cadenzauk.core.RandomValues)1 IsUtilityClass.isUtilityClass (com.cadenzauk.core.testutil.IsUtilityClass.isUtilityClass)1 DateFunctions.addDays (com.cadenzauk.siesta.grammar.expression.DateFunctions.addDays)1 DateFunctions.day (com.cadenzauk.siesta.grammar.expression.DateFunctions.day)1 DateFunctions.dayDiff (com.cadenzauk.siesta.grammar.expression.DateFunctions.dayDiff)1 DateFunctions.hour (com.cadenzauk.siesta.grammar.expression.DateFunctions.hour)1 DateFunctions.hourDiff (com.cadenzauk.siesta.grammar.expression.DateFunctions.hourDiff)1 DateFunctions.minute (com.cadenzauk.siesta.grammar.expression.DateFunctions.minute)1 DateFunctions.minuteDiff (com.cadenzauk.siesta.grammar.expression.DateFunctions.minuteDiff)1 DateFunctions.month (com.cadenzauk.siesta.grammar.expression.DateFunctions.month)1 DateFunctions.second (com.cadenzauk.siesta.grammar.expression.DateFunctions.second)1