// Path: src/main/java/com/proofpoint/cloudmanagement/service/InMemoryManagerModule.java
// public static class InMemoryTagManager implements TagManager
// {
//     private final LoadingCache<String, Set<String>> tagCache =
//             CacheBuilder.newBuilder()
//                     .build(new CacheLoader<String, Set<String>>()
//                     {
// 
//                         @Override
//                         public Set<String> load(String key)
//                                 throws Exception
//                         {
//                             return new ConcurrentHashSet<String>();
//                         }
//                     });
// 
//     @Override
//     public TagUpdateStatus addTag(Instance instance, String tag)
//     {
//         tagCache.getUnchecked(instance.getId()).add(tag);
//         return TagUpdateStatus.UPDATED;
//     }
// 
//     @Override
//     public TagUpdateStatus deleteTag(Instance instance, String tag)
//     {
//         tagCache.getUnchecked(instance.getId()).remove(tag);
//         return TagUpdateStatus.UPDATED;
//     }
// 
//     @Override
//     public Iterable<String> getTags(Instance instance)
//     {
//         return tagCache.getUnchecked(instance.getId());
//     }
// }
// 
// Path: src/main/java/com/proofpoint/cloudmanagement/service/InMemoryManagerModule.java
// public static class NoOpDnsManager implements DnsManager
// {
//     @Override
//     public String getFullyQualifiedDomainName(Instance instance)
//     {
//         return instance.getHostname();
//     }
// }


import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.proofpoint.cloudmanagement.service.InMemoryManagerModule.InMemoryTagManager;
import com.proofpoint.cloudmanagement.service.InMemoryManagerModule.NoOpDnsManager;
import com.proofpoint.jaxrs.testing.MockUriInfo;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import java.net.URI;
import java.util.UUID;
import static org.testng.Assert.assertEquals;

        assertEquals(getResponse1.getStatus(), Status.OK.getStatusCode());

        Response deleteResponse = instanceResource.deleteInstance(createdInstance);

        assertEquals(deleteResponse.getStatus(), Status.NO_CONTENT.getStatusCode());

        Response getResponse2 = instanceResource.getInstance(createdInstance, INSTANCE_URI_INFO);

        assertEquals(getResponse2.getStatus(), Status.NOT_FOUND.getStatusCode());
    }

    @Test
    public void testDeleteMissingInstance()
    {
        Response deleteResponse = instanceResource.deleteInstance(UUID.randomUUID().toString());

        assertEquals(deleteResponse.getStatus(), Status.NOT_FOUND.getStatusCode());
    }

    @Test
    public void testConstructSelfUri()
    {
        String id = UUID.randomUUID().toString();
        URI self = InstanceResource.constructSelfUri(INSTANCE_URI_INFO, id);

        assertEquals(id, Strings.commonSuffix(id, self.getPath()));
        assertEquals(INSTANCE_URI_INFO.getAbsolutePath().toString(), Strings.commonPrefix(INSTANCE_URI_INFO.getAbsolutePath().toString(), self.toString()));
    }

// Path: src/main/java/com/proofpoint/cloudmanagement/service/InMemoryManagerModule.java
// public static class InMemoryTagManager implements TagManager
// {
//     private final LoadingCache<String, Set<String>> tagCache =
//             CacheBuilder.newBuilder()
//                     .build(new CacheLoader<String, Set<String>>()
//                     {
// 
//                         @Override
//                         public Set<String> load(String key)
//                                 throws Exception
//                         {
//                             return new ConcurrentHashSet<String>();
//                         }
//                     });
// 
//     @Override
//     public TagUpdateStatus addTag(Instance instance, String tag)
//     {
//         tagCache.getUnchecked(instance.getId()).add(tag);
//         return TagUpdateStatus.UPDATED;
//     }
// 
//     @Override
//     public TagUpdateStatus deleteTag(Instance instance, String tag)
//     {
//         tagCache.getUnchecked(instance.getId()).remove(tag);
//         return TagUpdateStatus.UPDATED;
//     }
// 
//     @Override
//     public Iterable<String> getTags(Instance instance)
//     {
//         return tagCache.getUnchecked(instance.getId());
//     }
// }
// 
// Path: src/main/java/com/proofpoint/cloudmanagement/service/InMemoryManagerModule.java
// public static class NoOpDnsManager implements DnsManager
// {
//     @Override
//     public String getFullyQualifiedDomainName(Instance instance)
//     {
//         return instance.getHostname();
//     }
// }


// Path: src/test/java/com/proofpoint/cloudmanagement/service/TestInstanceResource.java
import com.google.common.base.Strings;
import com.google.common.collect.ImmutableMap;
import com.proofpoint.cloudmanagement.service.InMemoryManagerModule.InMemoryTagManager;
import com.proofpoint.cloudmanagement.service.InMemoryManagerModule.NoOpDnsManager;
import com.proofpoint.jaxrs.testing.MockUriInfo;
import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
import java.net.URI;
import java.util.UUID;
import static org.testng.Assert.assertEquals;


        assertEquals(getResponse1.getStatus(), Status.OK.getStatusCode());

        Response deleteResponse = instanceResource.deleteInstance(createdInstance);

        assertEquals(deleteResponse.getStatus(), Status.NO_CONTENT.getStatusCode());

        Response getResponse2 = instanceResource.getInstance(createdInstance, INSTANCE_URI_INFO);

        assertEquals(getResponse2.getStatus(), Status.NOT_FOUND.getStatusCode());
    }

    @Test
    public void testDeleteMissingInstance()
    {
        Response deleteResponse = instanceResource.deleteInstance(UUID.randomUUID().toString());

        assertEquals(deleteResponse.getStatus(), Status.NOT_FOUND.getStatusCode());
    }

    @Test
    public void testConstructSelfUri()
    {
        String id = UUID.randomUUID().toString();
        URI self = InstanceResource.constructSelfUri(INSTANCE_URI_INFO, id);

        assertEquals(id, Strings.commonSuffix(id, self.getPath()));
        assertEquals(INSTANCE_URI_INFO.getAbsolutePath().toString(), Strings.commonPrefix(INSTANCE_URI_INFO.getAbsolutePath().toString(), self.toString()));
    }

    @Test(expectedExceptions = NullPointerException.class)