ActionPluginClientService { public void invokeScoreInformationCachedOperation(final RuleModeller ruleModeller, final Consumer<ScoreInformation> scoreInformationConsumer) { Object scoreInformationObject = ruleModeller.getServiceInvocationCache().get(SCORE_INFORMATION); if (!(scoreInformationObject instanceof ScoreInformation)) { scoreHolderService.call(scoreInformation -> { ruleModeller.getServiceInvocationCache().put(SCORE_INFORMATION, scoreInformation); scoreInformationConsumer.accept((ScoreInformation) scoreInformation); }).getProjectScoreInformation(ruleModeller.getPath()); } else { ScoreInformation scoreInformation = (ScoreInformation) ruleModeller.getServiceInvocationCache().get(SCORE_INFORMATION); scoreInformationConsumer.accept(scoreInformation); } } @Inject  ActionPluginClientService(final Caller<ScoreHolderService> scoreHolderService,
                                     final TranslationService translationService); void invokeScoreInformationCachedOperation(final RuleModeller ruleModeller,
                                                      final Consumer<ScoreInformation> scoreInformationConsumer); void initScoreHolderAwarePlugin(final RuleModeller ruleModeller,
                                           final ScoreHolderGlobalAware scoreHolderGlobalAware,
                                           final Collection supportedScoreHolderTypes); void addPluginToActionList(final RuleModeller ruleModeller,
                                      final Command addCommand,
                                      final Collection supportedScoreHolderTypes); void initBendableScoreLevels(final RuleModeller ruleModeller,
                                        final AbstractActionMultiConstraintBendableMatch constraintMatch);  }
@Test public void invokeScoreInformationCachedOperationCacheEmpty() { Map<String, Object> serviceCache = new HashMap<>(); RuleModeller ruleModeller = mock(RuleModeller.class); when(ruleModeller.getServiceInvocationCache()).thenReturn(serviceCache); service.invokeScoreInformationCachedOperation(ruleModeller, (scoreInformation) -> { }); verify(scoreHolderService, times(1)).getProjectScoreInformation(any(Path.class)); }
@Test public void invokeScoreInformationCachedOperationCacheNotEmpty() { Map<String, Object> serviceCache = new HashMap<>(); serviceCache.put(ActionPluginClientService.SCORE_INFORMATION, new ScoreInformation()); RuleModeller ruleModeller = mock(RuleModeller.class); when(ruleModeller.getServiceInvocationCache()).thenReturn(serviceCache); service.invokeScoreInformationCachedOperation(ruleModeller, (scoreInformation) -> { }); verify(scoreHolderService, never()).getProjectScoreInformation(any(Path.class)); }