Search in sources :

Example 6 with DefaultTemplates

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");
}
Also used : DefaultTemplates(org.sonar.db.organization.DefaultTemplates) Test(org.junit.Test)

Example 7 with DefaultTemplates

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");
}
Also used : DefaultTemplates(org.sonar.db.organization.DefaultTemplates) Test(org.junit.Test)

Example 8 with DefaultTemplates

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();
}
Also used : DefaultTemplates(org.sonar.db.organization.DefaultTemplates) Test(org.junit.Test)

Example 9 with DefaultTemplates

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);
}
Also used : DbSession(org.sonar.db.DbSession) DefaultTemplates(org.sonar.db.organization.DefaultTemplates)

Example 10 with DefaultTemplates

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);
}
Also used : OrganizationDao(org.sonar.db.organization.OrganizationDao) DefaultTemplates(org.sonar.db.organization.DefaultTemplates)

Aggregations

DefaultTemplates (org.sonar.db.organization.DefaultTemplates)13 PermissionTemplateDto (org.sonar.db.permission.template.PermissionTemplateDto)8 Test (org.junit.Test)6 OrganizationDto (org.sonar.db.organization.OrganizationDto)3 Date (java.util.Date)2 DbSession (org.sonar.db.DbSession)2 PermissionTemplateGroupDto (org.sonar.db.permission.template.PermissionTemplateGroupDto)2 GroupDto (org.sonar.db.user.GroupDto)2 UserDto (org.sonar.db.user.UserDto)2 ArrayList (java.util.ArrayList)1 CheckForNull (javax.annotation.CheckForNull)1 OrganizationDao (org.sonar.db.organization.OrganizationDao)1 ResolvedDefaultTemplates (org.sonar.server.permission.ws.template.DefaultTemplatesResolver.ResolvedDefaultTemplates)1 DefaultTemplatesResolverImpl (org.sonar.server.permission.ws.template.DefaultTemplatesResolverImpl)1