DefaultGroupedJobInitializerManager implements GroupedJobInitializerManager, Initializable { @Override public GroupedJobInitializer getGroupedJobInitializer(JobGroupPath jobGroupPath) { GroupedJobInitializer result = null; if (jobGroupPath != null) { result = this.cachedInitializers.get(jobGroupPath.toString()); if (result == null) { try { List<GroupedJobInitializer> initializers = this.componentManagerProvider.get().getInstanceList(GroupedJobInitializer.class); JobGroupPath currentPath = jobGroupPath; while (currentPath != null && result == null) { result = search(currentPath, initializers); currentPath = currentPath.getParent(); } } catch (ComponentLookupException e) { this.logger.error("Error while loading GroupedJobInitializer component: [{}]", ExceptionUtils.getRootCauseMessage(e)); } } } if (result == null) { result = this.defaultGoupedJobInitializer; } if (jobGroupPath != null) { this.cachedInitializers.set(jobGroupPath.toString(), result); } return result; }  @Override void initialize(); @Override GroupedJobInitializer getGroupedJobInitializer(JobGroupPath jobGroupPath); @Override void invalidateCache();  }
@Test public void getInitializerExactMatch() { assertSame(this.initializerList.get(0), this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Collections.singletonList("foo")))); assertSame(this.initializerList.get(3), this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Arrays.asList("foo", "bar", "buz")))); }
@Test public void getInitializerFallbackOnParent() { assertSame(this.initializerList.get(0), this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Arrays.asList("foo", "something")))); assertSame(this.initializerList.get(1), this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Arrays.asList("foo", "bar", "something")))); assertSame(this.initializerList.get(3), this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Arrays.asList("foo", "bar", "buz", "something")))); }
@Test public void getInitializerFallbackOnDefault() { assertSame(this.defaultGroupedJobInitializer, this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Collections.singletonList("something")))); assertSame(this.defaultGroupedJobInitializer, this.groupedJobInitializerManager.getGroupedJobInitializer(null)); assertSame(this.defaultGroupedJobInitializer, this.groupedJobInitializerManager.getGroupedJobInitializer( new JobGroupPath(Arrays.asList("a", "b")))); }