fix(personal): wire OCR services for Spring
This commit is contained in:
+2
@@ -11,6 +11,7 @@ import org.dromara.common.oss.factory.OssFactory;
|
||||
import org.dromara.common.tenant.helper.TenantHelper;
|
||||
import org.dromara.system.domain.vo.SysOssVo;
|
||||
import org.dromara.system.service.ISysOssService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
@@ -35,6 +36,7 @@ public class PersonalPdfOcrService {
|
||||
private final TransactionTemplate transactions;
|
||||
private final OcrSourceReader sourceReader;
|
||||
|
||||
@Autowired
|
||||
public PersonalPdfOcrService(JdbcTemplate jdbcTemplate, PersonalPdfPageRenderer renderer,
|
||||
PersonalVisionOcrService visionOcr, PlatformTransactionManager transactionManager,
|
||||
ISysOssService ossService, PersonalKnowledgeProperties properties) {
|
||||
|
||||
+2
@@ -4,6 +4,7 @@ import com.fasterxml.jackson.databind.JsonNode;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.node.ArrayNode;
|
||||
import com.fasterxml.jackson.databind.node.ObjectNode;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.dao.DataAccessException;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
@@ -35,6 +36,7 @@ public class PersonalVisionOcrService {
|
||||
private final RuntimeProvider runtimeProvider;
|
||||
private final VisionCaller caller;
|
||||
|
||||
@Autowired
|
||||
public PersonalVisionOcrService(ObjectMapper objectMapper, JdbcTemplate jdbcTemplate,
|
||||
@Value("${aihr.ai-runtime.enabled:${AIHR_AI_RUNTIME_ENABLED:true}}")
|
||||
boolean aiEnabled,
|
||||
|
||||
+8
@@ -8,6 +8,7 @@ import org.dromara.aihr.personal.support.PersonalOwner;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.mockito.ArgumentCaptor;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.jdbc.core.BatchPreparedStatementSetter;
|
||||
import org.springframework.jdbc.core.JdbcTemplate;
|
||||
import org.springframework.transaction.support.TransactionCallback;
|
||||
@@ -17,6 +18,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
import static org.mockito.ArgumentMatchers.any;
|
||||
import static org.mockito.ArgumentMatchers.contains;
|
||||
import static org.mockito.ArgumentMatchers.eq;
|
||||
@@ -28,6 +30,12 @@ import static org.mockito.Mockito.when;
|
||||
@Tag("dev")
|
||||
class PersonalPdfOcrServiceTest {
|
||||
|
||||
@Test
|
||||
void productionConstructorIsExplicitlyAutowiredWhenTestConstructorAlsoExists() {
|
||||
assertTrue(java.util.Arrays.stream(PersonalPdfOcrService.class.getDeclaredConstructors())
|
||||
.anyMatch(constructor -> constructor.isAnnotationPresent(Autowired.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void enqueueCreatesOwnerScopedJobAndOnePendingRowPerPage() {
|
||||
JdbcTemplate jdbc = mock(JdbcTemplate.class);
|
||||
|
||||
+7
@@ -7,6 +7,7 @@ import org.dromara.aihr.personal.service.PersonalVisionOcrService.VisionResponse
|
||||
import org.dromara.aihr.personal.service.PersonalVisionOcrService.VisionRuntime;
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.atomic.AtomicReference;
|
||||
@@ -20,6 +21,12 @@ class PersonalVisionOcrServiceTest {
|
||||
|
||||
private static final byte[] JPEG = new byte[] {1, 2, 3};
|
||||
|
||||
@Test
|
||||
void productionConstructorIsExplicitlyAutowiredWhenTestConstructorAlsoExists() {
|
||||
assertTrue(java.util.Arrays.stream(PersonalVisionOcrService.class.getDeclaredConstructors())
|
||||
.anyMatch(constructor -> constructor.isAnnotationPresent(Autowired.class)));
|
||||
}
|
||||
|
||||
@Test
|
||||
void recognizesAndNormalizesPageText() {
|
||||
AtomicReference<String> requestBody = new AtomicReference<>();
|
||||
|
||||
Reference in New Issue
Block a user