@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); }
@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); }
@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"); }
@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"); }
@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")); }
@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"); }
@Test public void testClean() { initializer.execute(); assertThat(rootWorkDir).exists(); assertThat(lock).exists(); assertThat(rootWorkDir.list()).containsOnly(DirectoryLock.LOCK_FILE_NAME); }
@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")); }
@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(); }
@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"); }
@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"); }
@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(); }
@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(); } }
@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"); }
@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"); }
@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()); }
@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()); }
@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"); } }
@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(); }
@Test public void build_query_minimal_properties() { ComponentQuery underTest = ComponentQuery.builder() .setQualifiers(PROJECT) .build(); assertThat(underTest.getNameOrKeyQuery()).isNull(); assertThat(underTest.getQualifiers()).containsOnly(PROJECT); }