GitlabRepositoryPathNotificationExtractor extends AbstraceNotificationExtractor { @Override public PropertyPathNotification extract( final MultiValueMap<String, String> headers, final Map<String, Object> payload ) { final PropertyPathNotification result; if ("Push Hook".equals(headers.getFirst("X-Gitlab-Event"))) { if (payload.get("commits") instanceof Collection) { final Set<String> paths = new HashSet<>(); @SuppressWarnings("unchecked") final Collection<Map<String, Object>> commits = (Collection<Map<String, Object>>) payload.get("commits"); for (final Map<String, Object> commit : commits) { addAllPaths(paths, commit, "added"); addAllPaths(paths, commit, "removed"); addAllPaths(paths, commit, "modified"); } result = !paths.isEmpty() ? new PropertyPathNotification(paths.toArray(new String[0])) : null; } else { result = null; } } else { result = null; } return result; }  @Override PropertyPathNotification extract( //
        final MultiValueMap<String, String> headers, //
        final Map<String, Object> payload //
    );  }
@Test public void testGitPath() { TestPropertyValues values = TestPropertyValues.of("spring.cloud.config.server.common-config.application=common"); values.applyTo(this.context); this.context.refresh(); this.extractor = this.context.getBean(GitlabRepositoryPathNotificationExtractor.class); final MultiValueMap<String, String> headers = new HttpHeaders(); headers.put("X-Gitlab-Event", newArrayList("Push Hook")); assertTrue(contains( this.extractor.extract(headers, payload("oss-todomvc-app-config")).getPaths(), "oss*" )); assertTrue(contains( this.extractor.extract(headers, payload("home1-oss-common-config")).getPaths(), "application" )); }
@Test public void testCommonProductConfigPath() { TestPropertyValues values = TestPropertyValues.of("spring.cloud.config.server.common-config.application=common-production"); values.applyTo(this.context); this.context.refresh(); extractor = this.context.getBean(GitlabRepositoryPathNotificationExtractor.class); final MultiValueMap<String, String> headers = new HttpHeaders(); headers.put("X-Gitlab-Event", newArrayList("Push Hook")); System.setProperty("spring.cloud.config.server.common-config.application", "common-production"); assertTrue(contains( this.extractor.extract(headers, payload("home1-oss-common-config")).getPaths(), "application" )); }