PodResourcePoolResolverChain implements PodResourcePoolResolver { @Override public List<ResourcePoolAssignment> resolve(Job<?> job) { for (PodResourcePoolResolver delegate : delegates) { List<ResourcePoolAssignment> result = delegate.resolve(job); if (!result.isEmpty()) { return result; } } return Collections.emptyList(); } PodResourcePoolResolverChain(List<PodResourcePoolResolver> delegates); @Override List<ResourcePoolAssignment> resolve(Job<?> job);  }
@Test public void testChainedExecution() { when(delegate1.resolve(any())).thenReturn(Collections.emptyList()); when(delegate2.resolve(any())).thenReturn(Collections.singletonList( ResourcePoolAssignment.newBuilder().withResourcePoolName("elastic").withRule("rule").build()) ); List<ResourcePoolAssignment> result = resolver.resolve(JobGenerator.oneBatchJob()); assertThat(result).hasSize(1); assertThat(result.get(0).getResourcePoolName()).isEqualTo("elastic"); }