// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken array(RedisToken... redisTokens) {
//   return new ArrayRedisToken(ImmutableList.of(redisTokens));
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken string(SafeString str) {
//   return new StringRedisToken(str);
// }
// 
// Path: src/test/java/com/github/tonivade/resp/protocol/test/Data.java
// public class Data {
//   private final int id;
//   private final String value;
// 
//   public Data(int id, String value) {
//     this.id = id;
//     this.value = value;
//   }
// 
//   public int getId() {
//     return id;
//   }
// 
//   public String getValue() {
//     return value;
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hash(id, value);
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     return Equal.<Data>of()
//         .comparing(Data::getId)
//         .comparing(Data::getValue)
//         .applyTo(this, obj);
//   }
// 
//   @Override
//   public String toString() {
//     return "Data [id=" + id + ", value=" + value + "]";
//   }
// }


import static com.github.tonivade.resp.protocol.RedisToken.array;
import static com.github.tonivade.resp.protocol.RedisToken.string;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import com.github.tonivade.resp.protocol.test.Data;
/*
 * 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.protocol;




public class RespSerializerTest {
  private RespSerializer serializer = new RespSerializer();

  private final Data data = new Data(1, "value");
  private final RedisToken expected = array(string("id"), string("1"),
                                            string("value"), string("value"));

  @Test
  public void getValue() {
    RedisToken array = serializer.getValue(data);

    assertThat(array, equalTo(expected));
  }

  @Test
  public void getValueCollection() {
    RedisToken array = serializer.getValue(asList(data, data, data));

    assertThat(array, equalTo(array(expected, expected, expected)));
  }

  @Test
  public void getValueArray() {
    RedisToken array = serializer.getValue(new Object[] { data, data, data });

    assertThat(array, equalTo(array(expected, expected, expected)));
  }

  @Test
  public void getValueMap() {
    RedisToken array = serializer.getValue(singletonMap("key", "value"));

// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken array(RedisToken... redisTokens) {
//   return new ArrayRedisToken(ImmutableList.of(redisTokens));
// }
// 
// Path: src/main/java/com/github/tonivade/resp/protocol/RedisToken.java
// static RedisToken string(SafeString str) {
//   return new StringRedisToken(str);
// }
// 
// Path: src/test/java/com/github/tonivade/resp/protocol/test/Data.java
// public class Data {
//   private final int id;
//   private final String value;
// 
//   public Data(int id, String value) {
//     this.id = id;
//     this.value = value;
//   }
// 
//   public int getId() {
//     return id;
//   }
// 
//   public String getValue() {
//     return value;
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hash(id, value);
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     return Equal.<Data>of()
//         .comparing(Data::getId)
//         .comparing(Data::getValue)
//         .applyTo(this, obj);
//   }
// 
//   @Override
//   public String toString() {
//     return "Data [id=" + id + ", value=" + value + "]";
//   }
// }


// Path: src/test/java/com/github/tonivade/resp/protocol/RespSerializerTest.java
import static com.github.tonivade.resp.protocol.RedisToken.array;
import static com.github.tonivade.resp.protocol.RedisToken.string;
import static java.util.Arrays.asList;
import static java.util.Collections.singletonMap;
import static org.hamcrest.Matchers.equalTo;
import static org.hamcrest.MatcherAssert.assertThat;
import org.junit.jupiter.api.Test;
import com.github.tonivade.resp.protocol.test.Data;

/*
 * 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.protocol;




public class RespSerializerTest {
  private RespSerializer serializer = new RespSerializer();

  private final Data data = new Data(1, "value");
  private final RedisToken expected = array(string("id"), string("1"),
                                            string("value"), string("value"));

  @Test
  public void getValue() {
    RedisToken array = serializer.getValue(data);

    assertThat(array, equalTo(expected));
  }

  @Test
  public void getValueCollection() {
    RedisToken array = serializer.getValue(asList(data, data, data));

    assertThat(array, equalTo(array(expected, expected, expected)));
  }

  @Test
  public void getValueArray() {
    RedisToken array = serializer.getValue(new Object[] { data, data, data });

    assertThat(array, equalTo(array(expected, expected, expected)));
  }

  @Test
  public void getValueMap() {
    RedisToken array = serializer.getValue(singletonMap("key", "value"));

    assertThat(array, equalTo(array(string("key"), string("value"))));