ActionPluginClientService { public void initBendableScoreLevels(final RuleModeller ruleModeller, final AbstractActionMultiConstraintBendableMatch constraintMatch) { invokeScoreInformationCachedOperation(ruleModeller, scoreInformation -> { Collection<BendableScoreLevelsWrapper> scoreLevels = scoreInformation.getBendableScoreLevelsWrappers(); if (scoreLevels.size() == 1) { BendableScoreLevelsWrapper scoreLevelsWrapper = scoreLevels.iterator().next(); ArrayList<ActionBendableHardConstraintMatch> hardConstraints = new ArrayList<>(scoreLevelsWrapper.getHardScoreLevels()); for (int i = 0; i < scoreLevelsWrapper.getHardScoreLevels(); i++) { hardConstraints.add(new ActionBendableHardConstraintMatch(i, null)); } constraintMatch.setActionBendableHardConstraintMatches(hardConstraints); ArrayList<ActionBendableSoftConstraintMatch> softConstraints = new ArrayList<>(scoreLevelsWrapper.getSoftScoreLevels()); for (int i = 0; i < scoreLevelsWrapper.getSoftScoreLevels(); i++) { softConstraints.add(new ActionBendableSoftConstraintMatch(i, null)); } constraintMatch.setActionBendableSoftConstraintMatches(softConstraints); } }); } @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 initBendableScoreLevels() { ScoreInformation scoreInformation = new ScoreInformation(Arrays.asList(HardSoftScoreHolder.class.getName()), Arrays.asList(new BendableScoreLevelsWrapper(1, 2))); Map<String, Object> serviceCache = new HashMap<>(); serviceCache.put(ActionPluginClientService.SCORE_INFORMATION, scoreInformation); RuleModeller ruleModeller = mock(RuleModeller.class); when(ruleModeller.getServiceInvocationCache()).thenReturn(serviceCache); AbstractActionMultiConstraintBendableMatch constraintMatch = new ActionMultiConstraintBendableMatch(); service.initBendableScoreLevels(ruleModeller, constraintMatch); Assert.assertEquals(1, constraintMatch.getActionBendableHardConstraintMatches().size()); Assert.assertEquals(2, constraintMatch.getActionBendableSoftConstraintMatches().size()); }