本文整理了Java中org.assertj.core.groups.Tuple
类的一些代码示例,展示了Tuple
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Tuple
类的具体详情如下:
包路径:org.assertj.core.groups.Tuple
类名称:Tuple
暂无
代码示例来源:origin: org.assertj/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: org.assertj/assertj-core
public static Tuple tuple(Object... values) {
return new Tuple(values);
}
代码示例来源:origin: org.assertj/assertj-core
protected String toStringOf(Tuple tuple) {
return singleLineFormat(tuple.toList(), TUPLE_START, TUPLE_END);
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void do_not_copy_already_copied_data() throws SQLException {
String project = insertProject();
insertProjectLink("Name", "custom", "http://link", project);
insertProjectLink("Home", "homepage", "http://homepage", project);
insertProjectLink2("UUID1", "Name", "custom", "http://link", project, PAST);
insertProjectLink2("UUID2", null, "homepage", "http://homepage", project, PAST);
underTest.execute();
assertThat(db.select("SELECT UUID, NAME, LINK_TYPE, HREF, PROJECT_UUID, CREATED_AT FROM PROJECT_LINKS2")
.stream()
.map(map -> new Tuple(map.get("UUID"), map.get("NAME"), map.get("LINK_TYPE"), map.get("HREF"), map.get("PROJECT_UUID"), map.get("CREATED_AT")))
.collect(Collectors.toList()))
.containsExactlyInAnyOrder(
tuple("UUID1", "Name", "custom", "http://link", project, PAST),
tuple("UUID2", null, "homepage", "http://homepage", project, PAST));
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: joel-costigliola/assertj-core
public static Tuple tuple(Object... values) {
return new Tuple(values);
}
代码示例来源:origin: joel-costigliola/assertj-core
protected String toStringOf(Tuple tuple) {
return singleLineFormat(tuple.toList(), TUPLE_START, TUPLE_END);
}
代码示例来源:origin: org.assertj/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: org.assertj/assertj-core
public AbstractListAssert<?, List<? extends Tuple>, Tuple, ObjectAssert<Tuple>> extracting(@SuppressWarnings("unchecked") Function<ELEMENT, ?>... extractors) {
Function<ELEMENT, Tuple> tupleExtractor = objectToExtractValueFrom -> new Tuple(Stream.of(extractors)
.map(extractor -> extractor.apply(objectToExtractValueFrom))
.toArray());
代码示例来源:origin: org.assertj/assertj-core
/**
* Extract the given property/field values from each {@code Iterable}'s element and
* flatten the extracted values in a list that is used as the new object under test.
* <p>
* Given 2 properties, if the extracted values were not flattened, instead having a simple list like :
* <pre>element1.value1, element1.value2, element2.value1, element2.value2, ... </pre>
* ... we would get a list of list :
* <pre>list(element1.value1, element1.value2), list(element2.value1, element2.value2), ... </pre>
* <p>
* Code example:
* <pre><code class='java'> // fellowshipOfTheRing is a List<TolkienCharacter>
*
* // values are extracted in order and flattened : age1, name1, age2, name2, age3 ...
* assertThat(fellowshipOfTheRing).flatExtracting("age", "name")
* .contains(33 ,"Frodo",
* 1000, "Legolas",
* 87, "Aragorn");</code></pre>
*
* @param fieldOrPropertyNames the field and/or property names to extract from each actual {@code Iterable}'s element
* @return a new assertion object whose object under test is a flattened list of all extracted values.
* @throws IllegalArgumentException if fieldOrPropertyNames vararg is null or empty
* @since 2.5.0 / 3.5.0
*/
@CheckReturnValue
public AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> flatExtracting(String... fieldOrPropertyNames) {
List<Object> extractedValues = FieldsOrPropertiesExtractor.extract(actual, byName(fieldOrPropertyNames)).stream()
.flatMap(tuple -> tuple.toList().stream())
.collect(toList());
return newListAssertInstanceForMethodsChangingElementType(extractedValues);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: org.assertj/assertj-core
public AbstractListAssert<?, List<? extends Tuple>, Tuple, ObjectAssert<Tuple>> extracting(@SuppressWarnings("unchecked") Function<ELEMENT, ?>... extractors) {
Function<ELEMENT, Tuple> tupleExtractor = objectToExtractValueFrom -> new Tuple(Stream.of(extractors)
.map(extractor -> extractor.apply(objectToExtractValueFrom))
.toArray());
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Extract the given property/field values from each {@code Iterable}'s element and
* flatten the extracted values in a list that is used as the new object under test.
* <p>
* Given 2 properties, if the extracted values were not flattened, instead having a simple list like :
* <pre>element1.value1, element1.value2, element2.value1, element2.value2, ... </pre>
* ... we would get a list of list :
* <pre>list(element1.value1, element1.value2), list(element2.value1, element2.value2), ... </pre>
* <p>
* Code example:
* <pre><code class='java'> // fellowshipOfTheRing is a List<TolkienCharacter>
*
* // values are extracted in order and flattened : age1, name1, age2, name2, age3 ...
* assertThat(fellowshipOfTheRing).flatExtracting("age", "name")
* .contains(33 ,"Frodo",
* 1000, "Legolas",
* 87, "Aragorn");</code></pre>
*
* @param fieldOrPropertyNames the field and/or property names to extract from each actual {@code Iterable}'s element
* @return a new assertion object whose object under test is a flattened list of all extracted values.
* @throws IllegalArgumentException if fieldOrPropertyNames vararg is null or empty
* @since 2.5.0 / 3.5.0
*/
@CheckReturnValue
public AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> flatExtracting(String... fieldOrPropertyNames) {
List<Object> extractedValues = FieldsOrPropertiesExtractor.extract(actual, byName(fieldOrPropertyNames)).stream()
.flatMap(tuple -> tuple.toList().stream())
.collect(toList());
return newListAssertInstanceForMethodsChangingElementType(extractedValues);
}
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: SonarSource/sonarqube
private List<Tuple> selectAllQualityGates(String... columns) {
return db.select("SELECT UUID, NAME, IS_BUILT_IN, CREATED_AT, UPDATED_AT FROM QUALITY_GATES")
.stream()
.map(map -> new Tuple(Arrays.stream(columns).map(c -> map.get(c)).collect(toList()).toArray()))
.collect(toList());
}
代码示例来源:origin: joel-costigliola/assertj-core
String extractedPropertiesOrFieldsDescription = extractedDescriptionOf(propertiesOrFields);
String description = mostRelevantDescription(info.description(), extractedPropertiesOrFieldsDescription);
return newListAssertInstance(values.toList()).as(description);
代码示例来源:origin: joel-costigliola/assertj-core
/**
* Utility method to build nicely a {@link Tuple} when working with {@link IterableAssert#extracting(String...)} or
* {@link ObjectArrayAssert#extracting(String...)}
*
* @param values the values stored in the {@link Tuple}
* @return the built {@link Tuple}
*/
public static Tuple tuple(Object... values) {
return Tuple.tuple(values);
}
代码示例来源:origin: SonarSource/sonarqube
private void assertProjectLinks2(Tuple... expectedTuples) {
assertThat(db.select("SELECT NAME, LINK_TYPE, HREF, PROJECT_UUID, CREATED_AT, UPDATED_AT FROM PROJECT_LINKS2")
.stream()
.map(map -> new Tuple(map.get("NAME"), map.get("LINK_TYPE"), map.get("HREF"), map.get("PROJECT_UUID"), map.get("CREATED_AT"), map.get("UPDATED_AT")))
.collect(Collectors.toList()))
.containsExactlyInAnyOrder(expectedTuples);
}
代码示例来源:origin: joel-costigliola/assertj-core
public AbstractListAssert<?, List<? extends Object>, Object, ObjectAssert<Object>> flatExtracting(String... keys) {
Tuple values = byName(keys).apply(actual);
List<Object> valuesFlattened = flatten(values.toList());
String extractedPropertiesOrFieldsDescription = extractedDescriptionOf(keys);
String description = mostRelevantDescription(info.description(), extractedPropertiesOrFieldsDescription);
代码示例来源:origin: SonarSource/sonarqube
@Test
public void set_onboarded_to_true() throws SQLException {
insertUser("admin");
insertUser("user");
assertUsers(tuple("admin", false, PAST), tuple("user", false, PAST));
underTest.execute();
assertUsers(tuple("admin", true, NOW), tuple("user", true, NOW));
}
内容来源于网络,如有侵权,请联系作者删除!