@Override public void onNewBranchAdded(String repositoryAlias, String branchName, Path branchPath) { Repository repository = getRepositoryByAlias(repositoryAlias); if (repository != null && (repository instanceof GitRepository)) { //only git repositories exists RepositoryItemPresenter itemPresenter = repositoryToWidgetMap.remove(repository); if (itemPresenter != null) { ((GitRepository) repository).addBranch(branchName, branchPath); repositoryToWidgetMap.put(repository, itemPresenter); itemPresenter.refreshBranches(); } } }
@Override public void onNewBranchAdded(String repositoryAlias, String branchName, Path branchPath) { Repository repository = getRepositoryByAlias(repositoryAlias); if (repository != null && (repository instanceof GitRepository)) { //only git repositories exists RepositoryItemPresenter itemPresenter = repositoryToWidgetMap.remove(repository); if (itemPresenter != null) { ((GitRepository) repository).addBranch(new Branch(branchName, branchPath)); repositoryToWidgetMap.put(repository, itemPresenter); itemPresenter.refreshBranches(); } } }
public void onNewBranch(final @Observes NewBranchEvent changedEvent) { if (repositoriesByAlias.containsKey(changedEvent.getRepositoryAlias())) { final Repository repository = getRepositoryByRepositoryAlias(changedEvent.getRepositoryAlias()); if (repository instanceof GitRepository) { ((GitRepository) repository).addBranch(changedEvent.getBranchName(), changedEvent.getBranchPath()); repositoriesByBranchRoot.put(changedEvent.getBranchPath(), repository); } } }
private Repository createRepository(String alias) { GitRepository repository = new GitRepository(alias); repository.addBranch("master", branchPath); return repository; } }
@Test public void testNewBranchTest() { final GuvnorStructureContextChangeHandler handler = mock(GuvnorStructureContextChangeHandler.class); guvnorStructureContext.addGuvnorStructureContextChangeHandler(handler); presenter.onStartup(); //Emulates the master branch was selected for the given repository prior the new branch was created. when(itemView1.getSelectedBranch()).thenReturn("master"); final Branch theNewBranch = new Branch("theNewBranch", branchPath); ((GitRepository) r1).addBranch(theNewBranch); //Emulates the context receiving the new branch event for a branch created in r1. guvnorStructureContext.onNewBranch(new NewBranchEvent(r1, "theNewBranch", mock(User.class))); verify(handler).onNewBranchAdded("r1", "theNewBranch", branchPath); }
private Repository createRepository(String alias, String space) { GitRepository repository = new GitRepository(alias, new Space(space)); repository.addBranch(new Branch("master", branchPath)); return repository; } }