RepositoryCopierImpl implements RepositoryCopier { public void fireNewBranchEvent(final Path targetRoot, final org.uberfire.java.nio.file.Path nioTargetRepositoryRoot, final org.uberfire.java.nio.file.Path originRepositoryRoot) { final Repository repository = repositoryService.getRepository(targetRoot); final Optional<Branch> branch = repository.getBranch(Paths.convert(nioTargetRepositoryRoot.getRoot())); final Optional<Branch> origBranch = repository.getBranch(Paths.convert(originRepositoryRoot.getRoot())); if (branch.isPresent()) { newBranchEventEvent.fire(new NewBranchEvent(repository, branch.get().getName(), origBranch.get().getName(), sessionInfo.getIdentity().getIdentifier())); } else { throw new IllegalStateException("Could not find a branch that was just created. The Path used was " + nioTargetRepositoryRoot.getRoot()); } } RepositoryCopierImpl(); @Inject  RepositoryCopierImpl(final @Named("ioStrategy") IOService ioService,
                                final Event<NewBranchEvent> newBranchEventEvent,
                                final ConfiguredRepositories configuredRepositories,
                                final RepositoryService repositoryService,
                                final SessionInfo sessionInfo); @Override Repository copy(final OrganizationalUnit targetOU,
                           final String newRepositoryName,
                           final Path originRoot); @Override void copy(final Path originRoot,
                     final Path targetRoot); @Override void copy(Space space,
                     Path originRoot,
                     Path targetRoot); void fireNewBranchEvent(final Path targetRoot,
                                   final org.uberfire.java.nio.file.Path nioTargetRepositoryRoot,
                                   final org.uberfire.java.nio.file.Path originRepositoryRoot); void fireNewBranchEvent(final Space space,
                                   final Path targetRoot,
                                   final org.uberfire.java.nio.file.Path nioTargetRepositoryRoot,
                                   final org.uberfire.java.nio.file.Path originRepositoryRoot); @Override String makeSafeRepositoryName(final String oldName);  }
@Test public void testFireNewBranchEvent() throws Exception { final org.uberfire.java.nio.file.Path nioFrom = fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "from")); final org.uberfire.java.nio.file.Path nioTo = fileSystemTestingUtils.getIoService().get(URI.create(PATH_PREFIX + "to")); final Path to = Paths.convert(nioTo); doReturn(repository).when(repositoryService).getRepository(any(Path.class)); when(repository.getBranch(any(Path.class))).thenReturn(Optional.of(branch)); when(branch.getName()).thenReturn("testBranch"); when(sessionInfo.getIdentity()).thenReturn(user); copier.fireNewBranchEvent(to, nioTo, nioFrom); verify(newBranchEventEvent, times(1)).fire(any(NewBranchEvent.class)); }