/** creates a rule, which listens for the received SMSes and send back a response */
  public void testSmsEventRule() {
    if (mRuleManager.loadAllRules().size() != 0) {
      return;
    }

    /*
     * Create the conditions
     */
    // ToDo: to be handled an event without conditions and without building the condition tree
    RuleCondition cTrue = mConditionManager.getDefaultCondition();
    mConditionManager.saveCondition(cTrue);

    // create dependencies between conditions
    // Build the condition tree
    RuleConditionTree.Builder builder = new ConditionTree.Builder();
    builder.add(cTrue, new RuleCondition[] {cTrue, cTrue}, ConditionTree.Operator.OR);
    RuleConditionTree root = mConditionManager.buildConditionTree(builder);

    /*
     * Create actions
     */

    RuleAction aSms = generateNewAction(Action.Type.SEND_SMS_ACTION.getType());
    // ToDo: when the Trigger button was pushed more than one time, the fields in
    // SendSmsActionPlugin will be null. ?
    //        ((SendSmsActionPlugin) aSms.getActionPlugin()).setPhoneNumber("0740507135");
    //        ((SendSmsActionPlugin) aSms.getActionPlugin()).setMessage("From the plugin :-)");

    mActionManager.saveActions(aSms);

    // Create a rule with these actions and conditions
    RuleRecord ruleRecord = new RuleRecord();

    // set the event
    ruleRecord.setRuleName("Respond to Sms Rule");
    ruleRecord.setEventCode(Event.Type.RULE_EVENT_SMS.getType());
    ruleRecord.setRuleConditionTree(root);
    ruleRecord.addRuleActions(aSms);
    mRuleManager.saveRuleRecord(ruleRecord);
  }
  /** we create a rule which listens for the incoming calls, rejects it, and sends back an sms */
  public void testCallEventRule() {
    if (mRuleManager.loadAllRules().size() != 0) {
      return;
    }

    /*
     * Create the conditions
     */
    // ToDo: to be handled an event without conditions and without building the condition tree
    RuleCondition cTrue = mConditionManager.getDefaultCondition();
    mConditionManager.saveCondition(cTrue);

    // create dependencies between conditions
    // Build the condition tree
    RuleConditionTree.Builder builder = new ConditionTree.Builder();
    builder.add(cTrue, new RuleCondition[] {cTrue, cTrue}, ConditionTree.Operator.OR);
    RuleConditionTree root = mConditionManager.buildConditionTree(builder);

    /*
     * Create actions
     */

    RuleAction aRejectCall = generateNewAction(Action.Type.REJECT_CALL_ACTION.getType());

    RuleAction aSms = generateNewAction(Action.Type.SEND_SMS_ACTION.getType());
    ((SendSmsActionPlugin) aSms.getActionPlugin()).setMessage("I'll call you back later.");

    mActionManager.saveActions(aRejectCall, aSms);

    // Create a rule with these actions and conditions
    RuleRecord ruleRecord = new RuleRecord();

    // set the event
    ruleRecord.setRuleName("Reject call Rule");
    ruleRecord.setEventCode(Event.Type.RULE_EVENT_CALL.getType());
    ruleRecord.setRuleConditionTree(root);
    ruleRecord.addRuleActions(aRejectCall, aSms);
    mRuleManager.saveRuleRecord(ruleRecord);
  }