private FileSystem newFileSystem(URI uri) { return ioService.newFileSystem(uri, new HashMap<String, Object>(repo.getEnvironment()) {{ if (!repo.getEnvironment().containsKey("origin")) { put("init", true); } put(FileSystemHooks.ExternalUpdate.name(), externalUpdatedCallBack()); put(FileSystemHooks.PostCommit.name(), postCommitCallback()); }}); }
private void verifyFSHook(FileSystemHooks.FileSystemHook hook, FileSystemHooks hookType) { verify(hook).execute(contextArgumentCaptor.capture()); FileSystemHookExecutionContext ctx = contextArgumentCaptor.getValue(); Assertions.assertThat(ctx) .isNotNull() .hasFieldOrPropertyWithValue("fsName", FS_NAME); if (hookType.equals(FileSystemHooks.PostCommit)) { Assertions.assertThat(ctx.getParamValue(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE)) .isNotNull() .isEqualTo(EXIT_CODE); } } }
private void verifyFSHook(FileSystemHooks.FileSystemHook hook, FileSystemHooks hookType) { verify(hook).execute(contextArgumentCaptor.capture()); FileSystemHookExecutionContext ctx = contextArgumentCaptor.getValue(); Assertions.assertThat(ctx) .isNotNull() .hasFieldOrPropertyWithValue("fsName", FS_NAME); if (hookType.equals(FileSystemHooks.PostCommit)) { Assertions.assertThat(ctx.getParamValue(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE)) .isNotNull() .isEqualTo(EXIT_CODE); } } }
@Before public void init() { final URI newRepo = URI.create(GIT + REPO_NAME); final Map<String, Object> env = new HashMap<>(); env.put(FileSystemHooks.PostCommit.name(), postCommitHook); fs = (JGitFileSystem) provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); }
@Test public void extractFSHooksTest() { Map<String, Object> env = new HashMap<>(); Object hook = (FileSystemHooks.FileSystemHook) context -> { }; env.put("dora", "bento"); env.put(FileSystemHooks.ExternalUpdate.name(), hook); Map<FileSystemHooks, ?> fileSystemHooksMap = JGitFileSystemProvider.extractFSHooks(env); assertEquals(1, fileSystemHooksMap.size()); assertTrue(fileSystemHooksMap.keySet().contains(FileSystemHooks.ExternalUpdate)); assertEquals(hook, fileSystemHooksMap.get(FileSystemHooks.ExternalUpdate)); }
@Before public void init() { final URI newRepo = URI.create(GIT + REPO_NAME); final Map<String, Object> env = new HashMap<>(); env.put(FileSystemHooks.PostCommit.name(), postCommitHook); fs = (JGitFileSystem) provider.newFileSystem(newRepo, env); assertThat(fs).isNotNull(); }
@Test public void extractFSHooksTest() { Map<String, Object> env = new HashMap<>(); Object hook = (FileSystemHooks.FileSystemHook) context -> { }; env.put("dora", "bento"); env.put(FileSystemHooks.ExternalUpdate.name(), hook); Map<FileSystemHooks, ?> fileSystemHooksMap = JGitFileSystemProvider.extractFSHooks(env); assertEquals(1, fileSystemHooksMap.size()); assertTrue(fileSystemHooksMap.keySet().contains(FileSystemHooks.ExternalUpdate)); assertEquals(hook, fileSystemHooksMap.get(FileSystemHooks.ExternalUpdate)); }
@Test public void testFileSystemHooks() { rootDirectories.add(createPath("default://master@uf-playground")); ConfigGroup configGroup = getConfigGroup(); configGroup.setName("test"); final IOService service = getServiceToTest(); helper.newRepository(configGroup); ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); verify(service).newFileSystem(any(URI.class), captor.capture()); Map params = captor.getValue(); Assertions.assertThat(params) .isNotNull(); Assertions.assertThat(params.get(FileSystemHooks.ExternalUpdate.name())) .isNotNull() .isInstanceOf(FileSystemHooks.FileSystemHook.class); FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext("test"); FileSystemHooks.FileSystemHook hook = (FileSystemHooks.FileSystemHook) params.get(FileSystemHooks.ExternalUpdate.name()); hook.execute(ctx); verify(repositoryExternalUpdate).fire(any()); Assertions.assertThat(params.get(FileSystemHooks.PostCommit.name())) .isNotNull() .isInstanceOf(FileSystemHooks.FileSystemHook.class); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, 0); hook = (FileSystemHooks.FileSystemHook) params.get(FileSystemHooks.PostCommit.name()); hook.execute(ctx); verify(postCommitNotificationService).notifyUser(any(), eq(0)); }
@Test public void testFileSystemHooks() { rootDirectories.add(createPath("default://master@uf-playground")); ConfigGroup configGroup = getConfigGroup(); configGroup.setName("test"); final IOService service = getServiceToTest(); helper.newRepository(configGroup); ArgumentCaptor<Map> captor = ArgumentCaptor.forClass(Map.class); verify(service).newFileSystem(any(URI.class), captor.capture()); Map params = captor.getValue(); Assertions.assertThat(params) .isNotNull(); Assertions.assertThat(params.get(FileSystemHooks.ExternalUpdate.name())) .isNotNull() .isInstanceOf(FileSystemHooks.FileSystemHook.class); FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext("test"); FileSystemHooks.FileSystemHook hook = (FileSystemHooks.FileSystemHook) params.get(FileSystemHooks.ExternalUpdate.name()); hook.execute(ctx); verify(repositoryExternalUpdate).fire(any()); Assertions.assertThat(params.get(FileSystemHooks.PostCommit.name())) .isNotNull() .isInstanceOf(FileSystemHooks.FileSystemHook.class); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, 0); hook = (FileSystemHooks.FileSystemHook) params.get(FileSystemHooks.PostCommit.name()); hook.execute(ctx); verify(postCommitNotificationService).notifyUser(any(), eq(0)); }