Refine search
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldExitOnErrorFromExecute() throws IOException, InterruptedException { String sql = "select * from hive.default.nations; select * from hive.default.nation;"; launchPrestoCliWithServerArgument("--execute", sql); assertThat(trimLines(presto.readRemainingOutputLines())).isEmpty(); assertThatThrownBy(() -> presto.waitForWithTimeoutAndKill()).hasMessage("Child process exited with non-zero code: 1"); }
private void assertSingleGetCall() { Assertions.assertThat(getCalls).hasSize(1); Assertions.assertThat(postCalls).isEmpty(); Assertions.assertThat(rawCalls).isEmpty(); }
@Test public void selectPotentialPermissions_with_unknown_template_and_no_user() { List<String> result = underTest.selectPotentialPermissionsByUserIdAndTemplateId(dbSession, null, 42L); assertThat(result).isEmpty(); }
@Test public void return_public_project_with_only_AllowAnyone_true_when_no_permission_in_DB() { List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(publicProject.uuid())); Assertions.assertThat(dtos).hasSize(1); IndexPermissions dto = dtos.get(0); assertThat(dto.getGroupIds()).isEmpty(); assertThat(dto.getUserIds()).isEmpty(); assertThat(dto.isAllowAnyone()).isTrue(); assertThat(dto.getProjectUuid()).isEqualTo(publicProject.uuid()); assertThat(dto.getQualifier()).isEqualTo(publicProject.qualifier()); }
@Test public void convertToDocs_empty() { SearchHits hits = mock(SearchHits.class, Mockito.RETURNS_MOCKS); List<BaseDoc> docs = EsUtils.convertToDocs(hits, IssueDoc::new); assertThat(docs).isEmpty(); }
@Test public void getAtMostThreeActiveUsersForScmAccount_is_case_sensitive_for_login() { UserDoc user = newUser("the_login", singletonList("John.Smith")); es.putDocuments(INDEX_TYPE_USER, user); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("the_login", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("the_Login", ORGANIZATION_UUID)).isEmpty(); }
private void assertSinglePostCall() { Assertions.assertThat(postCalls).hasSize(1); Assertions.assertThat(getRawCalls()).isEmpty(); Assertions.assertThat(rawCalls).isEmpty(); }
@Test(groups = CLI, timeOut = TIMEOUT) public void shouldExitOnErrorFromFile() throws IOException, InterruptedException { try (TempFile file = new TempFile()) { Files.write("select * from hive.default.nations;\nselect * from hive.default.nation;\n", file.file(), UTF_8); launchPrestoCliWithServerArgument("--file", file.file().getAbsolutePath()); assertThat(trimLines(presto.readRemainingOutputLines())).isEmpty(); assertThatThrownBy(() -> presto.waitForWithTimeoutAndKill()).hasMessage("Child process exited with non-zero code: 1"); } }
@Test public void return_404_if_resource_not_found_in_installed_plugin() throws Exception { system.pluginStream = null; when(pluginRepository.hasPlugin("myplugin")).thenReturn(true); Response response = call("/static/myplugin/foo.css"); assertThat(response.code()).isEqualTo(404); assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty(); assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); }
@Test public void return_private_project_without_any_permission_when_no_permission_in_DB() { List<IndexPermissions> dtos = underTest.selectByUuids(dbClient, dbSession, singletonList(privateProject1.uuid())); // no permissions Assertions.assertThat(dtos).hasSize(1); IndexPermissions dto = dtos.get(0); assertThat(dto.getGroupIds()).isEmpty(); assertThat(dto.getUserIds()).isEmpty(); assertThat(dto.isAllowAnyone()).isFalse(); assertThat(dto.getProjectUuid()).isEqualTo(privateProject1.uuid()); assertThat(dto.getQualifier()).isEqualTo(privateProject1.qualifier()); }
@Test public void return_404_if_plugin_does_not_exist() throws Exception { system.pluginStream = null; when(pluginRepository.hasPlugin("myplugin")).thenReturn(false); Response response = call("/static/myplugin/foo.css"); assertThat(response.code()).isEqualTo(404); assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty(); assertThat(logTester.logs(LoggerLevel.WARN)).isEmpty(); }
@Test public void deleteGroupAuthorityRemovesCorrectRows() throws Exception { GrantedAuthority auth = new SimpleGrantedAuthority("ROLE_A"); manager.removeGroupAuthority("GROUP_0", auth); assertThat( template.queryForList( "select authority from group_authorities where group_id = 0")).isEmpty(); manager.removeGroupAuthority("GROUP_2", auth); assertThat( template.queryForList( "select authority from group_authorities where group_id = 2")).hasSize(2); }
@Test public void visit_subView_with_depth_VIEW_does_not_call_visit_subView_nor_visitAny() { Component component = component(SUBVIEW, 1); viewCrawler.visit(component); assertThat(viewVisitor.callsRecords).isEmpty(); }
@Test public void getAtMostThreeActiveUsersForScmAccount_is_case_insensitive_for_email() { UserDoc user = newUser("the_login", "the_EMAIL@corp.com", singletonList("John.Smith")); es.putDocuments(INDEX_TYPE_USER, user); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("the_EMAIL@corp.com", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("the_email@corp.com", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("email", ORGANIZATION_UUID)).isEmpty(); }
@Test public void empty_pages_if_no_page_definition() { underTest.start(); List<Page> result = underTest.getAllPages(); assertThat(result).isEmpty(); }
@Test public void getAtMostThreeActiveUsersForScmAccount_is_case_insensitive_for_scm_account() { UserDoc user = newUser("the_login", singletonList("John.Smith")); es.putDocuments(INDEX_TYPE_USER, user); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("John.Smith", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("JOHN.SMIth", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("JOHN.SMITH", ORGANIZATION_UUID)).hasSize(1); assertThat(underTest.getAtMostThreeActiveUsersForScmAccount("JOHN", ORGANIZATION_UUID)).isEmpty(); }
@Test public void visit_projectView_with_depth_SUBVIEW_does_not_call_visit_projectView_nor_visitAny() { Component component = component(PROJECT_VIEW, 1); subViewCrawler.visit(component); assertThat(subViewVisitor.callsRecords).isEmpty(); }
@Test public void index_on_startup() { db.prepareDbUnit(getClass(), "index.xml"); underTest.indexOnStartup(emptySet()); List<ViewDoc> docs = es.getDocuments(ViewIndexDefinition.INDEX_TYPE_VIEW, ViewDoc.class); assertThat(docs).hasSize(4); Map<String, ViewDoc> viewsByUuid = Maps.uniqueIndex(docs, ViewDoc::uuid); assertThat(viewsByUuid.get("ABCD").projects()).containsOnly("JKLM"); assertThat(viewsByUuid.get("EFGH").projects()).containsOnly("KLMN", "JKLM"); assertThat(viewsByUuid.get("FGHI").projects()).containsOnly("JKLM"); assertThat(viewsByUuid.get("IJKL").projects()).isEmpty(); }
@Test public void visit_projectView_with_depth_VIEW_does_not_call_visit_projectView_nor_visitAny() { Component component = component(PROJECT_VIEW, 1); viewCrawler.visit(component); assertThat(viewVisitor.callsRecords).isEmpty(); }
@Test public void do_no_log_error_when_task_fails_with_MessageException() throws Exception { CeTask ceTask = createCeTask(submitter); when(queue.peek(anyString())).thenReturn(Optional.of(ceTask)); taskProcessorRepository.setProcessorForTask(CeTaskTypes.REPORT, taskProcessor); makeTaskProcessorFail(ceTask, MessageException.of("simulate MessageException thrown by TaskProcessor#process")); underTest.call(); List<String> logs = logTester.logs(LoggerLevel.INFO); assertThat(logs).hasSize(2); assertThat(logs.get(1)).contains(" | submitter=" + submitter.getLogin()); assertThat(logs.get(1)).contains(String.format(" | submitter=%s | status=FAILED | time=", submitter.getLogin())); assertThat(logTester.logs(LoggerLevel.ERROR)).isEmpty(); }