Search in sources :

Example 61 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class ExpressionBuilderTest method testExpression.

@ParameterizedTest
@MethodSource("argsForTestExpression")
void testExpression(BiFunction<ExpressionBuilder<String, InWhereExpectingAnd<String>>, Alias<SalespersonRow>, InWhereExpectingAnd<String>> method, String expectedSql, Object[] expectedArgs) {
    MockitoAnnotations.initMocks(this);
    Database database = testDatabase(new AnsiDialect());
    Alias<SalespersonRow> alias = database.table(SalespersonRow.class).as("s");
    ExpressionBuilder<String, InWhereExpectingAnd<String>> select = database.from(alias).select(SalespersonRow::firstName, "name").where(SalespersonRow::firstName);
    method.apply(select, alias).list(transaction);
    verify(transaction).query(sql.capture(), args.capture(), any());
    assertThat(sql.getValue(), is("select s.FIRST_NAME as name from SIESTA.SALESPERSON s where s.FIRST_NAME " + expectedSql));
    assertThat(args.getValue(), is(expectedArgs));
}
Also used : InWhereExpectingAnd(com.cadenzauk.siesta.grammar.select.InWhereExpectingAnd) AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) SalespersonRow(com.cadenzauk.siesta.model.SalespersonRow) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 62 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project siesta by cadenzauk.

the class FunctionTest method functionTest.

@ParameterizedTest
@MethodSource("parametersForFunctionTest")
void functionTest(Function<Alias<TestRow>, TypedExpression<?>> sutSupplier, String expectedSql, Object[] expectedArgs) {
    MockitoAnnotations.initMocks(this);
    Database database = testDatabase(new AnsiDialect());
    Alias<TestRow> alias = database.table(TestRow.class).as("s");
    database.from(alias).select(sutSupplier.apply(alias), "foo").list(transaction);
    verify(transaction).query(sql.capture(), args.capture(), rowMapper.capture());
    assertThat(sql.getValue(), is("select " + expectedSql + " as foo from SIESTA.TEST_TABLE s"));
    assertThat(args.getValue(), is(expectedArgs));
}
Also used : AnsiDialect(com.cadenzauk.siesta.dialect.AnsiDialect) TestRow(com.cadenzauk.siesta.model.TestRow) TestDatabase.testDatabase(com.cadenzauk.siesta.model.TestDatabase.testDatabase) Database(com.cadenzauk.siesta.Database) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest) MethodSource(org.junit.jupiter.params.provider.MethodSource)

Example 63 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project narchy by automenta.

the class NAL7Test method induction_on_events_composition_post.

@ValueSource(ints = { 0, 1, 2, 3, 4 })
@ParameterizedTest
public void induction_on_events_composition_post(int dt) {
    TestNAR tester = test;
    int t = 0;
    String component = "(open(John,door) &| hold(John,key))";
    tester.inputAt(t, component + ". :|:");
    tester.inputAt(t + dt, "enter(John,room). :|:");
    tester.mustBelieve((2 * (t + Math.max(2, dt)) + Math.max(2, dt) + 1), /**
     * approx
     */
    "(" + component + " ==>+" + dt + " enter(John,room))", 1.00f, 0.45f, t);
}
Also used : TestNAR(nars.test.TestNAR) ValueSource(org.junit.jupiter.params.provider.ValueSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 64 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project qpp-conversion-tool by CMSgov.

the class CpcClinicalDocumentValidatorTest method testCpcPlusSubmissionAfterEndDate.

@ParameterizedTest
@CsvSource({ "meep@mawp.blah, meep@mawp.blah", ", cpcplus@telligen.com" })
void testCpcPlusSubmissionAfterEndDate(String systemValue, String expected) {
    LocalDate endDate = LocalDate.now().minusYears(3);
    String formattedDate = endDate.format(CpcClinicalDocumentValidator.END_DATE_FORMAT);
    if (systemValue != null) {
        System.setProperty(CpcClinicalDocumentValidator.CPC_PLUS_CONTACT_EMAIL, systemValue);
    }
    System.setProperty(CpcClinicalDocumentValidator.END_DATE_VARIABLE, endDate.toString());
    Node clinicalDocument = createValidCpcPlusClinicalDocument();
    cpcValidator.internalValidateSingleNode(clinicalDocument);
    assertThat(cpcValidator.getDetails()).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsExactly(ErrorCode.CPC_PLUS_SUBMISSION_ENDED.format(formattedDate, expected));
}
Also used : Node(gov.cms.qpp.conversion.model.Node) LocalDate(java.time.LocalDate) CsvSource(org.junit.jupiter.params.provider.CsvSource) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Example 65 with ParameterizedTest

use of org.junit.jupiter.params.ParameterizedTest in project qpp-conversion-tool by CMSgov.

the class MeasureDataEncoderTest method testDenominator.

@DisplayName("Verify measure data retrieval")
@ParameterizedTest(name = "retrieval of ''{0}''")
@EnumSource(Fixture.class)
void testDenominator(Fixture fixture) throws EncodeException {
    Node measureDataNode = setUpMeasureDataNode(fixture.name());
    JsonWrapper jsonWrapper = encode(measureDataNode);
    assertThat(jsonWrapper.getInteger(fixture.value)).isEqualTo(900);
}
Also used : Node(gov.cms.qpp.conversion.model.Node) EnumSource(org.junit.jupiter.params.provider.EnumSource) DisplayName(org.junit.jupiter.api.DisplayName) ParameterizedTest(org.junit.jupiter.params.ParameterizedTest)

Aggregations

ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2045 MethodSource (org.junit.jupiter.params.provider.MethodSource)1116 EnumSource (org.junit.jupiter.params.provider.EnumSource)325 ValueSource (org.junit.jupiter.params.provider.ValueSource)302 ArgumentsSource (org.junit.jupiter.params.provider.ArgumentsSource)181 Transaction (org.neo4j.graphdb.Transaction)117 CsvSource (org.junit.jupiter.params.provider.CsvSource)113 ArrayList (java.util.ArrayList)112 ByteBuffer (java.nio.ByteBuffer)81 List (java.util.List)81 Path (java.nio.file.Path)75 Test (org.junit.jupiter.api.Test)74 InterruptAfter (io.aeron.test.InterruptAfter)72 IOException (java.io.IOException)72 KernelTransaction (org.neo4j.kernel.api.KernelTransaction)67 TimeUnit (java.util.concurrent.TimeUnit)65 ExtendWith (org.junit.jupiter.api.extension.ExtendWith)62 CountDownLatch (java.util.concurrent.CountDownLatch)61 SelfSignedCertificate (io.netty.handler.ssl.util.SelfSignedCertificate)60 Stream (java.util.stream.Stream)59