@CheckForNull
public PermissionTemplate selectPermissionTemplate(String templateKey) {
checkGlobalAdminUser(userSession);
- PermissionTemplateDto permissionTemplateDto = permissionTemplateDao.selectPermissionTemplate(templateKey);
+ PermissionTemplateDto permissionTemplateDto = permissionTemplateDao.selectByKeyWithUserAndGroupPermissions(templateKey);
return PermissionTemplate.create(permissionTemplateDto);
}
public void deletePermissionTemplate(Long templateId) {
checkGlobalAdminUser(userSession);
- permissionTemplateDao.deletePermissionTemplate(templateId);
+ permissionTemplateDao.deleteById(templateId);
}
/**
underTest.deletePermissionTemplate(1L);
- verify(permissionTemplateDao, times(1)).deletePermissionTemplate(1L);
+ verify(permissionTemplateDao, times(1)).deleteById(1L);
}
@Test
.setUsersPermissions(usersPermissions)
.setGroupsByPermission(groupsPermissions);
- when(permissionTemplateDao.selectPermissionTemplate("my template")).thenReturn(permissionTemplateDto);
+ when(permissionTemplateDao.selectByKeyWithUserAndGroupPermissions("my template")).thenReturn(permissionTemplateDto);
PermissionTemplate permissionTemplate = underTest.selectPermissionTemplate("my template");
}
@CheckForNull
- public PermissionTemplateDto selectPermissionTemplate(DbSession session, String templateKey) {
+ public PermissionTemplateDto selectByKeyWithUserAndGroupPermissions(DbSession session, String templateKey) {
PermissionTemplateDto permissionTemplate = null;
PermissionTemplateMapper mapper = mapper(session);
permissionTemplate = mapper.selectByKey(templateKey);
}
@CheckForNull
- public PermissionTemplateDto selectPermissionTemplate(String templateKey) {
+ public PermissionTemplateDto selectByKeyWithUserAndGroupPermissions(String templateKey) {
DbSession session = myBatis.openSession(false);
try {
- return selectPermissionTemplate(session, templateKey);
+ return selectByKeyWithUserAndGroupPermissions(session, templateKey);
} finally {
MyBatis.closeQuietly(session);
}
mapper(dbSession).deleteByKey(key);
}
- public void deletePermissionTemplate(Long templateId) {
+ public void deleteById(Long templateId) {
SqlSession session = myBatis.openSession(false);
try {
PermissionTemplateMapper mapper = mapper(session);
if (permissionTemplateDto == null) {
throw new IllegalArgumentException("Could not retrieve permission template with key " + templateKey);
}
- PermissionTemplateDto templateWithPermissions = selectPermissionTemplate(session, permissionTemplateDto.getKee());
+ PermissionTemplateDto templateWithPermissions = selectByKeyWithUserAndGroupPermissions(session, permissionTemplateDto.getKee());
if (templateWithPermissions == null) {
throw new IllegalArgumentException("Could not retrieve permissions for template with key " + templateKey);
}
public void should_select_permission_template() {
db.prepareDbUnit(getClass(), "selectPermissionTemplate.xml");
- PermissionTemplateDto permissionTemplate = underTest.selectPermissionTemplate("my_template_20130102_030405");
+ PermissionTemplateDto permissionTemplate = underTest.selectByKeyWithUserAndGroupPermissions("my_template_20130102_030405");
assertThat(permissionTemplate).isNotNull();
assertThat(permissionTemplate.getName()).isEqualTo("my template");
public void should_select_empty_permission_template() {
db.prepareDbUnit(getClass(), "selectEmptyPermissionTemplate.xml");
- PermissionTemplateDto permissionTemplate = underTest.selectPermissionTemplate("my_template_20130102_030405");
+ PermissionTemplateDto permissionTemplate = underTest.selectByKeyWithUserAndGroupPermissions("my_template_20130102_030405");
assertThat(permissionTemplate).isNotNull();
assertThat(permissionTemplate.getName()).isEqualTo("my template");
public void should_delete_permission_template() {
db.prepareDbUnit(getClass(), "deletePermissionTemplate.xml");
- underTest.deletePermissionTemplate(1L);
+ underTest.deleteById(1L);
checkTemplateTables("deletePermissionTemplate-result.xml");
}
PermissionTemplateDto templateWithPermissions = new PermissionTemplateDto().setKee("test_template");
underTest = mock(PermissionTemplateDao.class);
when(underTest.selectByKey(db.getSession(), "test_template")).thenReturn(permissionTemplateDto);
- when(underTest.selectPermissionTemplate(db.getSession(), "test_template")).thenReturn(templateWithPermissions);
+ when(underTest.selectByKeyWithUserAndGroupPermissions(db.getSession(), "test_template")).thenReturn(templateWithPermissions);
when(underTest.selectPermissionTemplateWithPermissions(db.getSession(), "test_template")).thenCallRealMethod();
PermissionTemplateDto permissionTemplate = underTest.selectPermissionTemplateWithPermissions(db.getSession(), "test_template");