// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java
// public class IndexConfictException extends Exception
// {
// 
//     private static final long serialVersionUID = -4856615780463752787L;
// 
// }
// 
// Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java
// public class ReservedArtifact extends IndexArtifact
// {
//     private static final long serialVersionUID = -5676826253822808582L;
//     private final UUID id;
//     private Map<String, Boolean> files = new HashMap<String, Boolean>();
// 
//     public ReservedArtifact(String location)
//     {
//         super(location);
//         id = UUID.randomUUID();
//     }
// 
//     @Override
//     protected Map<String, Boolean> getFileTypes()
//     {
//         return files;
//     }
// 
//     public UUID getId()
//     {
//         return id;
//     }
// 
//     @Override
//     public boolean equals(Object object)
//     {
//         // self check
//         if (this == object)
//         {
//             return true;
//         }
//         // null check
//         if (object == null)
//         {
//             return false;
//         }
//         // type check and cast
//         if (getClass() != object.getClass())
//         {
//             return false;
//         }
//         
//         ReservedArtifact ra = (ReservedArtifact) object;
// 
//         return Objects.equals(getLocation(), ra.getLocation())
//                 && Objects.equals(getId(), ra.getId())
//                 && Objects.equals(getFileTypes(), ra.getFileTypes());
//     }
// }
// 
// Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java
// public enum IndexUtils 
// {	
// 	TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"),
// 		  generateArtifact("/this/is/a/location/")),
// 	TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"),
// 		  generateArtifact("/this/is/another/location/"));
// 	
// 	private IndexKey key;
// 	private IndexArtifact ia;
// 	
// 	IndexUtils(IndexKey key, IndexArtifact artifact)
// 	{
// 		this.key = key;
// 		this.ia = artifact;
// 	}
// 
// 	public IndexKey getKey() {
// 		return this.key;
// 	}
// 
// 	public IndexArtifact getArtifact() {
// 		return this.ia;
// 	}
// 	
// 	private static IndexArtifact generateArtifact(String location)
// 	{
// 		IndexArtifact ia = new JavaIndexArtifact(location);
// 		return ia;
// 	}
// }


import static org.junit.Assert.assertEquals;
import org.apache.curator.test.TestingServer;
import org.apache.curator.utils.CloseableUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.spedge.hangar.index.IndexConfictException;
import com.spedge.hangar.index.ReservedArtifact;
import com.spedge.hangar.testutils.IndexUtils;
	}
	
	
	@Test
	public void testReservedArtifact() throws Exception
	{		
		TestingServer testingServer = new TestingServer();
		index.startClient(testingServer.getConnectString());
		
		try
		{
			// Add a reserved artifact
			ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey());
					
			// Is there an artifact?
			Assert.assertTrue(index.isArtifact(IndexUtils.TEST2.getKey()));
			
			try
			{
				index.addArtifact(IndexUtils.TEST2.getKey(), IndexUtils.TEST2.getArtifact());
				Assert.fail("Index Conflict was never triggered.");
			}
			catch(IndexConfictException ice){}
			
			// Attempt to update a reserved artifact with an incorrect reserved token!
			try
			{
				index.addReservedArtifact(IndexUtils.TEST2.getKey(), new ReservedArtifact(""), IndexUtils.TEST2.getArtifact());
				Assert.fail("Reserved Conflict was never triggered.");
			}
// Path: hangar-api/src/main/java/com/spedge/hangar/index/IndexConfictException.java
// public class IndexConfictException extends Exception
// {
// 
//     private static final long serialVersionUID = -4856615780463752787L;
// 
// }
// 
// Path: hangar-api/src/main/java/com/spedge/hangar/index/ReservedArtifact.java
// public class ReservedArtifact extends IndexArtifact
// {
//     private static final long serialVersionUID = -5676826253822808582L;
//     private final UUID id;
//     private Map<String, Boolean> files = new HashMap<String, Boolean>();
// 
//     public ReservedArtifact(String location)
//     {
//         super(location);
//         id = UUID.randomUUID();
//     }
// 
//     @Override
//     protected Map<String, Boolean> getFileTypes()
//     {
//         return files;
//     }
// 
//     public UUID getId()
//     {
//         return id;
//     }
// 
//     @Override
//     public boolean equals(Object object)
//     {
//         // self check
//         if (this == object)
//         {
//             return true;
//         }
//         // null check
//         if (object == null)
//         {
//             return false;
//         }
//         // type check and cast
//         if (getClass() != object.getClass())
//         {
//             return false;
//         }
//         
//         ReservedArtifact ra = (ReservedArtifact) object;
// 
//         return Objects.equals(getLocation(), ra.getLocation())
//                 && Objects.equals(getId(), ra.getId())
//                 && Objects.equals(getFileTypes(), ra.getFileTypes());
//     }
// }
// 
// Path: hangar-api/src/test/java/com/spedge/hangar/testutils/IndexUtils.java
// public enum IndexUtils 
// {	
// 	TEST1(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.3"),
// 		  generateArtifact("/this/is/a/location/")),
// 	TEST2(new JavaIndexKey(RepositoryType.RELEASE_JAVA, JavaGroup.dotDelimited("com.spedge.test"), "test-artifact", "0.1.2.6"),
// 		  generateArtifact("/this/is/another/location/"));
// 	
// 	private IndexKey key;
// 	private IndexArtifact ia;
// 	
// 	IndexUtils(IndexKey key, IndexArtifact artifact)
// 	{
// 		this.key = key;
// 		this.ia = artifact;
// 	}
// 
// 	public IndexKey getKey() {
// 		return this.key;
// 	}
// 
// 	public IndexArtifact getArtifact() {
// 		return this.ia;
// 	}
// 	
// 	private static IndexArtifact generateArtifact(String location)
// 	{
// 		IndexArtifact ia = new JavaIndexArtifact(location);
// 		return ia;
// 	}
// }


// Path: hangar-api/src/test/java/com/spedge/hangar/index/zookeeper/TestZookeeperIndex.java
import static org.junit.Assert.assertEquals;
import org.apache.curator.test.TestingServer;
import org.apache.curator.utils.CloseableUtils;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import com.spedge.hangar.index.IndexConfictException;
import com.spedge.hangar.index.ReservedArtifact;
import com.spedge.hangar.testutils.IndexUtils;

	}
	
	
	@Test
	public void testReservedArtifact() throws Exception
	{		
		TestingServer testingServer = new TestingServer();
		index.startClient(testingServer.getConnectString());
		
		try
		{
			// Add a reserved artifact
			ReservedArtifact ra = index.addReservationKey(IndexUtils.TEST2.getKey());
					
			// Is there an artifact?
			Assert.assertTrue(index.isArtifact(IndexUtils.TEST2.getKey()));
			
			try
			{
				index.addArtifact(IndexUtils.TEST2.getKey(), IndexUtils.TEST2.getArtifact());
				Assert.fail("Index Conflict was never triggered.");
			}
			catch(IndexConfictException ice){}
			
			// Attempt to update a reserved artifact with an incorrect reserved token!
			try
			{
				index.addReservedArtifact(IndexUtils.TEST2.getKey(), new ReservedArtifact(""), IndexUtils.TEST2.getArtifact());
				Assert.fail("Reserved Conflict was never triggered.");
			}
			catch(IndexConfictException ice){}