|
16 | 16 | */ |
17 | 17 | package com.ctrip.framework.apollo.portal.spi.defaultImpl; |
18 | 18 |
|
| 19 | +import static org.junit.Assert.assertEquals; |
| 20 | +import static org.junit.Assert.assertFalse; |
| 21 | +import static org.junit.Assert.assertTrue; |
| 22 | + |
19 | 23 | import com.ctrip.framework.apollo.common.entity.BaseEntity; |
20 | 24 | import com.ctrip.framework.apollo.portal.AbstractIntegrationTest; |
21 | 25 | import com.ctrip.framework.apollo.portal.entity.bo.UserInfo; |
|
29 | 33 | import com.ctrip.framework.apollo.portal.repository.UserRoleRepository; |
30 | 34 | import com.ctrip.framework.apollo.portal.service.RolePermissionService; |
31 | 35 | import com.google.common.collect.Sets; |
| 36 | +import java.util.List; |
| 37 | +import java.util.Set; |
| 38 | +import java.util.stream.Collectors; |
| 39 | +import org.assertj.core.api.Assertions; |
32 | 40 | import org.junit.Before; |
33 | 41 | import org.junit.Test; |
34 | 42 | import org.springframework.beans.factory.annotation.Autowired; |
35 | 43 | import org.springframework.test.context.jdbc.Sql; |
36 | 44 |
|
37 | | -import java.util.List; |
38 | | -import java.util.Set; |
39 | | -import java.util.stream.Collectors; |
40 | | - |
41 | | -import static org.junit.Assert.assertEquals; |
42 | | -import static org.junit.Assert.assertFalse; |
43 | | -import static org.junit.Assert.assertTrue; |
44 | | - |
45 | 45 | /** |
46 | 46 | * @author Jason Song(song_s@ctrip.com) |
47 | 47 | */ |
@@ -285,13 +285,14 @@ public void testRemoveRoleFromUsersWithRoleNotExisted() throws Exception { |
285 | 285 | @Sql(scripts = "/sql/permission/insert-test-userroles.sql", executionPhase = Sql.ExecutionPhase.BEFORE_TEST_METHOD) |
286 | 286 | @Sql(scripts = "/sql/cleanup.sql", executionPhase = Sql.ExecutionPhase.AFTER_TEST_METHOD) |
287 | 287 | public void testQueryUsersWithRole() throws Exception { |
288 | | - String someRoleName = "someRoleName"; |
289 | | - |
290 | | - Set<UserInfo> users = rolePermissionService.queryUsersWithRole(someRoleName); |
| 288 | + String roleName = "someRoleName"; |
| 289 | + Set<UserInfo> users = rolePermissionService.queryUsersWithRole(roleName); |
| 290 | + Assertions.assertThat(users).isEmpty(); |
291 | 291 |
|
| 292 | + roleName = "apolloRoleName"; |
| 293 | + users = rolePermissionService.queryUsersWithRole(roleName); |
292 | 294 | Set<String> userIds = users.stream().map(UserInfo::getUserId).collect(Collectors.toSet()); |
293 | | - |
294 | | - assertTrue(userIds.containsAll(Sets.newHashSet("someUser", "anotherUser"))); |
| 295 | + assertTrue(userIds.containsAll(Sets.newHashSet("apollo"))); |
295 | 296 | } |
296 | 297 |
|
297 | 298 | @Test |
|
0 commit comments