Exemplo n.º 1
0
  public State(
      final String stateId,
      final boolean initialised,
      final boolean invariantKo,
      final boolean timeoutOccured,
      final boolean maxOperationReached,
      final Collection<Variable> stateValues,
      final List<Operation> enabledOperations,
      final Collection<StateError> stateErrors,
      final Set<String> timeoutedOperations) {
    this.id = stateId;
    this.initialized = initialised;
    this.invariantViolated = invariantKo;
    this.timeoutOccured = timeoutOccured;
    this.maxOperationReached = maxOperationReached;
    this.stateErrors = stateErrors;
    this.timeout = timeoutedOperations;

    Map<String, Variable> vars = new HashMap<String, Variable>(stateValues.size());
    for (Variable v : stateValues) {
      final String identifier = v.getIdentifier();
      if (vars.containsKey(identifier)) {
        Logger.notifyUser("ProB returned a variable twice.");
      } else {
        vars.put(identifier, v);
      }
    }
    this.stateValues = Collections.unmodifiableMap(vars);

    Logger.assertProB(ERROR_MSG, enabledOperations != null);

    this.enabledOperations = Collections.unmodifiableList(enabledOperations);
  }
Exemplo n.º 2
0
  /**
   * Check a property. The method notifies the user and throws an exception if the assertion fails.
   * <br>
   * <b>Examples:</b><br>
   * {@code Logger.assertProB(this.getClass(),"x != null", x != null); } <br>
   * {@code Logger.assertProB(this.getClass(),"x should not be null", x != null); } <br>
   * <b>Note:</b> If you check PrologTerm objects for their type, you should rather use the static
   * getXXX methods from {@link BindingGenerator} located in the de.prob.core package
   *
   * @param clazz The calling class. This is to help locating the problem
   * @param assertion The Property as a string, this helps to find out, what is going wrong, this
   *     can contain arbitrary text to help. It is recommended to include the property itself
   * @param property a boolean value, typically you want to use a boolean expression
   * @throws CliException
   */
  public static void assertProB(final String assertion, final boolean property)
      throws ProBAssertionFailed {
    if (!property) {

      StackTraceElement caller = Thread.currentThread().getStackTrace()[2];

      notifyUser(
          "ProB Assertion '"
              + assertion
              + "' failed in Class: "
              + caller.getClassName()
              + "\n Please submit a bugreport");

      throw new ProBAssertionFailed(assertion);
    }
  }
Exemplo n.º 3
0
 public static void notifyUser(final String message) {
   notifyUser(message, null);
 }
Exemplo n.º 4
0
 public final void notifyUserOnce() {
   if (!handled) {
     handled = true;
     Logger.notifyUser(this.getMessage(), this);
   }
 }