GuidedRuleEditorServiceImpl extends KieService<GuidedEditorContent> implements GuidedRuleEditorService { @Override protected GuidedEditorContent constructContent(Path path, Overview overview) { final RuleModel model = load(path); final PackageDataModelOracle oracle = dataModelService.getDataModel(path); final PackageDataModelOracleBaselinePayload dataModel = new PackageDataModelOracleBaselinePayload(); final GuidedRuleModelVisitor visitor = new GuidedRuleModelVisitor(model); final Set<String> consumedFQCNs = visitor.getConsumedModelClasses(); consumedFQCNs.addAll(oracle.getPackageGlobals().values()); consumedFQCNs.addAll(oracle.getModuleCollectionTypes() .entrySet() .stream() .filter(entry -> entry.getValue()) .map(entry -> entry.getKey()) .collect(Collectors.toSet())); DataModelOracleUtilities.populateDataModel(oracle, dataModel, consumedFQCNs); resourceOpenedEvent.fire(new ResourceOpenedEvent(path, safeSessionInfo)); return new GuidedEditorContent(model, overview, dataModel); } GuidedRuleEditorServiceImpl(); @Inject  GuidedRuleEditorServiceImpl(final SessionInfo sessionInfo,
                                       final Instance<RuleModelIActionPersistenceExtension> persistenceExtensionInstance); @PostConstruct void init(); @Override Path create(final Path context,
                       final String fileName,
                       final RuleModel model,
                       final String comment); @Override RuleModel load(final Path path); @Override GuidedEditorContent loadContent(final Path path); @Override Path save(final Path resource,
                     final RuleModel model,
                     final Metadata metadata,
                     final String comment); @Override void delete(final Path path,
                       final String comment); @Override Path rename(final Path path,
                       final String newName,
                       final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final String comment); @Override Path copy(final Path path,
                     final String newName,
                     final Path targetDirectory,
                     final String comment); @Override String toSource(final Path path,
                           final RuleModel model); @Override List<ValidationMessage> validate(final Path path,
                                            final RuleModel content); @Override Path saveAndRename(final Path path,
                              final String newFileName,
                              final Metadata metadata,
                              final RuleModel content,
                              final String comment);  }
@Test public void checkConstructContentPopulateProjectCollectionTypesAndDSLSentences() throws Exception { final Path path = mock(Path.class); final Overview overview = mock(Overview.class); final ModuleDataModelOracle projectDataModelOracle = ModuleDataModelOracleBuilder.newModuleOracleBuilder(new RawMVELEvaluator()) .addClass(List.class) .addClass(Set.class) .addClass(Collection.class) .addClass(Integer.class) .build(); final PackageDataModelOracle oracle = PackageDataModelOracleBuilder.newPackageOracleBuilder(new RawMVELEvaluator()) .setModuleOracle(projectDataModelOracle) .addExtension(DSLActionSentence.INSTANCE, Collections.singletonList(dslSentence)) .addExtension(DSLConditionSentence.INSTANCE, Collections.singletonList(dslSentence)) .build(); when(path.toURI()).thenReturn("file: when(dataModelService.getDataModel(any())).thenReturn(oracle); final GuidedEditorContent content = service.constructContent(path, overview); assertEquals(3, content.getDataModel().getCollectionTypes().size()); assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Collection")); assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.List")); assertTrue(content.getDataModel().getCollectionTypes().containsKey("java.util.Set")); assertTrue(content.getDataModel().getPackageElements(DSLActionSentence.INSTANCE).contains(dslSentence)); assertTrue(content.getDataModel().getPackageElements(DSLConditionSentence.INSTANCE).contains(dslSentence)); }