InMemoryIndex implements IIndex { public void addArtifact(IndexKey key, IndexArtifact artifact) throws IndexConfictException { if (index.containsKey(key.toString())) { if (!(index.get(key.toString()) instanceof ReservedArtifact)) { index.put(key.toString(), artifact); } else { throw new IndexConfictException(); } } else { index.put(key.toString(), artifact); } } InMemoryIndex(); boolean isArtifact(IndexKey key); void addArtifact(IndexKey key, IndexArtifact artifact); IndexArtifact getArtifact(IndexKey key); void load(RepositoryType type, IStorage storage, String uploadPath); @Override ReservedArtifact addReservationKey(IndexKey key); @Override void addReservedArtifact(IndexKey key, ReservedArtifact reservation, IndexArtifact ia);  }
@Test public void testAddArtifact() throws IndexConfictException { index.addArtifact(IndexUtils.TEST1.getKey(), IndexUtils.TEST1.getArtifact()); Assert.assertTrue(index.isArtifact(IndexUtils.TEST1.getKey())); assertEquals(IndexUtils.TEST1.getArtifact(), index.getArtifact(IndexUtils.TEST1.getKey())); }