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

The following examples show how to use org.junit.jupiter.params.provider.NullSource. 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: GcsSinkConfigTest.java    From aiven-kafka-connect-gcs with GNU Affero General Public License v3.0 6 votes vote down vote up
@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);
}
 
Example #2
Source File: JsonMediaTypeTest.java    From logbook with MIT License 6 votes vote down vote up
@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));
}
 
Example #3
Source File: EthSignBodyProviderTest.java    From ethsigner with Apache License 2.0 5 votes vote down vote up
@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());
}
 
Example #4
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 #5
Source File: GcsSinkConfigTest.java    From aiven-kafka-connect-gcs with GNU Affero General Public License v3.0 5 votes vote down vote up
@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());
}
 
Example #6
Source File: TestHoodieSnapshotExporter.java    From hudi with Apache License 2.0 5 votes vote down vote up
@ParameterizedTest
@NullSource
public void testValidateOutputFormat_withNullFormat(String format) {
  assertThrows(ParameterException.class, () -> {
    new OutputFormatValidator().validate(null, format);
  });
}
 
Example #7
Source File: RequestUtilTest.java    From feast with Apache License 2.0 4 votes vote down vote up
@ParameterizedTest
@NullSource
void createFeatureSets_ShouldThrowExceptionForNullFeatureRefs(List<String> input) {
  assertThrows(IllegalArgumentException.class, () -> RequestUtil.createFeatureRefs(input));
}
 
Example #8
Source File: ParameterizedSimpleTestCase.java    From quarkus with Apache License 2.0 4 votes vote down vote up
@ParameterizedTest
@NullSource
public void nullArgument(String arg) {
    assertNull(arg);
}