Ejemplo n.º 1
0
  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());
  }
Ejemplo n.º 2
0
  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());
  }
Ejemplo n.º 3
0
  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));
  }
Ejemplo n.º 4
0
  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));
  }