Ejemplo n.º 1
0
  @Test
  public void should_select_permission_template() throws Exception {
    setupData("selectPermissionTemplate");
    PermissionTemplateDto permissionTemplate =
        permissionDao.selectPermissionTemplate("my template");

    assertThat(permissionTemplate).isNotNull();
    assertThat(permissionTemplate.getName()).isEqualTo("my template");
    assertThat(permissionTemplate.getKee()).isEqualTo("my_template_20130102_030405");
    assertThat(permissionTemplate.getDescription()).isEqualTo("my description");
    assertThat(permissionTemplate.getUsersPermissions()).hasSize(3);
    assertThat(permissionTemplate.getUsersPermissions())
        .onProperty("userId")
        .containsOnly(1L, 2L, 1L);
    assertThat(permissionTemplate.getUsersPermissions())
        .onProperty("userLogin")
        .containsOnly("login1", "login2", "login2");
    assertThat(permissionTemplate.getUsersPermissions())
        .onProperty("userName")
        .containsOnly("user1", "user2", "user2");
    assertThat(permissionTemplate.getUsersPermissions())
        .onProperty("permission")
        .containsOnly("user_permission1", "user_permission1", "user_permission2");
    assertThat(permissionTemplate.getGroupsPermissions()).hasSize(3);
    assertThat(permissionTemplate.getGroupsPermissions())
        .onProperty("groupId")
        .containsOnly(1L, 2L, null);
    assertThat(permissionTemplate.getGroupsPermissions())
        .onProperty("groupName")
        .containsOnly("group1", "group2", null);
    assertThat(permissionTemplate.getGroupsPermissions())
        .onProperty("permission")
        .containsOnly("group_permission1", "group_permission1", "group_permission2");
  }
Ejemplo n.º 2
0
  @Test
  public void should_select_empty_permission_template() throws Exception {
    setupData("selectEmptyPermissionTemplate");
    PermissionTemplateDto permissionTemplate =
        permissionDao.selectPermissionTemplate("my template");

    assertThat(permissionTemplate).isNotNull();
    assertThat(permissionTemplate.getName()).isEqualTo("my template");
    assertThat(permissionTemplate.getDescription()).isEqualTo("my description");
    assertThat(permissionTemplate.getUsersPermissions()).isNull();
    assertThat(permissionTemplate.getGroupsPermissions()).isNull();
  }