|
@@ -11,6 +11,7 @@ import com.etotem.num.entity.RatingAnnotation;
|
|
|
import com.etotem.num.entity.Tag;
|
|
import com.etotem.num.entity.Tag;
|
|
|
import com.etotem.num.entity.User;
|
|
import com.etotem.num.entity.User;
|
|
|
import com.etotem.num.entity.Withdraw;
|
|
import com.etotem.num.entity.Withdraw;
|
|
|
|
|
+import com.etotem.num.repository.UserRepository;
|
|
|
import com.etotem.num.service.*;
|
|
import com.etotem.num.service.*;
|
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
import org.junit.jupiter.api.BeforeEach;
|
|
|
import org.junit.jupiter.api.Test;
|
|
import org.junit.jupiter.api.Test;
|
|
@@ -71,6 +72,9 @@ class ControllerIntegrationTest {
|
|
|
@MockBean
|
|
@MockBean
|
|
|
private AnnotationService annotationService;
|
|
private AnnotationService annotationService;
|
|
|
|
|
|
|
|
|
|
+ @MockBean
|
|
|
|
|
+ private UserRepository userRepository;
|
|
|
|
|
+
|
|
|
@MockBean
|
|
@MockBean
|
|
|
private ExportService exportService;
|
|
private ExportService exportService;
|
|
|
|
|
|
|
@@ -456,10 +460,10 @@ class ControllerIntegrationTest {
|
|
|
mockUser.setLastQuotaDate(java.time.LocalDate.now());
|
|
mockUser.setLastQuotaDate(java.time.LocalDate.now());
|
|
|
when(userService.isVip(100L)).thenReturn(true);
|
|
when(userService.isVip(100L)).thenReturn(true);
|
|
|
when(userService.getAndResetDailyQuota(100L)).thenReturn(mockUser);
|
|
when(userService.getAndResetDailyQuota(100L)).thenReturn(mockUser);
|
|
|
- when(userService.getById(100L)).thenReturn(mockUser);
|
|
|
|
|
|
|
|
|
|
mockMvc.perform(post("/api/profile/quota")
|
|
mockMvc.perform(post("/api/profile/quota")
|
|
|
- .header("Authorization", "Bearer " + userToken))
|
|
|
|
|
|
|
+ .header("Authorization", "Bearer " + userToken)
|
|
|
|
|
+ .contentType(MediaType.APPLICATION_JSON))
|
|
|
.andExpect(status().isOk())
|
|
.andExpect(status().isOk())
|
|
|
.andExpect(jsonPath("$.code").value(0))
|
|
.andExpect(jsonPath("$.code").value(0))
|
|
|
.andExpect(jsonPath("$.data.isVip").value(true))
|
|
.andExpect(jsonPath("$.data.isVip").value(true))
|
|
@@ -478,7 +482,6 @@ class ControllerIntegrationTest {
|
|
|
mockUser.setLastQuotaDate(java.time.LocalDate.now());
|
|
mockUser.setLastQuotaDate(java.time.LocalDate.now());
|
|
|
when(userService.isVip(100L)).thenReturn(false);
|
|
when(userService.isVip(100L)).thenReturn(false);
|
|
|
when(userService.getAndResetDailyQuota(100L)).thenReturn(mockUser);
|
|
when(userService.getAndResetDailyQuota(100L)).thenReturn(mockUser);
|
|
|
- when(userService.getById(100L)).thenReturn(mockUser);
|
|
|
|
|
// ConfigService is mocked — set default quota return values
|
|
// ConfigService is mocked — set default quota return values
|
|
|
when(configService.getQuota("chart")).thenReturn(3);
|
|
when(configService.getQuota("chart")).thenReturn(3);
|
|
|
when(configService.getQuota("chat")).thenReturn(3);
|
|
when(configService.getQuota("chat")).thenReturn(3);
|
|
@@ -812,6 +815,17 @@ class ControllerIntegrationTest {
|
|
|
when(configService.getInt("pricing.annual", 13100)).thenReturn(13100);
|
|
when(configService.getInt("pricing.annual", 13100)).thenReturn(13100);
|
|
|
when(configService.getInt("pricing.practitioner.seed_limit", 300)).thenReturn(300);
|
|
when(configService.getInt("pricing.practitioner.seed_limit", 300)).thenReturn(300);
|
|
|
|
|
|
|
|
|
|
+ // Mock founder check: current user (100) was invited by a founder (200)
|
|
|
|
|
+ User currentUser = new User();
|
|
|
|
|
+ currentUser.setId(100L);
|
|
|
|
|
+ currentUser.setInvitedBy(200L);
|
|
|
|
|
+ User founder = new User();
|
|
|
|
|
+ founder.setId(200L);
|
|
|
|
|
+ founder.setInvitedBy(null);
|
|
|
|
|
+ founder.setVipType("practitioner");
|
|
|
|
|
+ when(userRepository.findById(100L)).thenReturn(Optional.of(currentUser));
|
|
|
|
|
+ when(userRepository.findById(200L)).thenReturn(Optional.of(founder));
|
|
|
|
|
+
|
|
|
mockMvc.perform(post("/api/pricing/current")
|
|
mockMvc.perform(post("/api/pricing/current")
|
|
|
.header("Authorization", "Bearer " + userToken)
|
|
.header("Authorization", "Bearer " + userToken)
|
|
|
.contentType(MediaType.APPLICATION_JSON))
|
|
.contentType(MediaType.APPLICATION_JSON))
|