org.junit.jupiter.params.provider.ValueSource Java Examples

The following examples show how to use org.junit.jupiter.params.provider.ValueSource. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ServerlessWorkflowTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"serverless/single-operation-many-functions.sw.json", "serverless/single-operation-many-functions.sw.yml"})
public void testMultipleFunctionsCallWorkflow(String processLocation) throws Exception {

    Application app = generateCodeProcessesOnly(processLocation);
    assertThat(app).isNotNull();

    Process<? extends Model> p = app.processes().processById("function");

    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);

    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();

    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
 
Example #2
Source File: FloatDST1DTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3, 4, 5, 31, 32, 33, 34, 1023, 1024, 1025, 4095, 4096, 4097, (2 << 16) - 100, 2 << 16,
                     (2 << 16) + 100 })
public void
identityDSTTests(final int nSamples) {
    FloatDST_1D fft = new FloatDST_1D(nSamples);
    float[] testSignal1Ref = generateDelta(2 * nSamples);
    float[] testSignal1 = generateDelta(2 * nSamples);
    float[] testSignal2Ref = generateRamp(2 * nSamples, nSamples);
    float[] testSignal2 = generateRamp(2 * nSamples, nSamples);

    // basic identity tests
    fft.forward(testSignal1, true);
    fft.inverse(testSignal1, true);
    assertArrayEquals(testSignal1Ref, testSignal1, nSamples * FFT_NUMERIC_LIMITS, "delta identity");

    fft.forward(testSignal2, true);
    fft.inverse(testSignal2, true);
    assertArrayEquals(testSignal2Ref, testSignal2, nSamples * FFT_NUMERIC_LIMITS, "ramp identity");
}
 
Example #3
Source File: ServlerlessWorkflowParsingTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"/exec/parallel-state.sw.json", "/exec/parallel-state.sw.yml"})
public void testParallelWorkflow(String workflowLocation) throws Exception {
    RuleFlowProcess process = (RuleFlowProcess) getWorkflowParser(workflowLocation).parseWorkFlow(classpathResourceReader(workflowLocation));
    assertEquals("parallelworkflow", process.getId());
    assertEquals("parallel-wf", process.getName());
    assertEquals("1.0", process.getVersion());
    assertEquals("org.kie.kogito.serverless", process.getPackageName());
    assertEquals(RuleFlowProcess.PUBLIC_VISIBILITY, process.getVisibility());

    assertEquals(6, process.getNodes().length);

    Node node = process.getNodes()[0];
    assertTrue(node instanceof StartNode);
    node = process.getNodes()[1];
    assertTrue(node instanceof EndNode);
    node = process.getNodes()[2];
    assertTrue(node instanceof Split);
    node = process.getNodes()[3];
    assertTrue(node instanceof Join);
    node = process.getNodes()[4];
    assertTrue(node instanceof SubProcessNode);
    node = process.getNodes()[5];
    assertTrue(node instanceof SubProcessNode);
}
 
Example #4
Source File: RandomIntExpressionProcessorTests.java    From vividus with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {
    "randomInt(3)",
    "randomInt(-3)",
    "randomInt(+3)",
    "randomInt(1.1, 1)",
    "randomInt(0, 1.1)",
    "randomInt(0, 1, 2)",
    "randomInt(1aef)",
    "randomInt(-)",
    "randomInt()",
    "randomInt(, 1)",
    "randomInt(1, )"
})
void testDoesNotMatch(String expression)
{
    assertFalse(processor.execute(expression).isPresent());
}
 
Example #5
Source File: DoubleFFT1DTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3, 4, 5, 1023, 1024, 1025, 4095, 4096, 4097, (2 << 16) - 100, 2 << 16,
                     (2 << 16) + 100 })
public void
identityComplexlFFTTests(final int nSamples) {
    DoubleFFT_1D fft = new DoubleFFT_1D(nSamples);
    double[] testSignal1Ref = generateDelta(2 * nSamples);
    double[] testSignal1 = generateDelta(2 * nSamples);
    double[] testSignal2Ref = generateRamp(2 * nSamples, nSamples);
    double[] testSignal2 = generateRamp(2 * nSamples, nSamples);

    // basic identity tests
    fft.complexForward(testSignal1);
    fft.complexInverse(testSignal1, true);
    assertArrayEquals(testSignal1Ref, testSignal1, nSamples * FFT_NUMERIC_LIMITS, "delta identity");

    fft.complexForward(testSignal2);
    fft.complexInverse(testSignal2, true);
    assertArrayEquals(testSignal2Ref, testSignal2, nSamples * FFT_NUMERIC_LIMITS, "ramp identity");
}
 
Example #6
Source File: ServlerlessWorkflowParsingTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"/exec/single-inject-state.sw.json", "/exec/single-inject-state.sw.yml"})
public void testSingleInjectWorkflow(String workflowLocation) throws Exception {
    RuleFlowProcess process = (RuleFlowProcess) getWorkflowParser(workflowLocation).parseWorkFlow(classpathResourceReader(workflowLocation));
    assertEquals("function", process.getId());
    assertEquals("test-wf", process.getName());
    assertEquals("1.0", process.getVersion());
    assertEquals("org.kie.kogito.serverless", process.getPackageName());
    assertEquals(RuleFlowProcess.PUBLIC_VISIBILITY, process.getVisibility());

    assertEquals(3, process.getNodes().length);

    Node node = process.getNodes()[0];
    assertTrue(node instanceof StartNode);
    node = process.getNodes()[2];
    assertTrue(node instanceof ActionNode);
    node = process.getNodes()[1];
    assertTrue(node instanceof EndNode);

    ActionNode actionNode = (ActionNode) process.getNodes()[2];
    assertEquals("SimpleInject", actionNode.getName());
}
 
Example #7
Source File: GcsSinkTaskTest.java    From aiven-kafka-connect-gcs with GNU Affero General Public License v3.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"none", "gzip", "snappy", "zstd"})
final void nullKeyValueAndTimestamp(final String compression) {
    properties.put(GcsSinkConfig.FILE_COMPRESSION_TYPE_CONFIG, compression);
    properties.put(GcsSinkConfig.FORMAT_OUTPUT_FIELDS_CONFIG, "key,value,timestamp,offset");
    final GcsSinkTask task = new GcsSinkTask(properties, storage);

    final List<SinkRecord> records = Arrays.asList(
        createNullRecord("topic0", 0, 10),
        createNullRecord("topic0", 0, 11),
        createNullRecord("topic0", 0, 12)
    );
    task.put(records);
    task.flush(null);

    final CompressionType compressionType = CompressionType.forName(compression);

    assertIterableEquals(
        Lists.newArrayList("topic0-0-10" + compressionType.extension()),
        testBucketAccessor.getBlobNames());
    assertIterableEquals(
        Lists.newArrayList(",,,10", ",,,11", ",,,12"),
        readRawLinesFromBlob("topic0-0-10" + compressionType.extension(), compression));
}
 
Example #8
Source File: FloatDHT1DTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3, 4, 5, 31, 32, 33, 34, 1023, 1024, 1025, 4095, 4096, 4097, (2 << 16) - 100, 2 << 16,
                     (2 << 16) + 100 })
public void
identityDHTTests(final int nSamples) {
    FloatDHT_1D fft = new FloatDHT_1D(nSamples);
    float[] testSignal1Ref = generateDelta(2 * nSamples);
    float[] testSignal1 = generateDelta(2 * nSamples);
    float[] testSignal2Ref = generateRamp(2 * nSamples, nSamples);
    float[] testSignal2 = generateRamp(2 * nSamples, nSamples);

    // basic identity tests
    fft.forward(testSignal1);
    fft.inverse(testSignal1, true);
    assertArrayEquals(testSignal1Ref, testSignal1, nSamples * FFT_NUMERIC_LIMITS, "delta identity");

    fft.forward(testSignal2);
    fft.inverse(testSignal2, true);
    assertArrayEquals(testSignal2Ref, testSignal2, nSamples * FFT_NUMERIC_LIMITS, "ramp identity");
}
 
Example #9
Source File: IndexesMaintenanceOnHostImplTest.java    From pg-index-health with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getUnusedIndexesOnDatabaseWithThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withData().withDuplicatedIndex(),
            ctx -> {
                final List<UnusedIndex> unusedIndexes = indexesMaintenance.getUnusedIndexes(ctx);
                assertNotNull(unusedIndexes);
                assertThat(unusedIndexes, hasSize(6));
                final Set<String> names = unusedIndexes.stream().map(UnusedIndex::getIndexName).collect(toSet());
                assertThat(names, containsInAnyOrder(
                        ctx.enrichWithSchema("i_clients_last_first"),
                        ctx.enrichWithSchema("i_clients_last_name"),
                        ctx.enrichWithSchema("i_accounts_account_number"),
                        ctx.enrichWithSchema("i_accounts_number_balance_not_deleted"),
                        ctx.enrichWithSchema("i_accounts_account_number_not_deleted"),
                        ctx.enrichWithSchema("i_accounts_id_account_number_not_deleted")));
            });
}
 
Example #10
Source File: TablesMaintenanceOnHostImplTest.java    From pg-index-health with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getTablesWithBloatOnDatabaseWithThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withData().withStatistics(),
            ctx -> {
                waitForStatisticsCollector();
                assertTrue(existsStatisticsForTable(ctx, "accounts"));

                final List<TableWithBloat> tables = tablesMaintenance.getTablesWithBloat(ctx);
                assertNotNull(tables);
                assertThat(tables, hasSize(2));
                final TableWithBloat table = tables.get(0);
                assertEquals(ctx.enrichWithSchema("accounts"), table.getTableName());
                assertEquals(114688L, table.getTableSizeInBytes());
                assertEquals(0L, table.getBloatSizeInBytes());
                assertEquals(0, table.getBloatPercentage());
            });
}
 
Example #11
Source File: DoubleDCT1DTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3, 4, 5, 31, 32, 33, 34, 1023, 1024, 1025, 4095, 4096, 4097, (2 << 16) - 100, 2 << 16,
                     (2 << 16) + 100 })
public void
identityDCTTests(final int nSamples) {
    DoubleDCT_1D fft = new DoubleDCT_1D(nSamples);
    double[] testSignal1Ref = generateDelta(2 * nSamples);
    double[] testSignal1 = generateDelta(2 * nSamples);
    double[] testSignal2Ref = generateRamp(2 * nSamples, nSamples);
    double[] testSignal2 = generateRamp(2 * nSamples, nSamples);

    // basic identity tests
    fft.forward(testSignal1, true);
    fft.inverse(testSignal1, true);
    assertArrayEquals(testSignal1Ref, testSignal1, nSamples * FFT_NUMERIC_LIMITS, "delta identity");

    fft.forward(testSignal2, true);
    fft.inverse(testSignal2, true);
    assertArrayEquals(testSignal2Ref, testSignal2, nSamples * FFT_NUMERIC_LIMITS, "ramp identity");
}
 
Example #12
Source File: ValidatorTest.java    From aws-cloudformation-resource-schema with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { "anyOf", "allOf", "oneOf" })
public void validateObject_invalidCombiner_messageShouldNotContainValue(final String keyword) {
    final String propName = keyword + "Property";
    final String propVal = "NotAnInteger";
    final JSONObject object = new JSONObject().put(propName, propVal);

    final ValidationException e = catchThrowableOfType(
        () -> validator.validateObject(object, loadJSON(TEST_VALUE_SCHEMA_PATH)),
        ValidationException.class);

    final String pointer = "#/" + propName;
    assertThat(e.getSchemaPointer()).isEqualTo(pointer);
    assertThat(e.getKeyword()).isEqualTo(keyword);
    assertThat(e).hasMessageNotContaining(propVal);
    assertThat(e.getCausingExceptions()).hasSize(1);

    final ValidationException enumEx = e.getCausingExceptions().get(0);
    assertThat(enumEx.getSchemaPointer()).isEqualTo(pointer);
    assertThat(enumEx).hasMessageNotContaining(propVal);
    assertThat(enumEx.getKeyword()).isEqualTo("type");
    assertThat(enumEx.getCausingExceptions()).isEmpty();
}
 
Example #13
Source File: HttpTest.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { "ahc", "http", "netty-http" })
public void basicProducer(String component) {
    RestAssured
            .given()
            .queryParam("test-port", RestAssured.port)
            .when()
            .get("/test/client/{component}/get", component)
            .then()
            .body(is("get"));

    RestAssured
            .given()
            .queryParam("test-port", RestAssured.port)
            .body("message")
            .when()
            .post("/test/client/{component}/post", component)
            .then()
            .body(is("MESSAGE"));
}
 
Example #14
Source File: ServerlessWorkflowTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"serverless/multiple-operations.sw.json", "serverless/multiple-operations.sw.yml"})
public void testMultipleOperationsWorkflow(String processLocation) throws Exception {

    Application app = generateCodeProcessesOnly(processLocation);
    assertThat(app).isNotNull();

    Process<? extends Model> p = app.processes().processById("function");

    Model m = p.createModel();
    Map<String, Object> parameters = new HashMap<>();
    m.fromMap(parameters);

    ProcessInstance<?> processInstance = p.createInstance(m);
    processInstance.start();

    assertThat(processInstance.status()).isEqualTo(ProcessInstance.STATE_COMPLETED);
}
 
Example #15
Source File: FloatFFT1DTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(ints = { 1, 2, 3, 4, 5, 1023, 1024, 1025, 4095, 4096, 4097, (2 << 16) - 100, 2 << 16,
                     (2 << 16) + 100 })
public void
identityComplexlFFTTests(final int nSamples) {
    FloatFFT_1D fft = new FloatFFT_1D(nSamples);
    float[] testSignal1Ref = generateDelta(2 * nSamples);
    float[] testSignal1 = generateDelta(2 * nSamples);
    float[] testSignal2Ref = generateRamp(2 * nSamples, nSamples);
    float[] testSignal2 = generateRamp(2 * nSamples, nSamples);

    // basic identity tests
    fft.complexForward(testSignal1);
    fft.complexInverse(testSignal1, true);
    assertArrayEquals(testSignal1Ref, testSignal1, nSamples * FFT_NUMERIC_LIMITS, "delta identity");

    fft.complexForward(testSignal2);
    fft.complexInverse(testSignal2, true);
    assertArrayEquals(testSignal2Ref, testSignal2, nSamples * FFT_NUMERIC_LIMITS, "ramp identity");
}
 
Example #16
Source File: DatabaseHealthImplTest.java    From pg-index-health with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getUnusedIndexesOnDatabaseWithThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withData().withDuplicatedIndex(),
            ctx -> {
                final List<UnusedIndex> unusedIndexes = databaseHealth.getUnusedIndexes(ctx);
                assertNotNull(unusedIndexes);
                assertThat(unusedIndexes, hasSize(6));
                final Set<String> names = unusedIndexes.stream().map(UnusedIndex::getIndexName).collect(toSet());
                assertThat(names, containsInAnyOrder(
                        ctx.enrichWithSchema("i_clients_last_first"),
                        ctx.enrichWithSchema("i_clients_last_name"),
                        ctx.enrichWithSchema("i_accounts_account_number"),
                        ctx.enrichWithSchema("i_accounts_number_balance_not_deleted"),
                        ctx.enrichWithSchema("i_accounts_account_number_not_deleted"),
                        ctx.enrichWithSchema("i_accounts_id_account_number_not_deleted")));
            });
}
 
Example #17
Source File: ServlerlessWorkflowParsingTest.java    From kogito-runtimes with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"/exec/single-subflow.sw.json", "/exec/single-subflow.sw.yml"})
public void testSingleSubFlowWorkflow(String workflowLocation) throws Exception {
    RuleFlowProcess process = (RuleFlowProcess) getWorkflowParser(workflowLocation).parseWorkFlow(classpathResourceReader(workflowLocation));
    assertEquals("function", process.getId());
    assertEquals("test-wf", process.getName());
    assertEquals("1.0", process.getVersion());
    assertEquals("org.kie.kogito.serverless", process.getPackageName());
    assertEquals(RuleFlowProcess.PUBLIC_VISIBILITY, process.getVisibility());

    assertEquals(3, process.getNodes().length);

    Node node = process.getNodes()[0];
    assertTrue(node instanceof StartNode);
    node = process.getNodes()[2];
    assertTrue(node instanceof SubProcessNode);
    node = process.getNodes()[1];
    assertTrue(node instanceof EndNode);

    SubProcessNode subProcessNode = (SubProcessNode) process.getNodes()[2];
    assertEquals("abc", subProcessNode.getProcessId());
}
 
Example #18
Source File: BinarySerialiserTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@DisplayName("test getDoubleArray([boolean[], byte[], ..., String[]) helper method")
@ParameterizedTest(name = "IoBuffer class - {0}")
@ValueSource(classes = { FastByteBuffer.class, ByteBuffer.class })
public void testGetDoubleArrayHelper(final Class<? extends IoBuffer> bufferClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    assertNotNull(bufferClass, "bufferClass being not null");
    assertNotNull(bufferClass.getConstructor(int.class), "Constructor(Integer) present");
    final IoBuffer buffer = bufferClass.getConstructor(int.class).newInstance(2 * BUFFER_SIZE); // a bit larger buffer since we test more cases at once

    putGenericTestArrays(buffer);

    buffer.reset();

    // test conversion to double array
    assertThrows(IllegalArgumentException.class, () -> BinarySerialiser.getDoubleArray(buffer, DataType.OTHER));
    assertArrayEquals(new double[] { 1.0, 0.0, 1.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.BOOL_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.BYTE_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.CHAR_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.SHORT_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.INT_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.LONG_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.FLOAT_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.DOUBLE_ARRAY));
    assertArrayEquals(new double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getDoubleArray(buffer, DataType.STRING_ARRAY));
}
 
Example #19
Source File: BinarySerialiserTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@DisplayName("test getGenericArrayAsBoxedPrimitive(...) helper method")
@ParameterizedTest(name = "IoBuffer class - {0}")
@ValueSource(classes = { FastByteBuffer.class, ByteBuffer.class })
public void testgetGenericArrayAsBoxedPrimitiveHelper(final Class<? extends IoBuffer> bufferClass) throws InstantiationException, IllegalAccessException, IllegalArgumentException, InvocationTargetException, NoSuchMethodException, SecurityException {
    assertNotNull(bufferClass, "bufferClass being not null");
    assertNotNull(bufferClass.getConstructor(int.class), "Constructor(Integer) present");
    final IoBuffer buffer = bufferClass.getConstructor(int.class).newInstance(2 * BUFFER_SIZE); // a bit larger buffer since we test more cases at once

    putGenericTestArrays(buffer);

    buffer.reset();

    // test conversion to double array
    assertThrows(IllegalArgumentException.class, () -> BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.OTHER));

    assertArrayEquals(new Boolean[] { true, false, true }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.BOOL));
    assertArrayEquals(new Byte[] { (byte) 1.0, (byte) 0.0, (byte) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.BYTE));
    assertArrayEquals(new Character[] { (char) 1.0, (char) 0.0, (char) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.CHAR));
    assertArrayEquals(new Short[] { (short) 1.0, (short) 0.0, (short) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.SHORT));
    assertArrayEquals(new Integer[] { (int) 1.0, (int) 0.0, (int) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.INT));
    assertArrayEquals(new Long[] { (long) 1.0, (long) 0.0, (long) 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.LONG));
    assertArrayEquals(new Float[] { 1.0f, 0.0f, 2.0f }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.FLOAT));
    assertArrayEquals(new Double[] { 1.0, 0.0, 2.0 }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.DOUBLE));
    assertArrayEquals(new String[] { "1.0", "0.0", "2.0" }, BinarySerialiser.getGenericArrayAsBoxedPrimitive(buffer, DataType.STRING));
}
 
Example #20
Source File: JmsTest.java    From camel-quarkus with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { "jms", "paho", "paho-ws", "sjms" })
public void testJmsComponent(String component) {
    String message = "Hello Camel Quarkus " + component;

    RestAssured.given()
            .contentType(ContentType.TEXT)
            .body(message)
            .post("/messaging/" + component + "/{queueName}", component + "-test-queue")
            .then()
            .statusCode(201);

    RestAssured.given()
            .contentType(ContentType.TEXT)
            .get("/messaging/" + component + "/{queueName}", component + "-test-queue")
            .then()
            .statusCode(200)
            .body(is(message));
}
 
Example #21
Source File: WebDriverTypeEditorTests.java    From vividus with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"", " "})
void testBlankValue(String propertyValue)
{
    WebDriverTypeEditor editor = new WebDriverTypeEditor();
    editor.setAsText(propertyValue);
    assertNull(editor.getValue());
}
 
Example #22
Source File: ServlerlessWorkflowParsingTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"/exec/rule-operation.sw.json", "/exec/rule-operation.sw.yml"})
public void testRuleSetService(String workflowLocation) throws Exception {
    RuleFlowProcess process = (RuleFlowProcess) getWorkflowParser(workflowLocation).parseWorkFlow(classpathResourceReader(workflowLocation));
    assertEquals("ruleunitworkflow", process.getId());
    assertEquals("Rule Unit Workflow", process.getName());
    assertEquals("1.0", process.getVersion());
    assertEquals("org.kie.kogito.serverless", process.getPackageName());
    assertEquals(RuleFlowProcess.PUBLIC_VISIBILITY, process.getVisibility());

    assertEquals(3, process.getNodes().length);
    Node node = process.getNodes()[0];
    assertTrue(node instanceof StartNode);
    node = process.getNodes()[2];
    assertTrue(node instanceof CompositeContextNode);
    node = process.getNodes()[1];
    assertTrue(node instanceof EndNode);

    // now check the composite one to see what nodes it has
    CompositeContextNode compositeNode = (CompositeContextNode) process.getNodes()[2];

    assertEquals(3, compositeNode.getNodes().length);

    node = compositeNode.getNodes()[0];
    assertTrue(node instanceof StartNode);
    node = compositeNode.getNodes()[1];
    assertTrue(node instanceof RuleSetNode);
    node = compositeNode.getNodes()[2];
    assertTrue(node instanceof EndNode);
}
 
Example #23
Source File: ValidatorTest.java    From aws-cloudformation-resource-schema with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { "https://github.com/aws-cloudformation/aws-cloudformation-rpdk",
    "https://github.com/aws-cloudformation/aws-cloudformation-rpdk.git", "https://example.com/%F0%9F%8E%85", })
public void validateDefinition_matchingDocumentationUrl_shouldNotThrow(final String documentationUrl) {
    final JSONObject definition = baseSchema().put("documentationUrl", documentationUrl);

    validator.validateResourceDefinition(definition);
}
 
Example #24
Source File: RestTemplateConnectTimeoutTest.java    From hellokoding-courses with MIT License 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"http://example.com:81", "http://10.255.255.255"})
public void testConnectTimeout(String url) {
    long startMillis = System.currentTimeMillis();

    Throwable throwable = catchThrowable(() -> {
        restTemplateWithConnectTimeout.getForObject(url, String.class);
    });

    long endMillis = System.currentTimeMillis();
    System.out.println("Execution time: " + (endMillis - startMillis));

    assertThat(throwable).hasRootCauseInstanceOf(SocketTimeoutException.class);
}
 
Example #25
Source File: TextParserTest.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"-oo", "0", "-1337"})
void testParseIntegerOutOfRange(String text) {
  assertEquals(
      "error.outOfRange",
      assertThrows(TextException.class, () -> parseInteger(text, Range.greaterThan(0)))
          .getMessage());
}
 
Example #26
Source File: TopicPartitionRecordGrouperTest.java    From aiven-kafka-connect-gcs with GNU Affero General Public License v3.0 5 votes vote down vote up
@ParameterizedTest
@NullSource
@ValueSource(ints = 10)
final void empty(final Integer maxRecordsPerFile) {
    final Template filenameTemplate = Template.of("{{topic}}-{{partition}}-{{start_offset}}");
    final TopicPartitionRecordGrouper grouper =
        new TopicPartitionRecordGrouper(filenameTemplate, maxRecordsPerFile, DEFAULT_TS_SOURCE);
    assertThat(grouper.records(), anEmptyMap());
}
 
Example #27
Source File: DatabaseHealthImplTest.java    From pg-index-health with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getForeignKeysNotCoveredWithIndexOnDatabaseWithNotSuitableIndex(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withNonSuitableIndex(),
            ctx -> {
                final List<ForeignKey> foreignKeys = databaseHealth.getForeignKeysNotCoveredWithIndex(ctx);
                assertNotNull(foreignKeys);
                assertThat(foreignKeys, hasSize(1));
                final ForeignKey foreignKey = foreignKeys.get(0);
                assertEquals(ctx.enrichWithSchema("accounts"), foreignKey.getTableName());
                assertThat(foreignKey.getColumnsInConstraint(), contains("client_id"));
            });
}
 
Example #28
Source File: DatabaseHealthImplTest.java    From pg-index-health with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getForeignKeysNotCoveredWithIndexOnDatabaseWithoutThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp,
            ctx -> {
                final List<ForeignKey> foreignKeys = databaseHealth.getForeignKeysNotCoveredWithIndex(ctx);
                assertNotNull(foreignKeys);
                assertThat(foreignKeys, empty());
            });
}
 
Example #29
Source File: DatabaseHealthImplTest.java    From pg-index-health with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getIntersectedIndexesWithDifferentOpclassShouldReturnNothing(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withDifferentOpclassIndexes(),
            ctx -> {
                final List<DuplicatedIndexes> intersectedIndexes = databaseHealth.getIntersectedIndexes(ctx);
                assertNotNull(intersectedIndexes);
                assertThat(intersectedIndexes, empty());
            });
}
 
Example #30
Source File: DatabaseHealthImplTest.java    From pg-index-health with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getDuplicatedIndexesWithDifferentCollationShouldReturnNothing(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withCustomCollation().withDuplicatedCustomCollationIndex(),
            ctx -> {
                final List<DuplicatedIndexes> duplicatedIndexes = databaseHealth.getDuplicatedIndexes(ctx);
                assertNotNull(duplicatedIndexes);
                assertThat(duplicatedIndexes, empty());
            });
}