Exemplo n.º 1
0
  public boolean matches(Object actual) {
    if (actual == null) {
      this.self.appendText(
          "MapPropertyEqaulMatcher, the actual object can't be null or list/array.");
      return false;
    }

    List<Map<String, ?>> expecteds = new ArrayList<Map<String, ?>>();
    List<Map<String, ?>> actuals = new ArrayList<Map<String, ?>>();
    List list = ListHelper.toList(actual);
    if (list == null || list.size() == 0) {
      this.self.appendText("the actual value is empty.");
      return false;
    } else if (list.size() > 1) {
      this.self.appendText(
          "the size of actual list/array are greater than one, please use API: reflectionEqMap(count, DataMap).");
      return false;
    }
    Object item = list.get(0);
    if (ArrayHelper.isCollOrArray(item)) {
      this.self.appendText("MapPropertyEqaulMatcher, the item of actual list can't list/array.");
      return false;
    } else {
      Map<String, Object> map = item == null ? null : this.getValueByMapKeys(item);
      actuals.add(map);
      expecteds.add(this.expected);
    }

    ReflectionComparator reflectionComparator = createRefectionComparator(modes);
    this.difference = reflectionComparator.getDifference(expecteds, actuals);
    return difference == null;
  }
Exemplo n.º 2
0
 public boolean matches(Object actual) {
   if (ArrayHelper.isCollOrArray(actual) == false) {
     buff.append("PropertyItemsMatcher, the actual value must be a array or collection.");
     return false;
   }
   List list = ListHelper.toList(actual);
   actualItems = PropertyAccessor.getPropertyOfList(list, property, true);
   for (Object item : actualItems) {
     boolean match = this.matcher.matches(item);
     if (match == false) {
       return false;
     }
   }
   return true;
 }