Refine search
@Test public void index_supports_duplicate_keys() { Multimap<Integer, MyObj> multimap = LIST_WITH_DUPLICATE_ID.stream().collect(index(MyObj::getId)); assertThat(multimap.keySet()).containsOnly(1, 2); assertThat(multimap.get(1)).containsOnly(MY_OBJ_1_A, MY_OBJ_1_C); assertThat(multimap.get(2)).containsOnly(MY_OBJ_2_B); }
private void verifyCeQueueStatuses(String[] taskUuids, CeQueueDto.Status[] statuses) { Map<String, Object>[] rows = new Map[taskUuids.length]; for (int i = 0; i < taskUuids.length; i++) { rows[i] = rowMap(taskUuids[i], statuses[i]); } assertThat(upperizeKeys(db.select(SELECT_QUEUE_UUID_AND_STATUS_QUERY))).containsOnly(rows); }
@Test public void get_returns_status_RED_with_cause_if_elasticsearch_process_is_not_operational_in_ClusterAppState() { Properties properties = new Properties(); setRequiredPropertiesAndMocks(properties); when(clusterAppState.isOperational(ProcessId.ELASTICSEARCH, true)).thenReturn(false); SearchNodeHealthProvider underTest = new SearchNodeHealthProvider(new Props(properties), clusterAppState, networkUtils, clock); NodeHealth nodeHealth = underTest.get(); assertThat(nodeHealth.getStatus()).isEqualTo(NodeHealth.Status.RED); assertThat(nodeHealth.getCauses()).containsOnly("Elasticsearch is not operational"); }
@Test public void index_returns_multimap() { Multimap<Integer, MyObj> multimap = LIST.stream().collect(index(MyObj::getId)); assertThat(multimap.size()).isEqualTo(3); Map<Integer, Collection<MyObj>> map = multimap.asMap(); assertThat(map.get(1)).containsOnly(MY_OBJ_1_A); assertThat(map.get(2)).containsOnly(MY_OBJ_2_B); assertThat(map.get(3)).containsOnly(MY_OBJ_3_C); }
@SafeVarargs private final void assertThatFacetHasOnly(IssueQuery.Builder query, String facet, Map.Entry<String, Long>... expectedEntries) { SearchResponse result = underTest.search(query.build(), new SearchOptions().addFacets(singletonList(facet))); Facets facets = new Facets(result, system2.getDefaultTimeZone()); assertThat(facets.getNames()).containsOnly(facet, "effort"); assertThat(facets.get(facet)).containsOnly(expectedEntries); }
@Test public void uniqueIndex_supports_duplicate_keys() { Multimap<Integer, String> multimap = LIST_WITH_DUPLICATE_ID.stream().collect(index(MyObj::getId, MyObj::getText)); assertThat(multimap.keySet()).containsOnly(1, 2); assertThat(multimap.get(1)).containsOnly("A", "C"); assertThat(multimap.get(2)).containsOnly("B"); }
@Test public void index_with_valueFunction_returns_multimap() { Multimap<Integer, String> multimap = LIST.stream().collect(index(MyObj::getId, MyObj::getText)); assertThat(multimap.size()).isEqualTo(3); Map<Integer, Collection<String>> map = multimap.asMap(); assertThat(map.get(1)).containsOnly("A"); assertThat(map.get(2)).containsOnly("B"); assertThat(map.get(3)).containsOnly("C"); }
@Test public void iteratorWhenContainsGithubThenContains() { assertThat(this.repository.iterator()) .containsOnly(this.registration); } }
@Test public void listResources_all() { Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "org/sonar/sqale", s -> true); assertThat(strings).containsOnly( "org/sonar/sqale/", "org/sonar/sqale/app/", "org/sonar/sqale/app/copyright.txt", "org/sonar/sqale/app/README.md"); }
@Test public void iteratorWhenGetThenContainsAll() { assertThat(this.clients.iterator()).containsOnly(this.registration); } }
@Test public void listFiles() { Collection<String> strings = ClassLoaderUtils.listFiles(classLoader, "org/sonar/sqale"); assertThat(strings).containsOnly( "org/sonar/sqale/app/copyright.txt", "org/sonar/sqale/app/README.md"); }
@Test public void set_uuids_makes_a_copy_of_input_issues() { Set<String> issues = newHashSet("ABCD", "EFGH"); sut.setUuids(issues); assertThat(sut.getUuids()).containsOnly("ABCD", "EFGH"); // Remove a element from the list, number of issues from the queue should remain the same issues.remove("ABCD"); assertThat(sut.getUuids()).containsOnly("ABCD", "EFGH"); }
@Test public void testGetter() { Collection<Path> files = Collections.singletonList(Paths.get("files")); scmChangedFiles = new ScmChangedFiles(files); assertThat(scmChangedFiles.get()).containsOnly(Paths.get("files")); }
@Test public void keepAuthorizedProjectIds_should_be_able_to_handle_lots_of_projects() { List<ComponentDto> projects = IntStream.range(0, 2000).mapToObj(i -> db.components().insertPublicProject(organization)).collect(Collectors.toList()); Collection<Long> ids = projects.stream().map(ComponentDto::getId).collect(Collectors.toSet()); assertThat(underTest.keepAuthorizedProjectIds(dbSession, ids, null, UserRole.USER)) .containsOnly(ids.toArray(new Long[0])); }
@Test public void keepAuthorizedProjectUuids_should_be_able_to_handle_lots_of_projects() { List<ComponentDto> projects = IntStream.range(0, 2000).mapToObj(i -> db.components().insertPublicProject(organization)).collect(Collectors.toList()); Collection<String> uuids = projects.stream().map(ComponentDto::uuid).collect(Collectors.toSet()); assertThat(underTest.keepAuthorizedProjectUuids(dbSession, uuids, null, UserRole.USER)) .containsOnly(uuids.toArray(new String[0])); }
@Test public void set_uuids() { sut.setUuids(newHashSet("ABCD", "EFGH")); assertThat(sut.getUuids()).containsOnly("ABCD", "EFGH"); }
@Test public void listResources_use_predicate() { Collection<String> strings = ClassLoaderUtils.listResources(classLoader, "org/sonar/sqale", s -> endsWith(s, "md")); assertThat(strings).containsOnly("org/sonar/sqale/app/README.md"); }
@Test public void shouldConvertLineRangeToLines() { LineRange range = new LineRange(12, 15); assertThat(range.toLines()).containsOnly(12, 13, 14, 15); }
@Test public void verify_getters() { assertThat(underTest.getId()).isEqualTo(QUALIGATE_ID); assertThat(underTest.getName()).isEqualTo(QUALIGATE_NAME); assertThat(underTest.getConditions()).containsOnly(CONDITION_1, CONDITION_2); }
@Test public void should_find_matching_file_in_index() throws IOException { String filename = "some name"; InputFile inputFile = mock(InputFile.class); when(inputFile.filename()).thenReturn(filename); FileSystem.Index index = mock(FileSystem.Index.class); when(index.getFilesByName(filename)).thenReturn(Collections.singleton(inputFile)); assertThat(new FilenamePredicate(filename).get(index)).containsOnly(inputFile); }