@Test public void first_enricher_returns_result_does_not_call_create_on_other_enrichers() { Object enricherAResult = new Object(); when(mockEnricherA.enrich(this.request, null)).thenReturn(enricherAResult); compositeEnricher.enrich(this.request, null); verify(mockEnricherB, never()).enrich(this.request, null); }
@Override public Object enrich(Object request, Annotation annotation) { for( RequestEnricher enricher : this.enrichers) { Object newRequest = enricher.enrich(request, annotation); if(newRequest != null) { return newRequest; } } return null; }
CompositeRequestEnricher implements RequestEnricher { @Override public Object enrich(Object request, Annotation annotation) { for( RequestEnricher enricher : this.enrichers) { Object newRequest = enricher.enrich(request, annotation); if(newRequest != null) { return newRequest; } } return null; } }
CompositeRequestEnricher implements RequestEnricher { @Override public Object enrich(Object request, Annotation annotation) { for( RequestEnricher enricher : this.enrichers) { Object newRequest = enricher.enrich(request, annotation); if(newRequest != null) { return newRequest; } } return null; } CompositeRequestEnricher(RequestEnricher... enrichers); }
CompositeRequestEnricher implements RequestEnricher { @Override public Object enrich(Object request, Annotation annotation) { for( RequestEnricher enricher : this.enrichers) { Object newRequest = enricher.enrich(request, annotation); if(newRequest != null) { return newRequest; } } return null; } CompositeRequestEnricher(RequestEnricher... enrichers); @Override Object enrich(Object request, Annotation annotation); }
CompositeRequestEnricher implements RequestEnricher { @Override public Object enrich(Object request, Annotation annotation) { for( RequestEnricher enricher : this.enrichers) { Object newRequest = enricher.enrich(request, annotation); if(newRequest != null) { return newRequest; } } return null; } CompositeRequestEnricher(RequestEnricher... enrichers); @Override Object enrich(Object request, Annotation annotation);  }