// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/BackingStoreException.java
// public class BackingStoreException extends Exception {
//   private static final long serialVersionUID = 1L;
// 
//   public BackingStoreException() {
//   }
// 
//   public BackingStoreException(String message) {
//     super(message);
//   }
// 
//   public BackingStoreException(Throwable cause) {
//     super(cause);
//   }
// 
//   public BackingStoreException(String message, Throwable cause) {
//     super(message, cause);
//   }
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/CassandraRingDao.java
// public interface CassandraRingDao {
// 
//   /**
//    * Returns the set of Cassandra rings.
//    *
//    * @return set of Cassandra rings
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   ImmutableSet<CassandraRing> findAll() throws BackingStoreException;
// 
//   /**
//    * Returns the Cassandra ring with the given {@code name} or {@code null} if not found.
//    *
//    * @param name the Cassandra ring name
//    * @return the Cassandra ring or {@code null} if not found
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   @Nullable CassandraRing findByName(String name) throws BackingStoreException;
// 
//   /**
//    * Saves the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void save(CassandraRing ring);
// 
//   /**
//    * Deletes the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void delete(CassandraRing ring);
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/model/CassandraRing.java
// public class CassandraRing {
// 
//   private final String name;
//   private final ImmutableSet<CassandraInstance> instances;
// 
//   private CassandraRing(@JsonProperty("name") String name,
//       @JsonProperty("instances") Set<CassandraInstance> instances) {
//     this(new Builder()
//         .name(name)
//         .instances(instances));
//   }
// 
//   private CassandraRing(Builder builder) {
//     this.name = builder.name;
//     this.instances = builder.instances.build();
//   }
// 
//   public @NotEmpty String getName() {
//     return name;
//   }
// 
//   public @NotEmpty ImmutableSet<CassandraInstance> getInstances() {
//     return instances;
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(significantAttributes());
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (obj == null) {
//       return false;
//     } else if (obj == this) {
//       return true;
//     } else if (!getClass().isAssignableFrom(obj.getClass())) {
//       return false;
//     }
//     return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes());
//   }
// 
//   @Override
//   public String toString() {
//     return Objects.toStringHelper(this)
//         .add("name", name)
//         .add("instances", instances)
//         .toString();
//   }
// 
//   Object[] significantAttributes() {
//     return new Object[] { name, instances };
//   }
// 
//   /**
//    * Fluent builder for {@link CassandraRing}s.
//    *
//    * @author codyaray
//    * @since 9/16/2013
//    */
//   public static class Builder {
// 
//     private String name;
//     private final ImmutableSet.Builder<CassandraInstance> instances = ImmutableSet.builder();
// 
//     public Builder instances(Collection<CassandraInstance> instances) {
//       this.instances.addAll(instances);
//       return this;
//     }
// 
//     public Builder name(String name) {
//       this.name = name;
//       return this;
//     }
// 
//     public CassandraRing build() {
//       checkNotNull(name);
//       return new CassandraRing(this);
//     }
// 
//   }
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/service/ServiceUnavailableException.java
// public class ServiceUnavailableException extends RuntimeException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   public ServiceUnavailableException() {
//   }
// 
//   public ServiceUnavailableException(String message) {
//     super(message);
//   }
// 
//   public ServiceUnavailableException(Throwable cause) {
//     super(cause);
//   }
// 
//   public ServiceUnavailableException(String message, Throwable cause) {
//     super(message, cause);
//   }
// 
// }


import com.google.common.collect.ImmutableSet;
import org.easymock.EasyMockSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.brighttag.agathon.dao.BackingStoreException;
import com.brighttag.agathon.dao.CassandraRingDao;
import com.brighttag.agathon.model.CassandraRing;
import com.brighttag.agathon.service.ServiceUnavailableException;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;

  @Test
  public void findAll() throws Exception {
    CassandraRing ring1 = createMock(CassandraRing.class);
    CassandraRing ring2 = createMock(CassandraRing.class);
    CassandraRing ring3 = createMock(CassandraRing.class);
    ImmutableSet<CassandraRing> rings = ImmutableSet.of(ring1, ring2, ring3);
    expect(dao.findAll()).andReturn(rings);
    replayAll();

    assertEquals(rings, service.findAll());
  }

  @Test(expected = ServiceUnavailableException.class)
  public void findAll_backingStoreException() throws Exception {
    expect(dao.findAll()).andThrow(new BackingStoreException());
    replayAll();

    service.findAll();
  }

  @Test
  public void findByName() throws Exception {
    CassandraRing ring = createMock(CassandraRing.class);
    expect(dao.findByName(RING_NAME)).andReturn(ring);
    replayAll();

    assertEquals(ring, service.findByName(RING_NAME));
  }

// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/BackingStoreException.java
// public class BackingStoreException extends Exception {
//   private static final long serialVersionUID = 1L;
// 
//   public BackingStoreException() {
//   }
// 
//   public BackingStoreException(String message) {
//     super(message);
//   }
// 
//   public BackingStoreException(Throwable cause) {
//     super(cause);
//   }
// 
//   public BackingStoreException(String message, Throwable cause) {
//     super(message, cause);
//   }
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/dao/CassandraRingDao.java
// public interface CassandraRingDao {
// 
//   /**
//    * Returns the set of Cassandra rings.
//    *
//    * @return set of Cassandra rings
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   ImmutableSet<CassandraRing> findAll() throws BackingStoreException;
// 
//   /**
//    * Returns the Cassandra ring with the given {@code name} or {@code null} if not found.
//    *
//    * @param name the Cassandra ring name
//    * @return the Cassandra ring or {@code null} if not found
//    * @throws BackingStoreException if there was a problem communicating with the backing store.
//    */
//   @Nullable CassandraRing findByName(String name) throws BackingStoreException;
// 
//   /**
//    * Saves the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void save(CassandraRing ring);
// 
//   /**
//    * Deletes the Cassandra {@code ring}.
//    *
//    * @param ring the Cassandra ring
//    */
//   void delete(CassandraRing ring);
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/model/CassandraRing.java
// public class CassandraRing {
// 
//   private final String name;
//   private final ImmutableSet<CassandraInstance> instances;
// 
//   private CassandraRing(@JsonProperty("name") String name,
//       @JsonProperty("instances") Set<CassandraInstance> instances) {
//     this(new Builder()
//         .name(name)
//         .instances(instances));
//   }
// 
//   private CassandraRing(Builder builder) {
//     this.name = builder.name;
//     this.instances = builder.instances.build();
//   }
// 
//   public @NotEmpty String getName() {
//     return name;
//   }
// 
//   public @NotEmpty ImmutableSet<CassandraInstance> getInstances() {
//     return instances;
//   }
// 
//   @Override
//   public int hashCode() {
//     return Objects.hashCode(significantAttributes());
//   }
// 
//   @Override
//   public boolean equals(Object obj) {
//     if (obj == null) {
//       return false;
//     } else if (obj == this) {
//       return true;
//     } else if (!getClass().isAssignableFrom(obj.getClass())) {
//       return false;
//     }
//     return Arrays.equals(significantAttributes(), getClass().cast(obj).significantAttributes());
//   }
// 
//   @Override
//   public String toString() {
//     return Objects.toStringHelper(this)
//         .add("name", name)
//         .add("instances", instances)
//         .toString();
//   }
// 
//   Object[] significantAttributes() {
//     return new Object[] { name, instances };
//   }
// 
//   /**
//    * Fluent builder for {@link CassandraRing}s.
//    *
//    * @author codyaray
//    * @since 9/16/2013
//    */
//   public static class Builder {
// 
//     private String name;
//     private final ImmutableSet.Builder<CassandraInstance> instances = ImmutableSet.builder();
// 
//     public Builder instances(Collection<CassandraInstance> instances) {
//       this.instances.addAll(instances);
//       return this;
//     }
// 
//     public Builder name(String name) {
//       this.name = name;
//       return this;
//     }
// 
//     public CassandraRing build() {
//       checkNotNull(name);
//       return new CassandraRing(this);
//     }
// 
//   }
// 
// }
// 
// Path: agathon-manager/src/main/java/com/brighttag/agathon/service/ServiceUnavailableException.java
// public class ServiceUnavailableException extends RuntimeException {
// 
//   private static final long serialVersionUID = 1L;
// 
//   public ServiceUnavailableException() {
//   }
// 
//   public ServiceUnavailableException(String message) {
//     super(message);
//   }
// 
//   public ServiceUnavailableException(Throwable cause) {
//     super(cause);
//   }
// 
//   public ServiceUnavailableException(String message, Throwable cause) {
//     super(message, cause);
//   }
// 
// }


// Path: agathon-manager/src/test/java/com/brighttag/agathon/service/impl/CassandraRingServiceImplTest.java
import com.google.common.collect.ImmutableSet;
import org.easymock.EasyMockSupport;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import com.brighttag.agathon.dao.BackingStoreException;
import com.brighttag.agathon.dao.CassandraRingDao;
import com.brighttag.agathon.model.CassandraRing;
import com.brighttag.agathon.service.ServiceUnavailableException;
import static org.easymock.EasyMock.expect;
import static org.junit.Assert.assertEquals;


  @Test
  public void findAll() throws Exception {
    CassandraRing ring1 = createMock(CassandraRing.class);
    CassandraRing ring2 = createMock(CassandraRing.class);
    CassandraRing ring3 = createMock(CassandraRing.class);
    ImmutableSet<CassandraRing> rings = ImmutableSet.of(ring1, ring2, ring3);
    expect(dao.findAll()).andReturn(rings);
    replayAll();

    assertEquals(rings, service.findAll());
  }

  @Test(expected = ServiceUnavailableException.class)
  public void findAll_backingStoreException() throws Exception {
    expect(dao.findAll()).andThrow(new BackingStoreException());
    replayAll();

    service.findAll();
  }

  @Test
  public void findByName() throws Exception {
    CassandraRing ring = createMock(CassandraRing.class);
    expect(dao.findByName(RING_NAME)).andReturn(ring);
    replayAll();

    assertEquals(ring, service.findByName(RING_NAME));
  }

  @Test(expected = ServiceUnavailableException.class)