JIRAs created:-

https://issues.jboss.org/browse/JBRULES-3417

https://issues.jboss.org/browse/JBRULES-3418

Unit tests added to 5.3.x branch (@Ignore'd failing) and master (not @Ignore'd and passing).

Thanks,

Mike

---------- Forwarded message ----------
From: Michael Anstis <michael.anstis@gmail.com>
Date: 27 February 2012 13:00
Subject: Re: 5.3.x regression in TypeDeclarationDescr
To: drools-dev <rules-dev@lists.jboss.org>


This now manifests itself as:-
With kind regards,

Mike

On 17 February 2012 13:30, Michael Anstis <michael.anstis@gmail.com> wrote:
Hi,

There appears to be a regression in TypeDeclarationDescr in 5.3.x branch, as illustrated by the below.

Bean2 is shown as having a super-type of "Object" whereas it should be "Bean1". The fields are correctly listed.

This is causing tests in Guvnor to fail.

Could somebody please take a look?

Thanks,

Mike

package org.drools.ide.common.server.rules;

import java.io.StringReader;
import java.util.List;

import org.drools.compiler.DrlParser;
import org.drools.compiler.DroolsError;
import org.drools.compiler.PackageBuilder;
import org.drools.definition.type.FactField;
import org.drools.lang.descr.PackageDescr;
import org.drools.lang.descr.TypeDeclarationDescr;
import org.junit.Test;

public class RegressionTest {

    @Test
    public void regression() {
        String drl = "package foo \n"
                     + "declare Bean1 \n"
                     + "age: int \n"
                     + "name : String \n"
                     + "end \n"
                     + "declare Bean2 extends Bean1\n"
                     + "cheese : String \n"
                     + "end";

        PackageBuilder builder = new PackageBuilder();
        try {
            DrlParser parser = new DrlParser();
            PackageDescr pkgDescr = parser.parse( drl );
            for ( TypeDeclarationDescr baseType : pkgDescr.getTypeDeclarations() ) {
                String declaredSuperTypeName = baseType.getSuperTypeName();
                System.out.println( baseType.getTypeName() + " extends " + declaredSuperTypeName );
            }

            builder.addPackageFromDrl( new StringReader( drl ) );

            System.out.println("foo.Bean1 fields=");
            List<FactField> fieldsBean1 = builder.getPackage().getFactType( "foo.Bean1" ).getFields();
            for ( FactField field : fieldsBean1 ) {
                System.out.println( field.getName() );
            }

            System.out.println("foo.Bean2 fields=");
            List<FactField> fieldsBean2 = builder.getPackage().getFactType( "foo.Bean2" ).getFields();
            for ( FactField field : fieldsBean2 ) {
                System.out.println( field.getName() );
            }

            if ( builder.hasErrors() ) {
                for ( DroolsError e : builder.getErrors().getErrors() ) {
                    System.out.println( e.getMessage() );
                }
            }
        } catch ( Exception e ) {
            e.printStackTrace();
        }

    }

}