@Test(expected = NotFoundException.class) public void deleteContentNull() { Owner owner = mock(Owner.class); Content content = mock(Content.class); when(content.getId()).thenReturn("10"); when(oc.lookupByKey(eq("owner"))).thenReturn(owner); when(cc.lookupById(eq(owner), eq("10"))).thenReturn(null); ocr.remove("owner", "10"); verify(cc, never()).delete(eq(content)); }
@Test public void deleteContent() { Owner owner = mock(Owner.class); Content content = mock(Content.class); when(content.getId()).thenReturn("10"); when(content.getOwner()).thenReturn(owner); when(oc.lookupByKey(eq("owner"))).thenReturn(owner); when(cc.lookupById(eq(owner), eq("10"))).thenReturn(content); EnvironmentContent ec = new EnvironmentContent(mock(Environment.class), content, true); List<EnvironmentContent> envContents = Arrays.asList(ec); when(envContentCurator.lookupByContent(owner, content.getId())).thenReturn(envContents); ocr.remove("owner", "10"); verify(cc, atLeastOnce()).delete(eq(content)); verify(envContentCurator, atLeastOnce()).delete(eq(ec)); }