ilogjrulesibm-odm

DSV : Custome Scenario Provider - NullPointerException


I'm trying to create Custom Scenario Provider for Rule Designer and have created a Plug-in to execute it through Run Configurations. I'm able to create the plug-in and run DVS Runner; however, I'm receiving NullPointerException in IlrDVSRunner. I'm unable to resolve the exception through all means. Any help would be highly appreciated.

MotorScenarioProvider.java

public class MotorScenarioProvider implements IlrScenarioProvider, Serializable {
private static final long serialVersionUID = 20150702L;

public MotorScenarioProvider() {
    super();
    System.out.println("MotorScenarioProvider - Constructor");
}

public void initialize(IlrScenarioSuiteExecutionContext context)
        throws IlrInitializationException {
    System.out.println("MotorScenarioProvider - Initialize");
}

public int getScenarioCount() throws IlrScenarioProviderException {
    System.out.println("MotorScenarioProvider - getScenarioCount");
    return 1;
}

public IlrScenario getScenarioAt(int indx)
        throws IlrScenarioProviderException {
    System.out.println("MotorScenarioProvider - getScenarioAt");

    IlrScenarioImpl scenario = new IlrScenarioImpl();
    Map<String, Object> inputParameters = new HashMap<String, Object>();

    //Setting Blank Scenario for testing purpose
    scenario.setName("Scenario 1");
    inputParameters.put("req", new Object());
    inputParameters.put("req", new Object());
    scenario.setInputParameters(inputParameters);

    return scenario;
}

MotorScenarioProviderRunner.java

public class MotorScenarioProviderRunner extends IlrDVSRunner {
/**
 * Create a DVS scenario suite descriptor
 * 
 * @return The scenario suite descriptor
 */
public IlrScenarioSuiteDescriptor createScenarioSuiteDescriptor() {
    IlrScenarioSuiteDescriptorFactory scenarioSuiteDescriptorFactory = new IlrScenarioSuiteDescriptorFactory();
    IlrScenarioFormatDescriptor formatDescriptor = IlrScenarioFormatDescriptorFactory
            .getInstance().createScenarioFormatDescriptor();
    formatDescriptor
        .setScenarioProviderClassName(MotorScenarioProvider.class.getName());
    IlrScenarioSuiteDescriptor suiteDescriptor = scenarioSuiteDescriptorFactory
            .createScenarioSuiteDescriptor(formatDescriptor);
    suiteDescriptor.setKPIEnabled(false);
    suiteDescriptor.setTestEnabled(true);
    suiteDescriptor.setProductionRulesetArchive(new IlrRulesetArchive());
    System.out.println("MotorScenarioProviderRunner: createScenarioSuiteDescriptor");

    suiteDescriptor.add("SCENARIO_NAME", "Scenario 1");

    return suiteDescriptor;
}

/**
 * The main method run from the {@link IlrDVSLaunchConfigurationDelegate}
 * launch method.
 * 
 * @param args
 *            The args needed to run the scenarios and build the scenario
 *            suite descriptor.
 */
public static void main(String[] args) {
    MotorScenarioProviderRunner runner = new MotorScenarioProviderRunner();
    String[] data = runner.extractCustomArgs(args);
    // TODO read the custom parameters from the 'data' attribute and not
    // from the 'args' attribute
    System.out.println("MotorScenarioProviderRunner: main");

    try {
        IlrScenarioSuiteDescriptor scenarioSuite = runner
                .createScenarioSuiteDescriptor();

        if(scenarioSuite == null)
            System.out.println("scenarioSuite is NULL");
        if(args == null)
            System.out.println("args is NULL");

        runner.run(args, scenarioSuite); **//EXCEPTION OCCURS HERE**
    } catch (IOException e) {
        e.printStackTrace();
    }
} }

Solution

  • I figured out the solution of this.

    Actually, IlrDVSRunner.Run methods looks for type of launch configuration i.e. Run or Debug at 3 place in the custum args auto inserted from launch config.

    The first arg in custom args is the custom data we gonna provide to DVS Runner. In my case, it was my Scenario Provider class which adds the data to scenario. So, when I updated the launch configuation to put a Text-Box which will provide the Scenario Provider class name to my custom scenario provider, eventually I end-up with solution of my problem.

    Here is my XML Scenario Provider which can be used to run\debug XMLs directly in Rule Designer: XML Scenario Provider

    Thanks to all