}
@Override
- public boolean isEnabled() {
+ public boolean isAvailable() {
return sonarRuntime.getEdition() == ENTERPRISE || sonarRuntime.getEdition() == DATACENTER;
}
String getName();
- boolean isEnabled();
+ boolean isAvailable();
}
}
@Override
- public boolean isEnabled() {
+ public boolean isAvailable() {
return sonarRuntime.getEdition() == ENTERPRISE || sonarRuntime.getEdition() == DATACENTER;
}
public void isEnabled_shouldOnlyBeEnabledInEnterpriseEditionPlus(SonarEdition edition, boolean shouldBeEnabled) {
when(sonarRuntime.getEdition()).thenReturn(edition);
- boolean isEnabled = underTest.isEnabled();
+ boolean isAvailable = underTest.isAvailable();
- assertThat(isEnabled).isEqualTo(shouldBeEnabled);
+ assertThat(isAvailable).isEqualTo(shouldBeEnabled);
}
@DataProvider
@Test
@UseDataProvider("editionsAndLoginMessageFeatureAvailability")
- public void isEnabled_shouldOnlyBeEnabledInEnterpriseEditionPlus(SonarEdition edition, boolean shouldBeEnabled) {
+ public void isAvailable_shouldOnlyBeEnabledInEnterpriseEditionPlus(SonarEdition edition, boolean shouldBeEnabled) {
when(sonarRuntime.getEdition()).thenReturn(edition);
- boolean isEnabled = underTest.isEnabled();
+ boolean isAvailable = underTest.isAvailable();
- assertThat(isEnabled).isEqualTo(shouldBeEnabled);
+ assertThat(isAvailable).isEqualTo(shouldBeEnabled);
}
@Test
@Override
public boolean isEnabled() {
- return branchFeatureExtension != null && branchFeatureExtension.isEnabled();
+ return branchFeatureExtension != null && branchFeatureExtension.isAvailable();
}
}
@Test
public void return_false_when_extension_returns_false() {
- when(branchFeatureExtension.isEnabled()).thenReturn(false);
+ when(branchFeatureExtension.isAvailable()).thenReturn(false);
assertThat(new BranchFeatureProxyImpl(branchFeatureExtension).isEnabled()).isFalse();
}
@Test
public void return_true_when_extension_returns_ftrue() {
- when(branchFeatureExtension.isEnabled()).thenReturn(true);
+ when(branchFeatureExtension.isAvailable()).thenReturn(true);
assertThat(new BranchFeatureProxyImpl(branchFeatureExtension).isEnabled()).isTrue();
}
}
@Before
public void before() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto azureAlmSetting = db.almSettings().insertAzureAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertAzureAlmSetting();
@Before
public void before() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed_and_bitbucket_cloud_exists() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketCloudAlmSetting();
@Before
public void before() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto bitbucketAlmSetting = db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketCloudAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed_and_bitbucket_server_exists() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertBitbucketAlmSetting();
@Test
public void fail_when_workspace_id_format_is_incorrect() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
String workspace = "workspace/name";
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
@Test
public void do_not_fail_when_workspace_id_format_is_correct() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
String workspace = "work-space_123";
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
@Before
public void setUp() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
}
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
AlmSettingDto gitHubAlmSetting = db.almSettings().insertGitHubAlmSetting();
TestRequest request = buildTestRequest().setParam("key", gitHubAlmSetting.getKey());
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
db.almSettings().insertGitHubAlmSetting();
TestRequest request = buildTestRequest();
@Before
public void before() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
}
@Test
@Test
public void fail_when_key_is_already_used() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
AlmSettingDto gitlabAlmSetting = db.almSettings().insertGitlabAlmSetting();
@Test
public void fail_when_no_multiple_instance_allowed() {
- when(multipleAlmFeature.isEnabled()).thenReturn(false);
+ when(multipleAlmFeature.isAvailable()).thenReturn(false);
UserDto user = db.users().insertUser();
userSession.logIn(user).setSystemAdministrator();
db.almSettings().insertGitlabAlmSetting();
@Before
public void before() {
- when(multipleAlmFeature.isEnabled()).thenReturn(true);
+ when(multipleAlmFeature.isAvailable()).thenReturn(true);
}
@Test
public void checkAlmMultipleFeatureEnabled(ALM alm) {
try (DbSession dbSession = dbClient.openSession(false)) {
- if (!multipleAlmFeature.isEnabled() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
+ if (!multipleAlmFeature.isAvailable() && !dbClient.almSettingDao().selectByAlm(dbSession, alm).isEmpty()) {
throw BadRequestException.create("A " + alm + " setting is already defined");
}
}
try (JsonWriter json = response.newJsonWriter()) {
json.beginArray();
sonarQubeFeatures.stream()
- .filter(SonarQubeFeature::isEnabled)
+ .filter(SonarQubeFeature::isAvailable)
.forEach(f -> json.value(f.getName()));
json.endArray();
}
public void handle(Request request, Response response) throws Exception {
try (JsonWriter writer = response.newJsonWriter()) {
writer.beginObject()
- .prop("message", isMessageDisplayEnabled() && loginMessageFeature.isEnabled() ? Markdown.convertToHtml(getLoginMessage()) : "")
+ .prop("message", isMessageDisplayEnabled() && loginMessageFeature.isAvailable() ? Markdown.convertToHtml(getLoginMessage()) : "")
.endObject()
.close();
}
}
@Override
- public boolean isEnabled() {
+ public boolean isAvailable() {
return enabled;
}
}
@Before
public void setup() {
propertiesDao = mock(PropertiesDao.class);
- doReturn(true).when(loginMessageFeature).isEnabled();
+ doReturn(true).when(loginMessageFeature).isAvailable();
doReturn(propertiesDao).when(dbClient).propertiesDao();
}
public void return_empty_message_when_feature_not_enabled() {
mockProperty(SONAR_LOGIN_DISPLAY_MESSAGE, "true");
mockProperty(SONAR_LOGIN_MESSAGE, LOGIN_MESSAGE_TEXT);
- when(loginMessageFeature.isEnabled()).thenReturn(false);
+ when(loginMessageFeature.isAvailable()).thenReturn(false);
TestResponse response = ws.newRequest().execute();
assertThat(response.getInput()).isEqualTo(EMPTY_JSON_RESPONSE);