final GitRepository repo = new GitRepository( repoConfig.getName() ); repo.addEnvironmentParameter( item.getName(), secureService.decrypt( item.getValue().toString() ) ); } else { repo.addEnvironmentParameter( item.getName(), item.getValue() ); if ( !repo.isValid() ) { throw new IllegalStateException( "Repository " + repoConfig.getName() + " not valid" ); final Object command = repo.getEnvironment().get( "org.kie.config.cli.command.CliCommand" ); if ( command != null ) { repo.getEnvironment().put( "init", true ); } else { final String url = context.getScheme() + "://" + context.getUser() + "@" + context.getHost() + ":" + context.getPort() + "/" + repo.getAlias(); repo.getEnvironment().put( "origin", url ); repo.getEnvironment().put( "username", context.getUser() ); repo.getEnvironment().put( "password", context.getPassword() ); URI uri = null; try { uri = URI.create( repo.getUri() ); fs = ioService.newFileSystem( uri, new HashMap<String, Object>( repo.getEnvironment() ) ); } catch ( final FileSystemAlreadyExistsException e ) { fs = ioService.getFileSystem( uri );
private Repository createRepository(String alias) { GitRepository repository = new GitRepository(alias); repository.addBranch("master", branchPath); return repository; } }
private void setBranches(final FileSystem fileSystem) { final Map<String, Path> branches = getBranches(fileSystem); repo.setBranches(branches); repo.setRoot(getDefaultRoot(fileSystem, branches)); }
public static GitRepository makeGitRepository() { final GitRepository repository = new GitRepository("guvnorng-playground", new Space("space")); final Map<String, Branch> branches = Collections.singletonMap("master", new Branch("master", mock(Path.class))); repository.setBranches(branches); return repository; } }
private void makeWorkspaceProject() { final DefaultPublicURI uri = new DefaultPublicURI("git", "git://uri:9999/space/project"); final GitRepository repository = new GitRepository("alias", mock(Space.class), singletonList(uri)); workspaceProject = spy(new WorkspaceProject()); when(workspaceProject.getRepository()).thenReturn(repository); }
private ConfigGroup addRepository(final String alias, final String... branches) { final ConfigGroup configGroup = new ConfigGroup(); final GitRepository repository = new GitRepository(alias); final HashMap<String, Path> branchMap = new HashMap<>(); for (String branch : branches) { branchMap.put(branch, mock(Path.class)); } repository.setBranches(branchMap); repository.setRoot(branchMap.get("master")); when(repositoryFactory.newRepository(configGroup)).thenReturn(repository); return configGroup; }
public Repository build(final ConfigGroup repoConfig) { repo = new GitRepository(repoConfig.getName()); if (!repo.isValid()) { throw new IllegalStateException("Repository " + repoConfig.getName() + " not valid"); } else { addEnvironmentParameters(repoConfig.getItems()); FileSystem fileSystem = createFileSystem(repo); setBranches(fileSystem); setPublicURIs(fileSystem); return repo; } }
private FileSystem createFileSystem(final GitRepository repo) { FileSystem fs = null; URI uri = null; try { uri = URI.create(repo.getUri()); fs = newFileSystem(uri); } catch (final FileSystemAlreadyExistsException e) { fs = ioService.getFileSystem(uri); Object replaceIfExists = repo.getEnvironment().get("replaceIfExists"); if (replaceIfExists != null && Boolean.valueOf(replaceIfExists.toString())) { org.uberfire.java.nio.file.Path root = fs.getPath(null); ioService.delete(root); fs = newFileSystem(uri); } } catch (final Throwable ex) { throw new RuntimeException(ex.getCause().getMessage(), ex); } return fs; }
private void setBranches(final FileSystem fileSystem) { final Map<String, Branch> branches = getBranches(fileSystem); repo.setBranches(branches); }
@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(); } } }
when(exProject1.getRoot()).thenReturn(module1Root); when(repository1.getBranch("dev_branch")).thenReturn(Optional.of(new Branch("dev_branch", repositoryRoot))); final Optional<Branch> master = Optional.of(new Branch("master", PathFactory.newPath("testFile", "file:///"))); when(repository1.getDefaultBranch()).thenReturn(master); doReturn("module1").when(repository1).getAlias(); doReturn(repository1.getAlias()).when(project).getName(); doReturn(mock(Module.class)).when(project).getMainModule(); doReturn(mock(OrganizationalUnit.class)).when(project).getOrganizationalUnit();
private FileSystem newFileSystem(URI uri) { return ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{ if (!repo.getEnvironment().containsKey("origin")) { put("init", true); } }}); }
@Override public String getIdentifier() { return getUri(); }
private void addEnvironmentParameters(final Collection<ConfigItem> items) { for (final ConfigItem item : items) { if (item instanceof SecureConfigItem) { repo.addEnvironmentParameter(item.getName(), secureService.decrypt(item.getValue().toString())); } else { repo.addEnvironmentParameter(item.getName(), item.getValue()); } } }
private GitRepository getGitRepository(final String alias) { final GitRepository repository = new GitRepository(alias, new Space("scheme")); final HashMap<String, Branch> branches = new HashMap<>(); final Path path = PathFactory.newPath("/", "file://master@module/"); branches.put("master", new Branch("master", path)); repository.setBranches(branches); return repository; } }
private void testNotify(int code, String message, NotificationType notificationType, int times) { service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), code); ArgumentCaptor<PostCommitNotificationEvent> eventCaptor = ArgumentCaptor.forClass(PostCommitNotificationEvent.class); verify(notificationEvent, times(times)).fire(eventCaptor.capture()); Assertions.assertThat(eventCaptor.getValue()) .isNotNull() .hasFieldOrPropertyWithValue("text", message) .hasFieldOrPropertyWithValue("type", notificationType); }
public Repository build(final ConfigGroup repoConfig) { ConfigItem space = repoConfig.getConfigItem(EnvironmentParameters.SPACE); if (space == null) { throw new IllegalStateException("Repository " + repoConfig.getName() + " space is not valid"); } repo = new GitRepository(repoConfig.getName(), spacesAPI.getSpace(space.getValue().toString())); if (!repo.isValid()) { throw new IllegalStateException("Repository " + repoConfig.getName() + " not valid"); } else { addEnvironmentParameters(repoConfig.getItems()); FileSystem fileSystem = createFileSystem(repo); setBranches(fileSystem); setPublicURIs(fileSystem); return repo; } }
private FileSystem createFileSystem(final GitRepository repo) { FileSystem fs; URI uri = null; try { uri = URI.create(repo.getUri()); fs = newFileSystem(uri); } catch (final FileSystemAlreadyExistsException e) { fs = ioService.getFileSystem(uri); Object replaceIfExists = repo.getEnvironment().get("replaceIfExists"); if (replaceIfExists != null && Boolean.valueOf(replaceIfExists.toString())) { org.uberfire.java.nio.file.Path root = fs.getPath(null); ioService.delete(root); fs = newFileSystem(uri); } } catch (final Throwable ex) { throw new RuntimeException(ex); } return fs; }
@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(); } } }