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


Java MatcherAssert.assertThat方法代碼示例

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


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

示例1: returnsTaggedArchitects

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void returnsTaggedArchitects() {
    final ComdorYaml read = Mockito.mock(ComdorYaml.class);
    Mockito.when(read.taggedArchitects())
            .thenReturn("")
            .thenReturn("@amihaiemil")
            .thenReturn("@amihaiemil @joe or @jana");

    MatcherAssert.assertThat(
        new ComdorYamlRules(read).taggedArchitects(),
        Matchers.equalTo("")
    );

    final String tagged1 = new ComdorYamlRules(read).taggedArchitects();
    MatcherAssert.assertThat(
        tagged1, Matchers.equalTo("@amihaiemil")
    );

    final String tagged2 = new ComdorYamlRules(read).taggedArchitects();
    MatcherAssert.assertThat(
        tagged2, Matchers.equalTo("@amihaiemil @joe or @jana")
    );
}
 
開發者ID:amihaiemil,項目名稱:comdor,代碼行數:24,代碼來源:ComdorYamlRulesTestCase.java

示例2: knowsAdmin

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * JsonAuthenticated knows if the user is an admin.
 */
@Test
public void knowsAdmin() {
    final Authenticated auth = new JsonAuthenticated(
        Json.createObjectBuilder().add("admin", true).build()
    );
    MatcherAssert.assertThat(auth.admin(), Matchers.is(true));
}
 
開發者ID:decorators-squad,項目名稱:versioneye-api,代碼行數:11,代碼來源:JsonAuthenticatedTestCase.java

示例3: returnsSize

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * RtYamlSequence can return its size.
 */
@Test
public void returnsSize(){
    List<YamlNode> nodes = new LinkedList<>();
    nodes.add(new Scalar("test"));
    nodes.add(Mockito.mock(YamlMapping.class));
    nodes.add(new Scalar("mihai"));
    YamlSequence seq = new RtYamlSequence(nodes);
    MatcherAssert.assertThat(seq.size(), Matchers.is(3));
}
 
開發者ID:decorators-squad,項目名稱:camel,代碼行數:13,代碼來源:RtYamlSequenceTest.java

示例4: readsDocker

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * Reads the docker attribute.
 * @throws IOException If something goes wrong.
 */
@Test
public void readsDocker() throws IOException {
    final ComdorYaml comdor = new ComdorYamlInput(
        new ByteArrayInputStream(
            "docker: amihaiemil/java9".getBytes()
        )
    );
    MatcherAssert.assertThat(
        comdor.docker(), Matchers.equalTo("amihaiemil/java9")
    );
}
 
開發者ID:amihaiemil,項目名稱:comdor,代碼行數:16,代碼來源:ComdorYamlInputTestCase.java

示例5: repeatsCharText

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void repeatsCharText() {
    MatcherAssert.assertThat(
        "Can't repeats a char",
        // @checkstyle MagicNumber (1 line)
        new RepeatedText("A", 5),
        new TextHasString("AAAAA")
    );
}
 
開發者ID:yegor256,項目名稱:cactoos,代碼行數:10,代碼來源:RepeatedTextTest.java

示例6: trimsCommentsAtEndOfLineWithoutQuotes

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * NoCommentsYamlLine removes only comments and leave original string.
 */
@Test
public void trimsCommentsAtEndOfLineWithoutQuotes() {
    YamlLine noComments = new NoCommentsYamlLine(
        new RtYamlLine("  this isn't comment   #here is the comment", 1)
    );
    MatcherAssert.assertThat(
        noComments.trimmed(), Matchers.is("this isn't comment")
    );
}
 
開發者ID:decorators-squad,項目名稱:camel,代碼行數:13,代碼來源:NoCommentsYamlLineTest.java

示例7: addsPairOfYamlNodeString

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * RtYamlMappingBuilder can add a K:V pair of String and YamlNode.
 */
@Test
public void addsPairOfYamlNodeString() {
    YamlMappingBuilder mappingBuilder = new RtYamlMappingBuilder();
    YamlMappingBuilder withAdded = mappingBuilder.add(
        new Scalar("key"), "value"
    );
    MatcherAssert.assertThat(withAdded, Matchers.notNullValue());
    MatcherAssert.assertThat(
        mappingBuilder, Matchers.not(Matchers.is(withAdded))
    );
}
 
開發者ID:decorators-squad,項目名稱:camel,代碼行數:15,代碼來源:RtYamlMappingBuilderTest.java

示例8: splitTextWithTextRegex

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void splitTextWithTextRegex() throws Exception {
    MatcherAssert.assertThat(
        "Can't split an text with text regex",
        new SplitText(
            new TextOf("Split#OOP!"),
            "\\W+"
        ).iterator().next(),
        new TextHasString("Split")
    );
}
 
開發者ID:yegor256,項目名稱:cactoos,代碼行數:12,代碼來源:SplitTextTest.java

示例9: createsAndRemovesLocalContainer

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * RtDockerHost creates and removes a container from the local dockerd.
 * @throws Exception If something goes wrong.
 */
@Test
public void createsAndRemovesLocalContainer() throws Exception {
    final DockerHost host = new RtDockerHost().connect();
    final Container created = host.create("hello-world", "");
    MatcherAssert.assertThat(created, Matchers.notNullValue());
    MatcherAssert.assertThat(created.isStarted(), Matchers.is(false));
    host.remove(created.containerId());
}
 
開發者ID:amihaiemil,項目名稱:comdor,代碼行數:13,代碼來源:RtDockerHostITCase.java

示例10: iteratesOverOne

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * SimplifiedNotifications can iterate over a single notification.
 */
@Test
public void iteratesOverOne() {
    final Notifications notifs = new SimplifiedNotifications(
        Json.createArrayBuilder()
            .add(Json.createObjectBuilder().add("repoFullName", "mary/tesla").add("issueNumber", 458).build())
            .build()
            .toString()
    );
    int size = 0;
    for(final Notification n : notifs) {
        size++; 
    }
    MatcherAssert.assertThat(size, Matchers.is(1));
}
 
開發者ID:amihaiemil,項目名稱:comdor,代碼行數:18,代碼來源:SimplifiedNotificationsTestCase.java

示例11: addsPairOfYamlNodes

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
/**
 * RtYamlMappingBuilder can add a K:V pair of YamlNode.
 */
@Test
public void addsPairOfYamlNodes() {
    YamlMappingBuilder mappingBuilder = new RtYamlMappingBuilder();
    YamlMappingBuilder withAdded = mappingBuilder.add(
        new Scalar("key"), new Scalar("value")
    );
    MatcherAssert.assertThat(withAdded, Matchers.notNullValue());
    MatcherAssert.assertThat(
        mappingBuilder, Matchers.not(Matchers.is(withAdded))
    );
}
 
開發者ID:decorators-squad,項目名稱:camel,代碼行數:15,代碼來源:RtYamlMappingBuilderTest.java

示例12: makesDataAvailable

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void makesDataAvailable() throws IOException {
    final String content = "Hello,חבר!";
    MatcherAssert.assertThat(
        "Can't show that data is available",
        new InputOf(content).stream().available(),
        Matchers.greaterThan(0)
    );
}
 
開發者ID:yegor256,項目名稱:cactoos,代碼行數:10,代碼來源:InputOfTest.java

示例13: withDoubleCollection

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void withDoubleCollection() {
    MatcherAssert.assertThat(
        new AvgOf(
            new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4])
        ).intValue(),
        Matchers.equalTo(2)
    );
    MatcherAssert.assertThat(
        new AvgOf(
            new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4])
        ).longValue(),
        Matchers.equalTo(2L)
    );
    MatcherAssert.assertThat(
        new AvgOf(
            new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4])
        ).doubleValue(),
        Matchers.equalTo(2.5d)
    );
    MatcherAssert.assertThat(
        new AvgOf(
            new ListOf<>(1.0d, 2.0d, 3.0d, 4.0d).toArray(new Double[4])
        ).floatValue(),
        Matchers.equalTo(2.5f)
    );
}
 
開發者ID:yegor256,項目名稱:cactoos,代碼行數:28,代碼來源:AvgOfTest.java

示例14: test_hasOneOf_missingAnnotationParameters

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
@Test
public void test_hasOneOf_missingAnnotationParameters() {

    Element element = Mockito.mock(Element.class);

    ModifierMatcher modifierMatcher = Mockito.mock(ModifierMatcher.class);


    Mockito.when(modifierMatcher.checkForMatchingCharacteristic(element, Modifier.FINAL)).thenReturn(false);
    Mockito.when(modifierMatcher.checkForMatchingCharacteristic(element, Modifier.PUBLIC)).thenReturn(false);

    Matcher<Modifier> matcher = Mockito.mock(Matcher.class);
    Mockito.when(matcher.getMatcher()).thenReturn(modifierMatcher);


    GenericElementCharacteristicValidator<Modifier> unit = new GenericElementCharacteristicValidator<Modifier>(matcher, ValidatorMesssageEnum.MODIFIER);
    MatcherAssert.assertThat("Should always return true for non existing characteristics", unit.hasOneOf(element));
    MatcherAssert.assertThat("Should always return true for single null valued characteristics", unit.hasOneOf(element, null));
    MatcherAssert.assertThat("Should always return true for multiple nulll valued characteristics", unit.hasOneOf(element, null, null));


}
 
開發者ID:toolisticon,項目名稱:annotation-processor-toolkit,代碼行數:23,代碼來源:ModifierValidatorTest.java

示例15: testActualPeta

import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
public void testActualPeta() {
    MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.PB).getBytes(), equalTo(4503599627370496L));
}
 
開發者ID:justor,項目名稱:elasticsearch_my,代碼行數:4,代碼來源:ByteSizeValueTests.java


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