@Test public void update_not_local_user() throws Exception { insertUserWithPassword("john", false); migration.execute(); List<Map<String, Object>> rows = db.select("SELECT CRYPTED_PASSWORD,SALT,UPDATED_AT FROM users"); assertThat(rows).hasSize(1); assertThat(rows.get(0).get("CRYPTED_PASSWORD")).isNull(); assertThat(rows.get(0).get("SALT")).isNull(); assertThat(rows.get(0).get("UPDATED_AT")).isEqualTo(NOW); }
@Test public void configure_turns_off_some_Tomcat_loggers_if_global_log_level_is_TRACE() { props.set("sonar.log.level", "TRACE"); LoggerContext context = underTest.configure(props); assertThat(context.getLogger("org.apache.catalina.core.ContainerBase").getLevel()).isNull(); assertThat(context.getLogger("org.apache.catalina.core.StandardContext").getLevel()).isNull(); assertThat(context.getLogger("org.apache.catalina.core.StandardService").getLevel()).isNull(); }
@Test public void shouldNotCreateDesCipherIfCipherFileMissing() { assertThat(desCipherFile).doesNotExist(); GoCipher goCipher = new GoCipher(systemEnvironment); assertThat(goCipher.aesEncrypter).isNotNull(); assertThat(goCipher.desEncrypter).isNull(); }
@Test public void no_web_services_by_default() { assertThat(context.controllers()).isEmpty(); assertThat(context.controller("metric")).isNull(); }
@Test public void shouldNotFailWhenUnableToDeserialize() throws Exception { NotificationQueueDto dto1 = mock(NotificationQueueDto.class); when(dto1.toNotification()).thenThrow(new InvalidClassException("Pouet")); List<NotificationQueueDto> dtos = Arrays.asList(dto1); when(notificationQueueDao.selectOldest(1)).thenReturn(dtos); underTest = spy(underTest); assertThat(underTest.getFromQueue()).isNull(); assertThat(underTest.getFromQueue()).isNull(); verify(underTest, times(1)).logDeserializationIssue(); }
@Test public void do_not_log_to_console() { LoggerContext ctx = underTest.configure(props); Logger root = ctx.getLogger(Logger.ROOT_LOGGER_NAME); Appender appender = root.getAppender("CONSOLE"); assertThat(appender).isNull(); }
@Test public void set_past_line() { issue.setLine(42); boolean updated = underTest.setPastLine(issue, 123); assertThat(updated).isTrue(); assertThat(issue.isChanged()).isTrue(); assertThat(issue.line()).isEqualTo(42); assertThat(issue.mustSendNotifications()).isFalse(); // do not save change assertThat(issue.currentChange()).isNull(); }
@Test public void cant_find_relative_path_from_multiple_dirs() throws IOException { PathResolver resolver = new PathResolver(); File dir1 = temp.newFolder("D1"); File dir2 = temp.newFolder("D2"); File org = new File(dir2, "org"); File hello = new File(org, "hello"); File world = new File(hello, "World.java"); PathResolver.RelativePath relativePath = resolver.relativePath(Arrays.asList(dir1), world); assertThat(relativePath).isNull(); }
@Test public void no_realm() { when(securityRealmFactory.getRealm()).thenReturn(null); ProtobufSystemInfo.Section protobuf = underTest.toProtobuf(); assertThat(attribute(protobuf, "External User Authentication")).isNull(); }
private void assertProperties(PropertyDefinitions definitions) { assertThat(definitions.get("foo").name()).isEqualTo("Foo"); assertThat(definitions.get("one").name()).isEqualTo("One"); assertThat(definitions.get("two").name()).isEqualTo("Two"); assertThat(definitions.get("unknown")).isNull(); assertThat(definitions.getDefaultValue("foo")).isNull(); assertThat(definitions.getDefaultValue("two")).isEqualTo("2"); assertThat(definitions.getAll().size()).isEqualTo(3); }
@Test public void test_default_result() { Result<Object> result = Result.of(); assertThat(result.ok()).isTrue(); assertThat(result.errors()).isEmpty(); assertThat(result.httpStatus()).isEqualTo(200); assertThat(result.get()).isNull(); Object obj = new Object(); result.set(obj); assertThat(result.get()).isSameAs(obj); }
@Test public void should_create_plugin_referential() { PluginInfo info = new PluginInfo("foo"); PluginRepository pluginRepository = mock(PluginRepository.class); when(pluginRepository.getPluginInfos()).thenReturn(newArrayList(info)); InstalledPluginReferentialFactory factory = new InstalledPluginReferentialFactory(pluginRepository); assertThat(factory.getInstalledPluginReferential()).isNull(); factory.start(); assertThat(factory.getInstalledPluginReferential()).isNotNull(); assertThat(factory.getInstalledPluginReferential().getPlugins()).hasSize(1); }
@Test public void build_column_def_with_only_required_attributes() { BooleanColumnDef def = new BooleanColumnDef.Builder() .setColumnName("enabled") .build(); assertThat(def.getName()).isEqualTo("enabled"); assertThat(def.isNullable()).isTrue(); assertThat(def.getDefaultValue()).isNull(); }
private void assertInitializedIssue(DefaultIssue issue) { assertThat(issue.projectKey()).isEqualTo(PROJECT.getKey()); assertThat(issue.componentKey()).isEqualTo(FILE.getKey()); assertThat(issue.componentUuid()).isEqualTo(FILE.getUuid()); assertThat(issue.resolution()).isNull(); assertThat(issue.status()).isEqualTo(Issue.STATUS_OPEN); assertThat(issue.key()).isNull(); assertThat(issue.authorLogin()).isNull(); assertThat(issue.effort()).isNull(); assertThat(issue.effortInMinutes()).isNull(); }
@Test public void set_new_attribute_value() { boolean updated = underTest.setAttribute(issue, "JIRA", "FOO-123", context); assertThat(updated).isTrue(); assertThat(issue.attribute("JIRA")).isEqualTo("FOO-123"); assertThat(issue.currentChange().diffs()).hasSize(1); assertThat(issue.currentChange().get("JIRA").oldValue()).isNull(); assertThat(issue.currentChange().get("JIRA").newValue()).isEqualTo("FOO-123"); assertThat(issue.mustSendNotifications()).isFalse(); }
@Test public void test_setAttribute_with_boolean_parameter() { Section.Builder builder = Section.newBuilder(); SystemInfoUtils.setAttribute(builder, "isNull", (Boolean)null); SystemInfoUtils.setAttribute(builder, "isTrue", true); SystemInfoUtils.setAttribute(builder, "isFalse", false); Section section = builder.build(); assertThat(SystemInfoUtils.attribute(section, "isNull")).isNull(); assertThat(SystemInfoUtils.attribute(section, "isTrue").getBooleanValue()).isTrue(); assertThat(SystemInfoUtils.attribute(section, "isFalse").getBooleanValue()).isFalse(); }
@Test public void select_by_external_login_and_identity_provider() { UserDto activeUser = db.users().insertUser(); UserDto disableUser = db.users().insertUser(u -> u.setActive(false)); assertThat(underTest.selectByExternalLoginAndIdentityProvider(session, activeUser.getExternalLogin(), activeUser.getExternalIdentityProvider())).isNotNull(); assertThat(underTest.selectByExternalLoginAndIdentityProvider(session, disableUser.getExternalLogin(), disableUser.getExternalIdentityProvider())).isNotNull(); assertThat(underTest.selectByExternalLoginAndIdentityProvider(session, "unknown", "unknown")).isNull(); }
@Test public void searchRulesByConfigKey() { RulesProfile profile = RulesProfile.create(); profile.activateRule(Rule.create("repo", "key1", "name1"), null); profile.activateRule(Rule.create("repo", "key2", "name2").setConfigKey("config2"), null); assertThat(profile.getActiveRuleByConfigKey("repo", "unknown")).isNull(); assertThat(profile.getActiveRuleByConfigKey("repo", "config2").getRuleKey()).isEqualTo("key2"); }
@Test public void shouldParseOnlyWantedProfile() { BuiltInQualityProfilesDefinition.Context context = new BuiltInQualityProfilesDefinition.Context(); NewBuiltInQualityProfile newProfile = context.createBuiltInQualityProfile("Foo way", "java"); new BuiltInQualityProfileAnnotationLoader().load(newProfile, "squid", FakeRule.class, RuleOnOtherProfile.class, RuleNoProfile.class); newProfile.done(); assertThat(context.profile("java", "Foo way").rule(RuleKey.of("squid", "fake"))).isNotNull(); assertThat(context.profile("java", "Foo way").rule(RuleKey.of("squid", "other"))).isNull(); } }