forked from gooddata/gooddata-java
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRoleTest.java
More file actions
50 lines (41 loc) · 1.91 KB
/
Copy pathRoleTest.java
File metadata and controls
50 lines (41 loc) · 1.91 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/**
* Copyright (C) 2004-2016, GoodData(R) Corporation. All rights reserved.
* This source code is licensed under the BSD-style license found in the
* LICENSE.txt file in the root directory of this source tree.
*/
package com.gooddata.project;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.testng.annotations.Test;
import java.io.IOException;
import java.io.InputStream;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.hasItem;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.not;
import static org.hamcrest.Matchers.notNullValue;
import static org.hamcrest.collection.IsCollectionWithSize.hasSize;
public class RoleTest {
@Test
public void testDeserialization() throws Exception {
final Role role = readRole("");
assertThat(role, notNullValue());
assertThat(role.getPermissions(), notNullValue());
assertThat(role.getPermissions(), hasSize(71));
assertThat(role.getGrantedPermissions(), not(hasItem("canManageProjectDashboard")));
assertThat(role.hasPermissionGranted("canManageProjectDashboard"), is(false));
assertThat(role.getGrantedPermissions(), hasItem("canCreateReportResult2"));
assertThat(role.hasPermissionGranted("canCreateReportResult2"), is(true));
assertThat(role.getTitle(), is("Embedded Dashboard Only"));
}
@Test
public void testEquals() throws IOException {
final Role role1 = readRole("");
assertThat(role1.equals(readRole("")), is(true));
assertThat(role1.equals(readRole("2")), is(false));
assertThat(role1.equals(readRole("3")), is(false));
}
private Role readRole(final String suffix) throws java.io.IOException {
final InputStream stream = getClass().getResourceAsStream("/project/project-role" + suffix + ".json");
return new ObjectMapper().readValue(stream, Role.class);
}
}