@Test public void testImportGeneration() { final InputStream is = this.getClass().getResourceAsStream("GUVNOR-2478.xls"); when(ioService.newInputStream(any(org.uberfire.java.nio.file.Path.class))).thenReturn(is); final ConversionResult result = converter.convert(path); assertNotNull(result); final ArgumentCaptor<Path> projectImportsPathArgumentCaptor = ArgumentCaptor.forClass(Path.class); final ArgumentCaptor<ProjectImports> projectImportsArgumentCaptor = ArgumentCaptor.forClass(ProjectImports.class); verify(importsService, times(1)).save(projectImportsPathArgumentCaptor.capture(), projectImportsArgumentCaptor.capture(), any(Metadata.class), any(String.class)); assertNotNull(projectImportsPathArgumentCaptor.getValue()); final Path actualProjectImportsPath = projectImportsPathArgumentCaptor.getValue(); assertEquals(expectedProjectImportsPath.toURI(), actualProjectImportsPath.toURI()); assertNotNull(projectImportsArgumentCaptor.getValue()); final ProjectImports projectImports = projectImportsArgumentCaptor.getValue(); assertEquals(1, projectImports.getImports().getImports().size()); assertEquals("java.util.List", projectImports.getImports().getImports().get(0).getType()); verify(guidedDecisionTableService, times(1)).create(any(Path.class), any(String.class), any(GuidedDecisionTable52.class), any(String.class)); }
@Override public ConversionResult convert(final Path path) { ConversionResult result = new ConversionResult(); if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) { result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel(path); final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo); final Path context = Paths.convert(Paths.convert(path).getParent()); createNewImports(context, listener.getImports(), result); createNewFunctions(context, listener.getImports(), listener.getFunctions(), result); createNewQueries(context, listener.getImports(), listener.getQueries(), result); makeNewJavaTypes(context, listener.getTypeDeclarations(), result); createNewGlobals(context, listener.getImports(), listener.getGlobals(), result); createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result); return result; }
DecisionTableXLSToDecisionTableGuidedConverter implements DecisionTableXLSConversionService { @Override public ConversionResult convert(final Path path) { ConversionResult result = new ConversionResult(); if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) { result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel(path); final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo); final Path context = Paths.convert(Paths.convert(path).getParent()); createNewImports(context, listener.getImports(), result); createNewFunctions(context, listener.getImports(), listener.getFunctions(), result); createNewQueries(context, listener.getImports(), listener.getQueries(), result); makeNewJavaTypes(context, listener.getTypeDeclarations(), result); createNewGlobals(context, listener.getImports(), listener.getGlobals(), result); createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result); return result; } }
DecisionTableXLSToDecisionTableGuidedConverter implements DecisionTableXLSConversionService { @Override public ConversionResult convert(final Path path) { ConversionResult result = new ConversionResult(); if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) { result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel(path); final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo); final Path context = Paths.convert(Paths.convert(path).getParent()); createNewImports(context, listener.getImports(), result); createNewFunctions(context, listener.getImports(), listener.getFunctions(), result); createNewQueries(context, listener.getImports(), listener.getQueries(), result); makeNewJavaTypes(context, listener.getTypeDeclarations(), result); createNewGlobals(context, listener.getImports(), listener.getGlobals(), result); createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result); return result; } DecisionTableXLSToDecisionTableGuidedConverter(); @Inject  DecisionTableXLSToDecisionTableGuidedConverter(final @Named("ioStrategy") IOService ioService,
                                                          final DRLTextEditorService drlService,
                                                          final GuidedDecisionTableEditorService guidedDecisionTableService,
                                                          final GlobalsEditorService globalsService,
                                                          final KieModuleService moduleService,
                                                          final ProjectImportsService importsService,
                                                          final MetadataService metadataService,
                                                          final DataModelerService modellerService,
                                                          final DataModelService dataModelService,
                                                          final AppConfigService appConfigService,
                                                          final DecisionTableXLSResourceTypeDefinition xlsDTableType,
                                                          final DecisionTableXLSXResourceTypeDefinition xlsxDTableType,
                                                          final GuidedDTableResourceTypeDefinition guidedDTableType,
                                                          final DRLResourceTypeDefinition drlType,
                                                          final GlobalResourceTypeDefinition globalsType); }
DecisionTableXLSToDecisionTableGuidedConverter implements DecisionTableXLSConversionService { @Override public ConversionResult convert(final Path path) { ConversionResult result = new ConversionResult(); if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) { result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel(path); final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo); final Path context = Paths.convert(Paths.convert(path).getParent()); createNewImports(context, listener.getImports(), result); createNewFunctions(context, listener.getImports(), listener.getFunctions(), result); createNewQueries(context, listener.getImports(), listener.getQueries(), result); makeNewJavaTypes(context, listener.getTypeDeclarations(), result); createNewGlobals(context, listener.getImports(), listener.getGlobals(), result); createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result); return result; } DecisionTableXLSToDecisionTableGuidedConverter(); @Inject  DecisionTableXLSToDecisionTableGuidedConverter(final @Named("ioStrategy") IOService ioService,
                                                          final DRLTextEditorService drlService,
                                                          final GuidedDecisionTableEditorService guidedDecisionTableService,
                                                          final GlobalsEditorService globalsService,
                                                          final KieModuleService moduleService,
                                                          final ProjectImportsService importsService,
                                                          final MetadataService metadataService,
                                                          final DataModelerService modellerService,
                                                          final DataModelService dataModelService,
                                                          final AppConfigService appConfigService,
                                                          final DecisionTableXLSResourceTypeDefinition xlsDTableType,
                                                          final DecisionTableXLSXResourceTypeDefinition xlsxDTableType,
                                                          final GuidedDTableResourceTypeDefinition guidedDTableType,
                                                          final DRLResourceTypeDefinition drlType,
                                                          final GlobalResourceTypeDefinition globalsType); @PostConstruct void setup(); @Override ConversionResult convert(final Path path); }
DecisionTableXLSToDecisionTableGuidedConverter implements DecisionTableXLSConversionService { @Override public ConversionResult convert(final Path path) { ConversionResult result = new ConversionResult(); if (!(xlsDTableType.accept(path) || xlsxDTableType.accept(path))) { result.addMessage("Source Asset must be either a XLS or XLSX Decision Table file.", ConversionMessageType.ERROR); return result; } final PackageDataModelOracle dmo = dataModelService.getDataModel(path); final GuidedDecisionTableGeneratorListener listener = parseAssets(path, result, dmo); final Path context = Paths.convert(Paths.convert(path).getParent()); createNewImports(context, listener.getImports(), result); createNewFunctions(context, listener.getImports(), listener.getFunctions(), result); createNewQueries(context, listener.getImports(), listener.getQueries(), result); makeNewJavaTypes(context, listener.getTypeDeclarations(), result); createNewGlobals(context, listener.getImports(), listener.getGlobals(), result); createNewDecisionTables(context, listener.getImports(), listener.getGuidedDecisionTables(), result); return result; } DecisionTableXLSToDecisionTableGuidedConverter(); @Inject  DecisionTableXLSToDecisionTableGuidedConverter(final @Named("ioStrategy") IOService ioService,
                                                          final DRLTextEditorService drlService,
                                                          final GuidedDecisionTableEditorService guidedDecisionTableService,
                                                          final GlobalsEditorService globalsService,
                                                          final KieModuleService moduleService,
                                                          final ProjectImportsService importsService,
                                                          final MetadataService metadataService,
                                                          final DataModelerService modellerService,
                                                          final DataModelService dataModelService,
                                                          final AppConfigService appConfigService,
                                                          final DecisionTableXLSResourceTypeDefinition xlsDTableType,
                                                          final DecisionTableXLSXResourceTypeDefinition xlsxDTableType,
                                                          final GuidedDTableResourceTypeDefinition guidedDTableType,
                                                          final DRLResourceTypeDefinition drlType,
                                                          final GlobalResourceTypeDefinition globalsType); @PostConstruct void setup(); @Override ConversionResult convert(final Path path);  }