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
58 lines (48 loc) · 2.14 KB
/
RoleTest.java
File metadata and controls
58 lines (48 loc) · 2.14 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
51
52
53
54
55
56
57
58
/*
* Copyright (C) 2004-2017, 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 nl.jqno.equalsverifier.EqualsVerifier;
import org.testng.annotations.Test;
import java.io.IOException;
import static com.gooddata.util.ResourceUtils.readObjectFromResource;
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 {
return readObjectFromResource("/project/project-role" + suffix + ".json", Role.class);
}
@Test
public void shouldVerifyEquals() throws Exception {
EqualsVerifier.forClass(Role.class)
.usingGetClass()
.withNonnullFields("permissions", "meta", "links")
.withIgnoredFields("links")
.verify();
}
}