Skip to content

Commit

Permalink
Fix unit tests
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Carbonetto <[email protected]>
  • Loading branch information
acarbonetto committed Jan 27, 2024
1 parent b062b9b commit 9a16d86
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

/** Object builder to add optional arguments to {@link ServerCommands#info(InfoOptions)} */
@Builder
public class InfoOptions extends Options {
public class InfoOptions {

@Singular private final List<Section> sections;

Expand Down Expand Up @@ -56,7 +56,7 @@ public enum Section {
* @return String[]
*/
public String[] toInfoOptions() {
optionArgs = sections.stream().map(Objects::toString).collect(Collectors.toList());
return toArgs();
List<String> optionArgs = sections.stream().map(Objects::toString).collect(Collectors.toList());
return optionArgs.toArray(new String[0]);
}
}
21 changes: 0 additions & 21 deletions java/client/src/main/java/glide/api/models/commands/Options.java

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
* String, SetOptions)}
*/
@Builder
public class SetOptions extends Options {
public class SetOptions {

/**
* if `conditional` is not set the value will be set regardless of prior value existence. <br>
Expand Down Expand Up @@ -90,13 +90,12 @@ public enum TimeToLiveType {
public static String TIME_TO_LIVE_UNIX_MILLISECONDS = "PXAT";

/**
* Converts SetOptions into a String[] to add to a {@link glide.api.models.Command}
* Converts SetOptions into a String[]
*
* @param arguments
* @return
* @return String[]
*/
public String[] toSetOptions(List<String> arguments) {
optionArgs = new LinkedList();
public String[] toArgs() {
List<String> optionArgs = new LinkedList();
if (conditionalSet != null) {
if (conditionalSet == ConditionalSet.ONLY_IF_EXISTS) {
optionArgs.add(CONDITIONAL_SET_ONLY_IF_EXISTS);
Expand Down Expand Up @@ -134,6 +133,6 @@ public String[] toSetOptions(List<String> arguments) {
}
}

return toArgs(arguments);
return optionArgs.toArray(new String[0]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class CommandManager {
*/
public <T> CompletableFuture<T> submitNewCommand(
Command command, RedisExceptionCheckedFunction<Response, T> responseHandler) {
var pb = prepareRedisRequest(command).build();
// write command request to channel
// when complete, convert the response to our expected type T using the given responseHandler
return channel
Expand Down
3 changes: 2 additions & 1 deletion java/client/src/main/java/glide/managers/models/Command.java
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ public static Command set(String key, String value) {
/** Command to set the given key with the given value. */
public static Command set(String key, String value, String[] options) {
String[] args = ArrayUtils.addAll(new String[] {key, value}, options);
return Command.builder().requestType(Command.RequestType.SET_STRING).arguments(args).build();
Command cmd = Command.builder().requestType(Command.RequestType.SET_STRING).arguments(args).build();
return cmd;
}

public enum RequestType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,6 @@ private RedisRequest.Builder prepareProtoBufRequest(
RedisRequestOuterClass.Command.newBuilder()
.setRequestType(requestType)
.setArgsArray(argsArray)
.build())
.setRoute(Routes.newBuilder().setSimpleRoutes(SimpleRoutes.AllNodes).build());
.build());
}
}

0 comments on commit 9a16d86

Please sign in to comment.