Package org.drools.workbench.models.guided.dtable.shared.model

Examples of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52


        return xt.toXML( dt );
    }

    public GuidedDecisionTable52 unmarshal( String xml ) {
        if ( xml == null || xml.trim().equals( "" ) ) {
            return new GuidedDecisionTable52();
        }

        //Upgrade DTModel to new class
        Object model = xt.fromXML( xml );
        GuidedDecisionTable52 newDTModel;
        if ( model instanceof GuidedDecisionTable ) {
            GuidedDecisionTable legacyDTModel = (GuidedDecisionTable) model;
            newDTModel = upgrader1.upgrade( legacyDTModel );
        } else {
            newDTModel = (GuidedDecisionTable52) model;
View Full Code Here


    @Test
    public void testIndexGuidedDecisionTableAttributes() throws IOException, InterruptedException {
        //Add test files
        final Path path = basePath.resolve( "dtable1.gdst" );
        final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithAttributeCol( "org.drools.workbench.screens.guided.dtable.backend.server.indexing",
                                                                                                  new ArrayList<Import>() {{
                                                                                                      add( new Import( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant" ) );
                                                                                                  }},
                                                                                                  "dtable1" );
        final String xml = GuidedDTXMLPersistence.getInstance().marshal( model );
View Full Code Here

    @Test
    public void testIndexGuidedDecisionTableConditions() throws IOException, InterruptedException {
        //Add test files
        final Path path = basePath.resolve( "dtable1.gdst" );
        final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithConditionCol( "org.drools.workbench.screens.guided.dtable.backend.server.indexing",
                                                                                                  new ArrayList<Import>() {{
                                                                                                      add( new Import( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant" ) );
                                                                                                      add( new Import( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage" ) );
                                                                                                  }},
                                                                                                  "dtable1" );
View Full Code Here

    @Test
    public void testIndexGuidedDecisionTableBRLFragmentConditions() throws IOException, InterruptedException {
        //Add test files
        final Path path = basePath.resolve( "dtable1.gdst" );
        final GuidedDecisionTable52 model = GuidedDecisionTableFactory.makeTableWithBRLFragmentConditionCol( "org.drools.workbench.screens.guided.dtable.backend.server.indexing",
                                                                                                             new ArrayList<Import>() {{
                                                                                                                 add( new Import( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Applicant" ) );
                                                                                                                 add( new Import( "org.drools.workbench.screens.guided.dtable.backend.server.indexing.classes.Mortgage" ) );
                                                                                                             }},
                                                                                                             "dtable1" );
View Full Code Here

        String content = jcrAssetItem.getContent();
       
        content = content.replaceAll( "org.drools.guvnor.client.modeldriven.dt52.Pattern52",
                                      "Pattern52" );

        GuidedDecisionTable52 model = GuidedDTXMLPersistence.getInstance().unmarshal( content );

        //Add package
        final Package pkg = projectService.resolvePackage( path );
        String pkName =pkg.getPackageName();
        try{
            if(pkName!=null && pkg.getPackageName().endsWith(path.getFileName())){
                pkName = pkg.getPackageName().substring(0,pkg.getPackageName().indexOf(path.getFileName())-1);
            }
        }catch (Exception e){

        }
        final String requiredPackageName = pkName;
        if ( requiredPackageName != null && !"".equals( requiredPackageName ) ) {
            model.setPackageName( requiredPackageName );
        }
        model.setParentName(getExtendedRuleFromCategoryRules(jcrModule,jcrAssetItem,""));

        //Add import
        if ( packageHeaderInfo.getHeader() != null ) {
            final Imports imports = ImportsParser.parseImports( packageHeaderInfo.getHeader() );
            if ( imports != null ) {
                model.setImports( imports );
            }
        }

        String sourceContent = GuidedDTXMLPersistence.getInstance().marshal( model );
       
View Full Code Here

        assertNotNull( dtables );
        assertEquals( 1,
                      dtables.size() );

        GuidedDecisionTable52 dtable = dtables.get( 0 );

        assertEquals( "ActionsTest",
                      dtable.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable.getTableFormat() );

        //Check expanded columns
        List<BaseColumn> columns = dtable.getExpandedColumns();
        assertNotNull( columns );
        assertEquals( 8,
                      columns.size() );
        assertTrue( columns.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns.get( 2 ) instanceof BRLActionVariableColumn );
        assertTrue( columns.get( 3 ) instanceof BRLActionVariableColumn );
        assertTrue( columns.get( 4 ) instanceof BRLActionVariableColumn );
        assertTrue( columns.get( 5 ) instanceof BRLActionVariableColumn );
        assertTrue( columns.get( 6 ) instanceof BRLActionVariableColumn );
        assertTrue( columns.get( 7 ) instanceof AnalysisCol52 );

        //Check individual action columns
        assertEquals( 4,
                      dtable.getActionCols().size() );
        assertTrue( dtable.getActionCols().get( 0 ) instanceof BRLActionColumn );
        assertTrue( dtable.getActionCols().get( 1 ) instanceof BRLActionColumn );
        assertTrue( dtable.getActionCols().get( 2 ) instanceof BRLActionColumn );
        assertTrue( dtable.getActionCols().get( 3 ) instanceof BRLActionColumn );

        //Column 1
        BRLActionColumn actionCol0 = ( (BRLActionColumn) dtable.getActionCols().get( 0 ) );
        assertEquals( "Multi-parameters",
                      actionCol0.getHeader() );
        assertEquals( 2,
                      actionCol0.getChildColumns().size() );

        List<IAction> actionCol0definition = actionCol0.getDefinition();
        assertEquals( 1,
                      actionCol0definition.size() );
        assertTrue( actionCol0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine actionCol0ffl = (FreeFormLine) actionCol0definition.get( 0 );
        assertEquals( "policy.setBasePrice(@{param1}, @{param2});",
                      actionCol0ffl.getText() );

        //Column 1 - Variable 1
        BRLActionVariableColumn actionCol0param0 = actionCol0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      actionCol0param0.getVarName() );
        assertEquals( "Multi-parameters",
                      actionCol0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      actionCol0param0.getFieldType() );
        assertNull( actionCol0param0.getFactType() );
        assertNull( actionCol0param0.getFactField() );

        //Column 1 - Variable 2
        BRLActionVariableColumn actionCol0param1 = actionCol0.getChildColumns().get( 1 );
        assertEquals( "param2",
                      actionCol0param1.getVarName() );
        assertEquals( "Multi-parameters",
                      actionCol0param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      actionCol0param1.getFieldType() );
        assertNull( actionCol0param1.getFactType() );
        assertNull( actionCol0param1.getFactField() );

        //Column 2
        BRLActionColumn actionCol1 = ( (BRLActionColumn) dtable.getActionCols().get( 1 ) );
        assertEquals( "Single-parameter",
                      actionCol1.getHeader() );
        assertEquals( 1,
                      actionCol1.getChildColumns().size() );

        List<IAction> actionCol1definition = actionCol1.getDefinition();
        assertEquals( 1,
                      actionCol1definition.size() );
        assertTrue( actionCol1definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine actionCol1ffl = (FreeFormLine) actionCol1definition.get( 0 );
        assertEquals( "policy.setSmurf(@{param3});",
                      actionCol1ffl.getText() );

        //Column 2 - Variable 1
        BRLActionVariableColumn actionCol1param0 = actionCol1.getChildColumns().get( 0 );
        assertEquals( "param3",
                      actionCol1param0.getVarName() );
        assertEquals( "Single-parameter",
                      actionCol1param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      actionCol1param0.getFieldType() );
        assertNull( actionCol1param0.getFactType() );
        assertNull( actionCol1param0.getFactField() );

        //Column 3
        BRLActionColumn actionCol2 = ( (BRLActionColumn) dtable.getActionCols().get( 2 ) );
        assertEquals( "Log-single-parameter",
                      actionCol2.getHeader() );
        assertEquals( 1,
                      actionCol2.getChildColumns().size() );

        List<IAction> actionCol2definition = actionCol2.getDefinition();
        assertEquals( 1,
                      actionCol2definition.size() );
        assertTrue( actionCol2definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine actionCol2ffl = (FreeFormLine) actionCol2definition.get( 0 );
        assertEquals( "System.out.println(\"@{param4}\");",
                      actionCol2ffl.getText() );

        //Column 3 - Variable 1
        BRLActionVariableColumn actionCol2param0 = actionCol2.getChildColumns().get( 0 );
        assertEquals( "param4",
                      actionCol2param0.getVarName() );
        assertEquals( "Log-single-parameter",
                      actionCol2param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      actionCol2param0.getFieldType() );
        assertNull( actionCol2param0.getFactType() );
        assertNull( actionCol2param0.getFactField() );

        //Column 4
        BRLActionColumn actionCol3 = ( (BRLActionColumn) dtable.getActionCols().get( 3 ) );
        assertEquals( "Zero-parameters",
                      actionCol3.getHeader() );
        assertEquals( 1,
                      actionCol3.getChildColumns().size() );

        List<IAction> actionCol3definition = actionCol3.getDefinition();
        assertEquals( 1,
                      actionCol3definition.size() );
        assertTrue( actionCol3definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine actionCol3ffl = (FreeFormLine) actionCol3definition.get( 0 );
        assertEquals( "System.out.println(\"Woot\");",
                      actionCol3ffl.getText() );

        //Column 3 - Variable 1
        BRLActionVariableColumn actionCol3param0 = actionCol3.getChildColumns().get( 0 );
        assertEquals( "",
                      actionCol3param0.getVarName() );
        assertEquals( "Zero-parameters",
                      actionCol3param0.getHeader() );
        assertEquals( DataType.TYPE_BOOLEAN,
                      actionCol3param0.getFieldType() );
        assertNull( actionCol3param0.getFactType() );
        assertNull( actionCol3param0.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 7", "10", "20", "30", "hello", "TRUE" },
                                     dtable.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 8", "50", "60", "70", "goodbye", "FALSE" },
                                     dtable.getData().get( 1 ) ) );
    }
View Full Code Here

        assertNotNull( dtables );
        assertEquals( 1,
                      dtables.size() );

        GuidedDecisionTable52 dtable = dtables.get( 0 );

        assertEquals( "ConditionsTest",
                      dtable.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable.getTableFormat() );

        //Check expanded columns
        List<BaseColumn> columns = dtable.getExpandedColumns();
        assertNotNull( columns );
        assertEquals( 8,
                      columns.size() );
        assertTrue( columns.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns.get( 2 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 3 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 4 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 5 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 6 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 7 ) instanceof AnalysisCol52 );

        //Check individual condition columns
        assertEquals( 2,
                      dtable.getConditions().size() );
        assertTrue( dtable.getConditions().get( 0 ) instanceof BRLConditionColumn );
        assertTrue( dtable.getConditions().get( 1 ) instanceof BRLConditionColumn );

        //Column 1
        BRLConditionColumn conditionCol0 = ( (BRLConditionColumn) dtable.getConditions().get( 0 ) );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0.getHeader() );
        assertEquals( 3,
                      conditionCol0.getChildColumns().size() );

        List<IPattern> conditionCol0definition = conditionCol0.getDefinition();
        assertEquals( 1,
                      conditionCol0definition.size() );
        assertTrue( conditionCol0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol0ffl = (FreeFormLine) conditionCol0definition.get( 0 );
        assertEquals( "Driver(age > \"@{param1}\", firstName == \"@{param2}\", surname == \"@{param3}\")",
                      conditionCol0ffl.getText() );

        //Column 1 - Variable 1
        BRLConditionVariableColumn conditionCol0param0 = conditionCol0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      conditionCol0param0.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param0.getFieldType() );
        assertNull( conditionCol0param0.getFactType() );
        assertNull( conditionCol0param0.getFactField() );

        //Column 1 - Variable 2
        BRLConditionVariableColumn conditionCol0param1 = conditionCol0.getChildColumns().get( 1 );
        assertEquals( "param2",
                      conditionCol0param1.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param1.getFieldType() );
        assertNull( conditionCol0param1.getFactType() );
        assertNull( conditionCol0param1.getFactField() );

        //Column 1 - Variable 3
        BRLConditionVariableColumn conditionCol0param2 = conditionCol0.getChildColumns().get( 2 );
        assertEquals( "param3",
                      conditionCol0param2.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param2.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param2.getFieldType() );
        assertNull( conditionCol0param2.getFactType() );
        assertNull( conditionCol0param2.getFactField() );

        //Column 2
        BRLConditionColumn conditionCol1 = ( (BRLConditionColumn) dtable.getConditions().get( 1 ) );
        assertEquals( "something",
                      conditionCol1.getHeader() );
        assertEquals( 2,
                      conditionCol1.getChildColumns().size() );

        List<IPattern> conditionCol1definition = conditionCol1.getDefinition();
        assertEquals( 1,
                      conditionCol1definition.size() );
        assertTrue( conditionCol1definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol1ffl = (FreeFormLine) conditionCol1definition.get( 0 );
        assertEquals( "Vehicle(make == \"@{param4}\", model == \"@{param5}\")",
                      conditionCol1ffl.getText() );

        //Column 2 - Variable 1
        BRLConditionVariableColumn conditionCol1param0 = conditionCol1.getChildColumns().get( 0 );
        assertEquals( "param4",
                      conditionCol1param0.getVarName() );
        assertEquals( "something",
                      conditionCol1param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1param0.getFieldType() );
        assertNull( conditionCol1param0.getFactType() );
        assertNull( conditionCol1param0.getFactField() );

        //Column 2 - Variable 2
        BRLConditionVariableColumn conditionCol1param1 = conditionCol1.getChildColumns().get( 1 );
        assertEquals( "param5",
                      conditionCol1param1.getVarName() );
        assertEquals( "something",
                      conditionCol1param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1param1.getFieldType() );
        assertNull( conditionCol1param1.getFactType() );
        assertNull( conditionCol1param1.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 7", "20", "Mike", "Brown", "BMW", "M3" },
                                     dtable.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 8", "30", "Jason", "Grey", "Audi", "S4" },
                                     dtable.getData().get( 1 ) ) );
    }
View Full Code Here

        assertNotNull( dtables );
        assertEquals( 1,
                      dtables.size() );

        GuidedDecisionTable52 dtable = dtables.get( 0 );

        assertEquals( "ConditionsTest",
                      dtable.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable.getTableFormat() );

        //Check expanded columns
        List<BaseColumn> columns = dtable.getExpandedColumns();
        assertNotNull( columns );
        assertEquals( 8,
                      columns.size() );
        assertTrue( columns.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns.get( 2 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 3 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 4 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 5 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 6 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 7 ) instanceof AnalysisCol52 );

        //Check individual condition columns
        assertEquals( 2,
                      dtable.getConditions().size() );
        assertTrue( dtable.getConditions().get( 0 ) instanceof BRLConditionColumn );
        assertTrue( dtable.getConditions().get( 1 ) instanceof BRLConditionColumn );

        //Column 1
        BRLConditionColumn conditionCol0 = ( (BRLConditionColumn) dtable.getConditions().get( 0 ) );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0.getHeader() );
        assertEquals( 3,
                      conditionCol0.getChildColumns().size() );

        List<IPattern> conditionCol0definition = conditionCol0.getDefinition();
        assertEquals( 1,
                      conditionCol0definition.size() );
        assertTrue( conditionCol0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol0ffl = (FreeFormLine) conditionCol0definition.get( 0 );
        assertEquals( "Driver(age > \"@{param1}\", firstName == \"@{param2}\", surname == \"@{param3}\")",
                      conditionCol0ffl.getText() );

        //Column 1 - Variable 1
        BRLConditionVariableColumn conditionCol0param0 = conditionCol0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      conditionCol0param0.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param0.getFieldType() );
        assertNull( conditionCol0param0.getFactType() );
        assertNull( conditionCol0param0.getFactField() );

        //Column 1 - Variable 2
        BRLConditionVariableColumn conditionCol0param1 = conditionCol0.getChildColumns().get( 1 );
        assertEquals( "param2",
                      conditionCol0param1.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param1.getFieldType() );
        assertNull( conditionCol0param1.getFactType() );
        assertNull( conditionCol0param1.getFactField() );

        //Column 1 - Variable 3
        BRLConditionVariableColumn conditionCol0param2 = conditionCol0.getChildColumns().get( 2 );
        assertEquals( "param3",
                      conditionCol0param2.getVarName() );
        assertEquals( "Converted from cell [C4]",
                      conditionCol0param2.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param2.getFieldType() );
        assertNull( conditionCol0param2.getFactType() );
        assertNull( conditionCol0param2.getFactField() );

        //Column 2
        BRLConditionColumn conditionCol1 = ( (BRLConditionColumn) dtable.getConditions().get( 1 ) );
        assertEquals( "something",
                      conditionCol1.getHeader() );
        assertEquals( 2,
                      conditionCol1.getChildColumns().size() );

        List<IPattern> conditionCol1definition = conditionCol1.getDefinition();
        assertEquals( 1,
                      conditionCol1definition.size() );
        assertTrue( conditionCol1definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol1ffl = (FreeFormLine) conditionCol1definition.get( 0 );
        assertEquals( "Vehicle(make == \"@{param4}\", model == \"@{param5}\")",
                      conditionCol1ffl.getText() );

        //Column 2 - Variable 1
        BRLConditionVariableColumn conditionCol1param0 = conditionCol1.getChildColumns().get( 0 );
        assertEquals( "param4",
                      conditionCol1param0.getVarName() );
        assertEquals( "something",
                      conditionCol1param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1param0.getFieldType() );
        assertNull( conditionCol1param0.getFactType() );
        assertNull( conditionCol1param0.getFactField() );

        //Column 2 - Variable 2
        BRLConditionVariableColumn conditionCol1param1 = conditionCol1.getChildColumns().get( 1 );
        assertEquals( "param5",
                      conditionCol1param1.getVarName() );
        assertEquals( "something",
                      conditionCol1param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1param1.getFieldType() );
        assertNull( conditionCol1param1.getFactType() );
        assertNull( conditionCol1param1.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 7", "20", "Mike", "Brown", "BMW", "M3" },
                                     dtable.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 8", "30", "Jason", "Grey", "", "" },
                                     dtable.getData().get( 1 ) ) );
    }
View Full Code Here

        assertNotNull( dtables );
        assertEquals( 2,
                      dtables.size() );

        GuidedDecisionTable52 dtable0 = dtables.get( 0 );
        assertEquals( "Table1",
                      dtable0.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable0.getTableFormat() );

        GuidedDecisionTable52 dtable1 = dtables.get( 1 );
        assertEquals( "Table2",
                      dtable1.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable1.getTableFormat() );

        //Check expanded columns
        List<BaseColumn> columns0 = dtable0.getExpandedColumns();
        assertNotNull( columns0 );
        assertEquals( 6,
                      columns0.size() );
        assertTrue( columns0.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns0.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns0.get( 2 ) instanceof AttributeCol52 );
        assertTrue( columns0.get( 3 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns0.get( 4 ) instanceof BRLActionVariableColumn );
        assertTrue( columns0.get( 5 ) instanceof AnalysisCol52 );

        AttributeCol52 attrCol0_2 = ( (AttributeCol52) columns0.get( 2 ) );
        assertEquals( GuidedDecisionTable52.AGENDA_GROUP_ATTR,
                      attrCol0_2.getAttribute() );

        //Check individual condition columns
        assertEquals( 1,
                      dtable0.getConditions().size() );
        assertTrue( dtable0.getConditions().get( 0 ) instanceof BRLConditionColumn );

        //Column 1
        BRLConditionColumn conditionCol0_0 = ( (BRLConditionColumn) dtable0.getConditions().get( 0 ) );
        assertEquals( "Person's name",
                      conditionCol0_0.getHeader() );
        assertEquals( 1,
                      conditionCol0_0.getChildColumns().size() );

        List<IPattern> conditionCol0_0definition = conditionCol0_0.getDefinition();
        assertEquals( 1,
                      conditionCol0_0definition.size() );
        assertTrue( conditionCol0_0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol0_0ffl = (FreeFormLine) conditionCol0_0definition.get( 0 );
        assertEquals( "Person(name == \"@{param1}\")",
                      conditionCol0_0ffl.getText() );

        //Column 1 - Variable 1
        BRLConditionVariableColumn conditionCol0_0param0 = conditionCol0_0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      conditionCol0_0param0.getVarName() );
        assertEquals( "Person's name",
                      conditionCol0_0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0_0param0.getFieldType() );
        assertNull( conditionCol0_0param0.getFactType() );
        assertNull( conditionCol0_0param0.getFactField() );

        //Column 2
        BRLActionColumn actionCol0_0 = ( (BRLActionColumn) dtable0.getActionCols().get( 0 ) );
        assertEquals( "Salutation",
                      actionCol0_0.getHeader() );
        assertEquals( 1,
                      actionCol0_0.getChildColumns().size() );

        List<IAction> actionCol0_0definition = actionCol0_0.getDefinition();
        assertEquals( 1,
                      actionCol0_0definition.size() );
        assertTrue( actionCol0_0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine actionCol0_0ffl = (FreeFormLine) actionCol0_0definition.get( 0 );
        assertEquals( "System.out.println(\"@{param2}\");",
                      actionCol0_0ffl.getText() );

        //Column 1 - Variable 1
        BRLActionVariableColumn actionCol0_0param0 = actionCol0_0.getChildColumns().get( 0 );
        assertEquals( "param2",
                      actionCol0_0param0.getVarName() );
        assertEquals( "Salutation",
                      actionCol0_0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      actionCol0_0param0.getFieldType() );
        assertNull( actionCol0_0param0.getFactType() );
        assertNull( actionCol0_0param0.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable0.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 7", "AG1", "John", "Hello Sir" },
                                     dtable0.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 8", "AG2", "Jane", "Hello Madam" },
                                     dtable0.getData().get( 1 ) ) );

        //Check expanded columns
        List<BaseColumn> columns1 = dtable1.getExpandedColumns();
        assertNotNull( columns1 );
        assertEquals( 5,
                      columns1.size() );
        assertTrue( columns1.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns1.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns1.get( 2 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns1.get( 3 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns1.get( 4 ) instanceof AnalysisCol52 );

        //Check individual condition columns
        assertEquals( 1,
                      dtable0.getConditions().size() );
        assertTrue( dtable0.getConditions().get( 0 ) instanceof BRLConditionColumn );

        //Column 1
        BRLConditionColumn conditionCol1_0 = ( (BRLConditionColumn) dtable1.getConditions().get( 0 ) );
        assertEquals( "Converted from cell [C12]",
                      conditionCol1_0.getHeader() );
        assertEquals( 2,
                      conditionCol1_0.getChildColumns().size() );

        List<IPattern> conditionCol1_0definition = conditionCol1_0.getDefinition();
        assertEquals( 1,
                      conditionCol1_0definition.size() );
        assertTrue( conditionCol1_0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol1_0ffl = (FreeFormLine) conditionCol1_0definition.get( 0 );
        assertEquals( "Person(name == \"@{param1}\", age == \"@{param2}\")",
                      conditionCol1_0ffl.getText() );

        //Column 1 - Variable 1
        BRLConditionVariableColumn conditionCol1_0param0 = conditionCol1_0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      conditionCol1_0param0.getVarName() );
        assertEquals( "Converted from cell [C12]",
                      conditionCol1_0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1_0param0.getFieldType() );
        assertNull( conditionCol1_0param0.getFactType() );
        assertNull( conditionCol1_0param0.getFactField() );

        //Column 1 - Variable 2
        BRLConditionVariableColumn conditionCol1_0param1 = conditionCol1_0.getChildColumns().get( 1 );
        assertEquals( "param2",
                      conditionCol1_0param1.getVarName() );
        assertEquals( "Converted from cell [C12]",
                      conditionCol1_0param1.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol1_0param1.getFieldType() );
        assertNull( conditionCol1_0param1.getFactType() );
        assertNull( conditionCol1_0param1.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable1.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 15", "John", "25" },
                                     dtable1.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 16", "Jane", "29" },
                                     dtable1.getData().get( 1 ) ) );

    }
View Full Code Here

        assertNotNull( dtables );
        assertEquals( 1,
                      dtables.size() );

        GuidedDecisionTable52 dtable = dtables.get( 0 );

        assertEquals( "MultipleSingleParameters",
                      dtable.getTableName() );
        assertEquals( GuidedDecisionTable52.TableFormat.EXTENDED_ENTRY,
                      dtable.getTableFormat() );

        //Check expanded columns
        List<BaseColumn> columns = dtable.getExpandedColumns();
        assertNotNull( columns );
        assertEquals( 4,
                      columns.size() );
        assertTrue( columns.get( 0 ) instanceof RowNumberCol52 );
        assertTrue( columns.get( 1 ) instanceof DescriptionCol52 );
        assertTrue( columns.get( 2 ) instanceof BRLConditionVariableColumn );
        assertTrue( columns.get( 3 ) instanceof AnalysisCol52 );

        //Check individual condition columns
        assertEquals( 1,
                      dtable.getConditions().size() );
        assertTrue( dtable.getConditions().get( 0 ) instanceof BRLConditionColumn );

        //Column 1
        BRLConditionColumn conditionCol0 = ( (BRLConditionColumn) dtable.getConditions().get( 0 ) );
        assertEquals( "Re-using single parameter",
                      conditionCol0.getHeader() );
        assertEquals( 1,
                      conditionCol0.getChildColumns().size() );

        List<IPattern> conditionCol0definition = conditionCol0.getDefinition();
        assertEquals( 1,
                      conditionCol0definition.size() );
        assertTrue( conditionCol0definition.get( 0 ) instanceof FreeFormLine );

        FreeFormLine conditionCol0ffl = (FreeFormLine) conditionCol0definition.get( 0 );
        assertEquals( "Driver(@{param1} != null, @{param1} == true)",
                      conditionCol0ffl.getText() );

        //Column 1 - Variable 1
        BRLConditionVariableColumn conditionCol0param0 = conditionCol0.getChildColumns().get( 0 );
        assertEquals( "param1",
                      conditionCol0param0.getVarName() );
        assertEquals( "Re-using single parameter",
                      conditionCol0param0.getHeader() );
        assertEquals( DataType.TYPE_OBJECT,
                      conditionCol0param0.getFieldType() );
        assertNull( conditionCol0param0.getFactType() );
        assertNull( conditionCol0param0.getFactField() );

        //Check data
        assertEquals( 2,
                      dtable.getData().size() );
        assertTrue( isRowEquivalent( new String[]{ "1", "Created from row 7", "isQualified" },
                                     dtable.getData().get( 0 ) ) );
        assertTrue( isRowEquivalent( new String[]{ "2", "Created from row 8", "isLicensed" },
                                     dtable.getData().get( 1 ) ) );
    }
View Full Code Here

TOP

Related Classes of org.drools.workbench.models.guided.dtable.shared.model.GuidedDecisionTable52

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.