Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[kie-issues#653] Don't use System.out and logger debug mode in test output in traits #5565

Merged
merged 1 commit into from
Oct 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions drools-compiler/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@
<logger name="org.kie" level="warn"/>
<logger name="org.drools" level="warn"/>

<logger name="org.drools.core.management" level="debug"/>
<logger name="org.drools.core.management" level="info"/>
<!--<logger name="org.drools.ancompiler" level="debug"/>-->

<logger name="org.drools.metric.util.MetricLogUtils" level="trace"/>
<logger name="org.drools.metric.util.MetricLogUtils" level="info"/>

<root level="warn">
<appender-ref ref="consoleAppender" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
</appender>

<logger name="org.kie" level="warn"/>
<logger name="org.drools" level="debug"/>
<logger name="org.drools" level="info"/>

<root level="warn">
<appender-ref ref="consoleAppender"/>
Expand Down
2 changes: 1 addition & 1 deletion drools-mvel/src/test/resources/logback-test.xml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<logger name="org.kie" level="warn"/>
<logger name="org.drools" level="warn"/>

<logger name="org.drools.core.management" level="debug"/>
<logger name="org.drools.core.management" level="info"/>
<!--<logger name="org.drools.ancompiler" level="debug"/>-->

<root level="warn">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
<logger name="org.drools.compiler.kie.builder.impl" level="ERROR" />
<!-- <logger name="org.drools.ruleunits.impl" level="debug"/>-->
<!-- <logger name="org.drools.model.codegen.execmodel.generator.expressiontyper" level="debug"/>-->
<logger name="org.drools.model.codegen.execmodel" level="debug"/>
<logger name="org.drools.model.codegen.execmodel" level="info"/>

<logger name="org.drools" level="warn"/>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,7 @@ private boolean isAssertAllowed( InternalFactHandle factHandle ) {

boolean allowed = ! vetoed || sameAndNotCoveredByDescendants((TraitProxyImpl) factHandle.getObject(), typeMask );
if ( allowed ) {
//System.err.println(" INSERT PASS !! " + factHandle.getObject() + " " + ( (TraitProxy) factHandle.getObject() )._getTypeCode() + " >> " + vetoMask + " checks in " + typeMask );
proxy.assignOtn( this.typeMask );
} else {
//System.err.println(" INSERT BLOCK !! " + factHandle.getObject() + " " + ( (TraitProxy) factHandle.getObject() )._getTypeCode() + " >> " + vetoMask + " checks in " + typeMask );
}
return allowed;
}
Expand Down Expand Up @@ -134,8 +131,6 @@ public void modifyObject( InternalFactHandle factHandle,
modifyPreviousTuples,
context.adaptModificationMaskForObjectType(objectType, reteEvaluator),
reteEvaluator);
} else {
//System.err.println( ((ClassObjectType) this.getObjectType()).getClassName() + " : MODIFY BLOCK !! " + ( (TraitProxy) factHandle.getObject() ).getTraitName() + " " + ( (TraitProxy) factHandle.getObject() )._getTypeCode() + " >> " + " checks in " + typeMask );
}
} else {
this.sink.propagateModifyObject(factHandle,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ public List<H> getSortedMembers() {
public Collection<H> upperAncestors( BitSet key ) {
List<H> vals = new LinkedList<>();
int l = key.length();
//System.out.println( key );

BitSet start = new BitSet( l );
BitSet end = new BitSet( l );
Expand All @@ -150,13 +149,8 @@ public Collection<H> upperAncestors( BitSet key ) {
start.set( s, true );
end.set( s, t, true );

// System.out.println( "X >> " + s + " << " + t );
// System.out.println( "S >> " + start );
// System.out.println( "E >> " + end );
// System.out.println( "E+1>> " + nextKey( end ) );
if ( t > 0 ) {
for ( J val : line.subMap( start, nextKey( end ) ).values() ) {
// System.out.println( "\t " + val.getValue() );
vals.add( val.getValue() );
}
}
Expand Down Expand Up @@ -230,11 +224,9 @@ List<J> gcsBorderNodes( BitSet key, boolean includeEquals ) {
J ex = border.get( k );
if ( ex != null ) {
if ( superset( candidate, ex.getBitMask() ) >= 0 ) {
// System.out.println( "Skipping " + val + " due to " + ex );
minimal = false;
break;
} else if ( superset( ex.getBitMask(), candidate ) > 0 ) {
// System.out.println( "Clearing " + ex + " due to " + val );
border.set( k, null );
}

Expand Down Expand Up @@ -276,8 +268,6 @@ Collection<H> lcs( BitSet key, boolean includeEquals ) {
List<J> lcsBorderNodes( BitSet key, boolean includeEquals ) {
List<J> border = new ArrayList<>();
if ( key == null ) { return border; }
// System.out.println( key );

int l = key.length();
BitSet start = new BitSet( l + 1 );
BitSet end = new BitSet( l + 1 );
Expand Down Expand Up @@ -308,13 +298,11 @@ List<J> lcsBorderNodes( BitSet key, boolean includeEquals ) {

if ( ex != null ) {
if ( superset( candidate, ex.getBitMask() ) > 0 ) {
// System.out.println( "Clearing " + ex + " due to " + val );
border.set( j, null );
}
}
}
}
// System.out.println( "\t\t " + border );
}

index = key.nextSetBit( t );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ public void addMember( T val, BitSet key ) {
}
}
add( node );
// System.out.println( " Added inst node " + node );
// System.out.println( " \t parents " + parents( key ) );
// System.out.println( " \t children " + children( key ) );
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,6 @@ List<T> ancestorValues( T name ) {

protected void encode( HierNode<T> node ) {
Collection<HierNode<T>> parents = node.getParents();
//System.out.println( "Trying to encode " + node );
switch ( parents.size() ) {
case 0 :
BitSet zero = new BitSet();
Expand Down Expand Up @@ -143,7 +142,6 @@ protected void encode( HierNode<T> node ) {
break;
default:
inheritMerged( node );
//System.out.println( " ----------------------------------------------------------------------------------------- " );
resolveConflicts( node );
break;
}
Expand All @@ -155,21 +153,17 @@ protected void resolveConflicts( HierNode<T> x ) {
Collection<HierNode<T>> nodes = new ArrayList<>( getNodes() );
for ( HierNode<T> y : nodes ) {
if ( incomparable( x, y ) ) {
// System.out.println( " \t\tIncomparability between " + x + " and " + y );
int sup = superset( y, x );
if ( sup == 0 ) {
//System.out.println( " \t\tIncomparable, with same mask " + y );
// can't use update mask here, or the already existing node would be removed
x.setBitMask( increment( x.getBitMask(), freeBit( x ) ) );
propagate( y, freeBit( x, y ) );
}
if ( sup > 0 ) {
// System.out.println( " \t\tIncomparable, but as parent " + y );
updateMask( x, increment( x.getBitMask(), freeBit( x ) ) );
}
int sub = superset( x, y );
if ( sub > 0 ) {
// System.out.println( " \t\tIncomparable, but as child " + y );
modify( x, y );
conflicted = true;
}
Expand All @@ -184,12 +178,9 @@ protected void resolveConflicts( HierNode<T> x ) {
}

protected void modify( HierNode<T> x, HierNode<T> y ) {
//System.out.println( "Modifying on a inc between " + x + " and " + y );

int i = freeBit( x, y );
//System.out.println( "I " + i );

//System.out.println( "Getting parents of " + y + " >> " + y.getParents() );
Collection<HierNode<T>> py = y.getParents();
BitSet t = new BitSet( y.getBitMask().length() );
for ( HierNode<T> parent : py ) {
Expand All @@ -202,10 +193,6 @@ protected void modify( HierNode<T> x, HierNode<T> y ) {
if ( inDex < 0 ) {
propagate( y, i );
} else {

//System.out.println( "D " + toBinaryString( d ) );


Set<HierNode<T>> ancestors = ancestorNodes( x );
Set<HierNode<T>> affectedAncestors = new HashSet<>();

Expand All @@ -214,16 +201,11 @@ protected void modify( HierNode<T> x, HierNode<T> y ) {
affectedAncestors.add( anc );
}
}
//System.out.println( "Ancestors of " + x + " >> " + ancestors );
//System.out.println( "Affected " + x + " >> " + affectedAncestors );

if ( affectedAncestors.size() == 0 ) {
return;
}

Set<HierNode<T>> gcs = gcs( affectedAncestors );
//System.out.println( "GCS of Affected " + gcs );

Set<HierNode<T>> affectedDescendants = new HashSet<>();
for ( HierNode<T> g : gcs ) {
affectedDescendants.addAll( descendantNodes( g ) );
Expand Down Expand Up @@ -251,8 +233,6 @@ protected void modify( HierNode<T> x, HierNode<T> y ) {
subMask = increment( subMask, i );

updateMask( sub, subMask );

//System.out.println( "\tModified Desc" + sub );
}

inDex = d.nextSetBit( inDex + 1 );
Expand Down Expand Up @@ -286,7 +266,6 @@ protected Set<HierNode<T>> gcs( Set<HierNode<T>> set ) {
while ( iter.hasNext() ) {
a.and( iter.next().getBitMask() );
}
//System.out.println( "Root mask for ceil " + toBinaryString( a ) );
for ( HierNode<T> node : getNodes() ) {
if ( superset( node.getBitMask(), a ) >= 0 ) {
s.add( node );
Expand All @@ -298,7 +277,6 @@ protected Set<HierNode<T>> gcs( Set<HierNode<T>> set ) {
}

protected Set<HierNode<T>> ceil( Set<HierNode<T>> s ) {
//System.out.println( "Looking for the ceiling of " + s);
if ( s.size() <= 1 ) { return s; }
Set<HierNode<T>> ceil = new HashSet<>( s );
for ( HierNode<T> x : s ) {
Expand All @@ -309,12 +287,10 @@ protected Set<HierNode<T>> ceil( Set<HierNode<T>> s ) {
}
}
}
//System.out.println("Found ceiling " + ceil);
return ceil;
}

protected Set<HierNode<T>> floor( Set<HierNode<T>> s ) {
//System.out.println( "Looking for the floor of " + s);
if ( s.size() <= 1 ) { return s; }
Set<HierNode<T>> ceil = new HashSet<>( s );
for ( HierNode<T> x : s ) {
Expand All @@ -325,7 +301,6 @@ protected Set<HierNode<T>> floor( Set<HierNode<T>> s ) {
}
}
}
//System.out.println("Found ceiling " + ceil);
return ceil;
}

Expand Down Expand Up @@ -370,30 +345,25 @@ protected int freeBit( HierNode<T> x ) {
}

protected int freeBit( HierNode<T> x, HierNode<T> z ) {
//System.out.println( "Looking for a free bit in node " + x );
BitSet forbid = new BitSet( this.size() );
forbid.or( x.getBitMask() );
for ( HierNode<T> y : getNodes() ) {

if ( superset( y, x ) > 0 ) {
//System.out.println( "\t\t Subtype " + y + " contributes " + toBinaryString( y.getBitMask() ) );
forbid.or( y.getBitMask() );
}

if ( z != null ) {
if ( superset( y, z ) > 0 ) {
// System.out.println( "\t\t Subtype " + y + " contributes " + toBinaryString( y.getBitMask() ) );
forbid.or( y.getBitMask() );
}
}

if ( superset( x, y ) < 0 ) {
BitSet diff = singleBitDiff( x.getBitMask(), y.getBitMask() );
//System.out.println( "\t\t Incomparable " + y + " contributes " + toBinaryString( diff ) );
forbid.or(diff);
}
}
//System.out.println( "\t Forbidden mask " + toBinaryString( forbid ) );
return firstZero( forbid );
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,15 @@
import org.kie.api.io.ResourceType;
import org.kie.api.runtime.KieSession;
import org.kie.internal.utils.KieHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.assertj.core.api.Assertions.assertThat;

public class UseOfRuleFlowGroupPlusLockOnTest {

private static final Logger LOGGER = LoggerFactory.getLogger(UseOfRuleFlowGroupPlusLockOnTest.class);

private static final String drl = "package com.sample\n"
+ "import " + Person.class.getCanonicalName() + " ;\n"
+ "import " + Cheese.class.getCanonicalName() + " ;\n"
Expand All @@ -57,16 +61,16 @@ public void test() {
KieHelper kieHelper = new KieHelper().addContent(drl, ResourceType.DRL);
KieBase kbase = kieHelper.build();
KieSession ksession = kbase.newKieSession();
ReteDumper.dumpRete(ksession);
if (LOGGER.isDebugEnabled()) {
ReteDumper.dumpRete(ksession);
}
ksession.addEventListener( new DebugAgendaEventListener() );
try {
ksession.insert(new Person());
ksession.insert(new Cheese("eidam"));
((DefaultAgenda) ksession.getAgenda()).activateRuleFlowGroup("group1");
int rulesFired = ksession.fireAllRules();
assertThat(rulesFired).isEqualTo(1);


} finally {
ksession.dispose();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,8 @@
import org.drools.base.factmodel.traits.TraitFieldTMS;
import org.drools.traits.core.factmodel.TraitFieldTMSImpl;
import org.drools.base.factmodel.traits.TraitableBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import java.util.BitSet;
import java.util.Collection;
Expand All @@ -33,6 +35,8 @@

public class Imp2 implements TraitableBean<Imp2,Imp2> {

private static final Logger LOGGER = LoggerFactory.getLogger(Imp2.class);

private String name;
private String school;

Expand Down Expand Up @@ -137,8 +141,7 @@ public int hashCode() {

public void foo() {
Object f = __$$dynamic_properties_map$$.get( "goo" );
System.out.println( f );

LOGGER.debug( f.toString() );
}

private TraitFieldTMS tms;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,8 @@
import org.kie.internal.builder.KnowledgeBuilderFactory;
import org.kie.internal.io.ResourceFactory;
import org.kie.internal.utils.KieHelper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.fail;
Expand All @@ -51,6 +53,8 @@
@RunWith(Parameterized.class)
public class LegacyTraitTest extends CommonTraitTest {

private static final Logger LOGGER = LoggerFactory.getLogger(LegacyTraitTest.class);

public VirtualPropertyMode mode;

@Parameterized.Parameters
Expand Down Expand Up @@ -290,7 +294,7 @@ public void traitWithMixedInterfacesExtendingEachOther() {

int n = ks.fireAllRules();

System.out.println( list );
LOGGER.debug( list.toString() );
assertThat(list).isEqualTo(Arrays.asList(1, 2, 3));
assertThat(n).isEqualTo(3);
}
Expand Down
Loading