Package org.drools.ide.common.client.modeldriven.brl

Examples of org.drools.ide.common.client.modeldriven.brl.RuleModel


    private List<DroolsBuildMarker> parseBRLFile(final IFile file) {
      return parseResource(new ResourceParser() {
        public DRLInfo parseResource() throws DroolsParserException, CoreException, IOException {
                String brl = convertToString( file.getContents() );
                RuleModel model = BRXMLPersistence.getInstance().unmarshal( brl );
                String drl = BRDRLPersistence.getInstance().marshal( model );

                // TODO pass this through DSL converter in case brl is based on dsl

                return DroolsEclipsePlugin.getDefault().parseBRLResource( drl, file );
View Full Code Here


*/
public class RuleModelCloneVisitorTests {

    @Test
    public void testRuleModel() {
        RuleModel model = new RuleModel();
        model.modelVersion = "1";
        model.name = "ruleModelName";
        model.parentName = "ruleModelParentName";

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertNotSame( model,
                       clone );

        assertEquals( "1",
View Full Code Here

    }

    @Test
    public void testRuleAttributes() {

        RuleModel model = new RuleModel();
        model.attributes = new RuleAttribute[2];
        model.attributes[0] = new RuleAttribute( "attr0",
                                                 "attr0Value" );
        model.attributes[1] = new RuleAttribute( "attr1",
                                                 "attr1Value" );

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.attributes.length );

        assertNotSame( model.attributes[0],
View Full Code Here

    }

    @Test
    public void testRuleMetadata() {

        RuleModel model = new RuleModel();
        model.metadataList = new RuleMetadata[2];
        model.metadataList[0] = new RuleMetadata( "md0",
                                                  "md0Value" );
        model.metadataList[1] = new RuleMetadata( "md1",
                                                  "md1Value" );

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.metadataList.length );

        assertNotSame( model.metadataList[0],
View Full Code Here

                      clone.metadataList[1].value );
    }

    @Test
    public void testActionInsertFact() {
        RuleModel model = new RuleModel();

        model.rhs = new IAction[2];
        ActionInsertFact aif0 = new ActionInsertFact( "AIF0" );
        aif0.setBoundName( "$t0" );
        ActionFieldValue aif0f0 = new ActionFieldValue( "AIF0F0",
                                                        "AIF0F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        aif0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        aif0.addFieldValue( aif0f0 );
        ActionFieldValue aif0f1 = new ActionFieldValue( "AIF0F1",
                                                        "AIF0F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        aif0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        aif0.addFieldValue( aif0f1 );
        model.rhs[0] = aif0;

        ActionInsertFact aif1 = new ActionInsertFact( "AIF1" );
        aif1.setBoundName( "$t1" );
        ActionFieldValue aif1f0 = new ActionFieldValue( "AIF1F0",
                                                        "AIF1F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        aif1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        aif1.addFieldValue( aif1f0 );
        ActionFieldValue aif1f1 = new ActionFieldValue( "AIF1F1",
                                                        "AIF1F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        aif1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        aif1.addFieldValue( aif1f1 );
        model.rhs[1] = aif1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.rhs.length );

        assertNotSame( model.rhs[0],
View Full Code Here

                      aif1f1Clone.value );
    }

    @Test
    public void testActionSetField() {
        RuleModel model = new RuleModel();

        model.rhs = new IAction[2];
        ActionSetField asf0 = new ActionSetField( "ASF0" );
        asf0.variable = "$t0";
        ActionFieldValue asf0f0 = new ActionFieldValue( "ASF0F0",
                                                        "ASF0F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf0.addFieldValue( asf0f0 );
        ActionFieldValue asf0f1 = new ActionFieldValue( "ASF0F1",
                                                        "ASF0F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf0.addFieldValue( asf0f1 );
        model.rhs[0] = asf0;

        ActionSetField asf1 = new ActionSetField( "ASF1" );
        asf1.variable = "$t1";
        ActionFieldValue asf1f0 = new ActionFieldValue( "ASF1F0",
                                                        "ASF1F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf1.addFieldValue( asf1f0 );
        ActionFieldValue asf1f1 = new ActionFieldValue( "ASF1F1",
                                                        "ASF1F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        asf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        asf1.addFieldValue( asf1f1 );
        model.rhs[1] = asf1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.rhs.length );

        assertNotSame( model.rhs[0],
View Full Code Here

                      asf1f1Clone.value );
    }

    @Test
    public void testActionUpdateField() {
        RuleModel model = new RuleModel();

        model.rhs = new IAction[2];
        ActionUpdateField auf0 = new ActionUpdateField();
        auf0.variable = "$t0";
        ActionFieldValue auf0f0 = new ActionFieldValue( "AUF0F0",
                                                        "AUF0F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf0.addFieldValue( auf0f0 );
        ActionFieldValue auf0f1 = new ActionFieldValue( "AUF0F1",
                                                        "AUF0F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf0f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf0.addFieldValue( auf0f1 );
        model.rhs[0] = auf0;

        ActionUpdateField auf1 = new ActionUpdateField();
        auf1.variable = "$t1";
        ActionFieldValue auf1f0 = new ActionFieldValue( "AUF1F0",
                                                        "AUF1F0Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf1f0.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf1.addFieldValue( auf1f0 );
        ActionFieldValue auf1f1 = new ActionFieldValue( "AUF1F1",
                                                        "AUF1F1Value",
                                                        SuggestionCompletionEngine.TYPE_STRING );
        auf1f1.setNature( BaseSingleFieldConstraint.TYPE_LITERAL );
        auf1.addFieldValue( auf1f1 );
        model.rhs[1] = auf1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.rhs.length );

        assertNotSame( model.rhs[0],
View Full Code Here

                      auf1f1Clone.value );
    }

    @Test
    public void testActionRetractFact() {
        RuleModel model = new RuleModel();

        model.rhs = new IAction[1];
        ActionRetractFact arf = new ActionRetractFact();
        arf.variableName = "$arf";
        model.rhs[0] = arf;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.rhs.length );

        assertNotSame( model.rhs[0],
View Full Code Here

                      arfClone.variableName );
    }

    @Test
    public void testDSLSentence() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[2];
        DSLSentence dsl0 = new DSLSentence();
        dsl0.setDefinition( "DSL Sentence 0" );
        dsl0.getValues().add( new DSLVariableValue( "dsl0v0" ) );
        dsl0.getValues().add( new DSLVariableValue( "dsl0v1" ) );
        model.lhs[0] = dsl0;
        DSLSentence dsl1 = new DSLSentence();
        dsl1.setDefinition( "DSL Sentence 1" );
        dsl1.getValues().add( new DSLVariableValue( "dsl1v0" ) );
        dsl1.getValues().add( new DSLVariableValue( "dsl1v1" ) );
        model.lhs[1] = dsl1;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 2,
                      clone.lhs.length );

        assertNotSame( model.lhs[0],
View Full Code Here

                      dsl1v1Clone.getValue() );
    }

    @Test
    public void testFactPattern_Basics() {
        RuleModel model = new RuleModel();

        model.lhs = new IPattern[1];
        FactPattern fp0 = new FactPattern();
        fp0.setBoundName( "$t0" );
        fp0.setFactType( "FT0" );
        fp0.setNegated( true );
        model.lhs[0] = fp0;

        RuleModelCloneVisitor cloneVisitor = new RuleModelCloneVisitor();
        RuleModel clone = cloneVisitor.visitRuleModel( model );

        assertEquals( 1,
                      clone.lhs.length );
        assertNotSame( model.lhs[0],
                       clone.lhs[0] );
View Full Code Here

TOP

Related Classes of org.drools.ide.common.client.modeldriven.brl.RuleModel

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.