private Repository createRepository(String alias) { GitRepository repository = new GitRepository(alias); repository.addBranch("master", branchPath); 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 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); }
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); }
@Before public void setup() { Set<Repository> repositories = new HashSet<Repository>(); repositories.add(new GitRepository("dora", new Space("space"))); final SocialEventRepositoryConstraint socialEventRepositoryConstraint = mock( SocialEventRepositoryConstraint.class); when(socialEventRepositoryConstraint.getAuthorizedRepositories()).thenReturn(repositories); service.repositoryConstraint = socialEventRepositoryConstraint; }
@Test public void testNoNotification() { init(BUNDLE_PATH); service.notifyUser(new GitRepository(REPO, new Space(SYSTEM_SPACE)), 0); verify(notificationEvent, never()).fire(any()); service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), 3); verify(notificationEvent, never()).fire(any()); }
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; }
@Test public void testNoNotification() { init(BUNDLE_PATH); service.notifyUser(new GitRepository(REPO, new Space(SYSTEM_SPACE)), 0); verify(notificationEvent, never()).fire(any()); service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), 3); verify(notificationEvent, never()).fire(any()); }
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; } }
@Test public void testLoadWrongBundle() { init("wrong bundle"); service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), 0); verify(notificationEvent, never()).fire(any()); }
@Test public void testLoadWrongBundle() { init("wrong bundle"); service.notifyUser(new GitRepository(REPO, new Space(VALID_SPACE)), 0); verify(notificationEvent, never()).fire(any()); }
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; } }
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; } }
@Test public void testNewRepository() throws Exception { final GuvnorStructureContextChangeHandler handler = mock(GuvnorStructureContextChangeHandler.class); context.addGuvnorStructureContextChangeHandler(handler); final GitRepository newRepository = new GitRepository(); final HashMap<String, Branch> branches = new HashMap<>(); branches.put("master", new Branch("master", mock(Path.class))); newRepository.setBranches(branches); context.onNewRepository(new NewRepositoryEvent(newRepository)); verify(handler).onNewRepositoryAdded(newRepository); }
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; } }
@Test public void testNewRepository() throws Exception { final GuvnorStructureContextChangeHandler handler = mock(GuvnorStructureContextChangeHandler.class); context.addGuvnorStructureContextChangeHandler(handler); final GitRepository newRepository = new GitRepository(); context.onNewRepository(new NewRepositoryEvent(newRepository)); verify(handler).onNewRepositoryAdded(newRepository); }
@Test public void testHandler() throws Exception { final GuvnorStructureContextChangeHandler handler1 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler handler2 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration1 = context.addGuvnorStructureContextChangeHandler(handler1); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration2 = context.addGuvnorStructureContextChangeHandler(handler2); assertNotNull(handlerRegistration1); assertNotNull(handlerRegistration2); context.removeHandler(handlerRegistration2); final GitRepository newRepository = new GitRepository(); context.onRepositoryRemoved(new RepositoryRemovedEvent(newRepository)); verify(handler1).onRepositoryDeleted(newRepository); verify(handler2, never()).onRepositoryDeleted(newRepository); }
private Repository createRepository(String alias, String space) { GitRepository repository = new GitRepository(alias, new Space(space)); repository.addBranch(new Branch("master", branchPath)); return repository; } }
@Test public void testHandler() throws Exception { final GuvnorStructureContextChangeHandler handler1 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler handler2 = mock(GuvnorStructureContextChangeHandler.class); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration1 = context.addGuvnorStructureContextChangeHandler(handler1); final GuvnorStructureContextChangeHandler.HandlerRegistration handlerRegistration2 = context.addGuvnorStructureContextChangeHandler(handler2); assertNotNull(handlerRegistration1); assertNotNull(handlerRegistration2); context.removeHandler(handlerRegistration2); final GitRepository newRepository = new GitRepository(); context.onRepositoryRemoved(new RepositoryRemovedEvent(newRepository)); verify(handler1).onRepositoryDeleted(newRepository); verify(handler2, never()).onRepositoryDeleted(newRepository); }
@Test public void resolveProjectRepository() throws Exception { final GitRepository repository = new GitRepository("alias", space); final HashMap<String, Branch> branches = new HashMap<>(); branches.put("master", new Branch("master", path)); repository.setBranches(branches); final WorkspaceProject workspaceProject = workspaceProjectService.resolveProject(repository); assertEquals(ou, workspaceProject.getOrganizationalUnit()); assertEquals(this.repository, workspaceProject.getRepository()); assertEquals(branch, workspaceProject.getBranch()); assertEquals(module, workspaceProject.getMainModule()); }