本文整理了Java中org.assertj.core.api.ListAssert.matches()
方法的一些代码示例,展示了ListAssert.matches()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ListAssert.matches()
方法的具体详情如下:
包路径:org.assertj.core.api.ListAssert
类名称:ListAssert
方法名:matches
暂无
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fetchAllAsJson_withMapper() throws Exception {
final CompletionStage<List<JsonNode>> categoryPagesStage = QueryExecutionUtils
.queryAll(client(), JsonNodeQuery.of("/categories"), category -> category, 500);
final List<JsonNode> categoryNodes = SphereClientUtils
.blockingWait(categoryPagesStage, Duration.ofMinutes(1));
assertThat(categoryNodes)
.hasSize(15)
.matches(cats -> cats.parallelStream()
.anyMatch(cat -> cat.get("slug").get("en").asText().equals("boots-women")));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fetchAllAsJson() throws Exception {
final CompletionStage<List<JsonNode>> categoriesStage = QueryExecutionUtils.queryAll(client(), JsonNodeQuery.of("/categories"), 500);
final List<JsonNode> categories = SphereClientUtils.blockingWait(categoriesStage, Duration.ofMinutes(1));
assertThat(categories)
.hasSize(15)
.matches(cats -> cats.parallelStream().anyMatch(cat -> cat.get("slug").get("en").asText().equals("boots-women")));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fetchAll() throws Exception {
final CompletionStage<List<Category>> categoriesStage = QueryExecutionUtils.queryAll(client(), CategoryQuery.of(), 500);
final List<Category> categories = SphereClientUtils.blockingWait(categoriesStage, Duration.ofMinutes(1));
assertThat(categories)
.hasSize(15)
.matches(cats -> cats.parallelStream().anyMatch(cat -> cat.getSlug().get(ENGLISH).equals("boots-women")));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fetchAll_withMapper() throws Exception {
final CompletionStage<List<Category>> categoriesStage = QueryExecutionUtils
.queryAll(client(), CategoryQuery.of(), category -> category, 500);
final List<Category> categories = SphereClientUtils
.blockingWait(categoriesStage, Duration.ofMinutes(1));
assertThat(categories)
.hasSize(15)
.matches(cats -> cats.parallelStream().anyMatch(cat -> cat.getSlug().get(ENGLISH).equals("boots-women")));
}
代码示例来源:origin: opencypher/cypher-for-gremlin
@Test
public void returnDuplicateNode() throws Exception {
submitAndGet(
"CREATE (x:root)-[:r]->(y)\n" +
"CREATE (x)-[:r]->(z)"
);
List<Map<String, Object>> results = submitAndGet(
"MATCH (x:root)-[:r]->()\n" +
"RETURN x"
);
List<Map<String, Object>> distinctResults = submitAndGet(
"MATCH (x:root)-[:r]->()\n" +
"RETURN DISTINCT x"
);
assertThat(results)
.hasSize(2)
.matches(rows -> {
Object first = rows.get(0);
Object second = rows.get(1);
return Objects.equals(first, second);
});
assertThat(distinctResults)
.hasSize(1)
.extracting("x")
.extracting(LABEL)
.containsExactly("root");
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fuzzySearch() {
final ProductProjectionSearch search = ProductProjectionSearch.ofStaged()
.withText(ENGLISH, "short")
.withQueryFilters(productModel -> productModel.productType().id().is(productType.getId()));
assertEventually(Duration.ofSeconds(45), Duration.ofMillis(200), () ->
assertThat(client().executeBlocking(search).getResults()).matches(containsIdentifiable(product2).negate(), "not included"));
assertEventually(Duration.ofSeconds(45), Duration.ofMillis(200), () ->
assertThat(client().executeBlocking(search.withFuzzy(true)).getResults()).matches(containsIdentifiable(product2), "included"));
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void addTaxRate() {
withUpdateableTaxCategory(client(), taxCategory -> {
//add tax rate
final String name = "ag7";
final CountryCode countryCode = CountryCode.AG;
final TaxRateDraft de7 = TaxRateDraftBuilder.of(name, 0.07, true, countryCode).build();
final TaxCategory taxCategoryWithTaRate = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategory, AddTaxRate.of(de7)));
final TaxRate actual = taxCategoryWithTaRate.getTaxRates().stream().filter(rate -> name.equals(rate.getName())).findFirst().get();
assertThat(actual.getCountry()).isEqualTo(countryCode);
assertThat(actual.getAmount()).isEqualTo(0.07);
assertThat(actual.getId())
.overridingErrorMessage("the tax rate fetched from API has an id")
.isNotNull();
assertThat(actual.getName()).isEqualTo(de7.getName());
//remove tax rate
final TaxCategory updatedTaxCategory = client().executeBlocking(TaxCategoryUpdateCommand.of(taxCategoryWithTaRate, RemoveTaxRate.of(actual.getId())));
assertThat(updatedTaxCategory.getTaxRates()).matches(rates -> !rates.stream().anyMatch(rate -> name.equals(rate.getName())));
return updatedTaxCategory;
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void suggestionForMultipleLanguages() {
withSuggestProduct(client(), product -> {
final SearchKeywords searchKeywords = SearchKeywords.of(
Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"),
SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())),
Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer",
CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser"))))
);
assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords);
final List<LocalizedStringEntry> keywords = asList(
LocalizedStringEntry.of(Locale.GERMAN, "offiz"),
LocalizedStringEntry.of(Locale.ENGLISH, "multi")
);
final SuggestQuery suggestQuery = SuggestQuery.of(keywords)
.withStaged(true);
assertEventually(() -> {
final SuggestionResult suggestionResult = client().executeBlocking(suggestQuery);
assertThat(suggestionResult.getSuggestionsForLocale(Locale.GERMAN))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Schweizer Messer")));
assertThat(suggestionResult.getSuggestionsForLocale(Locale.ENGLISH))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Multi tool")));
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void executionWithCustomTokenizer() {
withSuggestProduct(client(), product -> {
final SearchKeywords searchKeywords = SearchKeywords.of(
Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"),
SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())),
Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer",
CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser"))))
);
assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords);
final SuggestQuery suggestQuery = SuggestQuery.of(LocalizedStringEntry.of(Locale.GERMAN, "offiz"))
.withStaged(true);
assertEventually(() -> {
final SuggestionResult suggestionResult = client().executeBlocking(suggestQuery);
assertThat(suggestionResult.getSuggestionsForLocale(Locale.GERMAN))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Schweizer Messer")));
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void execution() {
withSuggestProduct(client(), product -> {
final SearchKeywords searchKeywords = SearchKeywords.of(
Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"),
SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())),
Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer",
CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser"))))
);
assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords);
final SuggestQuery suggestQuery = SuggestQuery.of(LocalizedStringEntry.of(Locale.ENGLISH, "knife"))
.withStaged(true);
assertEventually(() -> {
final SuggestionResult suggestionResult = client().executeBlocking(suggestQuery);
assertThat(suggestionResult.getSuggestionsForLocale(Locale.ENGLISH))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Swiss Army Knife")));
});
});
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
@Test
public void fuzzy() {
withSuggestProduct(client(), product -> {
final SearchKeywords searchKeywords = SearchKeywords.of(
Locale.ENGLISH, asList(SearchKeyword.of("Multi tool"),
SearchKeyword.of("Swiss Army Knife", WhiteSpaceSuggestTokenizer.of())),
Locale.GERMAN, singletonList(SearchKeyword.of("Schweizer Messer",
CustomSuggestTokenizer.of(asList("schweizer messer", "offiziersmesser", "sackmesser"))))
);
assertThat(product.getMasterData().getStaged().getSearchKeywords()).isEqualTo(searchKeywords);
final SuggestQuery suggestQuery = SuggestQuery.of(LocalizedStringEntry.of(Locale.ENGLISH, "knive"))
.withStaged(true).withFuzzy(true);
assertEventually(() -> {
final SuggestionResult suggestionResult = client().executeBlocking(suggestQuery);
assertThat(suggestionResult.getSuggestionsForLocale(Locale.ENGLISH))
.matches(suggestionsList -> suggestionsList.stream()
.anyMatch(suggestion -> suggestion.getText().equals("Swiss Army Knife")));
});
});
}
}
代码示例来源:origin: commercetools/commercetools-jvm-sdk
.hasSize(2)
.overridingErrorMessage("if a product is in a category, you can directy query for it")
.matches(elements -> elements.stream()
.anyMatch(product -> product.getCategories().contains(tshirtCategory.toReference())));
});
代码示例来源:origin: commercetools/commercetools-jvm-sdk
.matches(prices -> prices.stream().anyMatch(price -> price.getDiscounted() != null && price.getDiscounted().getDiscount().getObj() != null));
内容来源于网络,如有侵权,请联系作者删除!