use of org.junit.jupiter.params.provider.Arguments in project junit5 by junit-team.
the class ParameterizedTestExtensionTests method argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException.
@Test
void argumentsRethrowsOriginalExceptionFromProviderAsUncheckedException() {
ArgumentsProvider failingProvider = (context) -> {
throw new FileNotFoundException("a message");
};
var exception = assertThrows(FileNotFoundException.class, () -> arguments(failingProvider, null));
assertEquals("a message", exception.getMessage());
}
use of org.junit.jupiter.params.provider.Arguments in project siesta by cadenzauk.
the class DateFunctionsTest method parametersForFunctionTest.
@SuppressWarnings("unused")
private static Stream<Arguments> parametersForFunctionTest() {
LocalDate randomLocalDate = RandomValues.randomLocalDate();
LocalDateTime randomLocalDateTime = RandomValues.randomLocalDateTime();
ZonedDateTime randomZonedDateTime = RandomValues.randomZonedDateTime(ZoneId.systemDefault());
return Stream.of(testCase(s -> DateFunctions.currentDate(), "current_date", toArray()), testCase(s -> DateFunctions.currentTimestampLocal(), "current_timestamp", toArray()), testCase(s -> DateFunctions.currentTimestamp(), "current_timestamp", toArray()), testCase(s -> year(randomLocalDate), "year(cast(? as date))", toArray(Date.valueOf(randomLocalDate))), testCase(s -> year(randomLocalDateTime), "year(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> year(randomZonedDateTime), "year(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> year(TypedExpression.value(randomZonedDateTime)), "year(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> year(TestRow::localDateReq), "year(s.LOCAL_DATE_REQ)", toArray()), testCase(s -> year(TestRow::localDateOpt), "year(s.LOCAL_DATE_OPT)", toArray()), testCase(s -> year("s", TestRow::localDateReq), "year(s.LOCAL_DATE_REQ)", toArray()), testCase(s -> year("s", TestRow::localDateOpt), "year(s.LOCAL_DATE_OPT)", toArray()), testCase(s -> year(s, TestRow::localDateReq), "year(s.LOCAL_DATE_REQ)", toArray()), testCase(s -> year(s, TestRow::localDateOpt), "year(s.LOCAL_DATE_OPT)", toArray()), testCase(s -> month(randomLocalDate), "month(cast(? as date))", toArray(Date.valueOf(randomLocalDate))), testCase(s -> month(randomLocalDateTime), "month(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> month(randomZonedDateTime), "month(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> month(TypedExpression.value(randomZonedDateTime)), "month(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> month(TestRow::localDateTimeReq), "month(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> month(TestRow::localDateTimeOpt), "month(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> month("s", TestRow::localDateTimeReq), "month(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> month("s", TestRow::localDateTimeOpt), "month(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> month(s, TestRow::localDateTimeReq), "month(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> month(s, TestRow::localDateTimeOpt), "month(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> day(randomLocalDate), "day(cast(? as date))", toArray(Date.valueOf(randomLocalDate))), testCase(s -> day(randomLocalDateTime), "day(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> day(randomZonedDateTime), "day(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> day(TypedExpression.value(randomZonedDateTime)), "day(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> day(TestRow::utcDateTimeReq), "day(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> day(TestRow::utcDateTimeOpt), "day(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> day("s", TestRow::utcDateTimeReq), "day(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> day("s", TestRow::utcDateTimeOpt), "day(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> day(s, TestRow::utcDateTimeReq), "day(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> day(s, TestRow::utcDateTimeOpt), "day(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> hour(randomLocalDateTime), "hour(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> hour(randomZonedDateTime), "hour(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> hour(TypedExpression.value(randomZonedDateTime)), "hour(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> hour(TestRow::localDateTimeReq), "hour(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> hour(TestRow::localDateTimeOpt), "hour(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> hour("s", TestRow::localDateTimeReq), "hour(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> hour("s", TestRow::localDateTimeOpt), "hour(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> hour(s, TestRow::localDateTimeReq), "hour(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> hour(s, TestRow::localDateTimeOpt), "hour(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> minute(randomLocalDateTime), "minute(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> minute(randomZonedDateTime), "minute(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> minute(TypedExpression.value(randomZonedDateTime)), "minute(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> minute(TestRow::utcDateTimeReq), "minute(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> minute(TestRow::utcDateTimeOpt), "minute(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> minute("s", TestRow::utcDateTimeReq), "minute(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> minute("s", TestRow::utcDateTimeOpt), "minute(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> minute(s, TestRow::utcDateTimeReq), "minute(s.UTC_DATE_TIME_REQ)", toArray()), testCase(s -> minute(s, TestRow::utcDateTimeOpt), "minute(s.UTC_DATE_TIME_OPT)", toArray()), testCase(s -> second(randomLocalDateTime), "second(cast(? as timestamp))", toArray(Timestamp.valueOf(randomLocalDateTime))), testCase(s -> second(randomZonedDateTime), "second(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> second(TypedExpression.value(randomZonedDateTime)), "second(cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> second(TestRow::localDateTimeReq), "second(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> second(TestRow::localDateTimeOpt), "second(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> second("s", TestRow::localDateTimeReq), "second(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> second("s", TestRow::localDateTimeOpt), "second(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> second(s, TestRow::localDateTimeReq), "second(s.LOCAL_DATE_TIME_REQ)", toArray()), testCase(s -> second(s, TestRow::localDateTimeOpt), "second(s.LOCAL_DATE_TIME_OPT)", toArray()), testCase(s -> addDays(TypedExpression.value(randomZonedDateTime), 1), "dateadd(day, ?, cast(? as timestamp))", toArray(1, Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> addDays(TypedExpression.value(randomZonedDateTime), literal(4)), "dateadd(day, 4, cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> addDays(TestRow::localDateTimeReq, 1), "dateadd(day, ?, s.LOCAL_DATE_TIME_REQ)", toArray(1)), testCase(s -> addDays(TestRow::localDateTimeOpt, 1), "dateadd(day, ?, s.LOCAL_DATE_TIME_OPT)", toArray(1)), testCase(s -> addDays("s", TestRow::localDateTimeReq, 2), "dateadd(day, ?, s.LOCAL_DATE_TIME_REQ)", toArray(2)), testCase(s -> addDays("s", TestRow::localDateTimeOpt, 2), "dateadd(day, ?, s.LOCAL_DATE_TIME_OPT)", toArray(2)), testCase(s -> addDays(s, TestRow::localDateTimeReq, 3), "dateadd(day, ?, s.LOCAL_DATE_TIME_REQ)", toArray(3)), testCase(s -> addDays(s, TestRow::localDateTimeOpt, 3), "dateadd(day, ?, s.LOCAL_DATE_TIME_OPT)", toArray(3)), testCase(s -> secondDiff(TypedExpression.value(randomZonedDateTime), literal(LocalDate.of(2013, 12, 25))), "datediff(second, DATE '2013-12-25', cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> secondDiff(TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> secondDiff(TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> secondDiff("s", TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> secondDiff("s", TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> secondDiff(s, TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> secondDiff(s, TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(second, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff(TypedExpression.value(randomZonedDateTime), literal(LocalDate.of(2013, 12, 25))), "datediff(minute, DATE '2013-12-25', cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> minuteDiff(TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff(TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff("s", TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff("s", TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff(s, TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> minuteDiff(s, TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(minute, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff(TypedExpression.value(randomZonedDateTime), literal(LocalDate.of(2013, 12, 25))), "datediff(hour, DATE '2013-12-25', cast(? as timestamp))", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> hourDiff(TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff(TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff("s", TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff("s", TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff(s, TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_REQ)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> hourDiff(s, TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "datediff(hour, cast(? as date), s.LOCAL_DATE_TIME_OPT)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff(TypedExpression.value(randomZonedDateTime), literal(LocalDate.of(2013, 12, 25))), "cast(? as timestamp) - DATE '2013-12-25'", toArray(Timestamp.valueOf(randomZonedDateTime.toLocalDateTime()))), testCase(s -> dayDiff(TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_REQ - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff(TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_OPT - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff("s", TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_REQ - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff("s", TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_OPT - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff(s, TestRow::localDateTimeReq, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_REQ - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))), testCase(s -> dayDiff(s, TestRow::localDateTimeOpt, LocalDate.of(2013, 12, 25)), "s.LOCAL_DATE_TIME_OPT - cast(? as date)", toArray(Date.valueOf(LocalDate.of(2013, 12, 25)))));
}
use of org.junit.jupiter.params.provider.Arguments in project jmeter by apache.
the class ParallelResourcesAndIpSource method implementationsAndIps.
public static Iterable<Arguments> implementationsAndIps() throws SocketException {
List<Arguments> res = new ArrayList<>();
// Caveat: 127.0.0.1
InetAddress local4 = null;
InetAddress local6 = null;
List<InetAddress> localIps = Collections.list(NetworkInterface.getNetworkInterfaces()).stream().filter(networkInterface -> {
try {
return networkInterface.isLoopback();
} catch (SocketException e) {
return false;
}
}).flatMap(ni -> ni.getInterfaceAddresses().stream()).map(InterfaceAddress::getAddress).collect(Collectors.toList());
// We don't want to have accidental O(N^2) in case there are lots of source IPs
// So we use just two for the source IP
// So we shuffle them to use different ones every time
Collections.shuffle(localIps);
for (InetAddress localIp : localIps) {
if (local4 == null && localIp instanceof Inet4Address) {
local4 = localIp;
} else if (local6 == null && localIp instanceof Inet6Address) {
local6 = localIp;
}
}
// This is to allow the variables for use in lambda below (the vars should be effectively final)
InetAddress finalLocal4 = local4;
InetAddress finalLocal6 = local6;
// This is to make test names pretty
localIps.sort(Comparator.comparing(InetAddress::toString));
for (String impl : HTTPSamplerFactory.getImplementations()) {
for (String targetHost : new String[] { "127.0.0.1", "[::1]", "localhost" }) {
if ("localhost".equals(targetHost)) {
// with the given source IP
continue;
}
localIps.forEach(localIp -> {
if (finalLocal4 != null) {
res.add(arguments(impl, targetHost, finalLocal4));
}
if (finalLocal6 != null) {
res.add(arguments(impl, targetHost, finalLocal6));
}
});
}
}
return res;
}
use of org.junit.jupiter.params.provider.Arguments in project kafka by apache.
the class ApiErrorTest method parameters.
private static Collection<Arguments> parameters() {
List<Arguments> arguments = new ArrayList<>();
arguments.add(Arguments.of(new UnknownServerException("Don't leak sensitive information "), Errors.UNKNOWN_SERVER_ERROR, null));
arguments.add(Arguments.of(new NotEnoughReplicasException(), Errors.NOT_ENOUGH_REPLICAS, null));
// avoid populating the error message if it's a generic one
arguments.add(Arguments.of(new UnknownTopicOrPartitionException(Errors.UNKNOWN_TOPIC_OR_PARTITION.message()), Errors.UNKNOWN_TOPIC_OR_PARTITION, null));
String notCoordinatorErrorMsg = "Not coordinator";
arguments.add(Arguments.of(new NotCoordinatorException(notCoordinatorErrorMsg), Errors.NOT_COORDINATOR, notCoordinatorErrorMsg));
String notControllerErrorMsg = "Not controller";
// test the NotControllerException is wrapped in the CompletionException, should return correct error
arguments.add(Arguments.of(new CompletionException(new NotControllerException(notControllerErrorMsg)), Errors.NOT_CONTROLLER, notControllerErrorMsg));
String requestTimeoutErrorMsg = "request time out";
// test the TimeoutException is wrapped in the ExecutionException, should return correct error
arguments.add(Arguments.of(new ExecutionException(new TimeoutException(requestTimeoutErrorMsg)), Errors.REQUEST_TIMED_OUT, requestTimeoutErrorMsg));
// test the exception not in the Errors list, should return UNKNOWN_SERVER_ERROR
arguments.add(Arguments.of(new IOException(), Errors.UNKNOWN_SERVER_ERROR, null));
return arguments;
}
use of org.junit.jupiter.params.provider.Arguments in project kafka by apache.
the class HeaderFromTest method data.
public static List<Arguments> data() {
List<Arguments> result = new ArrayList<>();
for (Boolean testKeyTransform : asList(true, false)) {
result.add(Arguments.of("basic copy", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.COPY, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value")));
result.add(Arguments.of("basic move", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.MOVE, new RecordBuilder().withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value")));
result.add(Arguments.of("copy with preexisting header", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("inserted1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.COPY, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("inserted1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value")));
result.add(Arguments.of("move with preexisting header", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("inserted1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.MOVE, new RecordBuilder().withField("field2", STRING_SCHEMA, "field2-value").addHeader("inserted1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value")));
Schema schema = new SchemaBuilder(Schema.Type.STRUCT).field("foo", STRING_SCHEMA).build();
Struct struct = new Struct(schema).put("foo", "foo-value");
result.add(Arguments.of("copy with struct value", testKeyTransform, new RecordBuilder().withField("field1", schema, struct).withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.COPY, new RecordBuilder().withField("field1", schema, struct).withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", schema, struct)));
result.add(Arguments.of("move with struct value", testKeyTransform, new RecordBuilder().withField("field1", schema, struct).withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), singletonList("field1"), singletonList("inserted1"), HeaderFrom.Operation.MOVE, new RecordBuilder().withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", schema, struct)));
result.add(Arguments.of("two headers from same field", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), // two headers from the same field
asList("field1", "field1"), asList("inserted1", "inserted2"), HeaderFrom.Operation.MOVE, new RecordBuilder().withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value").addHeader("inserted2", STRING_SCHEMA, "field1-value")));
result.add(Arguments.of("two fields to same header", testKeyTransform, new RecordBuilder().withField("field1", STRING_SCHEMA, "field1-value").withField("field2", STRING_SCHEMA, "field2-value").addHeader("header1", STRING_SCHEMA, "existing-value"), // two headers from the same field
asList("field1", "field2"), asList("inserted1", "inserted1"), HeaderFrom.Operation.MOVE, new RecordBuilder().addHeader("header1", STRING_SCHEMA, "existing-value").addHeader("inserted1", STRING_SCHEMA, "field1-value").addHeader("inserted1", STRING_SCHEMA, "field2-value")));
}
return result;
}
Aggregations