本文整理匯總了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")
);
}
示例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));
}
示例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));
}
示例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")
);
}
示例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")
);
}
示例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")
);
}
示例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))
);
}
示例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")
);
}
示例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());
}
示例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));
}
示例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))
);
}
示例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)
);
}
示例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)
);
}
示例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));
}
示例15: testActualPeta
import org.hamcrest.MatcherAssert; //導入方法依賴的package包/類
public void testActualPeta() {
MatcherAssert.assertThat(new ByteSizeValue(4, ByteSizeUnit.PB).getBytes(), equalTo(4503599627370496L));
}