Package org.spockframework.mock

Examples of org.spockframework.mock.IArgumentConstraint


  private boolean matchesArgList(List<Object> args) {
    nextMatcher:
    for (int i = 0; i < argConstraints.size(); i++) {
      Object name = argNames.get(i);
      if (!name.equals("_")) return false; // cannot possibly match because we have unnamed args
      IArgumentConstraint matcher = argConstraints.get(i);

      Iterator<Object> argIter = args.iterator();
      while (argIter.hasNext())
        if (matcher.isSatisfiedBy(argIter.next())) {
          argIter.remove();
          continue nextMatcher;
        }

      return false;
View Full Code Here


  private boolean matchesArgMap(Map argMap) {
    // first pass: named matchers
    for (int i = 0; i < argConstraints.size(); i++) {
      Object name = argNames.get(i);
      if (name.equals("_")) continue;
      IArgumentConstraint matcher = argConstraints.get(i);
      if (!argMap.containsKey(name) || !matcher.isSatisfiedBy(argMap.remove(name)))
        return false;
    }

    // second pass: unnamed matchers
    nextMatcher:
    for (int i = 0; i < argConstraints.size(); i++) {
      Object name = argNames.get(i);
      if (!name.equals("_")) continue;
      IArgumentConstraint matcher = argConstraints.get(i);

      @SuppressWarnings("unchecked")
      Iterator<Object> argIter = argMap.values().iterator();
      while (argIter.hasNext())
        if (matcher.isSatisfiedBy(argIter.next())) {
          argIter.remove();
          continue nextMatcher;
        }

      return false;
View Full Code Here

   
    for (int i = 0; i < argConstraints.size() - 1; i++) {
      if (!argConstraints.get(i).isSatisfiedBy(args.get(i))) return false;
    }
   
    IArgumentConstraint lastConstraint = CollectionUtil.getLastElement(argConstraints);
    if (lastConstraint instanceof SpreadWildcardArgumentConstraint) return true;
    return argConstraints.size() == args.size() && lastConstraint.isSatisfiedBy(CollectionUtil.getLastElement(args));
  }
View Full Code Here

    return this;
  }

  public static final String TYPE_LAST_ARG = "typeLastArg";
  public InteractionBuilder typeLastArg(Class<?> type) {
    IArgumentConstraint last = argConstraints.get(argConstraints.size() - 1);
    argConstraints.set(argConstraints.size() - 1, new TypeArgumentConstraint(type, last));
    return this;
  }
View Full Code Here

    return this;
  }

  public static final String NEGATE_LAST_ARG = "negateLastArg";
  public InteractionBuilder negateLastArg() {
    IArgumentConstraint last = argConstraints.get(argConstraints.size() - 1);
    argConstraints.set(argConstraints.size() - 1, new NegatingArgumentConstraint(last));
    return this;
  }
View Full Code Here

TOP

Related Classes of org.spockframework.mock.IArgumentConstraint

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.