Exemple #1
0
 @Test
 public void should_create_permission_template() throws Exception {
   setupData("createPermissionTemplate");
   PermissionTemplateDto permissionTemplate =
       permissionDao.createPermissionTemplate("my template", "my description");
   assertThat(permissionTemplate).isNotNull();
   assertThat(permissionTemplate.getId()).isEqualTo(1L);
   checkTable(
       "createPermissionTemplate", "permission_templates", "id", "name", "kee", "description");
 }
Exemple #2
0
 @Test
 public void should_normalize_kee_on_template_creation() throws Exception {
   setupData("createNonAsciiPermissionTemplate");
   PermissionTemplateDto permissionTemplate =
       permissionDao.createPermissionTemplate("Môü Gnô Gnèçàß", "my description");
   assertThat(permissionTemplate).isNotNull();
   assertThat(permissionTemplate.getId()).isEqualTo(1L);
   checkTable(
       "createNonAsciiPermissionTemplate",
       "permission_templates",
       "id",
       "name",
       "kee",
       "description");
 }
Exemple #3
0
  @Test
  public void should_skip_key_normalization_on_default_template() throws Exception {

    PermissionTemplateMapper mapper = mock(PermissionTemplateMapper.class);

    SqlSession session = mock(SqlSession.class);
    when(session.getMapper(PermissionTemplateMapper.class)).thenReturn(mapper);

    MyBatis myBatis = mock(MyBatis.class);
    when(myBatis.openSession()).thenReturn(session);

    permissionDao = new PermissionDao(myBatis, dateProvider);
    PermissionTemplateDto permissionTemplate =
        permissionDao.createPermissionTemplate(PermissionTemplateDto.DEFAULT.getName(), null);

    verify(mapper).insert(permissionTemplate);
    verify(session).commit();

    assertThat(permissionTemplate.getKee()).isEqualTo(PermissionTemplateDto.DEFAULT.getKee());
  }