### Question:
InMemoryContainer extends InMemoryResource implements Container { @Override public Slug addSlug(String preferredPath) { checkNotNull(preferredPath,"Preferred path cannot be null"); InMemorySlug tmp = InMemorySlug.create(preferredPath,this); InMemorySlug slug=this.slugs.putIfAbsent(tmp.preferredPath(),tmp); if(slug==null) { return tmp; } synchronized(slug) { if(slug.version()<tmp.version()) { slug.setVersion(tmp.version()); return slug; } else if(slug.version()==tmp.version()) { return slug; } } return addSlug(preferredPath+"_1"); } InMemoryContainer(ResourceId id, ResourceId parentId);   InMemoryContainer(ResourceId id); @Override void accept(ResourceVisitor visitor); @Override Resource addMember(ResourceId resourceId); @Override boolean hasMember(ResourceId resource); @Override Set<Member> members(); @Override Member findMember(ResourceId resourceId); @Override boolean removeMember(Member member); @Override Set<Slug> slugs(); @Override Slug findSlug(String preferredPath); @Override Slug addSlug(String preferredPath); @Override String toString();  }### Answer:
@Test public void testAddSlug$new() throws Exception { Slug slug = this.container.addSlug("slug"); assertThat(slug,notNullValue()); assertThat(this.container.findSlug("slug"),sameInstance(slug)); }
@Test public void testAddSlug$new$derived_path$not_mergeable$lower() throws Exception { Slug original = this.container.addSlug("slug"); original.nextPath(); assertThat(original.version(),equalTo(1L)); original.nextPath(); assertThat(original.version(),equalTo(2L)); original.nextPath(); assertThat(original.version(),equalTo(3L)); Slug slug = this.container.addSlug("slug_2"); assertThat(slug,notNullValue()); assertThat(slug.preferredPath(),equalTo("slug_2")); assertThat(slug.version(),equalTo(1L)); assertThat(original.version(),equalTo(3L)); }
@Test public void testAddSlug$new$derived_path$not_mergeable$equal() throws Exception { Slug original = this.container.addSlug("slug"); original.nextPath(); assertThat(original.version(),equalTo(1L)); original.nextPath(); assertThat(original.version(),equalTo(2L)); original.nextPath(); assertThat(original.version(),equalTo(3L)); Slug slug = this.container.addSlug("slug_3"); assertThat(slug,sameInstance(original)); assertThat(original.version(),equalTo(3L)); }