本文整理了Java中org.assertj.core.api.AbstractListAssert.contains()
方法的一些代码示例,展示了AbstractListAssert.contains()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。AbstractListAssert.contains()
方法的具体详情如下:
包路径:org.assertj.core.api.AbstractListAssert
类名称:AbstractListAssert
方法名:contains
暂无
代码示例来源:origin: SonarSource/sonarqube
private void verifyDeleted(ComponentDto... projects) {
ArgumentCaptor<ComponentDto> argument = ArgumentCaptor.forClass(ComponentDto.class);
verify(componentCleanerService, times(projects.length)).delete(any(DbSession.class), argument.capture());
for (ComponentDto project : projects) {
assertThat(argument.getAllValues()).extracting(ComponentDto::uuid).contains(project.uuid());
}
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSingleDash() throws Exception {
String[] args = new String[]{"--copt",
"-b", "-",
"-a",
"-"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "a")).isTrue();
assertThat(getStringOption(evaluated, "b")).isEqualTo("-");
assertThat(getBooleanOption(evaluated, "c")).isTrue();
assertThat(evaluated.allArguments()).contains("-").hasSize(1);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSimpleLong() throws Exception {
String[] args = new String[]{"--enable-a",
"--bfile", "toast",
"foo", "bar"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "a")).isTrue();
assertThat(getStringOption(evaluated, "b")).isEqualTo("toast");
assertThat(getStringOption(evaluated, "bfile")).isEqualTo("toast");
assertThat(getBooleanOption(evaluated, "c")).isFalse();
assertThat(evaluated.allArguments()).contains("foo", "bar").hasSize(2);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testArgumentsInTheMiddle() throws Exception {
String[] args = new String[]{"-c",
"foobar",
"-b", "toast"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "c")).isTrue();
assertThat(getStringOption(evaluated, "b")).isEqualTo("toast");
assertThat(evaluated.allArguments()).contains("foobar").hasSize(1);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testSimpleShort() throws Exception {
String[] args = new String[]{
"-a",
"-b", "toast",
"foo", "bar"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "a")).isTrue();
assertThat(getStringOption(evaluated, "b")).isEqualTo("toast");
assertThat(getBooleanOption(evaluated, "c")).isFalse();
assertThat(evaluated.allArguments()).contains("foo", "bar").hasSize(2);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testBursting() throws Exception {
String[] args = new String[]{"-acbtoast", "foo", "bar"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "a")).isTrue();
assertThat(getBooleanOption(evaluated, "c")).isTrue();
assertThat(getStringOption(evaluated, "b")).isEqualTo("toast");
assertThat(evaluated.allArguments()).hasSize(2).contains("foo", "bar");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testUnrecognizedOptionWithBursting() throws Exception {
String[] args = new String[]{"-adbtoast", "foo", "bar"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(evaluated.allArguments()).contains("-adbtoast", "foo", "bar").hasSize(3);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testUnrecognizedOption() throws Exception {
String[] args = new String[]{"-a", "-d", "-b", "toast", "foo", "bar"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(evaluated.allArguments()).contains("-d", "foo", "bar").hasSize(3);
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testArguments() throws CLIException {
Option[] options = new Option[]{
new TypedOption<Boolean>().setShortName("f").setLongName("flag").setType(Boolean.class).setSingleValued(true)
};
cli.addOptions(Arrays.asList(options));
CommandLine evaluated = cli.parse(Arrays.asList("org.acme.Foo", "-f=no"));
assertThat(evaluated.allArguments()).contains("org.acme.Foo");
evaluated = cli.parse(Arrays.asList("-f=no", "org.acme.Foo"));
assertThat(evaluated.allArguments()).contains("org.acme.Foo");
evaluated = cli.parse(Arrays.asList("-f=no", "org.acme.Foo", "bar"));
assertThat(evaluated.allArguments()).contains("org.acme.Foo", "bar");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testDoubleDash1() throws Exception {
String[] args = new String[]{
"--copt",
"--",
"-b", "toast"};
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(getBooleanOption(evaluated, "c")).isTrue();
assertThat(getStringOption(evaluated, "b")).isNull();
assertThat(evaluated.allArguments()).hasSize(2).contains("-b", "toast");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectByOwnerId() {
when(uuidFactory.create()).thenReturn(A_UUID);
when(system2.now()).thenReturn(DATE);
underTest.insertOrUpdate(dbSession, GITHUB, A_OWNER, true, AN_INSTALL, null);
assertThat(underTest.selectByOwnerId(dbSession, GITHUB, A_OWNER).get())
.extracting(AlmAppInstallDto::getUuid, AlmAppInstallDto::getAlm, AlmAppInstallDto::getInstallId, AlmAppInstallDto::getOwnerId,
AlmAppInstallDto::getCreatedAt, AlmAppInstallDto::getUpdatedAt)
.contains(A_UUID, GITHUB, A_OWNER, AN_INSTALL, DATE, DATE);
assertThat(underTest.selectByOwnerId(dbSession, BITBUCKETCLOUD, A_OWNER)).isNotPresent();
assertThat(underTest.selectByOwnerId(dbSession, GITHUB, "Unknown owner")).isNotPresent();
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void toSystemInfoSection() {
JvmStateSection underTest = new JvmStateSection(PROCESS_NAME);
ProtobufSystemInfo.Section section = underTest.toProtobuf();
assertThat(section.getName()).isEqualTo(PROCESS_NAME);
assertThat(section.getAttributesCount()).isGreaterThan(0);
assertThat(section.getAttributesList()).extracting("key")
.contains(
"Max Memory (MB)", "Free Memory (MB)",
"Heap Max (MB)",
"System Load Average", "Threads");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testUnknownOption() throws CLIException {
Option[] options = new Option[]{
new TypedOption<Boolean>().setShortName("f").setLongName("flag")
.setType(Boolean.class).setRequired(true).setSingleValued(true)
};
cli.addOptions(Arrays.asList(options));
CommandLine evaluated = cli.parse(Arrays.asList("-flag=true", "-unknown=x"));
assertThat(evaluated.allArguments()).contains("-unknown=x");
}
代码示例来源:origin: eclipse-vertx/vert.x
@Test
public void testMultiValues() throws Exception {
String[] args = new String[]{"-e", "one", "two", "-f", "1"};
TypedOption<String> e = new TypedOption<String>().setShortName("e")
.setMultiValued(true).setType(String.class);
TypedOption<Integer> f = new TypedOption<Integer>().setShortName("f")
.setMultiValued(true).setType(Integer.class);
cli.addOption(e).addOption(f);
CommandLine evaluated = cli.parse(Arrays.asList(args));
assertThat(evaluated.getOptionValues("e")).contains("one", "two").hasSize(2);
assertThat(evaluated.getOptionValues("f")).contains(1).hasSize(1);
}
代码示例来源:origin: SonarSource/sonarqube
private void assertThatComponentHasName(ComponentDto component, String expectedName) {
SearchHit[] hits = es.client()
.prepareSearch(INDEX_TYPE_COMPONENT)
.setQuery(matchQuery(SORTABLE_ANALYZER.subField(FIELD_NAME), expectedName))
.get()
.getHits()
.getHits();
assertThat(hits)
.extracting(SearchHit::getId)
.contains(component.uuid());
}
}
代码示例来源:origin: SonarSource/sonarqube
private void assertThatProjectHasTag(ComponentDto project, String expectedTag) {
SearchRequestBuilder request = es.client()
.prepareSearch(INDEX_TYPE_PROJECT_MEASURES)
.setQuery(boolQuery().filter(termQuery(FIELD_TAGS, expectedTag)));
assertThat(request.get().getHits().getHits())
.extracting(SearchHit::getId)
.contains(project.uuid());
}
代码示例来源:origin: json-path/JsonPath
@Test
public void cached_path_with_predicates() {
Filter feq = Filter.filter(Criteria.where("category").eq("reference"));
Filter fne = Filter.filter(Criteria.where("category").ne("reference"));
DocumentContext JsonDoc = JsonPath.parse(JSON_DOCUMENT);
List<String> eq = JsonDoc.read("$.store.book[?].category", feq);
List<String> ne = JsonDoc.read("$.store.book[?].category", fne);
Assertions.assertThat(eq).contains("reference");
Assertions.assertThat(ne).doesNotContain("reference");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void selectMeasure_map_fields() {
MetricDto metric = db.measures().insertMetric();
ComponentDto project = db.components().insertPrivateProject();
ComponentDto file = db.components().insertComponent(newFileDto(project));
underTest.insert(db.getSession(), newLiveMeasure(file, metric).setValue(3.14).setVariation(0.1).setData("text_value"));
LiveMeasureDto result = underTest.selectMeasure(db.getSession(), file.uuid(), metric.getKey()).orElseThrow(() -> new IllegalArgumentException("Measure not found"));
assertThat(result).as("Fail to map fields of %s", result.toString()).extracting(
LiveMeasureDto::getProjectUuid, LiveMeasureDto::getComponentUuid, LiveMeasureDto::getMetricId, LiveMeasureDto::getValue, LiveMeasureDto::getVariation,
LiveMeasureDto::getDataAsString, LiveMeasureDto::getTextValue)
.contains(project.uuid(), file.uuid(), metric.getId(), 3.14, 0.1, "text_value", "text_value");
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void should_include_selected_matching_tag_in_facet() {
RuleDefinitionDto rule = db.rules().insert(setSystemTags("tag1", "tag2", "tag3", "tag4", "tag5", "tag6", "tag7", "tag8", "tag9", "tagA", "x"));
indexRules();
SearchResponse result = ws.newRequest()
.setParam("facets", "tags")
.setParam("tags", "x")
.executeProtobuf(SearchResponse.class);
assertThat(result.getFacets().getFacets(0).getValuesList()).extracting(v -> entry(v.getVal(), v.getCount())).contains(entry("x", 1L));
}
代码示例来源:origin: SonarSource/sonarqube
@Test
public void list_global_webhooks() {
WebhookDto dto1 = webhookDbTester.insertWebhook(db.getDefaultOrganization());
WebhookDto dto2 = webhookDbTester.insertWebhook(db.getDefaultOrganization());
userSession.logIn().addPermission(ADMINISTER, db.getDefaultOrganization().getUuid());
ListResponse response = wsActionTester.newRequest()
.executeProtobuf(ListResponse.class);
assertThat(response.getWebhooksList())
.extracting(Webhooks.ListResponseElement::getName, Webhooks.ListResponseElement::getUrl)
.contains(tuple(dto1.getName(), dto1.getUrl()),
tuple(dto2.getName(), dto2.getUrl()));
}
内容来源于网络,如有侵权,请联系作者删除!