@Test public void createContent() { 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(content); when(cc.merge(eq(content))).thenReturn(content); assertEquals(content, ocr.createContent("owner", content)); }
@Test public void createContentNull() { 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.createContent("owner", content); verify(cc, atLeastOnce()).create(content); }