类org.junit.jupiter.params.provider.CsvSource源码实例Demo

下面列出了怎么用org.junit.jupiter.params.provider.CsvSource的API类实例代码及写法,或者点击链接到github查看源代码。

源代码1 项目: incubator-tuweni   文件: BytesRLPReaderTest.java
@ParameterizedTest
// @formatter:off
@CsvSource({
  "80, ''",
  "00, '\u0000'",
  "01, '\u0001'",
  "7f, '\u007F'",
  "83646f67, dog",
  "b74c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c69" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipisicing eli'",
  "b8384c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e7365637465747572206164697069736963696e6720656c6974" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipisicing elit'",
  "b904004c6f72656d20697073756d20646f6c6f722073697420616d65742c20636f6e73656374657475722061646970697363696e6720656c69742e20437572616269747572206d6175726973206d61676e612c20737573636970697420736564207665686963756c61206e6f6e2c20696163756c697320666175636962757320746f72746f722e2050726f696e20737573636970697420756c74726963696573206d616c6573756164612e204475697320746f72746f7220656c69742c2064696374756d2071756973207472697374697175652065752c20756c7472696365732061742072697375732e204d6f72626920612065737420696d70657264696574206d6920756c6c616d636f7270657220616c6971756574207375736369706974206e6563206c6f72656d2e2041656e65616e2071756973206c656f206d6f6c6c69732c2076756c70757461746520656c6974207661726975732c20636f6e73657175617420656e696d2e204e756c6c6120756c74726963657320747572706973206a7573746f2c20657420706f73756572652075726e6120636f6e7365637465747572206e65632e2050726f696e206e6f6e20636f6e76616c6c6973206d657475732e20446f6e65632074656d706f7220697073756d20696e206d617572697320636f6e67756520736f6c6c696369747564696e2e20566573746962756c756d20616e746520697073756d207072696d697320696e206661756369627573206f726369206c756374757320657420756c74726963657320706f737565726520637562696c69612043757261653b2053757370656e646973736520636f6e76616c6c69732073656d2076656c206d617373612066617563696275732c2065676574206c6163696e6961206c616375732074656d706f722e204e756c6c61207175697320756c747269636965732070757275732e2050726f696e20617563746f722072686f6e637573206e69626820636f6e64696d656e74756d206d6f6c6c69732e20416c697175616d20636f6e73657175617420656e696d206174206d65747573206c75637475732c206120656c656966656e6420707572757320656765737461732e20437572616269747572206174206e696268206d657475732e204e616d20626962656e64756d2c206e6571756520617420617563746f72207472697374697175652c206c6f72656d206c696265726f20616c697175657420617263752c206e6f6e20696e74657264756d2074656c6c7573206c65637475732073697420616d65742065726f732e20437261732072686f6e6375732c206d65747573206163206f726e617265206375727375732c20646f6c6f72206a7573746f20756c747269636573206d657475732c20617420756c6c616d636f7270657220766f6c7574706174" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat'"
})
// @formatter:on
void shouldReadStrings(String hex, String value) {
  assertTrue(RLP.<Boolean>decode(fromHexString(hex), reader -> {
    assertEquals(value, reader.readString());
    return true;
  }));
}
 
源代码2 项目: incubator-tuweni   文件: BytesSSZReaderTest.java
@ParameterizedTest
// @formatter:off
@CsvSource({
  "00000000, ''",
  "0100000000, '\u0000'",
  "0100000001, '\u0001'",
  "010000007f, '\u007F'",
  "03000000646f67, dog",
  "370000004C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E7365637465747572206164697069736963696E6720656C69" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipisicing eli'",
  "380000004C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E7365637465747572206164697069736963696E6720656C6974" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipisicing elit'",
  "000400004C6F72656D20697073756D20646F6C6F722073697420616D65742C20636F6E73656374657475722061646970697363696E6720656C69742E20437572616269747572206D6175726973206D61676E612C20737573636970697420736564207665686963756C61206E6F6E2C20696163756C697320666175636962757320746F72746F722E2050726F696E20737573636970697420756C74726963696573206D616C6573756164612E204475697320746F72746F7220656C69742C2064696374756D2071756973207472697374697175652065752C20756C7472696365732061742072697375732E204D6F72626920612065737420696D70657264696574206D6920756C6C616D636F7270657220616C6971756574207375736369706974206E6563206C6F72656D2E2041656E65616E2071756973206C656F206D6F6C6C69732C2076756C70757461746520656C6974207661726975732C20636F6E73657175617420656E696D2E204E756C6C6120756C74726963657320747572706973206A7573746F2C20657420706F73756572652075726E6120636F6E7365637465747572206E65632E2050726F696E206E6F6E20636F6E76616C6C6973206D657475732E20446F6E65632074656D706F7220697073756D20696E206D617572697320636F6E67756520736F6C6C696369747564696E2E20566573746962756C756D20616E746520697073756D207072696D697320696E206661756369627573206F726369206C756374757320657420756C74726963657320706F737565726520637562696C69612043757261653B2053757370656E646973736520636F6E76616C6C69732073656D2076656C206D617373612066617563696275732C2065676574206C6163696E6961206C616375732074656D706F722E204E756C6C61207175697320756C747269636965732070757275732E2050726F696E20617563746F722072686F6E637573206E69626820636F6E64696D656E74756D206D6F6C6C69732E20416C697175616D20636F6E73657175617420656E696D206174206D65747573206C75637475732C206120656C656966656E6420707572757320656765737461732E20437572616269747572206174206E696268206D657475732E204E616D20626962656E64756D2C206E6571756520617420617563746F72207472697374697175652C206C6F72656D206C696265726F20616C697175657420617263752C206E6F6E20696E74657264756D2074656C6C7573206C65637475732073697420616D65742065726F732E20437261732072686F6E6375732C206D65747573206163206F726E617265206375727375732C20646F6C6F72206A7573746F20756C747269636573206D657475732C20617420756C6C616D636F7270657220766F6C7574706174" +
  ", 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Curabitur mauris magna, suscipit sed vehicula non, iaculis faucibus tortor. Proin suscipit ultricies malesuada. Duis tortor elit, dictum quis tristique eu, ultrices at risus. Morbi a est imperdiet mi ullamcorper aliquet suscipit nec lorem. Aenean quis leo mollis, vulputate elit varius, consequat enim. Nulla ultrices turpis justo, et posuere urna consectetur nec. Proin non convallis metus. Donec tempor ipsum in mauris congue sollicitudin. Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Suspendisse convallis sem vel massa faucibus, eget lacinia lacus tempor. Nulla quis ultricies purus. Proin auctor rhoncus nibh condimentum mollis. Aliquam consequat enim at metus luctus, a eleifend purus egestas. Curabitur at nibh metus. Nam bibendum, neque at auctor tristique, lorem libero aliquet arcu, non interdum tellus lectus sit amet eros. Cras rhoncus, metus ac ornare cursus, dolor justo ultrices metus, at ullamcorper volutpat'"
})
// @formatter:on
void shouldReadStrings(String hex, String value) {
  System.out.println(SSZ.encodeString(value));
  assertTrue(SSZ.<Boolean>decode(fromHexString(hex), reader -> {
    assertEquals(value, reader.readString());
    return true;
  }));
}
 
@ParameterizedTest
@CsvSource({ "test,minProperties", "test-test1-test2,maxProperties", "test-dep,dependencies" })
public void validateObject_invalidSubObject_messageShouldNotContainValue(final String keysAsString, final String keyword) {
    final String val = "testValue";
    final JSONObject subSchema = new JSONObject();

    final List<String> keys = Arrays.asList(keysAsString.split("-"));
    keys.forEach(k -> subSchema.put(k, val));

    final JSONObject object = new JSONObject().put("ObjectProperty", subSchema);

    final ValidationException e = catchThrowableOfType(
        () -> validator.validateObject(object,
            new JSONObject(new JSONTokener(this.getClass().getResourceAsStream(TEST_VALUE_SCHEMA_PATH)))),
        ValidationException.class);

    assertThat(e.getKeyword()).isEqualTo(keyword);
    assertThat(e.getSchemaPointer()).isEqualTo("#/ObjectProperty");
    assertThat(e).hasMessageNotContaining(val);
    assertThat(e.getCausingExceptions()).isEmpty();
}
 
源代码4 项目: vividus   文件: VividusLabelTests.java
@ParameterizedTest
@CsvSource({
        "TEST_CASE_ID,   testCaseId",
        "ISSUE_ID,       issueId",
        "REQUIREMENT_ID, requirementId",
        "SEVERITY,       severity",
        "EPIC,           epic",
        "FEATURE,        feature"
})
void shouldCreateLabel(VividusLabel vividusLabel, String expectedName)
{
    String value = "value";
    Label label = vividusLabel.createLabel(value);
    assertAll(
        () -> assertEquals(expectedName, label.getName()),
        () -> assertEquals(value, label.getValue())
    );
}
 
源代码5 项目: vividus   文件: VividusLabelTests.java
@ParameterizedTest
@CsvSource({
        "TEST_CASE_ID,   tms",
        "ISSUE_ID,       issue",
        "REQUIREMENT_ID, requirement"
})
void shouldCreateLink(VividusLabel vividusLabel, String type)
{
    String identifier = "VVD-5";
    Optional<Link> optionalLink = vividusLabel.createLink(identifier);
    assertTrue(optionalLink.isPresent());
    Link link = optionalLink.get();
    assertAll(
        () -> assertEquals(identifier, link.getName()),
        () -> assertEquals(type, link.getType()),
        () -> assertEquals(HTTPS + type + "/" + identifier, link.getUrl())
    );
}
 
源代码6 项目: vividus   文件: WebDriverProviderTests.java
@ParameterizedTest
@CsvSource({
    "false, false, false",
    "true, false, false",
    "true, true, true"
})
void testIsRemoteExecution(boolean initialized, boolean remote, boolean expected)
{
    WebDriverProvider spy = spy(webDriverProvider);
    testContext.put(VividusWebDriver.class, vividusWebDriver);

    when(spy.isWebDriverInitialized()).thenReturn(initialized);
    lenient().when(vividusWebDriver.isRemote()).thenReturn(remote);

    assertEquals(expected, spy.isRemoteExecution());
}
 
源代码7 项目: chart-fx   文件: TSpectrumTests.java
@ParameterizedTest
@CsvSource({ "10, 1", "1, 2", "0.1, 3", "0.01, 4" })
public void peakFinderTests(double threshold, final int nPeaks) {
    DoubleDataSet testDataSet = generateSineWaveSpectrumData(512);
    final double[] freq = testDataSet.getXValues();
    final double[] rawDataDecibel = testDataSet.getYValues();
    final double[] dataLin = ArrayMath.inverseDecibel(rawDataDecibel);

    double[] destVector = new double[dataLin.length];
    final int nMaxPeaks = 100;
    final double sigma = 1.0;
    List<DoublePoint> peaks = TSpectrum.search(freq, ArrayMath.inverseDecibel(rawDataDecibel), destVector, //
            dataLin.length, nMaxPeaks, sigma, threshold, //
            /* backgroundRemove */ false, //
            /* deconIterations */ 1, //
            /* markov */ false, //
            /* averWindow */ 5);

    assertEquals(nPeaks, peaks.size(), "peak finder with threshold = " + threshold);
}
 
源代码8 项目: chart-fx   文件: IirFilterTests.java
@DisplayName("ChebyshevI - High-Pass")
@ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}")
@CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" })
public void testChebyshevIHighPass(final int filterOrder, final int algorithmVariant) {
    final ChebyshevI iirHighPass = new ChebyshevI();
    switch (algorithmVariant) {
    case 1:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, ALLOWED_IN_BAND_RIPPLE_DB);
        break;
    }

    final DataSet magHighPass = filterAndGetMagnitudeSpectrum(iirHighPass, demoDataSet);
    assertThat("high-pass cut-off", magHighPass.getValue(DIM_X, F_CUT_HIGH), lessThan(-3.0 + EPSILON_DB));
    assertThat("high-pass rejection", magHighPass.getValue(DIM_X, 0.1 * F_CUT_HIGH), lessThan(-3.0 + EPSILON_DB - 20 * filterOrder));
    assertThat("high-pass pass-band ripple", getRange(magHighPass, (int) (N_SAMPLES_FFT * 0.95), N_SAMPLES_FFT), lessThan(ALLOWED_IN_BAND_RIPPLE_DB + EPSILON_DB));
}
 
源代码9 项目: vividus   文件: BeanFactoryIntegrationTests.java
@ParameterizedTest
@CsvSource({
        "${profile-to-use}, basicenv,               integration",
        "basicprofile,      ${environments-to-use}, integration",
        "basicprofile,      basicenv,               ${suite-to-use}"
})
void shouldResolvePlaceholdersInConfigurationProperties(String profile, String environments, String suite)
        throws IOException
{
    System.setProperty(CONFIGURATION_PROFILE, profile);
    System.setProperty(CONFIGURATION_ENVIRONMENTS, environments);
    System.setProperty(CONFIGURATION_SUITE, suite);
    BeanFactory.open();
    assertProperties(null, null);
    assertIntegrationSuiteProperty();
}
 
源代码10 项目: vividus   文件: DateExpressionProcessorTests.java
@ParameterizedTest
@CsvSource(delimiter = ';', value = {
        "generateDate(P5Y1M10D);                    1905-02-11",
        "generateDate(P1Y1M1W, dd-MM-YYYY);         08-02-1901",
        "generateDate(PT1H2M3S);                    1900-01-01T01:02:03",
        "generateDate(PT61M63S, YYYY'T'HH-mm-ss);   1900T01-02-03",
        "generateDate(-P1MT1M);                     1899-11-30T23:59:00",
        "generateDate(P, MMM);                      Jan",
        "generateDate(P, MMMM);                     January",
        "generateDate(P, d);                        1",
        "generateDate(P, EEE);                      Mon",
        "generateDate(P, EEEE);                     Monday",
        "generateDate(P, yyyy-MM-dd'T'HH:mm:ssZ);   1900-01-01T00:00:00+0000"
})
void testCalculatePeriod(String expression, String expected)
{
    mockGetCurrentDate();
    String actual = dateExpressionProcessor.execute(expression).get();
    assertEquals(expected, actual);
    assertThat(logger.getLoggingEvents(), equalTo(List.of()));
}
 
源代码11 项目: vividus   文件: HttpRequestStepsTests.java
@ParameterizedTest
@CsvSource({
        // CHECKSTYLE:OFF
        "'|name|type|value|\n|partName|STRING|content|',                                      text/plain; charset=ISO-8859-1",
        "'|name|type|value|contentType|\n|partName|STRING|content|text/html; charset=utf-8|', text/html; charset=utf-8"
        // CHECKSTYLE:ON
})
void testPutMultipartRequest(String tableAsString, String contentType)
{
    ExamplesTable requestParts = new ExamplesTable(tableAsString);
    httpRequestSteps.putMultipartRequest(requestParts);
    verify(httpTestContext).putRequestEntity(argThat(entity ->
    {
        try
        {
            return IOUtils.toString(entity.getContent(), StandardCharsets.UTF_8)
                    .contains("Content-Disposition: form-data; name=\"partName\"" + CR_LF
                            + "Content-Type: " + contentType + CR_LF
                            + "Content-Transfer-Encoding: 8bit" + CR_LF + CR_LF + CONTENT + CR_LF);
        }
        catch (@SuppressWarnings("unused") IOException e)
        {
            return false;
        }
    }));
}
 
@ParameterizedTest(name = "{index}: for expression \"{0}\", result is \"{1}\"")
@CsvSource({
    "removeWrappingDoubleQuotes(\"value\"),     value",
    "removeWrappingDoubleQuotes(value),         value",
    "removeWrappingDoubleQuotes(),              ''",
    "removeWrappingDoubleQuotes(\"\"),          ''",
    "removeWrappingDoubleQuotes(\"\"\"),        \"",
    "removeWrappingDoubleQuotes(\"value),       \"value",
    "removeWrappingDoubleQuotes(v\"alu\"e),     v\"alu\"e",
    "removeWrappingDoubleQuotes(\"va\"lu\"e\"), va\"lu\"e",
    "removeWrappingDoubleQuotes(\"va\"lu\"e),   \"va\"lu\"e",
    "removeWrappingDoubleQuotes(\"va\"lue),     \"va\"lue",
    "removeWrappingDoubleQuotes(va\"lue\"),     va\"lue\"",
    "RemoveWrappingdOUBLEQuotes(\"value\"),     value",
    "RemoveWrappingdOUBLEQuotes(\"value),       \"value",
    "removeWrappingDoubleQuotes(), ''"
    })
void testExecute(String expression, String expected)
{
    assertEquals(expected, processor.execute(expression).get());
}
 
源代码13 项目: vividus   文件: ExpressionAdapterTests.java
@ParameterizedTest
@CsvSource({
    "'target',         '#{target}',                                %s,             " + EXPRESSION_RESULT,
    "'target',         '{#{target}}',                              {%s},           " + EXPRESSION_RESULT,
    "'target',         '{#{target} and #{target}}',                {%1$s and %1$s}," + EXPRESSION_RESULT,
    "'target(})',      '#{target(})}',                             %s,             " + EXPRESSION_RESULT,
    "'tar\nget',       '#{tar\nget}',                              %s,             " + EXPRESSION_RESULT,
    "'expr(value{1})', '#{expr(#{expr(#{expr(value{1})})})}',      %s,                 value{1}"
})
void testSupportedExpression(String expressionKeyword, String input, String outputFormat, String outputValue)
{
    Mockito.lenient().when(mockedTargetProcessor.execute(EXPRESSION_KEYWORD))
            .thenReturn(Optional.of(EXPRESSION_RESULT));
    expressionAdaptor.setProcessors(List.of(mockedTargetProcessor, mockedAnotherProcessor));
    when(mockedTargetProcessor.execute(expressionKeyword)).thenReturn(Optional.of(outputValue));
    String actual = expressionAdaptor.process(input);
    String output = String.format(outputFormat, outputValue);
    assertEquals(output, actual);
}
 
源代码14 项目: chart-fx   文件: IirFilterTests.java
@DisplayName("ChebyshevI - Low-Pass")
@ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}")
@CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" })
public void testChebyshevILowPass(final int filterOrder, final int algorithmVariant) {
    final ChebyshevI iirLowPass = new ChebyshevI();
    switch (algorithmVariant) {
    case 1:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW, ALLOWED_IN_BAND_RIPPLE_DB);
        break;
    }
    final DataSet magLowPass = filterAndGetMagnitudeSpectrum(iirLowPass, demoDataSet);
    assertThat("low-pass cut-off", magLowPass.getValue(DIM_X, F_CUT_LOW), lessThan(-3.0 + EPSILON_DB));
    assertThat("low-pass rejection", magLowPass.getValue(DIM_X, 10 * F_CUT_LOW), lessThan(-3.0 + EPSILON_DB - 20 * filterOrder));
    assertThat("low-pass pass-band ripple", getRange(magLowPass, 0, magLowPass.getIndex(DIM_X, F_CUT_LOW * 0.1)), lessThan(ALLOWED_IN_BAND_RIPPLE_DB + EPSILON_DB));
}
 
源代码15 项目: chart-fx   文件: IirFilterTests.java
@DisplayName("Bessel - Low-Pass")
@ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}")
@CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" })
public void testBesselLowPass(final int filterOrder, final int algorithmVariant) {
    final Bessel iirLowPass = new Bessel();
    switch (algorithmVariant) {
    case 1:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirLowPass.lowPass(filterOrder, 1.0, F_CUT_LOW);
        break;
    }
    final DataSet magLowPass = filterAndGetMagnitudeSpectrum(iirLowPass, demoDataSet);
    assertThat("low-pass cut-off", magLowPass.getValue(DIM_X, F_CUT_LOW), lessThan(EPSILON_DB));
    assertThat("low-pass rejection", magLowPass.getValue(DIM_X, 10 * F_CUT_LOW), lessThan(-3.0 + EPSILON_DB - 10 * filterOrder));
    assertThat("low-pass pass-band ripple", getRange(magLowPass, 0, magLowPass.getIndex(DIM_X, F_CUT_LOW * 0.1)), lessThan(EPSILON_DB));
}
 
@ParameterizedTest
@CsvSource({
        "0.0.65537, 10, 20, admin-key, submit-key, '', 1000000, 1, 30",
        "0.0.2147483647, 9223372036854775807, 2147483647, admin-key, '', memo, 1000001, 1, 30",
        "0.0.1, -9223372036854775808, -2147483648, '', '', memo, 1000002, , ,",
        "0.0.55, 10, 20, admin-key, submit-key, memo, 1000003, 1, 30"
})
void createTopicTest(@ConvertWith(TopicIdConverter.class) TopicID topicId, long expirationTimeSeconds,
                     int expirationTimeNanos, @ConvertWith(KeyConverter.class) Key adminKey,
                     @ConvertWith(KeyConverter.class) Key submitKey, String memo, long consensusTimestamp,
                     Long autoRenewAccountNum, Long autoRenewPeriod) throws Exception {
    var responseCode = ResponseCodeEnum.SUCCESS;
    var transaction = createCreateTopicTransaction(adminKey, submitKey, memo, autoRenewAccountNum, autoRenewPeriod);
    var transactionRecord = createTransactionRecord(topicId, consensusTimestamp, responseCode);

    parseRecordItemAndCommit(new RecordItem(transaction, transactionRecord));

    long entityCount = autoRenewAccountNum != null ? 4 : 3; // Node, payer, topic & optionally autorenew
    var entity = getTopicEntity(topicId);
    assertTransactionInRepository(responseCode, consensusTimestamp, entity.getId());
    assertEquals(entityCount, entityRepository.count());
    var expectedEntity = createTopicEntity(topicId, null, null, adminKey, submitKey, memo, autoRenewAccountNum,
            autoRenewPeriod);
    assertThat(entity).isEqualTo(expectedEntity);
}
 
@ParameterizedTest(name = "with {0} s and expected {1} ns")
@CsvSource({
        "9223372036854775807, 9223372036854775807",
        "31556889864403199, 9223372036854775807",
        "-9223372036854775808, -9223372036854775808",
        "-1000000000000000000, -9223372036854775808"
})
void fileCreateExpirationTimeOverflow(long seconds, long expectedNanosTimestamp) throws Exception {
    Transaction transaction = fileCreateTransaction(Timestamp.newBuilder().setSeconds(seconds).build());
    TransactionBody transactionBody = TransactionBody.parseFrom(transaction.getBodyBytes());
    TransactionRecord record = transactionRecord(transactionBody);

    parseRecordItemAndCommit(new RecordItem(transaction, record));

    var dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());
    assertEquals(expectedNanosTimestamp, dbAccountEntity.getExpiryTimeNs());
}
 
@DisplayName("Filter using include")
@ParameterizedTest(name = "with entity {0} and type {1} resulting in {2}")
@CsvSource({
        "0.0.1, CONSENSUSSUBMITMESSAGE, true",
        "0.0.2, CRYPTOCREATEACCOUNT, true",
        "0.0.3, FREEZE, true",
        "0.0.4, FILECREATE, true",
        "0.0.1, CRYPTOCREATEACCOUNT, false",
        "0.0.2, CONSENSUSSUBMITMESSAGE, false",
        "0.0.4, FREEZE, false",
        ", CONSENSUSSUBMITMESSAGE, false",
        "0.0.1, UNKNOWN, false",
        ", UNKNOWN, false"
})
void filterInclude(String entityId, TransactionTypeEnum type, boolean result) {
    commonParserProperties.getInclude().add(filter("0.0.1", TransactionTypeEnum.CONSENSUSSUBMITMESSAGE));
    commonParserProperties.getInclude().add(filter("0.0.2", TransactionTypeEnum.CRYPTOCREATEACCOUNT));
    commonParserProperties.getInclude().add(filter("0.0.3", null));
    commonParserProperties.getInclude().add(filter(null, TransactionTypeEnum.FILECREATE));

    assertEquals(result, commonParserProperties.getFilter().test(
            new TransactionFilterFields(entity(entityId), type)));
}
 
@DisplayName("Filter using exclude")
@ParameterizedTest(name = "with entity {0} and type {1} resulting in {2}")
@CsvSource({
        "0.0.1, CONSENSUSSUBMITMESSAGE, false",
        "0.0.2, CRYPTOCREATEACCOUNT, false",
        "0.0.3, FREEZE, false",
        "0.0.4, FILECREATE, false",
        "0.0.1, CRYPTOCREATEACCOUNT, true",
        "0.0.2, CONSENSUSSUBMITMESSAGE, true",
        "0.0.4, FREEZE, true",
        ", CONSENSUSSUBMITMESSAGE, true",
        "0.0.1, UNKNOWN, true",
        ", UNKNOWN, true"
})
void filterExclude(String entityId, TransactionTypeEnum type, boolean result) {
    commonParserProperties.getExclude().add(filter("0.0.1", TransactionTypeEnum.CONSENSUSSUBMITMESSAGE));
    commonParserProperties.getExclude().add(filter("0.0.2", TransactionTypeEnum.CRYPTOCREATEACCOUNT));
    commonParserProperties.getExclude().add(filter("0.0.3", null));
    commonParserProperties.getExclude().add(filter(null, TransactionTypeEnum.FILECREATE));

    assertEquals(result, commonParserProperties.getFilter().test(
            new TransactionFilterFields(entity(entityId), type)));
}
 
源代码20 项目: PGM   文件: TextFormatterTest.java
@ParameterizedTest
@CsvSource(
    value = {
      "0;''",
      "1;alice",
      "2;alice and bob",
      "3;alice, bob, and jerry",
      "4;alice, bob, jerry, and nancy"
    },
    delimiter = ';')
void testList(int size, String expected) {
  final List<String> people = ImmutableList.of("alice", "bob", "jerry", "nancy");

  final List<Component> text = new LinkedList<>();
  for (String person : people.subList(0, size)) {
    text.add(TextComponent.of(person));
  }
  final Component actual = TextTranslations.translate(list(text, TextColor.WHITE), Locale.US);

  assertEquals(expected, PlainComponentSerializer.INSTANCE.serialize(actual));
}
 
源代码21 项目: hedera-mirror-node   文件: UtilityTest.java
@ParameterizedTest(name = "with seconds {0} and nanos {1}")
@CsvSource({
        "1569936354, 901",
        "0, 901",
        "1569936354, 0",
        "0,0"
})
public void timeStampInNanosTimeStamp(long seconds, int nanos) {
    Timestamp timestamp = Timestamp.newBuilder().setSeconds(seconds).setNanos(nanos).build();

    long timeStampInNanos = Utility.timeStampInNanos(timestamp);
    Instant fromTimeStamp = Instant.ofEpochSecond(0, timeStampInNanos);

    assertAll(
            () -> assertEquals(timestamp.getSeconds(), fromTimeStamp.getEpochSecond())
            , () -> assertEquals(timestamp.getNanos(), fromTimeStamp.getNano())
    );
}
 
源代码22 项目: hedera-mirror-node   文件: UtilityTest.java
@ParameterizedTest(name = "verifyHashChain {5}")
@CsvSource({
        // @formatter:off
        "'', '', 1970-01-01T00:00:00Z,        2000-01-01T10_00_00.000000Z.rcd, true,  passes if both hashes are empty",
        "xx, '', 1970-01-01T00:00:00Z,        2000-01-01T10_00_00.000000Z.rcd, true,  passes if hash mismatch and expected hash is empty", // starting stream in middle
        "'', xx, 1970-01-01T00:00:00Z,        2000-01-01T10_00_00.000000Z.rcd, false, fails if hash mismatch and actual hash is empty", // bad db state
        "xx, yy, 1970-01-01T00:00:00Z,        2000-01-01T10_00_00.000000Z.rcd, false, fails if hash mismatch and hashes are non-empty",
        "xx, yy, 2000-01-01T10:00:00.000001Z, 2000-01-01T10_00_00.000000Z.rcd, true,  passes if hash mismatch but verifyHashAfter is after filename",
        "xx, yy, 2000-01-01T10:00:00.000001Z, 2000-01-01T10_00_00.000000Z.rcd, true,  passes if hash mismatch but verifyHashAfter is same as filename",
        "xx, yy, 2000-01-01T09:59:59.999999Z, 2000-01-01T10_00_00.000000Z.rcd, false, fails if hash mismatch and verifyHashAfter is before filename",
        "xx, xx, 1970-01-01T00:00:00Z,        2000-01-01T10_00_00.000000Z.rcd, true,  passes if hashes are equal"
        // @formatter:on
})
public void testVerifyHashChain(String actualPrevFileHash, String expectedPrevFileHash,
                                @ConvertWith(InstantConverter.class) Instant verifyHashAfter, String fileName,
                                Boolean expectedResult, String testName) {
    assertThat(Utility.verifyHashChain(actualPrevFileHash, expectedPrevFileHash, verifyHashAfter, fileName))
            .isEqualTo(expectedResult);
}
 
源代码23 项目: milkman   文件: PrefixedTemplaterTest.java
@ParameterizedTest
@CsvSource({
        "AaBbCc,-",
        "LOW:AaBbCc,aabbcc",
        ":AaBbCc,-",
        "unknown:AaBbCc,-",
        "unknown:,-",
        "LOW:,-",
})
void shouldUseDefaultOnNoPrefix(String input, String output){
    PrefixedTemplaterResolver sut = new PrefixedTemplaterResolver(List.of(prefixTempl));
    assertThat(sut.resolveViaPluginTemplater(input).orElse("-")).isEqualTo(output);
}
 
源代码24 项目: incubator-tuweni   文件: BytesRLPReaderTest.java
@ParameterizedTest
@CsvSource({"80, 0", "01, 1", "10, 16", "4f, 79", "7f, 127", "8180, 128", "8203e8, 1000", "830186a0, 100000"})
void shouldReadIntegers(String hex, int value) {
  assertTrue(RLP.<Boolean>decode(fromHexString(hex), reader -> {
    assertEquals(value, reader.readInt());
    return true;
  }));
}
 
源代码25 项目: incubator-tuweni   文件: ByteBufferWriterTest.java
@ParameterizedTest
@CsvSource({"E8030000, 1000", "A0860100, 100000"})
void shouldWriteSmallIntegers(String expectedHex, int value) {
  ByteBuffer buffer = ByteBuffer.allocate(64);
  SSZ.encodeTo(buffer, writer -> writer.writeInt(value, 32));
  buffer.flip();
  assertEquals(fromHexString(expectedHex), Bytes.wrapByteBuffer(buffer));
}
 
源代码26 项目: PGM   文件: TextTranslationsTest.java
@ParameterizedTest
@CsvSource({"misc.console,Console", "misc.ownership,{0}''s {1}", "misc.snowman,☃"})
void testGetKey(String key, String translation) {
  final MessageFormat format = getKey(US, key);

  assertNotNull(format, "translation missing");
  assertEquals(US, format.getLocale(), "wrong locale");
  assertEquals(translation, format.toPattern(), "translation wrong");
}
 
@ParameterizedTest
@CsvSource({ "WaaaaaaaayTooLong,maxLength", "TooShort,minLength", "NoPatternMatch,pattern" })
public void validateObject_invalidStringValue_messageShouldNotContainValue(final String value, final String keyword) {
    final JSONObject object = new JSONObject().put("StringProperty", value);

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

    assertThat(e.getSchemaPointer()).isEqualTo("#/StringProperty");
    assertThat(e.getKeyword()).isEqualTo(keyword);
    assertThat(e.getMessage()).doesNotContain(value);
    assertThat(e.getCausingExceptions()).isEmpty();
}
 
源代码28 项目: chart-fx   文件: IirFilterTests.java
@DisplayName("Bessel - Band-Stop")
@ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}")
@CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" })
public void testBesselBandStop(final int filterOrder, final int algorithmVariant) {
    final Bessel iirBandStop = new Bessel();
    switch (algorithmVariant) {
    case 1:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH);
        break;
    }

    final DataSet magBandStop = filterAndGetMagnitudeSpectrum(iirBandStop, demoDataSet);
    assertThat("band-stop cut-off (low)", magBandStop.getValue(DIM_X, F_BAND_START), lessThan(EPSILON_DB));
    assertThat("band-stop cut-off (high)", magBandStop.getValue(DIM_X, F_BAND_STOP), lessThan(EPSILON_DB));
    assertThat("band-pass pass-band (low)", getRange(magBandStop, 0, magBandStop.getIndex(DIM_X, F_BAND_START * 0.1)), lessThan(EPSILON_DB));
    assertThat("band-pass pass-band (high)", getRange(magBandStop, (int) (N_SAMPLES_FFT * 0.95), N_SAMPLES_FFT), lessThan(EPSILON_DB));
    final double rangeStopBand = getMaximum(magBandStop,
            magBandStop.getIndex(DIM_X, (F_BAND_CENTRE - 0.03 * F_BAND_WIDTH)),
            magBandStop.getIndex(DIM_X, (F_BAND_CENTRE + 0.03 * F_BAND_WIDTH)));
    assertThat("band-pass stop-band ripple", rangeStopBand, lessThan(3.0 + EPSILON_DB - 10 * filterOrder));
}
 
源代码29 项目: chart-fx   文件: IirFilterTests.java
@DisplayName("ChebyshevI - Band-Stop")
@ParameterizedTest(name = "{displayName}: filter-order: {0}, algorithm: {1}")
@CsvSource({ "2, 0", "3, 0", "4, 0", "2, 1", "3, 1", "4, 1", "2, 2", "3, 2", "4, 2" })
public void testChebyshevIBandStop(final int filterOrder, final int algorithmVariant) {
    final ChebyshevI iirBandStop = new ChebyshevI();
    switch (algorithmVariant) {
    case 1:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_IN_BAND_RIPPLE_DB, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirBandStop.bandStop(filterOrder, 1.0, F_BAND_CENTRE, F_BAND_WIDTH, ALLOWED_IN_BAND_RIPPLE_DB);
        break;
    }

    final DataSet magBandStop = filterAndGetMagnitudeSpectrum(iirBandStop, demoDataSet);
    assertThat("band-stop cut-off (low)", magBandStop.getValue(DIM_X, F_BAND_START), lessThan(-3.0 + EPSILON_DB));
    assertThat("band-stop cut-off (high)", magBandStop.getValue(DIM_X, F_BAND_STOP), lessThan(-3.0 + EPSILON_DB));
    assertThat("band-pass pass-band (low)", getRange(magBandStop, 0, magBandStop.getIndex(DIM_X, F_BAND_START * 0.1)), lessThan(ALLOWED_IN_BAND_RIPPLE_DB + EPSILON_DB));
    assertThat("band-pass pass-band (high)", getRange(magBandStop, (int) (N_SAMPLES_FFT * 0.95), N_SAMPLES_FFT), lessThan(ALLOWED_IN_BAND_RIPPLE_DB + EPSILON_DB));
    final double rangeStopBand = getMaximum(magBandStop,
            magBandStop.getIndex(DIM_X, (F_BAND_CENTRE - 0.03 * F_BAND_WIDTH)),
            magBandStop.getIndex(DIM_X, (F_BAND_CENTRE + 0.03 * F_BAND_WIDTH)));
    assertThat("band-pass stop-band ripple", rangeStopBand, lessThan(-3.0 + EPSILON_DB - 20 * filterOrder));
}
 
源代码30 项目: hedera-mirror-node   文件: EntityIdEndecTest.java
@ParameterizedTest
@CsvSource({
        "0, 0, 0, 0",
        "0, 0, 10, 10",
        "0, 0, 4294967295, 4294967295",
        "10, 10, 10, 2814792716779530",
        "32767, 65535, 4294967295, 9223372036854775807", // max +ve for shard, max for realm, max for num = max +ve long
        "32767, 0, 0, 9223090561878065152"
})
void testEntityEncoding(long shard, long realm, long num, long encodedId) {
    assertThat(EntityIdEndec.encode(shard, realm, num)).isEqualTo(encodedId);
}
 
 类所在包
 类方法
 同包方法