@Override protected void describeMismatchSafelyDerived(SqlQuery actual, Description mismatchDescription) { mismatchDescription.appendText(getName()); mismatchDescription.appendText(" was "); mismatchDescription.appendValueList( "[", ",", "]", actual.children().map(this::extractIdentifier).collect(Collectors.toList())); }
@Override public void describeTo(Description description) { description.appendText("at a distance "); description.appendValue(distance); description.appendText(" from "); description.appendValue(seat); }
/** * Matches the contents of a mod ODU singal Id instruction. * * @param instructionJson JSON instruction to match * @param description Description object used for recording errors * @return true if contents matches, false otherwise */ private boolean matchModOduSingalIdInstruction( JsonNode instructionJson, Description description) { ModOduSignalIdInstruction instructionToMatch = (ModOduSignalIdInstruction) instruction; String jsonSubType = instructionJson.get("subtype").textValue(); if (!instructionToMatch.subtype().name().equals(jsonSubType)) { description.appendText("subtype was " + jsonSubType); return false; } String jsonType = instructionJson.get("type").textValue(); if (!instructionToMatch.type().name().equals(jsonType)) { description.appendText("type was " + jsonType); return false; } final JsonNode jsonOduSignal = instructionJson.get("oduSignalId"); int jsonTpn = jsonOduSignal.get("tributaryPortNumber").intValue(); int jsonTsLen = jsonOduSignal.get("tributarySlotLength").intValue(); byte[] tributaryBitMap = HexString.fromHexString(jsonOduSignal.get("tributarySlotBitmap").asText()); OduSignalId jsonOduSignalId = OduSignalId.oduSignalId(jsonTpn, jsonTsLen, tributaryBitMap); if (!instructionToMatch.oduSignalId().equals(jsonOduSignalId)) { description.appendText("oduSignalId was " + instructionToMatch); return false; } return true; }
/** * Matches the contents of a push header instruction. * * @param instructionJson JSON instruction to match * @param description Description object used for recording errors * @return true if contents match, false otherwise */ private boolean matchModMplsHeaderInstruction(JsonNode instructionJson, Description description) { ModMplsHeaderInstruction instructionToMatch = (ModMplsHeaderInstruction) instruction; final String jsonSubtype = instructionJson.get("subtype").textValue(); if (!instructionToMatch.subtype().name().equals(jsonSubtype)) { description.appendText("subtype was " + jsonSubtype); return false; } final String jsonType = instructionJson.get("type").textValue(); if (!instructionToMatch.type().name().equals(jsonType)) { description.appendText("type was " + jsonType); return false; } final JsonNode ethJson = instructionJson.get("ethernetType"); if (ethJson == null) { description.appendText("ethernetType was not null"); return false; } if (instructionToMatch.ethernetType().toShort() != ethJson.asInt()) { description.appendText("ethernetType was " + ethJson); return false; } return true; }
protected boolean fail( String reasonForFailure, Collection<? extends E> item, Description mismatchDescription) { mismatchDescription.appendText(reasonForFailure); mismatchDescription.appendText(" <"); mismatchDescription.appendText(item.toString()); mismatchDescription.appendText(">"); return false; }
@Override public void describeTo(Description description) { description.appendText("link lookup for source \""); description.appendText(source); description.appendText(" and destination "); description.appendText(destination); description.appendText("\""); }
@Override public void describeTo(Description description) { description.appendText("a Complex number having "); reMatcher.describeTo(description); description.appendText(" as real part and "); imMatcher.describeTo(description); description.appendText(" as imaginary part"); }
@Override public void describeMismatchSafely(Object bean, Description description) { if (beanPropertyValueFound) { description.appendText("found property value ").appendValue(beanPropertyValue); } else { description.appendText("property not found"); } }
@Override public void describeTo(Description description) { description.appendText("is about "); description.appendValue(d); description.appendText(" (factor "); description.appendValue(factor); description.appendText(")"); }
@Override public void describeMismatch(Object item, Description description) { description.appendText("was:"); if (item instanceof String) { description.appendText((String) item); } else { description.appendValue(item); } }
@Override public void describeMismatch(Object o, Description d) { if (o instanceof DcacheVersion) { d.appendText("Object not a DcacheVersion"); } else { DcacheVersion other = (DcacheVersion) o; d.appendText("version " + other + " is not before " + comparison); } }
@Override public void describeMismatch(Object item, Description description) { if (!snippetFileExists(item)) { description.appendText("The file " + item + " does not exist"); } else if (this.expectedContents != null) { try { this.expectedContents.describeMismatch(read((File) item), description); } catch (IOException e) { description.appendText("The contents of " + item + " cound not be read"); } } }
public void describeTo(Description description) { description.appendText("Found unexpected match at element " + index + " in the fragment."); if (matcher instanceof BaseHtmlElementMatcher) { description.appendText( "\nThe unexpected match is below: (the first is the element that actually matched, the second (after the but) is the full fragment)\n"); ((BaseHtmlElementMatcher) matcher).describeMatchSafely(description); } else { description.appendText("\nThe unexpected match is below:\n"); description.appendText("not ").appendDescriptionOf(matcher); } }
@Override protected void describeMismatchSafely(final T item, final Description mismatchDescription) { mismatchDescription.appendValue(item).appendText(" is not equivalent to "); if (comparison == null) { mismatchDescription.appendText("null value"); } else { mismatchDescription.appendValue(comparison); } mismatchDescription.appendText(" according with Equivalence ").appendValue(equivalence); }
static void assertBitSet(FixedBitSet actual, FixedBitSet expected, IndexSearcher searcher) throws IOException { if (!actual.equals(expected)) { Description description = new StringDescription(); description.appendText(reason(actual, expected, searcher)); description.appendText("\nExpected: "); description.appendValue(expected); description.appendText("\n got: "); description.appendValue(actual); description.appendText("\n"); throw new java.lang.AssertionError(description.toString()); } }
@Override protected boolean matchesSafely(final Metadata metadata, final Description description) { if (idIsSetAndDoesNotMatchWith(metadata)) { description.appendText("Metadata with id = " + metadata.id()); return false; } if (nameIsSetAndDoesNotMatchWith(metadata)) { description.appendText("Metadata with name = " + metadata.name()); return false; } if (causationIdsDoNotMatchWith(metadata)) { description.appendText("Metadata with causationIds = " + metadata.causation()); return false; } if (userIdIsSetAndDoesNotMatchWith(metadata)) { description.appendText("Metadata with userId = " + metadata.userId().orElse(NOT_SET)); return false; } if (sessionIdIsSetAndDoesNotMatchWith(metadata)) { description.appendText("Metadata with sessionId = " + metadata.sessionId().orElse(NOT_SET)); return false; } if (streamIdIsSetAndDoesNotMatchWith(metadata)) { description.appendText( "Metadata with streamId = " + metadata.streamId().map(UUID::toString).orElse(NOT_SET)); return false; } if (versionIsSetAndDoesNotMatchWith(metadata)) { description.appendText( "Metadata with version = " + metadata.version().map(String::valueOf).orElse(NOT_SET)); return false; } if (clientCorrelationIdIsSetAndDoesNotMatchWith(metadata)) { description.appendText( "Metadata with clientCorrelationId = " + metadata.clientCorrelationId().map(String::valueOf).orElse(NOT_SET)); return false; } if (jsonMatcherIsSetAndDoesNotMatchWith(metadata)) { description.appendText("Metadata "); jsonMatcher.ifPresent( matcher -> matcher.describeMismatch(metadata.asJsonObject().toString(), description)); return false; } return true; }
public void describeTo(Description description) { java.util.regex.Matcher arg = ARG_PATTERN.matcher(descriptionTemplate); int textStart = 0; while (arg.find()) { description.appendText(descriptionTemplate.substring(textStart, arg.start())); int argIndex = Integer.parseInt(arg.group(1)); description.appendValue(values[argIndex]); textStart = arg.end(); } if (textStart < descriptionTemplate.length()) { description.appendText(descriptionTemplate.substring(textStart)); } }
@Override protected boolean matchesSafely(String item, Description mismatchDescription) { try { if (!date.isEqual(ZonedDateTime.parse(item))) { mismatchDescription.appendText("was ").appendValue(item); return false; } return true; } catch (DateTimeParseException e) { mismatchDescription.appendText("was ").appendValue(item) .appendText(", which could not be parsed as a ZonedDateTime"); return false; } }
/** * Matches the contents of a meter instruction. * * @param instructionJson JSON instruction to match * @param description Description object used for recording errors * @return true if contents match, false otherwise */ private boolean matchMeterInstruction(JsonNode instructionJson, Description description) { final String jsonType = instructionJson.get("type").textValue(); MeterInstruction instructionToMatch = (MeterInstruction) instruction; if (!instructionToMatch.type().name().equals(jsonType)) { description.appendText("type was " + jsonType); return false; } final long jsonMeterId = instructionJson.get("meterId").longValue(); if (instructionToMatch.meterId().id() != jsonMeterId) { description.appendText("meterId was " + jsonMeterId); return false; } return true; }
/** * Matches the contents of a group instruction. * * @param instructionJson JSON instruction to match * @param description Description object used for recording errors * @return true if contents match, false otherwise */ private boolean matchGroupInstruction(JsonNode instructionJson, Description description) { final String jsonType = instructionJson.get("type").textValue(); GroupInstruction instructionToMatch = (GroupInstruction) instruction; if (!instructionToMatch.type().name().equals(jsonType)) { description.appendText("type was " + jsonType); return false; } final int jsonGroupId = instructionJson.get("groupId").intValue(); if (instructionToMatch.groupId().id() != jsonGroupId) { description.appendText("groupId was " + jsonGroupId); return false; } return true; }
public void describeTo(Description description) { if (this.fAssumption != null) { description.appendText(this.fAssumption); } if (this.fValueMatcher) { if (this.fAssumption != null) { description.appendText(": "); } description.appendText("got: "); description.appendValue(this.fValue); if (this.fMatcher != null) { description.appendText(", expected: "); description.appendDescriptionOf(this.fMatcher); } } }
public void describeTo(Description description) { description .appendText("a Message with Headers that match except ID and timestamp for payload: ") .appendValue(payload) .appendText(" and headers: ") .appendValue(headers); }
/** * メッセージの構築。 期待値をDateに変換してメッセージに追加する。(時間部分は差分として出ちゃうけど、めんどいのでこの辺は適当) * * @param description */ public void describeTo(Description description) { if (expected == null) { description.appendText(expected); } else { description.appendValue(expectedDate); } }
@Override protected void describeMismatchSafely(T[] item, Description mismatchDescription) { Matches<T> matches = new Matches<>(); Iterator<Matcher<T>> elementIterator = elements.iterator(); Iterator<? extends T> itemIterator = asList(item).iterator(); while (elementIterator.hasNext() && itemIterator.hasNext()) { Matcher<T> matcher = elementIterator.next(); T element = itemIterator.next(); if (!matcher.matches(element)) { matches.mismatch(matcher, element); } else { matches.match(); } } if (elementIterator.hasNext()) { int count = count(elementIterator); matches.mismatch("missing " + count + " elements"); } if (itemIterator.hasNext()) { List<T> items = collect(itemIterator); matches.mismatch("found " + items.size() + " elements surplus " + toDescriptionSet(items)); } if (matches.containsMismatches()) { mismatchDescription.appendText("mismatching elements ").appendDescriptionOf(matches); } }
@Override public void describeTo(Description description) { description .appendText("an Issue containing a link to ") .appendValue(expectedIssueKey) .appendText(" with description ") .appendValue(expectedLinkTypeName); }
@Override public void describeTo(Description description) { description .appendText("a numeric value within ") .appendValue(this.delta) .appendText(" of ") .appendValue(this.value); }
@Override public void describeTo(Description description) { description .appendText("expects expectedType ") .appendValue(expectedType) .appendText(" and a message ") .appendValue(expectedMessage); }
@Override public void describeTo(Description description) { if (this.expectedContents != null) { this.expectedContents.describeTo(description); } else { description.appendText("Asciidoctor snippet"); } }
@Override public void describeTo(final Description description) { if (this.expected.longValue() == 0L) { description.appendText("zero or null"); } else { description.appendValue(this.expected); } }
@Override public void describeTo(Description description) { description .appendText("total hits of size ") .appendValue(totalHits) .appendText(" with query ") .appendValue(query); }