Refine search
@Test public void decode_scm_accounts() { assertThat(UserDto.decodeScmAccounts(null)).isEmpty(); assertThat(UserDto.decodeScmAccounts("\nfoo\n")).containsOnly("foo"); assertThat(UserDto.decodeScmAccounts("\nfoo\nbar\n")).containsOnly("foo", "bar"); } }
@Test public void getChildren() { assertThat(tree.getChildren("TRK")).containsOnly("DIR"); assertThat(tree.getChildren("DIR")).containsOnly("FIL", "UTS"); assertThat(tree.getChildren("FIL")).isEmpty(); }
@Test public void getJwkListWhenNotEmpty() { JWK key = mock(JWK.class); JWKContext jwkContext = new JWKContext(Arrays.asList(key)); assertThat(jwkContext.getJwkList()).containsOnly(key); } }
@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 return_all_enabled_providers() { IdentityProviderRepository underTest = new IdentityProviderRepository(asList(GITHUB, BITBUCKET, DISABLED)); List<IdentityProvider> providers = underTest.getAllEnabledAndSorted(); assertThat(providers).containsOnly(GITHUB, BITBUCKET); }
@Test public void singleManifest() throws Exception { Manifest mf = new Manifest(); mf.getMainAttributes().putValue("foo", "bar"); mf.getMainAttributes().putValue("other", "value"); File jar = createJar(mf, "singleManifest.jar"); URLClassLoader classloader = new URLClassLoader(FileUtils.toURLs(new File[]{jar})); List<String> values = ManifestUtils.getPropertyValues(classloader, "foo"); assertThat(values).containsOnly("bar"); }
@Test public void toStrings() { assertThat(RubyUtils.toStrings(null)).isNull(); assertThat(RubyUtils.toStrings("")).isEmpty(); assertThat(RubyUtils.toStrings("foo")).containsOnly("foo"); assertThat(RubyUtils.toStrings("foo,bar")).containsOnly("foo", "bar"); assertThat(RubyUtils.toStrings(asList("foo", "bar"))).containsOnly("foo", "bar"); }
@Test public void get_issues() { sut.setIssues(FILE_1, Arrays.asList(DUMB_ISSUE)); assertThat(sut.getIssues(FILE_1)).containsOnly(DUMB_ISSUE); }
@Test public void read_file_source() throws Exception { ScannerReportWriter writer = new ScannerReportWriter(dir); try (FileOutputStream outputStream = new FileOutputStream(writer.getSourceFile(1))) { IOUtils.write("line1\nline2", outputStream); } try (InputStream inputStream = FileUtils.openInputStream(underTest.readFileSource(1))) { assertThat(IOUtils.readLines(inputStream)).containsOnly("line1", "line2"); } }
@Test public void create_exception_from_var_args() { BadRequestException underTest = BadRequestException.create("error1", "error2"); assertThat(underTest.errors()).containsOnly("error1", "error2"); }
@Test public void polls_without_delay_when_CeWorkerCallable_returns_TASK_PROCESSED() throws Exception { when(ceWorker.call()) .thenReturn(TASK_PROCESSED) .thenThrow(ERROR_TO_INTERRUPT_CHAINING); startSchedulingAndRun(); assertThat(processingExecutorService.getSchedulerCalls()).containsOnly( regularDelayedPoll, notDelayedPoll); }
@Test public void getEnabledProcesses_returns_configured_processes_in_cluster_mode() { TestAppSettings settings = newSettingsForAppNode(); assertThat(ClusterSettings.getEnabledProcesses(settings)).containsOnly(COMPUTE_ENGINE, WEB_SERVER); settings = newSettingsForSearchNode(); assertThat(ClusterSettings.getEnabledProcesses(settings)).containsOnly(ELASTICSEARCH); }
@Test public void addToQueue_submits_runnable_to_executorService_which_does_not_fail_if_Runnable_argument_throws_exception() { underTest.addToQueue(() -> { throw new RuntimeException("Faking an exception thrown by Runnable argument"); }); assertThat(logTester.logs()).hasSize(1); assertThat(logTester.logs(LoggerLevel.ERROR)).containsOnly("Asynchronous task failed"); }
@Test public void filter_on_multiple_component_uuids() { underTest.setMainComponentUuids(asList("UUID1", "UUID2")); assertThat(underTest.getMainComponentUuids()).containsOnly("UUID1", "UUID2"); assertThat(underTest.isShortCircuitedByMainComponentUuids()).isFalse(); }
@Test public void generate_sql_on_postgresql() { when(database.getDialect()).thenReturn(new PostgreSql()); assertThat(underTest.generateSql()) .containsOnly( "ALTER TABLE project_measures DROP COLUMN rules_category_id, DROP COLUMN tendency, DROP COLUMN measure_date, DROP COLUMN url, DROP COLUMN rule_priority, DROP COLUMN characteristic_id, DROP COLUMN rule_id"); }
@Test public void shouldProvideChannelList() { assertThat(underTest.getChannels()).containsOnly(emailChannel, twitterChannel); underTest = new DefaultNotificationManager(new NotificationChannel[] {}, dbClient); assertThat(underTest.getChannels()).hasSize(0); }
@Test public void parameterized_query() throws Exception { db.prepareDbUnit(getClass(), "persons.xml"); final List<Long> ids = new ArrayList<>(); new DataChange(db.database()) { @Override public void execute(Context context) throws SQLException { ids.addAll(context.prepareSelect("select id from persons where id>=?").setLong(1, 2L).list(Select.LONG_READER)); } }.execute(); assertThat(ids).containsOnly(2L, 3L); }
@Test public void filter_on_component_uuid() { underTest.setMainComponentUuid("UUID1"); assertThat(underTest.getMainComponentUuids()).containsOnly("UUID1"); assertThat(underTest.isShortCircuitedByMainComponentUuids()).isFalse(); }
@Test public void redirect_post_api_properties_to_api_settings_set_when_multi_values() throws Exception { when(request.getRequestURI()).thenReturn("/api/properties/my.property"); when(request.getParameter("value")).thenReturn("value1,value2,value3"); when(request.getMethod()).thenReturn("POST"); underTest.doFilter(request, response, chain); assertRedirection("api/settings/set", "POST"); assertParam("key", "my.property"); assertNoParam("value"); assertThat(servletRequestCaptor.getValue().hasParam("values")).as("Parameter '%s' hasn't been found", "values").isTrue(); assertThat(servletRequestCaptor.getValue().readMultiParam("values")).containsOnly("value1", "value2", "value3"); }
@Test public void import_xml_return_messages() { QProfileDto profile = createProfile(); QProfileResult result = underTest.importXml(profile, "XooProfileImporterWithMessages", toInputStream("<xml/>", UTF_8), db.getSession()); assertThat(result.infos()).containsOnly("an info"); assertThat(result.warnings()).containsOnly("a warning"); }