org.hamcrest.Description#appendText ( )源码实例Demo

下面列出了org.hamcrest.Description#appendText ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: tracecompass   文件: SWTBotCustomChartUtils.java
private static Matcher<Button> closeButtonForChart(final Chart chart) {
    return new AbstractMatcher<Button>() {

        @Override
        protected boolean doMatch(Object item) {
            if (!(item instanceof Button)) {
                return false;
            }
            Button button = (Button) item;
            return (button.getParent() == chart);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("delete button for custom chart");
        }
    };
}
 
源代码2 项目: go-bees   文件: HelpTest.java
private static Matcher<View> childAtPosition(
        final Matcher<View> parentMatcher, final int position) {

    return new TypeSafeMatcher<View>() {
        @Override
        public void describeTo(Description description) {
            description.appendText("Child at position " + position + " in parent ");
            parentMatcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            return parent instanceof ViewGroup && parentMatcher.matches(parent)
                    && view.equals(((ViewGroup) parent).getChildAt(position));
        }
    };
}
 
源代码3 项目: development   文件: JavaMatchers.java
/**
 * Checks if array is non-empty. This matcher can be replaced with JUnit 4.8
 */
public static Matcher<Object[]> hasItemInArray() {
    return new TypeSafeMatcher<Object[]>() {

        @Override
        public boolean matchesSafely(Object[] arrayToTest) {
            if (arrayToTest == null || arrayToTest.length == 0) {
                return false;
            }
            return true;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("non-empty array");
        }

    };
}
 
源代码4 项目: tool.accelerate.core   文件: FileContainsLines.java
@Override
public void describeMismatch(Object file, Description description) {
    List<String> lines = readLinesSafely(file, description);
    if (lines != null) {
        lineMatchingDelegate.describeMismatch(lines, description);
        description.appendText(" in file ");
        description.appendValue(file);
        description.appendText(" with lines ");
        description.appendValue(readLinesSafely(file, Description.NONE));
    }
}
 
@Override
protected boolean matchesSafely(final OperatorBackPressureStats stats, final Description mismatchDescription) {
	if (!isBackPressureRatioCorrect(stats)) {
		mismatchDescription.appendText("Not all subtask back pressure ratios in " + getBackPressureRatios(stats) + " are " + expectedBackPressureRatio);
		return false;
	}
	return true;
}
 
源代码6 项目: styx   文件: MetricsSupport.java
@Override
public void describeTo(Description description) {
    StringBuilder sb = new StringBuilder();
    sb.append("not updated");

    if (excludedNames.size() > 0) {
        sb.append(" except {");
        sb.append(String.join(", ", excludedNames));
        sb.append("}");
    }

    description.appendText(sb.toString());
}
 
源代码7 项目: beam   文件: BigqueryMatcher.java
@Override
public void describeMismatchSafely(TableAndQuery tableAndQuery, Description description) {
  String info;
  if (!response.getJobComplete()) {
    // query job not complete
    info = String.format("The query job hasn't completed. Got response: %s", response);
  } else {
    // checksum mismatch
    info =
        String.format(
            "was (%s).%n" + "\tTotal number of rows are: %d.%n" + "\tQueried data details:%s",
            actualChecksum, response.getTotalRows(), formatRows(TOTAL_FORMATTED_ROWS));
  }
  description.appendText(info);
}
 
源代码8 项目: astor   文件: Same.java
private void appendQuoting(Description description) {
    if (wanted instanceof String) {
        description.appendText("\"");
    } else if (wanted instanceof Character) {
        description.appendText("'");
    }
}
 
源代码9 项目: Scoops   文件: TestUtils.java
public static Matcher<View> withTextColor(final int color) {
    Checks.checkNotNull(color);
    return new BoundedMatcher<View, TextView>(TextView.class) {
        @Override
        public boolean matchesSafely(TextView warning) {
            return color == warning.getCurrentTextColor();
        }
        @Override
        public void describeTo(Description description) {
            description.appendText("with text color: ");
        }
    };
}
 
源代码10 项目: restdocs-wiremock   文件: SnippetMatchers.java
@Override
public void describeTo(Description description) {
	if (this.expectedContents != null) {
		this.expectedContents.describeTo(description);
	}
	else {
		description
				.appendText(this.templateFormat.getFileExtension() + " snippet");
	}
}
 
源代码11 项目: p4ic4idea   文件: IgnoreFilePatternTest.java
@Override
public void describeMismatch(Object item, Description description) {
    description.appendText("was ");
    if (!(item instanceof IgnoreFilePattern.PathNameMatchResult)) {
        description.appendValue(item);
    } else {
        IgnoreFilePattern.PathNameMatchResult res = (IgnoreFilePattern.PathNameMatchResult) item;
        description.appendText("isMatch? ").appendValue(res.isMatch)
                .appendText(" requiresMore? ").appendValue(res.requiresMore)
                .appendText(" isLast? ").appendValue(res.isLastElementMatch)
                .appendText(" next ").appendValue(res.next);
    }
}
 
源代码12 项目: android-nmea-parser   文件: Helper.java
public static <T> ArgumentMatcher<List> eq(final List<T> expected) {
    return new ArgumentMatcher<List>() {
        @Override
        public boolean matches(Object argument) {
            return argument.equals(expected);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText(expected.toString());
        }
    };
}
 
源代码13 项目: onos   文件: MappingActionJsonMatcher.java
/**
 * Matches the contents of a native forward mapping action.
 *
 * @param node        JSON action to match
 * @param description object used for recording errors
 * @return true if the contents match, false otherwise
 */
private boolean matchNativeForwardAction(JsonNode node, Description description) {
    NativeForwardMappingAction actionToMatch = (NativeForwardMappingAction) action;
    final String jsonType = node.get(MappingActionCodec.TYPE).textValue();
    if (!actionToMatch.type().name().equals(jsonType)) {
        description.appendText("type was " + jsonType);
        return false;
    }
    return true;
}
 
@Override
public Matcher<Object> isNull() {
    return new BaseMatcher<Object>() {
        @Override
        public boolean matches(Object item) {
            return item == null;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("is null");
        }
    };
}
 
@Override
public void describeTo(Description description) {
    String expectedJson = convertObjectToJsonString(expectedEvent);
    description.appendText("expected to look like " + expectedJson);
}
 
源代码16 项目: onos   文件: RegionJsonMatcher.java
@Override
protected boolean matchesSafely(JsonNode jsonRegion, Description description) {
    // check id
    String jsonRegionId = jsonRegion.get("id").asText();
    String regionId = region.id().toString();
    if (!jsonRegionId.equals(regionId)) {
        description.appendText("region id was " + jsonRegionId);
        return false;
    }

    // check type
    String jsonType = jsonRegion.get("type").asText();
    String type = region.type().toString();
    if (!jsonType.equals(type)) {
        description.appendText("type was " + jsonType);
        return false;
    }

    // check name
    String jsonName = jsonRegion.get("name").asText();
    String name = region.name();
    if (!jsonName.equals(name)) {
        description.appendText("name was " + jsonName);
        return false;
    }

    // check size of master array
    JsonNode jsonMasters = jsonRegion.get("masters");
    if (jsonMasters.size() != region.masters().size()) {
        description.appendText("masters size was " + jsonMasters.size());
        return false;
    }

    // check master
    for (Set<NodeId> set : region.masters()) {
        boolean masterFound = false;
        for (int masterIndex = 0; masterIndex < jsonMasters.size(); masterIndex++) {
            masterFound = checkEquality(jsonMasters.get(masterIndex), set);
        }

        if (!masterFound) {
            description.appendText("master not found " + set.toString());
            return false;
        }
    }

    return true;
}
 
源代码17 项目: onos   文件: LispTeRecordJsonMatcher.java
@Override
public void describeTo(Description description) {
    description.appendText(record.toString());
}
 
源代码18 项目: mattermost4j   文件: Assertions.java
/**
 * @see org.hamcrest.SelfDescribing#describeTo(org.hamcrest.Description)
 */
@Override
public void describeTo(Description description) {
  description.appendText("Should have failed");
}
 
源代码19 项目: vividus   文件: JsonDiffMatcher.java
@Override
public void describeMismatch(Object item, Description mismatchDescription)
{
    String differences = super.getDifferences();
    mismatchDescription.appendText(null != differences ? differences : item.toString());
}
 
源代码20 项目: styx   文件: MapMatcher.java
@Override
protected void describeMismatchSafely(Map<K, V> actual, Description mismatchDescription) {
    mismatchDescription.appendText(String.valueOf(difference(actual, expected)));
}