|
|
@@ -9,6 +9,7 @@ import com.yimeng.okr.enums.ScoreType;
|
|
|
import com.yimeng.okr.exception.BusinessException;
|
|
|
import com.yimeng.okr.event.NotificationEvent;
|
|
|
import com.yimeng.okr.mapper.*;
|
|
|
+import com.yimeng.okr.entity.PerformanceScoreItem;
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
import org.junit.jupiter.api.extension.ExtendWith;
|
|
|
import org.mockito.ArgumentCaptor;
|
|
|
@@ -29,6 +30,7 @@ class PerformanceServiceTest {
|
|
|
@Mock AssessmentPeriodMapper periodMapper;
|
|
|
@Mock SysUserMapper userMapper;
|
|
|
@Mock AuditCorrectionMapper auditCorrectionMapper;
|
|
|
+ @Mock PerformanceScoreItemMapper scoreItemMapper;
|
|
|
@Mock OkrService okrService;
|
|
|
@Mock AuthorizationService authorizationService;
|
|
|
@Mock ApplicationEventPublisher publisher;
|
|
|
@@ -270,4 +272,17 @@ class PerformanceServiceTest {
|
|
|
score.setTotal(80.0);
|
|
|
return score;
|
|
|
}
|
|
|
+
|
|
|
+ @Test
|
|
|
+ void submitSelfScoreWritesStructuredItems() {
|
|
|
+ when(periodMapper.selectById(1L)).thenReturn(period());
|
|
|
+ when(userMapper.selectById(2L)).thenReturn(user(2L, null));
|
|
|
+ when(scoreMapper.insert(any())).thenReturn(1);
|
|
|
+
|
|
|
+ String json = "{\"krScores\":[{\"krId\":1,\"title\":\"KR1\",\"score\":0.8}],"
|
|
|
+ + "\"dimensions\":[{\"id\":1,\"name\":\"质量\",\"maxScore\":10,\"score\":8}]}";
|
|
|
+ performanceService.submitSelfScore(1L, 2L, 50.0, 30.0, 0.0, 0.0, json);
|
|
|
+
|
|
|
+ verify(scoreItemMapper, times(2)).insert(any(PerformanceScoreItem.class));
|
|
|
+ }
|
|
|
}
|