package org.folio.okapi.common;

import io.vertx.core.json.JsonObject;
import org.junit.Test;
import static org.junit.Assert.*;
import java.util.Base64;

public class OkapiTokenTest {

  @Test
  public void test() {
    OkapiToken t = new OkapiToken();

    JsonObject o = new JsonObject();
    o.put("tenant", "test-lib");
    o.put("foo", "bar");
    String s = o.encodePrettily();
    byte[] encodedBytes = Base64.getEncoder().encode(s.getBytes());
    String e = new String(encodedBytes);
    String tokenStr = "method." + e + ".trail";
    t.setToken(tokenStr);
    assertEquals("test-lib", t.getTenant());
  }
}

@@ -609,10 +609,445 @@
 ));%0A  %7D%0A
+%0A  @Test%0A  public void test2() %7B%0A    String s = %22eyJzdWIiOiJfX3VuZGVmaW5lZF9fIiwidXNlcl9pZCI6Ijk5OTk5OTk5L%22%0A      + %22Tk5OTktOTk5OS05OTk5LTk5OTk5OTk5OTk5OSIsInRlbmFudCI6InRlc3RsaWIifQ%22;%0A    byte%5B%5D buf = Base64.getDecoder().decode(s);%0A    String got = new String(buf);%0A    String exp = %22%7B%5C%22sub%5C%22:%5C%22__undefined__%5C%22,%22%0A      + %22%5C%22user_id%5C%22:%5C%2299999999-9999-9999-9999-999999999999%5C%22,%5C%22tenant%5C%22:%5C%22testlib%5C%22%7D%22;%0A    assertEquals(exp, got);%0A  %7D%0A%0A
 %7D%0A

Add test case for MODAT-16