@Test public void write_content_when_closing_resource() throws IOException { underTest.write("content"); assertThat(writer.toString()).isEmpty(); underTest.close(); assertThat(writer.toString()).isEqualTo("content"); }
@Test public void load_source_hash_sequences() { when(sourceLinesHash.getLineHashesMatchingDBVersion(FILE)).thenReturn(Collections.singletonList("line")); Input<DefaultIssue> input = underTest.create(FILE); assertThat(input.getLineHashSequence()).isNotNull(); assertThat(input.getLineHashSequence().getHashForLine(1)).isEqualTo("line"); assertThat(input.getLineHashSequence().getHashForLine(2)).isEmpty(); assertThat(input.getLineHashSequence().getHashForLine(3)).isEmpty(); assertThat(input.getBlockHashSequence()).isNotNull(); }
@Test public void format_date_time_null_safe() { assertThat(DateUtils.formatDateTimeNullSafe(new Date())).startsWith("20"); assertThat(DateUtils.formatDateTimeNullSafe(new Date()).length()).isGreaterThan(20); assertThat(DateUtils.formatDateTimeNullSafe(null)).isEmpty(); }
@Test public void aggregate_empty_distribution() { RangeDistributionBuilder builder = new RangeDistributionBuilder(); String distribution = builder.build(); assertThat(distribution).isEmpty(); }
@Test public void return_empty_string_when_offset_is_empty() { assertThat(underTest.offsetToString(createTextRange(LINE_1, LINE_1, OFFSET_0, OFFSET_0), LINE_1, DEFAULT_LINE_LENGTH)) .isEmpty(); }
@Test public void param_as_input_stream() throws Exception { assertThat(underTest.paramAsInputStream("a_string")).isNull(); assertThat(IOUtils.toString(underTest.setParam("a_string", "").paramAsInputStream("a_string"))).isEmpty(); assertThat(IOUtils.toString(underTest.setParam("a_string", "foo").paramAsInputStream("a_string"))).isEqualTo("foo"); }
@Test public void triggers_cancel_for_downloads_and_uninstalls() throws Exception { userSessionRule.logIn().setSystemAdministrator(); underTest.handle(request, response); verify(pluginDownloader, times(1)).cancelDownloads(); verify(pluginUninstaller, times(1)).cancelUninstalls(); assertThat(response.outputAsString()).isEmpty(); }
@Test public void if_plugin_is_installed_uninstallation_is_triggered() throws Exception { logInAsSystemAdministrator(); when(serverPluginRepository.getPluginInfo(PLUGIN_KEY)).thenReturn(new PluginInfo(PLUGIN_KEY)); underTest.handle(validRequest, response); verify(pluginUninstaller).uninstall(PLUGIN_KEY); assertThat(response.outputAsString()).isEmpty(); }
@Test public void no_content_http_204_returned() { TestResponse result = call(organization.getKey(), user.getLogin()); assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT); assertThat(result.getInput()).isEmpty(); }
@Test public void read_nothing() { SymbolsLineReader symbolsLineReader = newReader(); assertThat(symbolsLineReader.read(line1)).isEmpty(); assertThat(line1.getSymbols()).isEmpty(); }
@Test public void empty_204_response() { logInAsSystemAdministrator(); TestResponse result = ws.newRequest() .setParam("keys", "my.key") .execute(); assertThat(result.getStatus()).isEqualTo(HTTP_NO_CONTENT); assertThat(result.getInput()).isEmpty(); }
@Test public void empty_204_response() { TestResponse result = ws.newRequest() .setParam("key", "my.key") .setParam("value", "my value") .execute(); assertThat(result.getStatus()).isEqualTo(HttpURLConnection.HTTP_NO_CONTENT); assertThat(result.getInput()).isEmpty(); }
@Test public void set_accepts_empty_value_and_trims_it() { MapSettings underTest = new MapSettings(); Random random = new Random(); String key = randomAlphanumeric(3); underTest.set(key, blank(random)); assertThat(underTest.getString(key)).isEmpty(); }
@Test public void if_plugin_has_an_update_download_is_triggered_with_latest_version_from_updatecenter() throws Exception { logInAsSystemAdministrator(); Version version = Version.create("1.0"); when(updateCenter.findPluginUpdates()).thenReturn(ImmutableList.of( PluginUpdate.createWithStatus(new Release(Plugin.factory(PLUGIN_KEY), version), Status.COMPATIBLE))); underTest.handle(validRequest, response); verify(pluginDownloader).download(PLUGIN_KEY, version); assertThat(response.outputAsString()).isEmpty(); }
@Test public void read_symbols() { SymbolsLineReader symbolsLineReader = newReader(newSymbol( newSingleLineTextRangeWithExpectedLabel(LINE_1, OFFSET_2, OFFSET_4, RANGE_LABEL_1), newSingleLineTextRangeWithExpectedLabel(LINE_3, OFFSET_1, OFFSET_3, RANGE_LABEL_2))); assertThat(symbolsLineReader.read(line1)).isEmpty(); assertThat(symbolsLineReader.read(line2)).isEmpty(); assertThat(symbolsLineReader.read(line3)).isEmpty(); assertThat(line1.getSymbols()).isEqualTo(RANGE_LABEL_1 + ",1"); assertThat(line2.getSymbols()).isEmpty(); assertThat(line3.getSymbols()).isEqualTo(RANGE_LABEL_2 + ",1"); }
@Test public void no_response() { ComponentDto project = db.components().insertPrivateProject(); ProjectLinkDto link = db.componentLinks().insertCustomLink(project); logInAsProjectAdministrator(project); TestResponse response = deleteLink(link); assertThat(response.getStatus()).isEqualTo(204); assertThat(response.getInput()).isEmpty(); }
@Test public void user_can_delete_its_own_tokens() { UserDto user = db.users().insertUser(); UserTokenDto token = db.users().insertToken(user); userSession.logIn(user); String response = newRequest(null, token.getName()); assertThat(response).isEmpty(); assertThat(dbClient.userTokenDao().selectByUser(dbSession, user)).isEmpty(); }
private void checkWithIfNoneMatchHeader(ComponentDto application, MetricDto metric, TestResponse response) { TestResponse newResponse = ws.newRequest() .setHeader("If-None-Match", response.getHeader("ETag")) .setParam("project", application.getKey()) .setParam("metric", metric.getKey()) .execute(); assertThat(newResponse.getInput()).isEmpty(); assertThat(newResponse.getStatus()).isEqualTo(304); } private MetricDto createQualityGateMetric() {
@Test public void test_response_with_no_content() { Request request = new TestRequest().setPath("api/foo"); RequestHandler handler = (req, resp) -> resp.noContent(); DumbResponse response = run(request, newWs("api/foo", a -> a.setHandler(handler))); assertThat(response.stream().outputAsString()).isEmpty(); assertThat(response.stream().status()).isEqualTo(204); }
@Test public void test_categories() { PropertyDefinitions def = new PropertyDefinitions( PropertyDefinition.builder("inCateg").name("In Categ").category("categ").build(), PropertyDefinition.builder("noCateg").name("No categ").build()); assertThat(def.getCategory("inCateg")).isEqualTo("categ"); assertThat(def.getCategory("noCateg")).isEmpty(); }