org.assertj.core.api.ObjectArrayAssert.containsOnly()方法的使用及代码示例

x33g5p2x  于2022-01-25 转载在 其他  
字(8.8k)|赞(0)|评价(0)|浏览(114)

本文整理了Java中org.assertj.core.api.ObjectArrayAssert.containsOnly()方法的一些代码示例,展示了ObjectArrayAssert.containsOnly()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。ObjectArrayAssert.containsOnly()方法的具体详情如下:
包路径:org.assertj.core.api.ObjectArrayAssert
类名称:ObjectArrayAssert
方法名:containsOnly

ObjectArrayAssert.containsOnly介绍

暂无

代码示例

代码示例来源:origin: SonarSource/sonarqube

@Test
public void check_output_metric_key_is_lines() {
 assertThat(LONG_SUM_FORMULA.getOutputMetricKeys()).containsOnly(LINES_KEY);
 assertThat(LONG_SUM_FORMULA_DEFAULT_INPUT_VALUE_15.getOutputMetricKeys()).containsOnly(LINES_KEY);
 assertThat(LONG_SUM_FORMULA_NULL_DEFAULT_INPUT_VALUE.getOutputMetricKeys()).containsOnly(LINES_KEY);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void check_output_metric_key_is_lines() {
 assertThat(INT_SUM_FORMULA.getOutputMetricKeys()).containsOnly(LINES_KEY);
 assertThat(INT_SUM_FORMULA_DEFAULT_INPUT_VALUE_15.getOutputMetricKeys()).containsOnly(LINES_KEY);
 assertThat(INT_SUM_FORMULA_NULL_DEFAULT_INPUT_VALUE.getOutputMetricKeys()).containsOnly(LINES_KEY);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldGetList() {
 Map<String, String> props = new HashMap<>();
 props.put("prop", "  foo  ,,  bar  , toto,tutu");
 assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldGetListWithComma() {
 Map<String, String> props = new HashMap<>();
 props.put("prop", "\"foo,bar\",  toto,tutu");
 assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo,bar", "toto", "tutu");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void unzipping_stream_extracts_subset_of_files() throws IOException {
 InputStream zip = urlToZip().openStream();
 File toDir = temp.newFolder();
 ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt"));
 assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt"));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_load_values_of_deprecated_key() {
 Settings settings = new MapSettings(definitions);
 settings.setProperty("oldKey", "a,b");
 assertThat(settings.getStringArray("newKey")).containsOnly("a", "b");
 assertThat(settings.getStringArray("oldKey")).containsOnly("a", "b");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void testClean() {
 initializer.execute();
 assertThat(rootWorkDir).exists();
 assertThat(lock).exists();
 assertThat(rootWorkDir.list()).containsOnly(DirectoryLock.LOCK_FILE_NAME);
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void unzipping_file_extracts_subset_of_files() throws IOException {
 File zip = FileUtils.toFile(urlToZip());
 File toDir = temp.newFolder();
 ZipUtils.unzip(zip, toDir, (ZipUtils.ZipEntryFilter)ze -> ze.getName().equals("foo.txt"));
 assertThat(toDir.listFiles()).containsOnly(new File(toDir, "foo.txt"));
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_get_suffixes() {
 Languages languages = new Languages(
   language("java", "java"),
   language("php", "php4", "php5"));
 assertThat(languages.getSuffixes()).containsOnly("java", "php4", "php5");
 assertThat(languages.getSuffixes("java")).containsOnly("java");
 assertThat(languages.getSuffixes("php")).containsOnly("php4", "php5");
 assertThat(languages.getSuffixes("xxx")).isEmpty();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void shouldGetListFromFile() throws IOException {
 String filePath = "shouldGetList/foo.properties";
 Map<String, String> props = loadPropsFromFile(filePath);
 assertThat(ProjectReactorBuilder.getListFromProperty(props, "prop")).containsOnly("foo", "bar", "toto", "tutu");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void load_inclusions() {
 MapSettings settings = new MapSettings();
 settings.setProperty(CoreProperties.PROJECT_INCLUSIONS_PROPERTY, "**/*Foo.java");
 settings.setProperty(CoreProperties.PROJECT_TEST_INCLUSIONS_PROPERTY, "**/*FooTest.java");
 FileExclusions moduleExclusions = new FileExclusions(settings.asConfig());
 assertThat(moduleExclusions.sourceInclusions()).containsOnly("**/*Foo.java");
 assertThat(moduleExclusions.testInclusions()).containsOnly("**/*FooTest.java");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_init_and_destroy_filters() throws Exception {
 ServletFilter filter = createMockFilter();
 FilterConfig config = mock(FilterConfig.class);
 MasterServletFilter master = new MasterServletFilter();
 master.init(config, singletonList(filter));
 assertThat(master.getFilters()).containsOnly(filter);
 verify(filter).init(config);
 master.destroy();
 verify(filter).destroy();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void get_string_array_value() throws Exception {
  underTest.setValue("key", "value1,value2");

  assertThat(underTest.getStringArray("key")).containsOnly("value1", "value2");
  assertThat(underTest.getStringArray("unknown")).isEmpty();
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_download_source_from_ws_if_preview_mode() {
 WsTestUtil.mockReader(wsClient, new StringReader("ae12\n\n43fb"));
 ServerLineHashesLoader lastSnapshots = new DefaultServerLineHashesLoader(wsClient);
 String[] hashes = lastSnapshots.getLineHashes("myproject:org/foo/Bar.c");
 assertThat(hashes).containsOnly("ae12", "", "43fb");
 WsTestUtil.verifyCall(wsClient, "/api/sources/hash?key=myproject%3Aorg%2Ffoo%2FBar.c");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void should_download_source_with_space_from_ws_if_preview_mode() {
 WsTestUtil.mockReader(wsClient, new StringReader("ae12\n\n43fb"));
 ServerLineHashesLoader lastSnapshots = new DefaultServerLineHashesLoader(wsClient);
 String[] hashes = lastSnapshots.getLineHashes("myproject:org/foo/Foo Bar.c");
 assertThat(hashes).containsOnly("ae12", "", "43fb");
 WsTestUtil.verifyCall(wsClient, "/api/sources/hash?key=myproject%3Aorg%2Ffoo%2FFoo+Bar.c");
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void uninstall() throws Exception {
 File installedJar = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File uninstallDir = temp.newFolder("uninstallDir");
 underTest.start();
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 underTest.uninstall("testbase", uninstallDir);
 assertThat(installedJar).doesNotExist();
 // still up. Will be dropped after next startup
 assertThat(underTest.getPluginInfosByKeys()).containsOnlyKeys("testbase");
 assertThat(uninstallDir.list()).containsOnly(installedJar.getName());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void uninstall_dependents() throws Exception {
 File base = copyTestPluginTo("test-base-plugin", fs.getInstalledPluginsDir());
 File extension = copyTestPluginTo("test-require-plugin", fs.getInstalledPluginsDir());
 File uninstallDir = temp.newFolder("uninstallDir");
 underTest.start();
 assertThat(underTest.getPluginInfos()).hasSize(2);
 underTest.uninstall("testbase", uninstallDir);
 assertThat(base).doesNotExist();
 assertThat(extension).doesNotExist();
 assertThat(uninstallDir.list()).containsOnly(base.getName(), extension.getName());
}

代码示例来源:origin: SonarSource/sonarqube

@Test
 public void load_exclusions() {
  MapSettings settings = new MapSettings();
  settings.setProperty(CoreProperties.PROJECT_EXCLUSIONS_PROPERTY, "**/*Foo.java");
  settings.setProperty(CoreProperties.PROJECT_TEST_EXCLUSIONS_PROPERTY, "**/*FooTest.java");
  FileExclusions moduleExclusions = new FileExclusions(settings.asConfig());

  assertThat(moduleExclusions.sourceInclusions()).isEmpty();
  assertThat(moduleExclusions.sourceExclusions()).containsOnly("**/*Foo.java");
  assertThat(moduleExclusions.testInclusions()).isEmpty();
  assertThat(moduleExclusions.testExclusions()).containsOnly("**/*FooTest.java");
 }
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void testTags() {
 Rule rule = Rule.create();
 assertThat(rule.getTags()).isEmpty();
 assertThat(rule.getSystemTags()).isEmpty();
 rule.setTags(new String[] {"tag1", "tag2"});
 assertThat(rule.getTags()).containsOnly("tag1", "tag2");
 assertThat(rule.getSystemTags()).isEmpty();
}

代码示例来源:origin: SonarSource/sonarqube

@Test
public void build_query_minimal_properties() {
 ComponentQuery underTest = ComponentQuery.builder()
  .setQualifiers(PROJECT)
  .build();
 assertThat(underTest.getNameOrKeyQuery()).isNull();
 assertThat(underTest.getQualifiers()).containsOnly(PROJECT);
}

相关文章