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

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

@ParameterizedTest
@NullSource
@ValueSource(strings = {"none", "gzip", "snappy", "zstd"})
void filenameTemplateNotSet(final String compression) {
    final Map<String, String> properties = new HashMap<>();
    properties.put("gcs.bucket.name", "test-bucket");
    if (compression != null) {
        properties.put("file.compression.type", compression);
    }

    final CompressionType compressionType =
            compression == null ? CompressionType.NONE : CompressionType.forName(compression);
    final String expected = "a-b-c" + compressionType.extension();

    final GcsSinkConfig config = new GcsSinkConfig(properties);
    final String actual = config.getFilenameTemplate()
        .instance()
        .bindVariable("topic", () -> "a")
        .bindVariable("partition", () -> "b")
        .bindVariable("start_offset", () -> "c")
        .render();
    assertEquals(expected, actual);
}
 
源代码2 项目: logbook   文件: JsonMediaTypeTest.java
@ParameterizedTest
@ValueSource(strings = {
        "application/notjson",
        "application/abc+notjson;charset=utf-8",
        "application/notjson;charset=utf-8",
        "application/abc+notjson;charset=utf-8",
        "text/json",
        "text/abc+json;charset=utf-8",
        "text/json;charset=utf-8",
        "text/abc+json;charset=utf-8",
        "image/json",
        "image/abc+json;charset=utf-8",
        "image/json;charset=utf-8",
        "image/abc+json;charset=utf-8"
        })
@NullSource
public void testNonJsonTypes(String mediaType) {
    assertFalse(JsonMediaType.JSON.test(mediaType));
    assertEquals(JsonMediaType.JSON.test(mediaType), JSON.test(mediaType));
}
 
源代码3 项目: ethsigner   文件: EthSignBodyProviderTest.java
@ParameterizedTest
@ArgumentsSource(InvalidParamsProvider.class)
@NullSource
public void ifParamIsInvalidErrorIsReturned(final Object params) {
  final TransactionSignerProvider mockSignerProvider = mock(TransactionSignerProvider.class);
  final EthSignBodyProvider bodyProvider = new EthSignBodyProvider(mockSignerProvider);

  final JsonRpcRequest request = new JsonRpcRequest("2.0", "eth_sign");
  request.setId(new JsonRpcRequestId(1));
  request.setParams(params);
  final JsonRpcBody body = bodyProvider.getBody(request);

  assertThat(body.hasError()).isTrue();
  assertThat(body.error().getCode()).isEqualTo(JsonRpcError.INVALID_PARAMS.getCode());
}
 
@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());
}
 
@ParameterizedTest
@NullSource
@ValueSource(strings = {"none", "gzip", "snappy", "zstd"})
void supportedCompression(final String compression) {
    final Map<String, String> properties = new HashMap<>();
    properties.put("gcs.bucket.name", "test-bucket");
    if (compression != null) {
        properties.put("file.compression.type", compression);
    }

    final GcsSinkConfig config = new GcsSinkConfig(properties);
    final CompressionType expectedCompressionType =
            compression == null ? CompressionType.NONE : CompressionType.forName(compression);
    assertEquals(expectedCompressionType, config.getCompressionType());
}
 
源代码6 项目: hudi   文件: TestHoodieSnapshotExporter.java
@ParameterizedTest
@NullSource
public void testValidateOutputFormat_withNullFormat(String format) {
  assertThrows(ParameterException.class, () -> {
    new OutputFormatValidator().validate(null, format);
  });
}
 
源代码7 项目: feast   文件: RequestUtilTest.java
@ParameterizedTest
@NullSource
void createFeatureSets_ShouldThrowExceptionForNullFeatureRefs(List<String> input) {
  assertThrows(IllegalArgumentException.class, () -> RequestUtil.createFeatureRefs(input));
}
 
源代码8 项目: quarkus   文件: ParameterizedSimpleTestCase.java
@ParameterizedTest
@NullSource
public void nullArgument(String arg) {
    assertNull(arg);
}
 
 类所在包
 同包方法