diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/AbstractTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/AbstractTest.java index 8925b8f..6505037 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/AbstractTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/AbstractTest.java @@ -1,5 +1,9 @@ package com.knecon.fforesight.service.layoutparser.server; +import static org.mockito.ArgumentMatchers.any; +import static org.mockito.Mockito.mock; +import static org.mockito.Mockito.when; + import java.io.File; import java.io.FileInputStream; import java.io.InputStream; @@ -12,6 +16,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitTemplate; +import org.springframework.amqp.rabbit.listener.MessageListenerContainer; import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; @@ -57,8 +62,6 @@ public abstract class AbstractTest { @MockBean private RabbitAdmin rabbitAdmin; - @MockBean - private RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry; protected final static String ORIGIN_FILE_ID = "origin"; protected final static String VISUAL_LAYOUT_FILE = "visual"; @@ -243,6 +246,16 @@ public abstract class AbstractTest { @ComponentScan("com.knecon.fforesight.service.layoutparser") public static class TestConfiguration { + @Bean + public RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry() { + + var mock = mock(RabbitListenerEndpointRegistry.class); + when(mock.getListenerContainer(any())).thenReturn(mock(MessageListenerContainer.class)); + + return mock; + } + + @Bean @Primary public StorageService inmemoryStorage() { diff --git a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/HeadlinesGoldStandardIntegrationTest.java b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/HeadlinesGoldStandardIntegrationTest.java index 35fa624..7fac654 100644 --- a/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/HeadlinesGoldStandardIntegrationTest.java +++ b/layoutparser-service/layoutparser-service-server/src/test/java/com/knecon/fforesight/service/layoutparser/server/HeadlinesGoldStandardIntegrationTest.java @@ -13,15 +13,9 @@ import org.junit.jupiter.api.Test; import org.junit.jupiter.api.extension.ExtendWith; import org.springframework.amqp.rabbit.core.RabbitAdmin; import org.springframework.amqp.rabbit.core.RabbitTemplate; -import org.springframework.amqp.rabbit.listener.RabbitListenerEndpointRegistry; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.autoconfigure.EnableAutoConfiguration; -import org.springframework.boot.autoconfigure.amqp.RabbitAutoConfiguration; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.mock.mockito.MockBean; -import org.springframework.context.annotation.ComponentScan; -import org.springframework.context.annotation.Configuration; -import org.springframework.context.annotation.FilterType; import org.springframework.context.annotation.Import; import org.springframework.core.io.ClassPathResource; import org.springframework.test.context.junit.jupiter.SpringExtension; @@ -29,7 +23,6 @@ import org.springframework.test.context.junit.jupiter.SpringExtension; import com.fasterxml.jackson.databind.ObjectMapper; import com.iqser.red.service.redaction.v1.server.model.document.nodes.Document; import com.iqser.red.service.redaction.v1.server.model.document.nodes.SemanticNode; -import com.iqser.red.storage.commons.StorageAutoConfiguration; import com.iqser.red.storage.commons.service.StorageService; import com.knecon.fforesight.service.layoutparser.internal.api.queue.LayoutParsingType; import com.knecon.fforesight.service.layoutparser.processor.LayoutParsingPipeline; @@ -48,7 +41,7 @@ import lombok.ToString; @Disabled @ExtendWith(SpringExtension.class) @SpringBootTest(classes = Application.class, webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT) -@Import(HeadlinesGoldStandardIntegrationTest.RedactionIntegrationTestConfiguration.class) +@Import(AbstractTest.TestConfiguration.class) public class HeadlinesGoldStandardIntegrationTest { @MockBean @@ -60,9 +53,6 @@ public class HeadlinesGoldStandardIntegrationTest { @MockBean private RabbitAdmin rabbitAdmin; - @MockBean - private RabbitListenerEndpointRegistry rabbitListenerEndpointRegistry; - @Autowired private ObjectMapper objectMapper; @@ -148,13 +138,6 @@ public class HeadlinesGoldStandardIntegrationTest { } - @Configuration - @EnableAutoConfiguration(exclude = {RabbitAutoConfiguration.class/*, StorageAutoConfiguration.class*/}) - @ComponentScan(excludeFilters = {@ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = StorageAutoConfiguration.class)}) - public static class RedactionIntegrationTestConfiguration { - - } - @Data @EqualsAndHashCode @AllArgsConstructor