ScoreHolderServiceImpl implements ScoreHolderService { @Override public ScoreInformation getProjectScoreInformation(final Path projectPath) { List<Path> classUsages = assetsUsageService.getAssetUsages(PlanningSolution.class.getName(), ResourceType.JAVA, projectPath); return new ScoreInformation(extractProjectScoreTypeFqns(classUsages), getBendableScoreLevelsSize(classUsages)); } ScoreHolderServiceImpl(); @Inject  ScoreHolderServiceImpl(final KieModuleService kieModuleService,
                                  @Named("ioStrategy") final IOService ioService,
                                  final GlobalsEditorService globalsEditorService,
                                  final DataModelerService dataModelerService,
                                  final JavaResourceTypeDefinition javaResourceTypeDefinition,
                                  final AssetsUsageService assetsUsageService); @Override ScoreInformation getProjectScoreInformation(final Path projectPath); BendableScoreLevelsWrapper extractSolutionBendableScoreLevelsSize(final Path solutionPath);  }
@Test public void getProjectScoreInformation() { Path dataObjectPath = PathFactory.newPath("Test.java", "file: when(assetsUsageService.getAssetUsages(PlanningSolution.class.getName(), ResourceType.JAVA, dataObjectPath)).thenReturn(Arrays.asList(dataObjectPath)); when(javaResourceTypeDefinition.accept(dataObjectPath)).thenReturn(true); Package resourcesPackage = mock(Package.class); when(resourcesPackage.getPackageMainResourcesPath()).thenReturn(PathFactory.newPath("Test.java", "file: when(kieModuleService.resolvePackage(dataObjectPath)).thenReturn(resourcesPackage); when(ioService.exists(any(org.uberfire.java.nio.file.Path.class))).thenReturn(true); GlobalsModel globalsModel = new GlobalsModel(); globalsModel.setGlobals(Arrays.asList(new Global("scoreHolder", BendableScore.class.getName()))); when(globalsEditorService.load(any(Path.class))).thenReturn(globalsModel); when(ioService.readAllString(Paths.convert(dataObjectPath))).thenReturn("testContent"); GenerationResult generationResult = new GenerationResult(); generationResult.setDataObject(createPlanningSolution()); when(dataModelerService.loadDataObject(dataObjectPath, "testContent", dataObjectPath)).thenReturn(generationResult); ScoreInformation scoreInformation = scoreHolderService.getProjectScoreInformation(dataObjectPath); assertNotNull(scoreInformation); Collection<String> scoreHolderFqnTypeFqns = scoreInformation.getScoreHolderFqnTypeFqns(); assertNotNull(scoreHolderFqnTypeFqns); assertEquals(1, scoreHolderFqnTypeFqns.size()); assertEquals(BendableScore.class.getName(), scoreHolderFqnTypeFqns.iterator().next()); Collection<BendableScoreLevelsWrapper> bendableScoreLevelsWrappers = scoreInformation.getBendableScoreLevelsWrappers(); assertNotNull(bendableScoreLevelsWrappers); assertEquals(1, bendableScoreLevelsWrappers.size()); BendableScoreLevelsWrapper bendableScoreLevelsWrapper = bendableScoreLevelsWrappers.iterator().next(); assertEquals(1, bendableScoreLevelsWrapper.getHardScoreLevels()); assertEquals(2, bendableScoreLevelsWrapper.getSoftScoreLevels()); }