當前位置: 首頁>>代碼示例>>Java>>正文


Java Description.appendText方法代碼示例

本文整理匯總了Java中org.hamcrest.Description.appendText方法的典型用法代碼示例。如果您正苦於以下問題:Java Description.appendText方法的具體用法?Java Description.appendText怎麽用?Java Description.appendText使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.hamcrest.Description的用法示例。


在下文中一共展示了Description.appendText方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: matchesSafely

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {

    // check node identifier of master
    String jsonNodeId = jsonNode.get("master").asText();
    String nodeId = mastershipTerm.master().id();
    if (!jsonNodeId.equals(nodeId)) {
        description.appendText("master's node id was " + jsonNodeId);
        return false;
    }

    // check term number
    long jsonTermNumber = jsonNode.get("termNumber").asLong();
    long termNumber = mastershipTerm.termNumber();
    if (jsonTermNumber != termNumber) {
        description.appendText("term number was " + jsonTermNumber);
        return false;
    }

    return true;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:MastershipTermCodecTest.java

示例2: isActuallyAnExcelFile

import org.hamcrest.Description; //導入方法依賴的package包/類
public static Matcher<byte[]> isActuallyAnExcelFile() {
    return new BaseMatcher<byte[]>() {
        @Override
        public boolean matches(Object o) {
            final List<String> names = new ArrayList<>();

            try (ZipInputStream zipStream = new ZipInputStream(new ByteArrayInputStream((byte[]) o))) {
                ZipEntry zipEntry;
                while ((zipEntry = zipStream.getNextEntry()) != null) {
                    names.add(zipEntry.getName());
                    zipStream.closeEntry();
                }
            } catch (IOException e) {
                return false;
            }

            return hasItems("_rels/.rels", "docProps/app.xml", "xl/styles.xml", "xl/workbook.xml").matches(names);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Given binary data corresponds to an excel file");
        }
    };
}
 
開發者ID:Dactilo,項目名稱:spring-spreadsheet,代碼行數:26,代碼來源:SpreadsheetsMatchers.java

示例3: hasFieldWithUserRef

import org.hamcrest.Description; //導入方法依賴的package包/類
public static <T> Matcher<T> hasFieldWithUserRef(final String fieldName, final User user) {
    return new BaseMatcher<T>() {
        @Override
        public boolean matches(Object o) {
            Ref<User> userRef = TestSupport.getField(o, fieldName);
            if (user == null) {
                return userRef == null;
            } else {
                String username = userRef.getKey().getName();

                return user.getUsername().equals(username);
            }
        }

        @Override
        public void describeTo(Description description) {
            description.appendText(String.format("User with username '%s' on field %s", user, fieldName));
        }
    };
}
 
開發者ID:3wks,項目名稱:generator-thundr-gae-react,代碼行數:21,代碼來源:Matchers.java

示例4: withItemViewAtPosition

import org.hamcrest.Description; //導入方法依賴的package包/類
/**
 * <p>
 * Returns a matcher that matches an item view at the given position
 * in the RecyclerView matched by {@code recyclerViewMatcher}.
 * </p>
 * <p>
 * If the item view at the given position is not laid out,
 * the matcher returned by this method will not match anything.
 * Call {@link android.support.test.espresso.contrib.RecyclerViewActions#scrollToPosition(int)}
 * with the same position prior to calling this method
 * in order to ensure that the item view is laid out.
 * </p>
 * <pre><code>
 *     onView(withId(R.id.recyclerView).perform(RecyclerViewActions.scrollToPosition(position);
 * </code></pre>
 *
 * @param recyclerViewMatcher a matcher for RecyclerView containing the item view.
 * @param position            position of the item view in RecyclerView
 */
public static Matcher<View> withItemViewAtPosition(final Matcher<View> recyclerViewMatcher, final int position) {
    return new TypeSafeMatcher<View>() {
        @Override
        protected boolean matchesSafely(View view) {
            ViewParent parent = view.getParent();
            if (!(parent instanceof RecyclerView) || !recyclerViewMatcher.matches(parent)) {
                return false;
            }
            RecyclerView.ViewHolder viewHolder = ((RecyclerView) parent).findViewHolderForAdapterPosition(position);
            return viewHolder != null && viewHolder.itemView.equals(view);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Item view at position " + position + " in recycler view ");
            recyclerViewMatcher.describeTo(description);
        }
    };
}
 
開發者ID:sumio,項目名稱:espresso-sample-for-droidkaigi2017,代碼行數:39,代碼來源:RecyclerViewUtils.java

示例5: matchModIPv6FlowLabelInstruction

import org.hamcrest.Description; //導入方法依賴的package包/類
/**
 * Matches the contents of a mod IPv6 Flow Label instruction.
 *
 * @param instructionJson JSON instruction to match
 * @param description Description object used for recording errors
 * @return true if contents match, false otherwise
 */
private boolean matchModIPv6FlowLabelInstruction(JsonNode instructionJson,
                                                 Description description) {
    ModIPv6FlowLabelInstruction instructionToMatch =
            (ModIPv6FlowLabelInstruction) 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 int jsonFlowLabel = instructionJson.get("flowLabel").intValue();
    final int flowLabel = instructionToMatch.flowLabel();
    if (flowLabel != jsonFlowLabel) {
        description.appendText("IPv6 flow label was " + jsonFlowLabel);
        return false;
    }

    return true;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:33,代碼來源:InstructionJsonMatcher.java

示例6: withinSecondsAfter

import org.hamcrest.Description; //導入方法依賴的package包/類
public static Matcher<String> withinSecondsAfter(Seconds seconds, DateTime after) {
    return new TypeSafeMatcher<String>() {
      @Override
      public void describeTo(Description description) {
        description.appendText(String.format(
          "a date time within %s seconds after %s",
          seconds.getSeconds(), after.toString()));
      }

      @Override
      protected boolean matchesSafely(String textRepresentation) {
        //response representation might vary from request representation
        DateTime actual = DateTime.parse(textRepresentation);

        return actual.isAfter(after) &&
          Seconds.secondsBetween(after, actual).isLessThan(seconds);
      }
    };
}
 
開發者ID:folio-org,項目名稱:mod-circulation-storage,代碼行數:20,代碼來源:TextDateTimeMatcher.java

示例7: matchesSafely

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(JsonNode jsonNode, Description description) {

    // check application role
    int jsonAppId = jsonNode.get("id").asInt();
    int appId = applicationId.id();
    if (jsonAppId != appId) {
        description.appendText("application ID was " + jsonAppId);
        return false;
    }

    String jsonAppName = jsonNode.get("name").asText();
    String appName = applicationId.name();

    if (!jsonAppName.equals(appName)) {
        description.appendText("application name was " + jsonAppName);
        return false;
    }

    return true;
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:22,代碼來源:ApplicationIdCodecTest.java

示例8: matchesSafely

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(RecordedRequest item, Description mismatchDescription) {
    if (item == null) {
        mismatchDescription.appendText("was null");
        return false;
    }

    switch (checkingOption) {
        default:
        case METHOD_PATH:
            return matchesMethodAndPath(item, mismatchDescription);
        case HEADER:
            return matchesHeader(item, mismatchDescription);
        case QUERY_PARAMETER:
            return matchesQueryParameter(item, mismatchDescription);
    }
}
 
開發者ID:auth0,項目名稱:Guardian.java,代碼行數:18,代碼來源:RecordedRequestMatcher.java

示例9: hasMeasurementPeriodInMillis

import org.hamcrest.Description; //導入方法依賴的package包/類
private static TypeSafeMatcher<IncreaseOverTimeFrameUsageThresholdCondition>
    hasMeasurementPeriodInMillis(final long millis) {
  return new TypeSafeMatcher<IncreaseOverTimeFrameUsageThresholdCondition>() {
    @Override
    protected boolean matchesSafely(
        IncreaseOverTimeFrameUsageThresholdCondition condition) {
      return millis == condition.measurementPeriod;
    }

    @Override
    public void describeTo(Description description) {
      description.appendText("has a measurement period of '" + millis + "' millis");
    }
  };
}
 
開發者ID:SAP,項目名稱:java-memory-assistant,代碼行數:16,代碼來源:IncreaseOverTimeFrameThresholdConditionTest.java

示例10: withDisconnectedHost

import org.hamcrest.Description; //導入方法依賴的package包/類
@NonNull
public static Matcher<RecyclerView.ViewHolder> withDisconnectedHost() {
	return new BoundedMatcher<RecyclerView.ViewHolder, HostListActivity.HostViewHolder>(HostListActivity.HostViewHolder.class) {
		@Override
		public boolean matchesSafely(HostListActivity.HostViewHolder holder) {
			return hasDrawableState(holder.icon, android.R.attr.state_expanded);
		}

		@Override
		public void describeTo(Description description) {
			description.appendText("is disconnected status");
		}
	};
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:15,代碼來源:ConnectbotMatchers.java

示例11: describeTo

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
public void describeTo(Description description) {
    description.appendText(reason);
}
 
開發者ID:shlee89,項目名稱:athena,代碼行數:5,代碼來源:MulticastRouteResourceTest.java

示例12: describeTo

import org.hamcrest.Description; //導入方法依賴的package包/類
public void describeTo(Description description) {
    description.appendText("an Object with the same fields as " + toMatch);
}
 
開發者ID:lxxlxx888,項目名稱:Reer,代碼行數:4,代碼來源:ReflectionEqualsMatcher.java

示例13: describeTo

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
public void describeTo(Description description) {
  description
      .appendText("SagaEvent {sagaId=" + sagaId + ", operation=" + operation + ", class=" + aClass.getCanonicalName());
}
 
開發者ID:apache,項目名稱:incubator-servicecomb-saga,代碼行數:6,代碼來源:SagaEventMatcher.java

示例14: describeTo

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
public void describeTo(final Description description) {
	description.appendText("a Success");
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:5,代碼來源:SuccessTry.java

示例15: matchesSafely

import org.hamcrest.Description; //導入方法依賴的package包/類
@Override
protected boolean matchesSafely(
	final FunctionalList<E> functionalList, final Description description) {

	E head = functionalList.head();

	Stream<E> stream = Stream.concat(
		Stream.of(head), functionalList.tailStream());

	List<E> list = stream.collect(Collectors.toList());

	if (_matcher.matches(list)) {
		return true;
	}

	description.appendText("was a functional list whose ");

	_matcher.describeMismatch(list, description);

	return false;
}
 
開發者ID:liferay,項目名稱:com-liferay-apio-architect,代碼行數:22,代碼來源:IsAFunctionalList.java


注:本文中的org.hamcrest.Description.appendText方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。