@Override public void notifyExternalUpdate() { Object hook = fsHooks.get(FileSystemHooks.ExternalUpdate); if(hook != null){ JGitFSHooks.executeFSHooks(hook, FileSystemHooks.ExternalUpdate, new FileSystemHookExecutionContext(name)); } }
@Override public void notifyPostCommit(int exitCode) { Object hook = fsHooks.get(FileSystemHooks.PostCommit); if(hook != null){ FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext(name); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, exitCode); JGitFSHooks.executeFSHooks(hook, FileSystemHooks.ExternalUpdate, ctx); } } }
@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)); }
@Test public void executeFSHooksTest() { FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext(FS_NAME); testExecuteFSHooks(ctx, FileSystemHooks.ExternalUpdate); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, EXIT_CODE); testExecuteFSHooks(ctx, FileSystemHooks.PostCommit); }
@Test public void executeFSHooksTest() { FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext(FS_NAME); testExecuteFSHooks(ctx, FileSystemHooks.ExternalUpdate); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, EXIT_CODE); testExecuteFSHooks(ctx, FileSystemHooks.PostCommit); }
@Test public void executeFSHooksArrayTest() { FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext(FS_NAME); testExecuteFSHooksArray(ctx, FileSystemHooks.ExternalUpdate); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, EXIT_CODE); testExecuteFSHooksArray(ctx, FileSystemHooks.PostCommit); }
@Test public void executeFSHooksArrayTest() { FileSystemHookExecutionContext ctx = new FileSystemHookExecutionContext(FS_NAME); testExecuteFSHooksArray(ctx, FileSystemHooks.ExternalUpdate); ctx.addParam(FileSystemHooksConstants.POST_COMMIT_EXIT_CODE, EXIT_CODE); testExecuteFSHooksArray(ctx, FileSystemHooks.PostCommit); }