// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
//   public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
//   private final String userId;
//   private final String tenantId;
// 
//   public Account(String userId, String tenantId) {
//     Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
//     Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
//     this.userId = userId;
//     this.tenantId = tenantId;
//   }
// 
//   public String getUserId() {
//     return userId;
//   }
// 
//   public String getTenantId() {
//     return tenantId;
//   }
// 
//   public boolean isAdmin() {
//     return Constants.ADMIN_USER.equals(userId);
//   }
// 
//   public boolean isSuperadmin() {
//     return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) {
//       return true;
//     }
//     if (!(o instanceof Account)) {
//       return false;
//     }
// 
//     Account other = (Account) o;
//     return Objects.equal(userId, other.userId) &&
//       Objects.equal(tenantId, other.tenantId);
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(userId, tenantId);
//   }
// 
//   @Override
//   public String toString() {
//     return Objects.toStringHelper(this)
//       .add("userId", userId)
//       .add("tenantId", tenantId)
//       .toString();
//   }
// }


import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceType;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;
    String contents = "this is the cookbook\nthis is the second line";
    ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks");
    String name = "hadoop";
    int version = 1;

    writeToStore(store, account1, resourceType, name, version, contents);

    Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version));
  }

  @Test
  public void testMultipleWrites() throws Exception {
    PluginStore store = getInitializedStore();
    String contents = "these are the first contents";
    ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks");
    String name = "hadoop";
    int version = 1;

    // write once
    writeToStore(store, account1, resourceType, name, version, contents);
    // overwrite
    contents = "these are the second contents";
    writeToStore(store, account1, resourceType, name, version, contents);

    Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version));
  }

  @Test
  public void testWriteDifferentVersions() throws Exception {
    PluginStore store = getInitializedStore();
// Path: coopr-server/src/main/java/co/cask/coopr/account/Account.java
// public final class Account {
//   public static final Account SUPERADMIN = new Account(Constants.ADMIN_USER, Constants.SUPERADMIN_TENANT);
//   private final String userId;
//   private final String tenantId;
// 
//   public Account(String userId, String tenantId) {
//     Preconditions.checkArgument(userId != null && !userId.isEmpty(), "Account must have a user id.");
//     Preconditions.checkArgument(tenantId != null && !tenantId.isEmpty(), "Account must have a tenant id.");
//     this.userId = userId;
//     this.tenantId = tenantId;
//   }
// 
//   public String getUserId() {
//     return userId;
//   }
// 
//   public String getTenantId() {
//     return tenantId;
//   }
// 
//   public boolean isAdmin() {
//     return Constants.ADMIN_USER.equals(userId);
//   }
// 
//   public boolean isSuperadmin() {
//     return Constants.ADMIN_USER.equals(userId) && Constants.SUPERADMIN_TENANT.equals(tenantId);
//   }
// 
//   @Override
//   public boolean equals(Object o) {
//     if (this == o) {
//       return true;
//     }
//     if (!(o instanceof Account)) {
//       return false;
//     }
// 
//     Account other = (Account) o;
//     return Objects.equal(userId, other.userId) &&
//       Objects.equal(tenantId, other.tenantId);
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(userId, tenantId);
//   }
// 
//   @Override
//   public String toString() {
//     return Objects.toStringHelper(this)
//       .add("userId", userId)
//       .add("tenantId", tenantId)
//       .toString();
//   }
// }


// Path: coopr-server/src/test/java/co/cask/coopr/store/provisioner/PluginStoreTest.java
import co.cask.coopr.account.Account;
import co.cask.coopr.common.conf.Constants;
import co.cask.coopr.provisioner.plugin.PluginType;
import co.cask.coopr.provisioner.plugin.ResourceType;
import com.google.common.base.Charsets;
import com.google.common.io.CharStreams;
import org.junit.After;
import org.junit.Assert;
import org.junit.Test;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.Reader;

    String contents = "this is the cookbook\nthis is the second line";
    ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks");
    String name = "hadoop";
    int version = 1;

    writeToStore(store, account1, resourceType, name, version, contents);

    Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version));
  }

  @Test
  public void testMultipleWrites() throws Exception {
    PluginStore store = getInitializedStore();
    String contents = "these are the first contents";
    ResourceType resourceType = new ResourceType(PluginType.AUTOMATOR, "chef-solo", "cookbooks");
    String name = "hadoop";
    int version = 1;

    // write once
    writeToStore(store, account1, resourceType, name, version, contents);
    // overwrite
    contents = "these are the second contents";
    writeToStore(store, account1, resourceType, name, version, contents);

    Assert.assertEquals(contents, readFromStore(store, account1, resourceType, name, version));
  }

  @Test
  public void testWriteDifferentVersions() throws Exception {
    PluginStore store = getInitializedStore();
    String contents1 = "v1 contents";