use of org.sonar.db.organization.DefaultTemplates in project sonarqube by SonarSource.
the class DefaultTemplatesResolverImplTest method view_is_view_of_DefaultTemplates_if_view_in_DefaultTemplates_is_not_null_and_views_is_installed.
@Test
public void view_is_view_of_DefaultTemplates_if_view_in_DefaultTemplates_is_not_null_and_views_is_installed() {
DefaultTemplates defaultTemplates = new DefaultTemplates().setProjectUuid("foo").setViewUuid("bar");
assertThat(underTestWithViews.resolve(defaultTemplates).getView()).contains("bar");
}
use of org.sonar.db.organization.DefaultTemplates in project sonarqube by SonarSource.
the class DefaultTemplatesResolverImplTest method view_is_project_of_DefaultTemplates_if_view_in_DefaultTemplates_is_null_and_views_is_installed.
@Test
public void view_is_project_of_DefaultTemplates_if_view_in_DefaultTemplates_is_null_and_views_is_installed() {
DefaultTemplates defaultTemplates = new DefaultTemplates().setProjectUuid("foo").setViewUuid(null);
assertThat(underTestWithViews.resolve(defaultTemplates).getView()).contains("foo");
}
use of org.sonar.db.organization.DefaultTemplates in project sonarqube by SonarSource.
the class DefaultTemplatesResolverImplTest method view_is_empty_no_matter_view_in_DefaultTemplates_if_views_is_not_installed.
@Test
public void view_is_empty_no_matter_view_in_DefaultTemplates_if_views_is_not_installed() {
DefaultTemplates defaultTemplatesNoView = new DefaultTemplates().setProjectUuid("foo").setViewUuid(null);
DefaultTemplates defaultTemplatesView = new DefaultTemplates().setProjectUuid("foo").setViewUuid("bar");
assertThat(underTestWithoutViews.resolve(defaultTemplatesNoView).getView()).isEmpty();
assertThat(underTestWithoutViews.resolve(defaultTemplatesView).getView()).isEmpty();
}
use of org.sonar.db.organization.DefaultTemplates in project sonarqube by SonarSource.
the class SetDefaultTemplateActionTest method assertDefaultTemplates.
private void assertDefaultTemplates(OrganizationDto organizationDto, @Nullable String projectDefaultTemplateUuid, @Nullable String viewDefaultTemplateUuid) {
DbSession dbSession = db.getSession();
DefaultTemplates defaultTemplates = db.getDbClient().organizationDao().getDefaultTemplates(dbSession, organizationDto.getUuid()).orElseThrow(() -> new IllegalStateException("No default templates for organization with uuid '" + organizationDto.getUuid() + "'"));
assertThat(defaultTemplates.getProjectUuid()).isEqualTo(projectDefaultTemplateUuid);
assertThat(defaultTemplates.getViewUuid()).isEqualTo(viewDefaultTemplateUuid);
}
use of org.sonar.db.organization.DefaultTemplates in project sonarqube by SonarSource.
the class SetDefaultTemplateAction method setDefaultTemplateUuid.
private void setDefaultTemplateUuid(DbSession dbSession, PermissionTemplateDto permissionTemplateDto, String qualifier) {
String organizationUuid = permissionTemplateDto.getOrganizationUuid();
OrganizationDao organizationDao = dbClient.organizationDao();
DefaultTemplates defaultTemplates = checkFoundWithOptional(organizationDao.getDefaultTemplates(dbSession, organizationUuid), "No Default templates for organization with uuid '%s'", organizationUuid);
if (Qualifiers.PROJECT.equals(qualifier)) {
defaultTemplates.setProjectUuid(permissionTemplateDto.getUuid());
} else if (Qualifiers.VIEW.equals(qualifier)) {
defaultTemplates.setViewUuid(permissionTemplateDto.getUuid());
}
organizationDao.setDefaultTemplates(dbSession, organizationUuid, defaultTemplates);
}
Aggregations