// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken string(SafeString str) {
//   return new StringRedisToken(str);
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/SafeString.java
// public static SafeString safeString(String str) {
//   return new SafeString(UTF_8.encode(checkNonNull(str)));
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// public interface RedisToken {
//   RedisToken NULL_STRING = string((SafeString) null);
//   RedisToken RESPONSE_OK = status("OK");
// 
//   RedisTokenType getType();
// 
//   <T> T accept(RedisTokenVisitor<T> visitor);
// 
//   static RedisToken nullString() {
//     return NULL_STRING;
//   }
// 
//   static RedisToken responseOk() {
//     return RESPONSE_OK;
//   }
// 
//   static RedisToken string(SafeString str) {
//     return new StringRedisToken(str);
//   }
// 
//   static RedisToken string(String str) {
//     return new StringRedisToken(safeString(str));
//   }
// 
//   static RedisToken status(String str) {
//     return new StatusRedisToken(str);
//   }
// 
//   static RedisToken integer(boolean b) {
//     return new IntegerRedisToken(b ? 1 : 0);
//   }
// 
//   static RedisToken integer(int i) {
//     return new IntegerRedisToken(i);
//   }
// 
//   static RedisToken error(String str) {
//     return new ErrorRedisToken(str);
//   }
// 
//   static RedisToken array(RedisToken... redisTokens) {
//     return new ArrayRedisToken(ImmutableList.of(redisTokens));
//   }
// 
//   static RedisToken array(Collection<RedisToken> redisTokens) {
//     return new ArrayRedisToken(ImmutableList.from(redisTokens));
//   }
// 
//   static RedisToken array(Sequence<RedisToken> redisTokens) {
//     return new ArrayRedisToken(redisTokens.asArray());
//   }
// 
//   static <T> Stream<T> visit(Stream<RedisToken> tokens, RedisTokenVisitor<T> visitor) {
//     return tokens.map(token -> token.accept(visitor));
//   }
// }


import static com.github.tonivade.resp.protocol.RedisToken.string;
import static com.github.tonivade.resp.protocol.SafeString.safeString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.github.tonivade.purefun.data.ImmutableArray;
import com.github.tonivade.resp.annotation.Command;
import com.github.tonivade.resp.annotation.ParamLength;
import com.github.tonivade.resp.protocol.RedisToken;
/*
 * Copyright (c) 2015-2022, Antonio Gabriel Muñoz Conejo <antoniogmc at gmail dot com>
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.resp.command;




public class CommandSuiteTest {

  private CommandSuite commandSuite;

  @BeforeEach
  public void setUp() {
    commandSuite = new CommandSuite();
  }

  @Test
  public void addCommandLambda() {
    String command = "test";
    commandSuite.addCommand(command, request -> string(request.getCommand()));

    RedisToken response = commandSuite.getCommand(command).execute(request(command));

    assertThat(response, equalTo(string(command)));
  }

  @Test
  public void addCommand() {
    commandSuite.addCommand(GoodCommand::new);

    assertThat(commandSuite.contains("good"), is(true));
  }

  @Test
  public void isPresent() {
    commandSuite.addCommand(GoodCommand::new);

    assertThat(commandSuite.isPresent("good", Command.class), is(true));
  }

  @Test
  public void notPresent() {
// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken string(SafeString str) {
//   return new StringRedisToken(str);
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/SafeString.java
// public static SafeString safeString(String str) {
//   return new SafeString(UTF_8.encode(checkNonNull(str)));
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// public interface RedisToken {
//   RedisToken NULL_STRING = string((SafeString) null);
//   RedisToken RESPONSE_OK = status("OK");
// 
//   RedisTokenType getType();
// 
//   <T> T accept(RedisTokenVisitor<T> visitor);
// 
//   static RedisToken nullString() {
//     return NULL_STRING;
//   }
// 
//   static RedisToken responseOk() {
//     return RESPONSE_OK;
//   }
// 
//   static RedisToken string(SafeString str) {
//     return new StringRedisToken(str);
//   }
// 
//   static RedisToken string(String str) {
//     return new StringRedisToken(safeString(str));
//   }
// 
//   static RedisToken status(String str) {
//     return new StatusRedisToken(str);
//   }
// 
//   static RedisToken integer(boolean b) {
//     return new IntegerRedisToken(b ? 1 : 0);
//   }
// 
//   static RedisToken integer(int i) {
//     return new IntegerRedisToken(i);
//   }
// 
//   static RedisToken error(String str) {
//     return new ErrorRedisToken(str);
//   }
// 
//   static RedisToken array(RedisToken... redisTokens) {
//     return new ArrayRedisToken(ImmutableList.of(redisTokens));
//   }
// 
//   static RedisToken array(Collection<RedisToken> redisTokens) {
//     return new ArrayRedisToken(ImmutableList.from(redisTokens));
//   }
// 
//   static RedisToken array(Sequence<RedisToken> redisTokens) {
//     return new ArrayRedisToken(redisTokens.asArray());
//   }
// 
//   static <T> Stream<T> visit(Stream<RedisToken> tokens, RedisTokenVisitor<T> visitor) {
//     return tokens.map(token -> token.accept(visitor));
//   }
// }


// Path: src/test/java/com/github/tonivade/resp/command/CommandSuiteTest.java
import static com.github.tonivade.resp.protocol.RedisToken.string;
import static com.github.tonivade.resp.protocol.SafeString.safeString;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.Matchers.instanceOf;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import com.github.tonivade.purefun.data.ImmutableArray;
import com.github.tonivade.resp.annotation.Command;
import com.github.tonivade.resp.annotation.ParamLength;
import com.github.tonivade.resp.protocol.RedisToken;

/*
 * Copyright (c) 2015-2022, Antonio Gabriel Muñoz Conejo <antoniogmc at gmail dot com>
 * Distributed under the terms of the MIT License
 */
package com.github.tonivade.resp.command;




public class CommandSuiteTest {

  private CommandSuite commandSuite;

  @BeforeEach
  public void setUp() {
    commandSuite = new CommandSuite();
  }

  @Test
  public void addCommandLambda() {
    String command = "test";
    commandSuite.addCommand(command, request -> string(request.getCommand()));

    RedisToken response = commandSuite.getCommand(command).execute(request(command));

    assertThat(response, equalTo(string(command)));
  }

  @Test
  public void addCommand() {
    commandSuite.addCommand(GoodCommand::new);

    assertThat(commandSuite.contains("good"), is(true));
  }

  @Test
  public void isPresent() {
    commandSuite.addCommand(GoodCommand::new);

    assertThat(commandSuite.isPresent("good", Command.class), is(true));
  }

  @Test
  public void notPresent() {
    commandSuite.addCommand(GoodCommand::new);