public class GlobalFactPopulatorTest {
@Test
public void testWithGlobals() throws Exception {
FactData global = new FactData( "Cheese",
"c",
Arrays.<Field>asList( new FieldData( "type",
"cheddar" ) ),
false );
TypeResolver resolver = new ClassTypeResolver( new HashSet<String>(),
Thread.currentThread().getContextClassLoader() );
resolver.addImport( "org.drools.workbench.models.testscenarios.backend.Cheese" );
KieSession ksession = mock( KieSession.class );
Map<String, Object> populatedData = new HashMap<String, Object>();
Map<String, Object> globalData = new HashMap<String, Object>();
GlobalFactPopulator globalFactPopulator = new GlobalFactPopulator( populatedData,
resolver,
global,
globalData );
globalFactPopulator.populate( ksession,
new HashMap<String, FactHandle>() );
verify( ksession ).setGlobal( eq( global.getName() ),
any( Object.class ) );
assertEquals( 1,
globalData.size() );
assertEquals( 0,
populatedData.size() );