org.junit.jupiter.params.ParameterizedTest Java Examples

The following examples show how to use org.junit.jupiter.params.ParameterizedTest. 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: TestStringBlockIndex.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_forwardMatch_4( final IBlockIndex index ) throws IOException{
  int[] mustReadIndex = { 0 , 3 };
  IFilter filter = new ForwardMatchStringFilter( "x" );
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
Example #2
Source File: WebhookTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest()
@EnumSource(WebhookAction.class)
public void testRegistrationFailure(WebhookAction action) throws Exception {
    ApplicationRuntime runtime = new ApplicationRuntime();
    runtime.setProperties(
        "camel.component.webhook.configuration.webhook-auto-register", "false",
        "camel.k.customizer.webhook.enabled", "true",
        "camel.k.customizer.webhook.action", action.name());

    runtime.getCamelContext().addComponent(
        "dummy",
        new DummyWebhookComponent(
        () -> {
            throw new RuntimeException("dummy error");
        },
        () -> {
            throw new RuntimeException("dummy error");
        })
    );

    runtime.addListener(new ContextConfigurer());
    runtime.addListener(RoutesConfigurer.forRoutes("classpath:webhook.js"));

    Assertions.assertThrows(FailedToCreateRouteException.class, runtime::run);
}
 
Example #3
Source File: TestStringBlockIndex.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_perfectMatch_3( final IBlockIndex index ) throws IOException{
  int[] mustReadIndex = { 0 , 3 };
  IFilter filter = new PerfectMatchStringFilter( "d" );
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
Example #4
Source File: TestNumberBlockIndex.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_le_3( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 , 1 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[8] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
Example #5
Source File: JCheckTests.java    From skara with GNU General Public License v2.0 6 votes vote down vote up
@ParameterizedTest
@EnumSource(VCS.class)
void checksForCommit(VCS vcs) throws Exception {
    try (var dir = new TemporaryDirectory()) {
        var repoPath = dir.path().resolve("repo");
        var repo = CheckableRepository.create(repoPath, vcs);

        var readme = repoPath.resolve("README");
        Files.write(readme, List.of("Hello, readme!"));
        repo.add(readme);
        var first = repo.commit("Add README", "duke", "[email protected]");

        var censusPath = dir.path().resolve("census");
        Files.createDirectories(censusPath);
        CensusCreator.populateCensusDirectory(censusPath);
        var census = Census.parse(censusPath);

        var checks = JCheck.checksFor(repo, census, first);
        var checkNames = checks.stream()
                               .map(Check::name)
                               .collect(Collectors.toSet());
        assertEquals(Set.of("whitespace", "reviewers"), checkNames);
    }
}
 
Example #6
Source File: TestCalcLogicalDataSizeDouble.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_notNull_1( final String targetClassName ) throws IOException {
  IColumn column = new PrimitiveColumn( ColumnType.DOUBLE , "column" );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)1 ) , 0 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)2 ) , 1 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)3 ) , 2 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)4 ) , 3 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)5 ) , 4 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)6 ) , 5 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)7 ) , 6 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)8 ) , 7 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)9 ) , 8 );
  column.add( ColumnType.DOUBLE , new DoubleObj( (double)10 ) , 9 );

  ColumnBinary columnBinary = create( column , targetClassName );
  assertEquals( columnBinary.logicalDataSize , Double.BYTES * 10 );
}
 
Example #7
Source File: RepositoryTests.java    From skara with GNU General Public License v2.0 6 votes vote down vote up
@ParameterizedTest
@EnumSource(VCS.class)
void testTagsOnNonEmptyRepository(VCS vcs) throws IOException {
    try (var dir = new TemporaryDirectory()) {
        var r = Repository.init(dir.path(), vcs);

        var readme = dir.path().resolve("README");
        Files.write(readme, List.of("Hello, readme!"));

        r.add(readme);
        r.commit("Add README", "duke", "[email protected]");

        var expected = vcs == VCS.GIT ? List.of() : List.of(new Tag("tip"));
        assertEquals(expected, r.tags());
    }
}
 
Example #8
Source File: RepositoryTests.java    From skara with GNU General Public License v2.0 6 votes vote down vote up
@ParameterizedTest
@EnumSource(VCS.class)
void testNonCheckedOutRepositoryIsHealthy(VCS vcs) throws IOException {
    try (var dir1 = new TemporaryDirectory();
         var dir2 = new TemporaryDirectory()) {
        var r1 = Repository.init(dir1.path(), vcs);

        var readme = dir1.path().resolve("README");
        Files.write(readme, List.of("Hello, readme!"));

        r1.add(readme);
        var hash = r1.commit("Add README", "duke", "[email protected]");
        r1.tag(hash, "tag", "tagging", "duke", "[email protected]");

        var r2 = Repository.init(dir2.path(), vcs);
        r2.fetch(r1.root().toUri(), r1.defaultBranch().name());

        assertTrue(r2.isHealthy());
    }
}
 
Example #9
Source File: TestNumberBlockIndex.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_lt_2( final IBlockIndex index , final IFilter[] filter ) throws IOException{
  int[] mustReadIndex = { 0 };
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter[4] );
  if( resultIndexList == null ){
    assertTrue( true );
    return;
  }
  Set<Integer> dic = new HashSet<Integer>();
  for( Integer i : resultIndexList ){
    dic.add( i );
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( dic.contains( mustReadIndex[i] ) );
  }
}
 
Example #10
Source File: TestShortPrimitiveColumn.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_notNull_1( final String targetClassName ) throws IOException{
  IColumn column = createNotNullColumn( targetClassName );
  assertEquals( ( (PrimitiveObject)( column.get(0).getRow() ) ).getShort() , Short.MAX_VALUE );
  assertEquals( ( (PrimitiveObject)( column.get(1).getRow() ) ).getShort() , Short.MIN_VALUE );
  assertEquals( ( (PrimitiveObject)( column.get(2).getRow() ) ).getShort() , (short)-200 );
  assertEquals( ( (PrimitiveObject)( column.get(3).getRow() ) ).getShort() , (short)-300 );
  assertEquals( ( (PrimitiveObject)( column.get(4).getRow() ) ).getShort() , (short)-400 );
  assertEquals( ( (PrimitiveObject)( column.get(5).getRow() ) ).getShort() , (short)-500 );
  assertEquals( ( (PrimitiveObject)( column.get(6).getRow() ) ).getShort() , (short)-600 );
  assertEquals( ( (PrimitiveObject)( column.get(7).getRow() ) ).getShort() , (short)700 );
  assertEquals( ( (PrimitiveObject)( column.get(8).getRow() ) ).getShort() , (short)800 );
  assertEquals( ( (PrimitiveObject)( column.get(9).getRow() ) ).getShort() , (short)900 );
  assertEquals( ( (PrimitiveObject)( column.get(10).getRow() ) ).getShort() , (short)0 );
}
 
Example #11
Source File: IirFilterTests.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
@DisplayName("Bessel - 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 testBesselHighPass(final int filterOrder, final int algorithmVariant) {
    final Bessel iirHighPass = new Bessel();
    switch (algorithmVariant) {
    case 1:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, DirectFormAbstract.DIRECT_FORM_I);
        break;
    case 2:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH, DirectFormAbstract.DIRECT_FORM_II);
        break;
    case 0:
    default:
        iirHighPass.highPass(filterOrder, 1.0, F_CUT_HIGH);
        break;
    }

    final DataSet magHighPass = filterAndGetMagnitudeSpectrum(iirHighPass, demoDataSet);
    assertThat("high-pass cut-off", magHighPass.getValue(DIM_X, F_CUT_HIGH), lessThan(EPSILON_DB));
    assertThat("high-pass rejection", magHighPass.getValue(DIM_X, 0.1 * F_CUT_HIGH), lessThan(3.0 + EPSILON_DB - 10 * filterOrder));
    assertThat("high-pass pass-band ripple", getRange(magHighPass, (int) (N_SAMPLES_FFT * 0.95), N_SAMPLES_FFT), lessThan(2 * EPSILON_DB));
}
 
Example #12
Source File: TestCalcLogicalDataSizeLong.java    From yosegi with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_notNull_1( final String targetClassName ) throws IOException {
  IColumn column = new PrimitiveColumn( ColumnType.LONG , "column" );
  column.add( ColumnType.LONG , new LongObj( (long)1 ) , 0 );
  column.add( ColumnType.LONG , new LongObj( (long)2 ) , 1 );
  column.add( ColumnType.LONG , new LongObj( (long)3 ) , 2 );
  column.add( ColumnType.LONG , new LongObj( (long)4 ) , 3 );
  column.add( ColumnType.LONG , new LongObj( (long)5 ) , 4 );
  column.add( ColumnType.LONG , new LongObj( (long)6 ) , 5 );
  column.add( ColumnType.LONG , new LongObj( (long)7 ) , 6 );
  column.add( ColumnType.LONG , new LongObj( (long)8 ) , 7 );
  column.add( ColumnType.LONG , new LongObj( (long)9 ) , 8 );
  column.add( ColumnType.LONG , new LongObj( (long)10 ) , 9 );

  ColumnBinary columnBinary = create( column , targetClassName );
  assertEquals( columnBinary.logicalDataSize , Long.BYTES * 10 );
}
 
Example #13
Source File: TextParserTest.java    From PGM with GNU Affero General Public License v3.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"", "notaduration", "1/2", "1m2d"})
void testParseDurationInvalid(String text) {
  assertEquals(
      "error.invalidFormat",
      assertThrows(TextException.class, () -> parseDuration(text)).getMessage());
}
 
Example #14
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 getDuplicatedHashIndexesOnDatabaseWithThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withDuplicatedHashIndex(),
            ctx -> {
                final List<DuplicatedIndexes> duplicatedIndexes = databaseHealth.getDuplicatedIndexes(ctx);
                assertNotNull(duplicatedIndexes);
                assertThat(duplicatedIndexes, empty());
            });
}
 
Example #15
Source File: PlatformHttpServiceCustomizerTest.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = { "/", "/test", "/test/nested" })
public void testPlatformHttpComponent(String path) throws Exception {
    Runtime runtime = Runtime.on(new DefaultCamelContext());
    runtime.addRoutes(new RouteBuilder() {
        @Override
        public void configure() throws Exception {
            fromF("platform-http:%s", path)
                .setBody().constant(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME);
        }
    });

    PlatformHttpServiceContextCustomizer httpService = new PlatformHttpServiceContextCustomizer();
    httpService.setBindPort(AvailablePortFinder.getNextAvailable());
    httpService.apply(runtime.getCamelContext());

    PlatformHttpComponent c = runtime.getCamelContext().getComponent(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME, PlatformHttpComponent.class);

    assertThat(c).isNotNull();
    assertThat(c.getEngine()).isInstanceOf(VertxPlatformHttpEngine.class);

    try {
        runtime.getCamelContext().start();

        given()
            .port(httpService.getBindPort())
        .when()
            .get(path)
        .then()
            .statusCode(200)
            .body(equalTo(PlatformHttpConstants.PLATFORM_HTTP_COMPONENT_NAME));
    } finally {
        runtime.getCamelContext().stop();
    }
}
 
Example #16
Source File: IndexesMaintenanceOnHostImplTest.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 = indexesMaintenance.getDuplicatedIndexes(ctx);
                assertNotNull(duplicatedIndexes);
                assertThat(duplicatedIndexes, empty());
            });
}
 
Example #17
Source File: TestLongRangeBlockIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_canBlockSkip_1( final IBlockIndex bIndex , final IFilter filter , final boolean result ){
  if( result ){
    assertEquals( result , bIndex.getBlockSpreadIndex( filter ).isEmpty() );
  }
  else{
    assertTrue( bIndex.getBlockSpreadIndex( filter ) == null );
  }
}
 
Example #18
Source File: ServlerlessWorkflowParsingTest.java    From kogito-runtimes with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"/exec/single-eventstate.sw.json", "/exec/single-eventstate.sw.yml"})
public void testSingleEventStateWorkflow(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()[2];
    assertTrue(node instanceof CompositeContextNode);
    node = process.getNodes()[0];
    assertTrue(node instanceof StartNode);
    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 ActionNode);
    node = compositeNode.getNodes()[2];
    assertTrue(node instanceof EndNode);

}
 
Example #19
Source File: TestNullCellIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_null_1( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 10 , 11 , 12 , 13 , 14 , 15 , 16 ,17 , 18 , 19 };
  IFilter filter = new NullFilter( column.getColumnType() );
  boolean[] filterResult = new boolean[30];
  filterResult = column.filter( filter , filterResult );
  if( filterResult == null ){
    assertTrue( true );
    return;
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( filterResult[mustReadIndex[i]] );
  }
}
 
Example #20
Source File: TestRangeStringIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_filter_1( final ICellIndex cIndex , final IFilter filter , final boolean[] result ) throws IOException{
  boolean[] r = cIndex.filter( filter , new boolean[0] );
  if( r == null ){
    assertNull( result );
  }
  else{
    assertEquals( result.length , 0 );
  }
}
 
Example #21
Source File: TestConstStringCellIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_compareString_7( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 };
  IFilter filter = new RangeStringCompareFilter( "0" , true , "15" , false , true );
  boolean[] filterResult = new boolean[10];
  filterResult = column.filter( filter , filterResult );
  if( filterResult == null ){
    assertTrue( true );
    return;
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( filterResult[mustReadIndex[i]] );
  }
}
 
Example #22
Source File: EntityRecordItemListenerCryptoTest.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@DisplayName("update account such that expiration timestamp overflows nanos_timestamp")
@ParameterizedTest(name = "with seconds {0} and expectedNanosTimestamp {1}")
@CsvSource({
        "9223372036854775807, 9223372036854775807",
        "31556889864403199, 9223372036854775807",
        "-9223372036854775808, -9223372036854775808",
        "-1000000000000000000, -9223372036854775808"
})
void cryptoUpdateExpirationOverflow(long seconds, long expectedNanosTimestamp) throws Exception {
    createAccount();

    // now update
    var updateTransaction = buildTransaction(builder -> {
        builder.getCryptoUpdateAccountBuilder()
                .setAccountIDToUpdate(accountId)
                // *** THIS IS THE OVERFLOW WE WANT TO TEST ***
                // This should result in the entity having a Long.MAX_VALUE or Long.MIN_VALUE expirations
                // (the results of overflows).
                .setExpirationTime(Timestamp.newBuilder().setSeconds(seconds));
    });
    var record = transactionRecordSuccess(TransactionBody.parseFrom(updateTransaction.getBodyBytes()));

    parseRecordItemAndCommit(new RecordItem(updateTransaction, record));

    var dbAccountEntity = getTransactionEntity(record.getConsensusTimestamp());

    assertAll(
            () -> assertEquals(2, transactionRepository.count()),
            () -> assertEquals(expectedNanosTimestamp, dbAccountEntity.getExpiryTimeNs())
    );
}
 
Example #23
Source File: UInt64Test.java    From incubator-tuweni with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource("orProvider")
void or(UInt64 v1, Object v2, UInt64 expected) {
  if (v2 instanceof UInt64) {
    assertValueEquals(expected, v1.or((UInt64) v2));
  } else if (v2 instanceof Bytes) {
    assertValueEquals(expected, v1.or((Bytes) v2));
  } else {
    throw new IllegalArgumentException(v2.getClass().getName());
  }
}
 
Example #24
Source File: TestConstStringCellIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_compareString_6( final IColumn column ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9 };
  IFilter filter = new RangeStringCompareFilter( "15" , false , "2" , true , true );
  boolean[] filterResult = new boolean[10];
  filterResult = column.filter( filter , filterResult );
  if( filterResult == null ){
    assertTrue( true );
    return;
  }
  for( int i = 0 ; i < mustReadIndex.length ; i++ ){
    assertTrue( filterResult[mustReadIndex[i]] );
  }
}
 
Example #25
Source File: IndexesMaintenanceOnHostImplTest.java    From pg-index-health with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@ValueSource(strings = {"public", "custom"})
void getInvalidIndexesOnDatabaseWithoutThem(final String schemaName) {
    executeTestOnDatabase(schemaName,
            DatabasePopulator::withReferences,
            ctx -> {
                final List<Index> invalidIndexes = indexesMaintenance.getInvalidIndexes(ctx);
                assertNotNull(invalidIndexes);
                assertThat(invalidIndexes, empty());
            });
}
 
Example #26
Source File: TestStringBlockIndex.java    From yosegi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@MethodSource( "data1" )
public void T_vackwardMatch_5( final IBlockIndex index ) throws IOException{
  int[] mustReadIndex = { 0 , 1 , 2 , 3 , 4 };
  IFilter filter = new BackwardMatchStringFilter( "a" );
  List<Integer> resultIndexList = index.getBlockSpreadIndex( filter );
  assertNull( resultIndexList );
}
 
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 getDuplicatedIndexesWithDifferentCollationShouldReturnNothing(final String schemaName) {
    executeTestOnDatabase(schemaName,
            dbp -> dbp.withReferences().withCustomCollation().withDuplicatedCustomCollationIndex(),
            ctx -> {
                final List<DuplicatedIndexes> duplicatedIndexes = databaseHealth.getDuplicatedIndexes(ctx);
                assertNotNull(duplicatedIndexes);
                assertThat(duplicatedIndexes, empty());
            });
}
 
Example #28
Source File: TimestampConverterTest.java    From hedera-mirror-node with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest(name = "toInstantByRegexPositive({0},{1},{2},{3})")
@MethodSource("toInstantByRegexPositiveSource")
public void toInstantByRegexPositive(long expectedSeconds, long expectedNanos, String pattern,
                                     String value) {
    var cut = getCut();
    var p = Pattern.compile(pattern);
    var m = p.matcher(value);
    assertTrue(m.find());
    var inst = cut.toInstant(m);
    assertAll(() -> assertEquals(expectedSeconds, inst.getEpochSecond()),
            () -> assertEquals(expectedNanos, inst.getNano())
    );
}
 
Example #29
Source File: IirFilterTests.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
@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));
}
 
Example #30
Source File: RepositoryTests.java    From skara with GNU General Public License v2.0 5 votes vote down vote up
@ParameterizedTest
@EnumSource(VCS.class)
void testDefaultBranch(VCS vcs) throws IOException {
    try (var dir = new TemporaryDirectory()) {
        var r = Repository.init(dir.path(), vcs);
        var expected = vcs == VCS.GIT ? "master" : "default";
        assertEquals(expected, r.defaultBranch().name());
    }
}