@Test void notContainsItself() { Package packageA = mock(Package.class); Package packageAa = mock(Package.class); Package packageAb = mock(Package.class); Package packageAba = mock(Package.class); when(packageA.getChildren()).thenReturn(asList(packageAa, packageAb)); when(packageAb.getChildren()).thenReturn(singletonList(packageAba)); CopyState state = CopyState.create(packageAba, mock(Progress.class)); assertThrows(RecursiveCopyException.class, () -> copier.copy(singletonList(packageA), state)); }
public void copy(List<Package> packages, CopyState state) { packages.forEach(pack -> copyPackage(pack, state)); }
PackageCopier { public void copy(List<Package> packages, CopyState state) { packages.forEach(pack -> copyPackage(pack, state)); } }
PackageCopier { public void copy(List<Package> packages, CopyState state) { packages.forEach(pack -> copyPackage(pack, state)); } PackageCopier(DataService dataService, IdGenerator idGenerator); }
PackageCopier { public void copy(List<Package> packages, CopyState state) { packages.forEach(pack -> copyPackage(pack, state)); } PackageCopier(DataService dataService, IdGenerator idGenerator); void copy(List<Package> packages, CopyState state); }
PackageCopier { public void copy(List<Package> packages, CopyState state) { packages.forEach(pack -> copyPackage(pack, state)); } PackageCopier(DataService dataService, IdGenerator idGenerator); void copy(List<Package> packages, CopyState state);  }