+ assertThat(lines, matchesFcpMessage("ClientGet", "URI=KSK@foo.txt", "Global=true"));
+ }
+
+ private Matcher<List<String>> matchesFcpMessage(String name, String... requiredLines) {
+ return new TypeSafeDiagnosingMatcher<List<String>>() {
+ @Override
+ protected boolean matchesSafely(List<String> item, Description mismatchDescription) {
+ if (!item.get(0).equals(name)) {
+ mismatchDescription.appendText("FCP message is named ").appendValue(item.get(0));
+ return false;
+ }
+ for (String requiredLine : requiredLines) {
+ if (item.indexOf(requiredLine) < 1) {
+ mismatchDescription.appendText("FCP message does not contain ").appendValue(requiredLine);
+ return false;
+ }
+ }
+ return true;
+ }
+
+ @Override
+ public void describeTo(Description description) {
+ description.appendText("FCP message named ").appendValue(name);
+ description.appendValueList(", containing the lines", ", ", "", requiredLines);
+ }
+ };