Refine search
@Test public void should_register_symbols() { assertThat(referencesPerSymbol).hasSize(2); }
@Test(dataProvider = "getDependencyData") public void testCreateDynamicGraphWithDependency(Class<?> clazz) { DynamicGraph<ITestNGMethod> graph = newGraph(clazz); assertThat(graph.getFreeNodes()).hasSize(1); Map<ITestNGMethod, Integer> edges = searchForMethod("b", graph); assertThat(edges).hasSize(1); edges = searchForMethod("a", graph); assertThat(edges).isEmpty(); }
@Test public void testEnqueueStateUpdate_withExperiment_checkAppliedStateUpdate() throws Exception { setup(true); mComponentTree.updateStateAsync(mTestComponent.getGlobalKey(), new TestStateUpdate(), "test"); assertThat(getPendingStateUpdatesForComponent(mTestComponent)).hasSize(1); mLayoutThreadShadowLooper.runToEndOfTasks(); assertThat( mTestComponent .getComponentForStateUpdate() .getScopedContext() .getStateHandler() .getAppliedStateUpdates()) .hasSize(1); }
@Test public void testSize() { assertThat(new UnionMap<>(of("1", "a"), of("2", "b"))).hasSize(2); assertThat(new UnionMap<>(of("1", "a", "2", "b"), of("1", "b"))).hasSize(2); assertThat(new UnionMap<>(of("1", "a"), of("1", "b", "2", "b"))).hasSize(2); }
private void assertThatFacetHasSize(IssueQuery issueQuery, String facet, int expectedSize) { SearchResponse result = underTest.search(issueQuery, new SearchOptions().addFacets(singletonList(facet))); Facets facets = new Facets(result, system2.getDefaultTimeZone()); assertThat(facets.get(facet)).hasSize(expectedSize); } }
@Test public void raw_properties() { Properties p = new Properties(); p.setProperty("encrypted_prop", "{aes}abcde"); p.setProperty("clear_prop", "foo"); Props props = new Props(p); assertThat(props.rawProperties()).hasSize(2); // do not decrypt assertThat(props.rawProperties().get("encrypted_prop")).isEqualTo("{aes}abcde"); assertThat(props.rawProperties().get("clear_prop")).isEqualTo("foo"); }
@Test void shouldValidateCronTimer() { BackupConfig backupConfig = new BackupConfig("bad expression", "/usr/local/bin/post-backup", false, false); backupConfig.validate(null); assertThat(backupConfig.errors()) .hasSize(1); assertThat(backupConfig.errors().getAll()) .containsExactlyInAnyOrder("Invalid cron syntax for backup configuration at offset 0: Illegal characters for this position: 'BAD'"); } }
@Test public void argumentsToProperties_throws_IAE_if_argument_does_not_start_with_minusD() { Properties p = CommandLineParser.argumentsToProperties(new String[] {"-Dsonar.foo=bar", "-Dsonar.whitespace=foo bar"}); assertThat(p).hasSize(2); assertThat(p.getProperty("sonar.foo")).isEqualTo("bar"); assertThat(p.getProperty("sonar.whitespace")).isEqualTo("foo bar"); expectedException.expect(IllegalArgumentException.class); expectedException.expectMessage("Command-line argument must start with -D, for example -Dsonar.jdbc.username=sonar. Got: sonar.bad=true"); CommandLineParser.argumentsToProperties(new String[] {"-Dsonar.foo=bar", "sonar.bad=true"}); } }
@Test public void loadPropsFromCommandLineArgs_load_properties_from_file() throws Exception { File propsFile = temp.newFile(); FileUtils.write(propsFile, "foo=bar"); Props result = ConfigurationUtils.loadPropsFromCommandLineArgs(new String[] {propsFile.getAbsolutePath()}); assertThat(result.value("foo")).isEqualTo("bar"); assertThat(result.rawProperties()).hasSize(1); }
@Test public void getCumulativeDurations_returns_an_non_empty_map_when_computation_is_enabled_in_constructor() { VisitorsCrawler underTest = new VisitorsCrawler(Arrays.asList(spyPreOrderTypeAwareVisitor, spyPostOrderTypeAwareVisitor), true); underTest.visit(COMPONENT_TREE); assertThat(underTest.getCumulativeDurations()).hasSize(2); }
@Test public void getCumulativeDurations_returns_an_non_empty_map_when_computation_is_enabled_in_constructor() { VisitorsCrawler underTest = new VisitorsCrawler(Arrays.asList(spyPreOrderTypeAwareVisitor, spyPostOrderTypeAwareVisitor), true); underTest.visit(COMPONENT_TREE); assertThat(underTest.getCumulativeDurations()).hasSize(2); }
@Test public void builder_levelByDomain_adds_global_process_and_domain_properties_in_order_for_specified_logger() { LogLevelConfig underTest = newBuilder(rootLoggerName) .levelByDomain("foo", ProcessId.WEB_SERVER, LogDomain.SQL) .build(); assertThat(underTest.getConfiguredByProperties()).hasSize(1); assertThat(underTest.getConfiguredByProperties().get("foo")) .containsExactly("sonar.log.level", "sonar.log.level.web", "sonar.log.level.web.sql"); assertThat(underTest.getConfiguredByHardcodedLevel()).hasSize(0); }
@Test public void saveAuthorizedClientWhenSavedThenSavedToSession() { OAuth2AuthorizedClient authorizedClient = new OAuth2AuthorizedClient( this.registration2, this.principalName1, mock(OAuth2AccessToken.class)); this.authorizedClientRepository.saveAuthorizedClient(authorizedClient, null, this.request, this.response); HttpSession session = this.request.getSession(false); assertThat(session).isNotNull(); @SuppressWarnings("unchecked") Map<String, OAuth2AuthorizedClient> authorizedClients = (Map<String, OAuth2AuthorizedClient>) session.getAttribute(HttpSessionOAuth2AuthorizedClientRepository.class.getName() + ".AUTHORIZED_CLIENTS"); assertThat(authorizedClients).isNotEmpty(); assertThat(authorizedClients).hasSize(1); assertThat(authorizedClients.values().iterator().next()).isSameAs(authorizedClient); }
@Test public void iterator_over_issue_from_project() { dbTester.prepareDbUnit(getClass(), "many_projects.xml"); Map<String, IssueDoc> issuesByKey = issuesByKey(factory -> factory.createForProject("THE_PROJECT_1")); assertThat(issuesByKey).hasSize(2); }
@Test public void builder_rootLevelFor_add_global_and_process_property_in_order_for_root_logger() { LogLevelConfig underTest = newBuilder(rootLoggerName).rootLevelFor(ProcessId.ELASTICSEARCH).build(); assertThat(underTest.getConfiguredByProperties()).hasSize(1); assertThat(underTest.getConfiguredByProperties().get(rootLoggerName)) .containsExactly("sonar.log.level", "sonar.log.level.es"); assertThat(underTest.getConfiguredByHardcodedLevel()).hasSize(0); }
@Test public void hasNoBackedUpDiskStoresIfNoMembers() { BackupStatus backupStatus = backupOperation.backupAllMembers(targetDirPath, baselineDirPath); assertThat(backupStatus.getBackedUpDiskStores()).hasSize(0); }
@Test public void generate_scm_info_when_nothing_in_report_nor_db() { when(dbLoader.getScmInfo(FILE)).thenReturn(Optional.empty()); ScmInfo scmInfo = underTest.getScmInfo(FILE).get(); assertThat(scmInfo.getAllChangesets()).hasSize(3); for (int i = 1; i <= 3; i++) { assertChangeset(scmInfo.getChangesetForLine(i), null, null, analysisDate.getTime()); } verify(dbLoader).getScmInfo(FILE); verifyNoMoreInteractions(dbLoader); verifyZeroInteractions(sourceHashRepository); verifyZeroInteractions(diff); }
@Test public void stream() throws Exception { assertThat(c.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) .hasSize(1) .containsOnlyKeys(1) .containsValues("A"); }
@Test public void stream() throws Exception { assertThat(c.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) .hasSize(2) .containsOnlyKeys(1, 2) .containsValues("A", "B"); }
@Test public void stream() throws Exception { assertThat(c.stream().collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue))) .hasSize(3) .containsOnlyKeys(1, 2, 3) .containsValues("A", "B", "C"); }