本文整理了Java中org.assertj.core.api.Assertions.extractProperty()
方法的一些代码示例,展示了Assertions.extractProperty()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Assertions.extractProperty()
方法的具体详情如下:
包路径:org.assertj.core.api.Assertions
类名称:Assertions
方法名:extractProperty
[英]Only delegate to Properties#extractProperty(String) so that Assertions offers a full feature entry point to all AssertJ features (but you can use Properties if you prefer).
Typical usage is to chain extractProperty
with from
method, see examples below :
// extract simple property values, as no type has been defined the extracted property will be considered as Object
// to define the real property type (here String) use extractProperty("name", String.class) instead.
assertThat(extractProperty("name").from(fellowshipOfTheRing))
.contains("Boromir", "Gandalf", "Frodo", "Legolas")
.doesNotContain("Sauron", "Elrond");
// extracting property works also with user's types (here Race), even though it will be considered as Object
// to define the real property type (here String) use extractProperty("name", Race.class) instead.
assertThat(extractProperty("race").from(fellowshipOfTheRing)).contains(HOBBIT, ELF).doesNotContain(ORC);
// extract nested property on Race
assertThat(extractProperty("race.name").from(fellowshipOfTheRing)).contains("Hobbit", "Elf").doesNotContain("Orc");
[中]仅委托给属性#extractProperty(String),这样断言就为所有AssertJ功能提供了完整的功能入口点(但如果愿意,您可以使用属性)。
典型用法是使用from
方法链接extractProperty
,请参见以下示例:
// extract simple property values, as no type has been defined the extracted property will be considered as Object
// to define the real property type (here String) use extractProperty("name", String.class) instead.
assertThat(extractProperty("name").from(fellowshipOfTheRing))
.contains("Boromir", "Gandalf", "Frodo", "Legolas")
.doesNotContain("Sauron", "Elrond");
// extracting property works also with user's types (here Race), even though it will be considered as Object
// to define the real property type (here String) use extractProperty("name", Race.class) instead.
assertThat(extractProperty("race").from(fellowshipOfTheRing)).contains(HOBBIT, ELF).doesNotContain(ORC);
// extract nested property on Race
assertThat(extractProperty("race.name").from(fellowshipOfTheRing)).contains("Hobbit", "Elf").doesNotContain("Orc");
代码示例来源:origin: org.assertj/assertj-core
/**
* Only delegate to {@link Properties#extractProperty(String)} so that Assertions offers a full feature entry point
* to
* all AssertJ features (but you can use {@link Properties} if you prefer).
* <p>
* Typical usage is to chain <code>extractProperty</code> with <code>from</code> method, see examples below :
*
* <pre><code class='java'> // extract simple property values, as no type has been defined the extracted property will be considered as Object
* // to define the real property type (here String) use extractProperty("name", String.class) instead.
* assertThat(extractProperty("name").from(fellowshipOfTheRing))
* .contains("Boromir", "Gandalf", "Frodo", "Legolas")
* .doesNotContain("Sauron", "Elrond");
*
* // extracting property works also with user's types (here Race), even though it will be considered as Object
* // to define the real property type (here String) use extractProperty("name", Race.class) instead.
* assertThat(extractProperty("race").from(fellowshipOfTheRing)).contains(HOBBIT, ELF).doesNotContain(ORC);
*
* // extract nested property on Race
* assertThat(extractProperty("race.name").from(fellowshipOfTheRing)).contains("Hobbit", "Elf").doesNotContain("Orc"); </code></pre>
*
* @param propertyName the name of the property to be read from the elements of a {@code Iterable}. It may be a nested
* property (e.g. "address.street.number").
* @throws NullPointerException if the given property name is {@code null}.
* @throws IllegalArgumentException if the given property name is empty.
* @return the created {@code Properties}.
*/
default Properties<Object> extractProperty(final String propertyName) {
return Assertions.extractProperty(propertyName);
}
代码示例来源:origin: org.assertj/assertj-core
return Assertions.extractProperty(propertyName, propertyType);
代码示例来源:origin: joel-costigliola/assertj-core
return Assertions.extractProperty(propertyName, propertyType);
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Only delegate to {@link Properties#extractProperty(String)} so that Assertions offers a full feature entry point
* to
* all AssertJ features (but you can use {@link Properties} if you prefer).
* <p>
* Typical usage is to chain <code>extractProperty</code> with <code>from</code> method, see examples below :
*
* <pre><code class='java'> // extract simple property values, as no type has been defined the extracted property will be considered as Object
* // to define the real property type (here String) use extractProperty("name", String.class) instead.
* assertThat(extractProperty("name").from(fellowshipOfTheRing))
* .contains("Boromir", "Gandalf", "Frodo", "Legolas")
* .doesNotContain("Sauron", "Elrond");
*
* // extracting property works also with user's types (here Race), even though it will be considered as Object
* // to define the real property type (here String) use extractProperty("name", Race.class) instead.
* assertThat(extractProperty("race").from(fellowshipOfTheRing)).contains(HOBBIT, ELF).doesNotContain(ORC);
*
* // extract nested property on Race
* assertThat(extractProperty("race.name").from(fellowshipOfTheRing)).contains("Hobbit", "Elf").doesNotContain("Orc"); </code></pre>
*
* @param propertyName the name of the property to be read from the elements of a {@code Iterable}. It may be a nested
* property (e.g. "address.street.number").
* @throws NullPointerException if the given property name is {@code null}.
* @throws IllegalArgumentException if the given property name is empty.
* @return the created {@code Properties}.
*/
default Properties<Object> extractProperty(final String propertyName) {
return Assertions.extractProperty(propertyName);
}
代码示例来源:origin: org.assertj/assertj-core-java8
/**
* Delegate call to {@link org.assertj.core.api.Assertions#extractProperty(String,Class)}
*/
default public <T> Properties<T> extractProperty(final String propertyName, final Class<T> propertyType) {
return Assertions.extractProperty(propertyName, propertyType);
}
代码示例来源:origin: org.assertj/assertj-core-java8
/**
* Delegate call to {@link org.assertj.core.api.Assertions#extractProperty(String)}
*/
default public Properties<Object> extractProperty(final String propertyName) {
return Assertions.extractProperty(propertyName);
}
内容来源于网络,如有侵权,请联系作者删除!