优化
This commit is contained in:
@@ -40,6 +40,11 @@ class IamOpenApiContractTest {
|
||||
.contains("TenantAddressListApiResponse:")
|
||||
.contains("TenantQualificationListApiResponse:")
|
||||
.contains("InternalUserListApiResponse:")
|
||||
.contains("MerchantMemberResponse:")
|
||||
.contains("username: {type: string, description: 统一认证登录账号}")
|
||||
.contains("lastLoginAt: {type: string, format: date-time, nullable: true")
|
||||
.contains("RoleResponse:")
|
||||
.contains("memberCount: {type: integer, format: int64, minimum: 0")
|
||||
.contains("/api/platform/v1/iam/internal-users/{membershipId}/roles:")
|
||||
.contains("AssignInternalUserRolesRequest:")
|
||||
.contains("/api/merchant/v1/iam/members/{membershipId}:")
|
||||
|
||||
@@ -19,6 +19,7 @@ import org.springframework.boot.test.mock.mockito.MockBean;
|
||||
import org.springframework.test.context.TestPropertySource;
|
||||
import org.springframework.test.context.junit.jupiter.SpringJUnitConfig;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@@ -44,15 +45,20 @@ class MemberServiceTest {
|
||||
when(repository.findByTenantAndId(100L, 20L)).thenReturn(member);
|
||||
when(repository.findUser(30L)).thenReturn(user);
|
||||
when(repository.findRoleIds(100L, 20L)).thenReturn(List.of(50L));
|
||||
when(auth.summary("internal-token", 40L)).thenReturn(ApiResponse.success(
|
||||
new AuthAccountClient.AccountSummary(40L, "member01", "测试成员", "ACTIVE",
|
||||
LocalDateTime.of(2026, 8, 17, 10, 30), 100L, 20L, "MERCHANT")));
|
||||
}
|
||||
|
||||
@Test void shouldHandleCase01() {
|
||||
user.setPhone("13800138000"); user.setEmail("member@example.com");
|
||||
MemberResponse result = service.detail(100L, 20L);
|
||||
assertEquals("测试成员", result.displayName());
|
||||
assertEquals("member01", result.username());
|
||||
assertEquals("13800138000", result.phone());
|
||||
assertEquals(LocalDateTime.of(2026, 8, 17, 10, 30), result.lastLoginAt());
|
||||
assertEquals(List.of(50L), result.roleIds());
|
||||
verifyNoInteractions(auth);
|
||||
verify(auth).summary("internal-token", 40L);
|
||||
}
|
||||
|
||||
@Test void shouldReturnOwnerAccountForPlatformCustomerDetail() {
|
||||
|
||||
@@ -27,6 +27,7 @@ import org.springframework.test.context.TestPropertySource;
|
||||
import jakarta.annotation.Resource;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.*;
|
||||
@@ -46,11 +47,14 @@ class RbacServiceTest {
|
||||
IamRole role = role(11L, 100L, "MERCHANT", "CUSTOM");
|
||||
when(repository.findRoles(100L, "MERCHANT")).thenReturn(List.of(role));
|
||||
when(repository.findRolePermissionIds(100L, 11L)).thenReturn(Set.of(21L, 22L));
|
||||
when(repository.findRoleMemberCounts(100L, List.of(11L))).thenReturn(Map.of(11L, 3L));
|
||||
|
||||
var result = service.roles(100L, "MERCHANT");
|
||||
|
||||
assertEquals(Set.of(21L, 22L), result.get(0).permissionIds());
|
||||
assertEquals(3L, result.get(0).memberCount());
|
||||
assertEquals(100L, result.get(0).tenantId());
|
||||
verify(repository, never()).countRoleMembers(anyLong(), anyLong());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
Reference in New Issue
Block a user