当前位置: 首页>>代码示例>>Java>>正文


Java Description类代码示例

本文整理汇总了Java中org.hamcrest.Description的典型用法代码示例。如果您正苦于以下问题:Java Description类的具体用法?Java Description怎么用?Java Description使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


Description类属于org.hamcrest包,在下文中一共展示了Description类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: childAtPosition

import org.hamcrest.Description; //导入依赖的package包/类
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));
        }
    };
}
 
开发者ID:sumio,项目名称:espresso-sample-for-droidkaigi2017,代码行数:19,代码来源:Step3.java

示例2: 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

示例3: 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

示例4: getGraph

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * @return the graph
 */
public GWGraph getGraph() {
	if (graph==null) {
		 List<SWTBotGefEditPart> parts = editor.editParts(new BaseMatcher<EditPart>() {
			@Override
			public boolean matches(Object item) {
				if (item instanceof org.gw4e.eclipse.studio.part.editor.GraphPart) return true;
				if (item instanceof org.gw4e.eclipse.studio.part.editor.VertexPart) return true;
				if (item instanceof org.gw4e.eclipse.studio.part.editor.EdgePart) return true;
				return false;
			}
			@Override
			public void describeTo(Description description) {
			}
		});
		 
		if (parts==null || parts.size() ==0) {
			throw new RuntimeException("Empty Graph");
		}
		graph = getGraph (parts.get(0));	
	}
	return graph;
}
 
开发者ID:gw4e,项目名称:gw4e.project,代码行数:26,代码来源:Graph.java

示例5: withIndex

import org.hamcrest.Description; //导入依赖的package包/类
public static Matcher<View> withIndex(final Matcher<View> matcher, final int index) {
    return new TypeSafeMatcher<View>() {
        int currentIndex = 0;

        @Override
        public void describeTo(Description description) {
            description.appendText("with index: ");
            description.appendValue(index);
            matcher.describeTo(description);
        }

        @Override
        public boolean matchesSafely(View view) {
            return matcher.matches(view) && currentIndex++ == index;
        }
    };
}
 
开发者ID:cuplv,项目名称:ChimpCheck,代码行数:18,代码来源:MatchWithIndex.java

示例6: childAtPosition

import org.hamcrest.Description; //导入依赖的package包/类
public static org.hamcrest.Matcher<View> childAtPosition(
        final org.hamcrest.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));
        }
    };
}
 
开发者ID:mirhoseini,项目名称:bcg,代码行数:19,代码来源:Matcher.java

示例7: 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

示例8: hasItems

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * Checks if collection has the given number of items.
 */
public static Matcher<Collection<?>> hasItems(final int numberOfItems) {
    return new TypeSafeMatcher<Collection<?>>() {

        @Override
        public boolean matchesSafely(Collection<?> collection) {
            if (collection == null || collection.size() != numberOfItems) {
                return false;
            }
            return true;
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("expected a collection with "
                    + numberOfItems + " items");
        }

    };
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:23,代码来源:JavaMatchers.java

示例9: matchModVlanPcpInstruction

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * Matches the contents of a mod vlan pcp instruction.
 *
 * @param instructionJson JSON instruction to match
 * @param description Description object used for recording errors
 * @return true if contents match, false otherwise
 */
private boolean matchModVlanPcpInstruction(JsonNode instructionJson,
                                          Description description) {
    ModVlanPcpInstruction instructionToMatch =
            (ModVlanPcpInstruction) 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 short jsonVlanPcp = instructionJson.get("vlanPcp").shortValue();
    final short vlanId = instructionToMatch.vlanPcp();
    if (jsonVlanPcp != vlanId) {
        description.appendText("vlan pcp was " + jsonVlanPcp);
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:InstructionJsonMatcher.java

示例10: matchModMplsLabelInstruction

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * Matches the contents of a mod MPLS 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 matchModMplsLabelInstruction(JsonNode instructionJson,
                                      Description description) {
    ModMplsLabelInstruction instructionToMatch =
            (ModMplsLabelInstruction) 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 jsonLabel = instructionJson.get("label").intValue();
    final int label = instructionToMatch.label().toInt();
    if (label != jsonLabel) {
        description.appendText("MPLS label was " + jsonLabel);
        return false;
    }

    return true;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:33,代码来源:InstructionJsonMatcher.java

示例11: equalsVideoDataInCursor

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * Checks that the given {@code VideoLibraryModel.Video} is equal to the video data in the given
 * cursor table at the given {@code index}.
 */
private Matcher<VideoLibraryModel.Video> equalsVideoDataInCursor(final Object[][] cursorTable,
        final int index) {
    return new BaseMatcher<VideoLibraryModel.Video>() {
        @Override
        public boolean matches(final Object item) {
            final VideoLibraryModel.Video video = (VideoLibraryModel.Video) item;
            return video.getId().equals(cursorTable[VIDEO_ID_COLUMN_INDEX][index])
                    && video.getYear() == (Integer) cursorTable[VIDEO_YEAR_COLUMN_INDEX][index]
                    && video.getTopic().equals(cursorTable[VIDEO_TOPIC_COLUMN_INDEX][index])
                    && video.getTitle().equals(cursorTable[VIDEO_TITLE_COLUMN_INDEX][index])
                    && video.getDesc().equals(cursorTable[VIDEO_DESC_COLUMN_INDEX][index])
                    && video.getVid().equals(cursorTable[VIDEO_VID_COLUMN_INDEX][index])
                    && video.getSpeakers().equals(
                        cursorTable[VIDEO_SPEAKER_COLUMN_INDEX][index])
                    && video.getThumbnailUrl().equals(
                        cursorTable[VIDEO_THUMBNAIL_URL_COLUMN_INDEX][index]);
        }
        @Override
        public void describeTo(final Description description) {
            description.appendText("The Video does not match the data in table ")
                    .appendValue(cursorTable).appendText(" at index ").appendValue(index);
        }
    };
}
 
开发者ID:dreaminglion,项目名称:iosched-reader,代码行数:29,代码来源:VideoLibraryModelTest.java

示例12: isSameAs

import org.hamcrest.Description; //导入依赖的package包/类
public static Matcher<List<AuditLogEntry>> isSameAs(
        final List<AuditLog> auditLogs) {
    return new BaseMatcher<List<AuditLogEntry>>() {
        private int errorPosition;

        @Override
        public boolean matches(Object object) {
            List<AuditLogEntry> auditLogEntries = (List<AuditLogEntry>) object;

            assertEquals(auditLogEntries.size(), auditLogs.size());
            for (int i = 0; i < auditLogEntries.size(); i++) {
                errorPosition = i;
                compareAuditLogEntry(auditLogEntries.get(i),
                        auditLogs.get(i));
            }
            return true;
        }

        @Override
        public void describeTo(Description description) {
            description
                    .appendText("AuditLogEntry is not equal with AuditLog at position "
                            + errorPosition);
        }
    };
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:27,代码来源:AuditLogMatchers.java

示例13: matchesQueryParameter

import org.hamcrest.Description; //导入依赖的package包/类
private boolean matchesQueryParameter(RecordedRequest item, Description mismatchDescription) {
    String path = item.getPath();
    boolean hasQuery = path.indexOf("?") > 0;
    if (!hasQuery) {
        mismatchDescription.appendText(" query was empty");
        return false;
    }

    String query = path.substring(path.indexOf("?") + 1, path.length());
    String[] parameters = query.split("&");
    for (String p : parameters) {
        if (p.equals(String.format("%s=%s", first, second))) {
            return true;
        }
    }
    mismatchDescription.appendValueList("Query parameters were {", ", ", "}.", parameters);
    return false;
}
 
开发者ID:auth0,项目名称:Guardian.java,代码行数:19,代码来源:RecordedRequestMatcher.java

示例14: describeMismatchSafely

import org.hamcrest.Description; //导入依赖的package包/类
@Override
public void describeMismatchSafely(
    final MimeType item,
    final Description desc
) {
    try {
        desc.appendText("was param ")
            .appendDescriptionOf(
                new ParamDescription(
                    this.name,
                    item.params().get(this.name)
                )
            );
    } catch (final IOException err) {
        desc.appendText("was not set");
    }
}
 
开发者ID:g4s8,项目名称:mime,代码行数:18,代码来源:HmMimeHasParam.java

示例15: hasItemInArray

import org.hamcrest.Description; //导入依赖的package包/类
/**
 * 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");
        }

    };
}
 
开发者ID:servicecatalog,项目名称:oscm,代码行数:22,代码来源:JavaMatchers.java


注:本文中的org.hamcrest.Description类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。