public static Role mockRole(String roleName, User creator) { Role role = mock(Role.class); when(role.getCreator()).thenReturn(creator); when(role.getCreationTimestamp()).thenReturn(TIMESTAMP_OLD); when(role.getEditor()).thenReturn(creator); when(role.getLastEditedTimestamp()).thenReturn(TIMESTAMP_NEW); when(role.getName()).thenReturn(roleName); when(role.getUuid()).thenReturn(ROLE_CLIENT_UUID); when(role.getRolesWithPerm(GraphPermission.READ_PERM)).thenReturn(createEmptyTraversal()); when(role.getElementVersion()).thenReturn(UUID_4); return role; }
/** * Transform the given object into a source JSON object which can be used to store the document in the search provider specific format. * * @param role * @return JSON document representing the role */ @Override public JsonObject toDocument(Role role) { JsonObject document = new JsonObject(); document.put(NAME_KEY, role.getName()); addBasicReferences(document, role); addPermissionInfo(document, role); document.put(VERSION_KEY, generateVersion(role)); return document; }
public RoleResponseAssert matches(Role role) { assertGenericNode(role, actual); assertEquals(role.getName(), actual.getName()); assertNotNull(actual.getGroups()); return this; }
public GraphQLObjectType createType() { Builder roleType = newObject(); roleType.name(ROLE_TYPE_NAME); roleType.description("Role description"); interfaceTypeProvider.addCommonFields(roleType); // .name roleType.field(newFieldDefinition().name("name").description("The name of the role").type(GraphQLString).dataFetcher((env) -> { Role role = env.getSource(); return role.getName(); })); // .groups roleType.field(newPagingFieldWithFetcher("groups", "Groups which reference the role.", (env) -> { Role role = env.getSource(); GraphQLContext gc = env.getContext(); return role.getGroups(gc.getUser(), getPagingInfo(env)); }, GROUP_PAGE_TYPE_NAME)); return roleType.build(); }