Refine search
@Test public void testHiddenCommandUsage() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(baos); System.setOut(stream); itf.execute("hidden", "-h"); assertThat(baos.toString()) .contains("-n <value>") .doesNotContain("-c ") .doesNotContain("count"); }
@Test public void testUsage() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(baos); System.setOut(stream); itf.execute("--help"); assertThat(baos.toString()).contains("hello").contains("bye") .doesNotContain("hidden").contains("A command saying hello"); }
@Test public void testUsageWhenNoArgsAndOptions() { final CLI cli = CLI.create("test").setDescription("A simple test command."); StringBuilder builder = new StringBuilder(); cli.usage(builder); assertThat(builder.toString()) .contains("test") .doesNotContain("Options").doesNotContain("Arguments"); }
@Test public void testUsageOnDifferentStream() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); PrintStream stream = new PrintStream(baos); itf = new VertxCommandLauncher() { /** * @return the printer used to write the messages. Defaults to {@link System#out}. */ @Override public PrintStream getPrintStream() { return stream; } }; itf.execute("--help"); assertThat(baos.toString()).contains("hello").contains("bye") .doesNotContain("hidden").contains("A command saying hello"); }
/** * Check that log message is not formatted, i.e. has no log level and timestamp. */ private void assertMsgClean(String msg) { // FP: [JOURNAL_FLUSHER] WARNING Journal flush operation took 2,093ms last 8 cycles average is 262ms if (msg.contains("[JOURNAL_FLUSHER]")) { return; } for (LogOutput.Level l : LogOutput.Level.values()) { assertThat(msg).doesNotContain(l.toString()); } Matcher matcher = simpleTimePattern.matcher(msg); assertThat(matcher.find()).isFalse(); }
@Test public void testOldBareWithClusterHost() throws InterruptedException, IOException { record(); cli.dispatch(new String[]{"-ha", "-cluster-host", "127.0.0.1"}); assertWaitUntil(() -> error.toString().contains("A quorum has been obtained.")); stop(); assertThat(error.toString()) .contains("Starting clustering...") .doesNotContain("No cluster-host specified") .contains("Any deploymentIDs waiting on a quorum will now be deployed"); }
@Test public void testRegularBareCommandWithClusterHost() { record(); cli.dispatch(new String[]{"bare", "-cluster-host", "127.0.0.1"}); assertWaitUntil(() -> error.toString().contains("A quorum has been obtained.")); assertThatVertxInstanceHasBeenCreated(); stop(); assertThat(error.toString()) .contains("Starting clustering...") .doesNotContain("No cluster-host specified") .contains("Any deploymentIDs waiting on a quorum will now be deployed"); }
@Test public void token_does_not_contain_colon() { assertThat(underTest.generate()).doesNotContain(":"); }
@Test public void dontLogInvalidOrganization() throws IOException { File srcDir = new File(baseDir, "src"); srcDir.mkdir(); File xooFile = new File(srcDir, "sample.xoo"); FileUtils.write(xooFile, "Sample xoo\ncontent", StandardCharsets.UTF_8); tester.newAnalysis() .properties(builder .put("sonar.sources", "src") .build()) .execute(); assertThat(logTester.logs()).contains("Project key: com.foo.project"); assertThat(logTester.logs().stream().collect(joining("\n"))).doesNotContain("Organization key"); assertThat(logTester.logs().stream().collect(joining("\n"))).doesNotContain("Branch key"); }
@Test public void appendErrorWithNotDesirableMessage_outputDataDoesNotContainThatMessage() throws Exception { String notDesirableMessage = "JavaSourceCompilerImpl compile"; //when seo.appendError("test\n" + notDesirableMessage + "\n"); //then SimpleEvaluationObject.EvaluationStdError stdErr = (SimpleEvaluationObject.EvaluationStdError) seo.getOutputdata().get(0); Assertions.assertThat(stdErr.payload).doesNotContain(notDesirableMessage); Assertions.assertThat(stdErr.payload).contains("test"); }
@Test public void edition_is_not_returned_if_not_defined() { init(); when(editionProvider.get()).thenReturn(Optional.empty()); String json = call(); assertThat(json).doesNotContain("edition"); }
@Test public void do_not_log_submitter_param_if_anonymous_and_success() throws Exception { when(queue.peek(anyString())).thenReturn(Optional.of(createCeTask(null))); taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor); underTest.call(); verifyWorkerUuid(); List<String> logs = logTester.logs(LoggerLevel.INFO); assertThat(logs).hasSize(2); for (int i = 0; i < 2; i++) { assertThat(logs.get(i)).doesNotContain("submitter="); } }
@Test public void search_metrics_ordered_by_name_case_insensitive() throws Exception { insertNewCustomMetric("3", "1", "2"); String firstResult = newRequest().setParam(Param.PAGE, "1").setParam(Param.PAGE_SIZE, "1").execute().outputAsString(); String secondResult = newRequest().setParam(Param.PAGE, "2").setParam(Param.PAGE_SIZE, "1").execute().outputAsString(); String thirdResult = newRequest().setParam(Param.PAGE, "3").setParam(Param.PAGE_SIZE, "1").execute().outputAsString(); assertThat(firstResult).contains("custom-key-1").doesNotContain("custom-key-2").doesNotContain("custom-key-3"); assertThat(secondResult).contains("custom-key-2").doesNotContain("custom-key-1").doesNotContain("custom-key-3"); assertThat(thirdResult).contains("custom-key-3").doesNotContain("custom-key-1").doesNotContain("custom-key-2"); }
@Test public void list_metric_with_chosen_fields() throws Exception { insertNewCustomMetric("1"); String result = newRequest().setParam(Param.FIELDS, "name").execute().outputAsString(); assertThat(result).contains("id", "key", "name", "type") .doesNotContain("domain") .doesNotContain("description"); }
@Test public void data_contains_no_license_type_on_commercial_edition_if_no_license() throws IOException { initTelemetrySettingsToDefaultValues(); settings.setProperty("sonar.telemetry.frequencyInSeconds", "1"); when(licenseReader.read()).thenReturn(Optional.empty()); commercialUnderTest.start(); ArgumentCaptor<String> jsonCaptor = captureJson(); assertThat(jsonCaptor.getValue()).doesNotContain("licenseType"); }
@Test public void createPomWithType() throws Exception { //given Dependency dependency = Dependency.create(asList("group", "art", "ver", "pom")); //when String pomAsString = pomFactory.createPom(new PomFactory.Params("/", asList(dependency), Maps.newHashMap(), MavenJarResolver.GOAL, MavenJarResolver.MAVEN_BUILT_CLASSPATH_FILE_NAME)); //then assertThat(removeWhitespaces(pomAsString)).contains("<type>pom</type>"); assertThat(removeWhitespaces(pomAsString)).doesNotContain("<classifier"); }
@Test public void list_metric_with_is_custom_false() throws Exception { insertNewCustomMetric("1", "2"); insertNewNonCustomMetric("3"); String result = newRequest() .setParam(PARAM_IS_CUSTOM, "false").execute().outputAsString(); assertThat(result).doesNotContain("custom-key-1") .doesNotContain("custom-key-2") .contains("non-custom-key-3"); }
@Test public void data_contains_no_license_type_on_community_edition() throws IOException { initTelemetrySettingsToDefaultValues(); settings.setProperty("sonar.telemetry.frequencyInSeconds", "1"); communityUnderTest.start(); ArgumentCaptor<String> jsonCaptor = captureJson(); assertThat(jsonCaptor.getValue()).doesNotContain("licenseType"); }
@Test public void testNestedTracing() throws Exception { final TracedNestedTestClass testClass = new TracedNestedTestClass(); testClass.foo(); final SpanContextInformation barInfo = spanCapturingReporter.get(); final SpanContextInformation fooInfo = spanCapturingReporter.get(); assertThat(fooInfo.getOperationName()).contains("foo").doesNotContain("bar"); assertThat(fooInfo.getCallTree().getSignature()).contains("foo").doesNotContain("bar"); assertThat(fooInfo.getCallTree().getChildren().get(0).getChildren().get(0).getSignature()).contains("bar()"); assertThat(barInfo.getCallTree()).isNull(); }
@Test public void search_for_users_with_query_as_a_parameter() { insertUsersHavingGlobalPermissions(); loginAsAdmin(db.getDefaultOrganization()); String result = newRequest() .setParam("permission", "scan") .setParam(TEXT_QUERY, "ame-1") .execute() .getInput(); assertThat(result).contains("login-1") .doesNotContain("login-2") .doesNotContain("login-3"); }