@Override
 protected IEditorCommandResult concreteDoCommand() {
   EntityClass theClass = this._domain.getEntityClassWithId(this._classId);
   EntityEventSpecification theSpec = theClass.getEventSpecificationWithId(this._specId);
   theSpec.removeEventParamWithId(this._paramId);
   return new SuccessfulEditorCommand();
 }
  public void test_i_f_empty_instance_set_fails_if_instance_set_is_from_an_any_select()
      throws InvalidActionLanguageSyntaxException, NameAlreadyBoundException {
    String proc = "";
    proc += "SELECT ANY notASet RELATED BY self->R1;\n";
    proc += "IF EMPTY notASet THEN\n";
    proc += "END IF;\n";

    EntityDomain ttdDomain = DomainTTD.getTTDDomain();
    EntityClass user = ttdDomain.getEntityClassWithName("User");
    EntityState state = new EntityState("Initial");
    user.addState(state);
    EntityProcedure procedure = new EntityProcedure(state);
    procedure.setProcedure(proc);

    Assert.assertTrue(procedure.validate());
  }
  public void test_i_f_not_empty_instance_set_fails_if_instance_set_is_not_a_set()
      throws InvalidActionLanguageSyntaxException, NameAlreadyBoundException {
    String proc = "";
    proc += "CREATE notASet FROM User;\n";
    proc += "IF NOT EMPTY notASet THEN\n";
    proc += "END IF;\n";

    EntityDomain ttdDomain = DomainTTD.getTTDDomain();
    EntityClass user = ttdDomain.getEntityClassWithName("User");
    EntityState state = new EntityState("Initial");
    user.addState(state);
    EntityProcedure procedure = new EntityProcedure(state);
    procedure.setProcedure(proc);

    Assert.assertTrue(procedure.validate());
  }
  @Override
  public IEditorCommandResult canDoCommand() {
    if (!this._domain.hasEntityClassWithId(this._classId)) {
      return BaseEditorCommand.failWhenClassNotFound(this._classId);
    }
    EntityClass theClass = this._domain.getEntityClassWithId(this._classId);
    if (!theClass.hasEventSpecificationWithId(this._specId)) {
      return BaseEditorCommand.failWhenSpecNotFound(this._classId, this._specId);
    }
    EntityEventSpecification theSpec = theClass.getEventSpecificationWithId(this._specId);
    if (!theSpec.hasParamWithId(this._paramId)) {
      return BaseEditorCommand.failWhenParamNotFound(this._paramId);
    }

    return new SuccessfulEditorCommand();
  }
  public void test_valid_if_empty()
      throws InvalidActionLanguageSyntaxException, NameAlreadyBoundException {
    String proc = "";
    proc += "SELECT MANY tasks RELATED BY self->R1;\n";
    proc += "IF EMPTY tasks THEN\n";
    proc += "END IF;\n";

    EntityDomain ttdDomain = DomainTTD.getTTDDomain();
    EntityClass user = ttdDomain.getEntityClassWithName("User");
    EntityState state = new EntityState("Initial");
    user.addState(state);
    EntityProcedure procedure = new EntityProcedure(state);
    procedure.setProcedure(proc);

    Assert.assertTrue(procedure.validate());
    Assert.assertEquals(0, TestHelper.countValidationErrors(procedure));
  }
  public void test_i_f_not_empty_instance_set_fails_if_instance_set_cannot_be_identified()
      throws InvalidActionLanguageSyntaxException, NameAlreadyBoundException {
    String proc = "";
    proc += "IF NOT EMPTY cantFind THEN\n";
    proc += "END IF;\n";

    EntityDomain ttdDomain = DomainTTD.getTTDDomain();
    EntityClass user = ttdDomain.getEntityClassWithName("User");
    EntityState state = new EntityState("Initial");
    user.addState(state);
    EntityProcedure procedure = new EntityProcedure(state);
    procedure.setProcedure(proc);

    Assert.assertTrue(!procedure.validate());
    Assert.assertEquals(1, TestHelper.countValidationErrors(procedure));
    Assert.assertTrue(
        TestHelper.checkValidationResultsForAnErrorOfType(
            procedure, CouldNotIdentifyInstanceSetValidationError.class));
  }
  public void test_cant_rename_state_where_state_exists() throws NameAlreadyBoundException {
    String stateName = "State1";
    EntityDomain domain = new EntityDomain("TestDomain");
    EntityClass klass = new EntityClass("Class");
    domain.addClass(klass);
    EntityState newState = new EntityState(stateName);
    klass.addState(newState);

    EditorCommand_RenameState command = new EditorCommand_RenameState();
    command.setDomain(domain);
    command.setStateId(stateName);
    command.setNewStateName(stateName);
    command.setClassId("Class");

    Assert.assertEquals(true, klass.hasStateWithName(stateName));

    Assert.assertEquals(false, command.canDoCommand().returnStatus());
    Assert.assertEquals(false, command.doCommand().returnStatus());

    Assert.assertEquals(true, klass.hasStateWithName(stateName));
  }