Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Convert lettuce-common test from groovy to java #9430

Merged
merged 3 commits into from
Sep 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/

package io.opentelemetry.instrumentation.lettuce.common;

import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Named.named;

import com.google.common.collect.ImmutableList;
import java.util.stream.Stream;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.Arguments;
import org.junit.jupiter.params.provider.MethodSource;

class LettuceArgSplitterTest {

@ParameterizedTest
@MethodSource("providesArguments")
void testShouldProperlySplitArguments(Parameter parameter) {
assertThat(LettuceArgSplitter.splitArgs(parameter.args)).isEqualTo(parameter.result);
}

private static Stream<Arguments> providesArguments() {
return Stream.of(
Arguments.of(named("a null value", new Parameter(null, ImmutableList.of()))),
Arguments.of(named("an empty value", new Parameter("", ImmutableList.of()))),
Arguments.of(named("a single key", new Parameter("key<key>", ImmutableList.of("key")))),
Arguments.of(
named("a single value", new Parameter("value<value>", ImmutableList.of("value")))),
Arguments.of(
named("a plain string", new Parameter("teststring", ImmutableList.of("teststring")))),
Arguments.of(named("an integer", new Parameter("42", ImmutableList.of("42")))),
Arguments.of(
named("a base64 value", new Parameter("TeST123==", ImmutableList.of("TeST123==")))),
Arguments.of(
named(
"a complex list of args",
new Parameter(
"key<key> aSDFgh4321= 5 test value<val>",
ImmutableList.of("key", "aSDFgh4321=", "5", "test", "val")))));
}

private static class Parameter {
public final String args;
public final ImmutableList<String> result;

public Parameter(String query, ImmutableList<String> result) {
this.args = query;
this.result = result;
}
}
}
Loading