Refine search
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldDisplayVersion() throws IOException { launchPrestoCli("--version"); String version = firstNonNull(Presto.class.getPackage().getImplementationVersion(), "(version unknown)"); assertThat(presto.readRemainingOutputLines()).containsExactly("Presto CLI " + version); }
@Test public void toUniqueAndSortedList_removes_duplicates() { assertThat(toUniqueAndSortedList(asList("A", "A", "A"))).containsExactly("A"); assertThat(toUniqueAndSortedList(asList("A", "C", "A"))).containsExactly("A", "C"); assertThat(toUniqueAndSortedList(asList("C", "C", "B", "B", "A", "N", "C", "A"))).containsExactly("A", "B", "C", "N"); }
@Test public void read_multi_param_from_source_with_values() { when(source.getParameterValues("param")).thenReturn(new String[]{"firstValue", "secondValue", "thirdValue"}); List<String> result = underTest.readMultiParam("param"); assertThat(result).containsExactly("firstValue", "secondValue", "thirdValue"); }
@Test public void execute_calls_2_delegates_in_order() throws SQLException { underTest.execute(); assertThat(calls).containsExactly(Call.CALL_1, Call.CALL_2); }
@Test public void shouldNormalizeHexIntegerLiteral() { assertThat(chunk("0xFF")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0xFFl")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0xFFL")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0XFF")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0XFFl")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0XFFL")).containsExactly(NUMERIC_LITTERAL); }
@Test public void read_multi_param_from_source_with_one_value() { when(source.getParameterValues("param")).thenReturn(new String[]{"firstValue"}); List<String> result = underTest.readMultiParam("param"); assertThat(result).containsExactly("firstValue"); }
@Test public void verify_supports_components() { assertThat(underTest.getSupportComponents()).containsExactly( FixProjectUuidOfDeveloperProjects.class, CleanUsurperRootComponents.class); }
@Test public void projectPermissions_must_be_ordered() { assertThat(underTest.getAllProjectPermissions()) .containsExactly("admin", "codeviewer", "issueadmin", "securityhotspotadmin", "scan", "user"); } }
/** * <a href="http://java.sun.com/docs/books/jls/third_edition/html/lexical.html#3.10.1">Integer Literals</a> */ @Test public void shouldNormalizeDecimalIntegerLiteral() { assertThat(chunk("543")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("543l")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("543L")).containsExactly(NUMERIC_LITTERAL); }
/** * New in Java 7. */ @Test public void shouldNormalizeBinaryIntegerLiteral() { assertThat(chunk("0b10")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0b10l")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0b10L")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0B10")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0B10l")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("0B10L")).containsExactly(NUMERIC_LITTERAL); }
@Test public void toUniqueAndSortedList_enforces_natural_order() { assertThat(toUniqueAndSortedList(asList("A", "B", "C"))).containsExactly("A", "B", "C"); assertThat(toUniqueAndSortedList(asList("B", "A", "C"))).containsExactly("A", "B", "C"); assertThat(toUniqueAndSortedList(asList("B", "C", "A"))).containsExactly("A", "B", "C"); }
@Test public void shouldNormalizeOctalIntegerLiteral() { assertThat(chunk("077")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("077l")).containsExactly(NUMERIC_LITTERAL); assertThat(chunk("077L")).containsExactly(NUMERIC_LITTERAL); }
@Test public void get_leaves_qualifiers() { assertThat(types.getLeavesQualifiers(Qualifiers.PROJECT)).containsExactly(Qualifiers.FILE); assertThat(types.getLeavesQualifiers(Qualifiers.DIRECTORY)).containsExactly(Qualifiers.FILE); assertThat(types.getLeavesQualifiers(Qualifiers.VIEW)).containsExactly(Qualifiers.PROJECT); assertThat(types.getLeavesQualifiers(Qualifiers.APP)).containsExactly(Qualifiers.PROJECT); assertThat(types.getLeavesQualifiers("xxx")).isEmpty(); }
@Test public void topNAndBottomN() { List<Integer> list = ArrayUtil.asList(3, 5, 7, 4, 2, 6, 9); assertThat(CollectionUtil.topN(list, 3)).containsExactly(9, 7, 6); assertThat(CollectionUtil.topN(list, 3, Ordering.natural().reverse())).containsExactly(2, 3, 4); assertThat(CollectionUtil.bottomN(list, 3)).containsExactly(2, 3, 4); assertThat(CollectionUtil.bottomN(list, 3, Ordering.natural().reverse())).containsExactly(9, 7, 6); } }
@Test public void collectionCalc() { List<String> list1 = ListUtil.newArrayList("1", "2", "3", "6", "6"); List<String> list2 = ListUtil.newArrayList("4", "5", "6", "7", "6", "6"); List<String> result = ListUtil.union(list1, list2); assertThat(result).containsExactly("1", "2", "3", "6", "6", "4", "5", "6", "7", "6", "6"); List<String> result2 = ListUtil.intersection(list1, list2); assertThat(result2).containsExactly("6", "6"); List<String> result3 = ListUtil.difference(list2, list1); assertThat(result3).containsExactly("4", "5", "7", "6"); List<String> result4 = ListUtil.disjoint(list1, list2); assertThat(result4).containsExactly("1", "2", "3", "4", "5", "7", "6"); } }
@Test public void toList_builds_an_ImmutableList() { List<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toList()); assertThat(res).isInstanceOf(ImmutableList.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void toList_with_size_builds_an_ImmutableList() { List<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toList(30)); assertThat(res).isInstanceOf(ImmutableList.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void toArrayList_with_size_builds_an_ArrayList() { List<Integer> res = Arrays.asList(1, 2, 3, 4, 5).stream().collect(toArrayList(30)); assertThat(res).isInstanceOf(ArrayList.class) .containsExactly(1, 2, 3, 4, 5); }
@Test public void openSession_without_caching_always_returns_a_new_batch_session_when_parameter_is_true() { DbSession[] expected = {mock(DbSession.class), mock(DbSession.class), mock(DbSession.class), mock(DbSession.class)}; when(myBatis.openSession(true)) .thenReturn(expected[0]) .thenReturn(expected[1]) .thenReturn(expected[2]) .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(true)).collect(MoreCollectors.toList())) .containsExactly(expected); }
@Test public void openSession_without_caching_always_returns_a_new_regular_session_when_parameter_is_false() { DbSession[] expected = {mock(DbSession.class), mock(DbSession.class), mock(DbSession.class), mock(DbSession.class)}; when(myBatis.openSession(false)) .thenReturn(expected[0]) .thenReturn(expected[1]) .thenReturn(expected[2]) .thenReturn(expected[3]) .thenThrow(oneCallTooMuch()); assertThat(Arrays.stream(expected).map(ignored -> underTest.openSession(false)).collect(MoreCollectors.toList())) .containsExactly(expected); }