Skip to content

Commit 778ad1a

Browse files
committed
On conditional AAChannelProcessor configuration
Means the integration tests won't try to autowire it
1 parent 82ae89d commit 778ad1a

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

src/main/java/org/phoebus/channelfinder/configuration/AAChannelProcessor.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import org.phoebus.channelfinder.service.model.archiver.aa.ArchiverInfo;
2222
import org.springframework.beans.factory.annotation.Autowired;
2323
import org.springframework.beans.factory.annotation.Value;
24+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2425
import org.springframework.context.annotation.Configuration;
2526

2627
/**
@@ -31,6 +32,7 @@
3132
* <p>e.g. archive=monitor@1.0
3233
*/
3334
@Configuration
35+
@ConditionalOnProperty(name = "aa.enabled", havingValue = "true")
3436
public class AAChannelProcessor implements ChannelProcessor {
3537

3638
private static final Logger logger = Logger.getLogger(AAChannelProcessor.class.getName());

src/main/java/org/phoebus/channelfinder/service/external/ArchiverService.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.phoebus.channelfinder.service.model.archiver.aa.ArchivePVOptions;
1818
import org.springframework.beans.factory.annotation.Autowired;
1919
import org.springframework.beans.factory.annotation.Value;
20+
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
2021
import org.springframework.core.ParameterizedTypeReference;
2122
import org.springframework.http.MediaType;
2223
import org.springframework.http.client.SimpleClientHttpRequestFactory;
@@ -25,6 +26,7 @@
2526
import org.springframework.web.util.UriComponentsBuilder;
2627

2728
@Component
29+
@ConditionalOnProperty(name = "aa.enabled", havingValue = "true")
2830
public class ArchiverService {
2931
private static final Logger logger = Logger.getLogger(ArchiverService.class.getName());
3032
private static final int STATUS_BATCH_SIZE =

src/test/java/org/phoebus/channelfinder/processors/ChannelProcessorControllerIT.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
import org.phoebus.channelfinder.entity.Scroll;
1515
import org.phoebus.channelfinder.rest.api.IChannelScroll;
1616
import org.phoebus.channelfinder.rest.controller.ChannelProcessorController;
17+
import org.phoebus.channelfinder.service.external.ArchiverService;
1718
import org.springframework.beans.factory.annotation.Autowired;
1819
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest;
1920
import org.springframework.boot.test.mock.mockito.MockBean;
2021
import org.springframework.http.HttpHeaders;
2122
import org.springframework.test.context.TestPropertySource;
23+
import org.springframework.test.context.bean.override.mockito.MockitoBean;
2224
import org.springframework.test.context.junit.jupiter.SpringExtension;
2325
import org.springframework.test.web.servlet.MockMvc;
2426
import org.springframework.test.web.servlet.request.MockHttpServletRequestBuilder;
@@ -27,14 +29,15 @@
2729
@WebMvcTest(ChannelProcessorController.class)
2830
@TestPropertySource(
2931
value = "classpath:application_test.properties",
30-
properties = {"elasticsearch.create.indices = false"})
32+
properties = {"elasticsearch.create.indices = false", "aa.enabled=true"})
3133
class ChannelProcessorControllerIT {
3234

3335
protected static final String AUTHORIZATION =
3436
"Basic " + Base64.getEncoder().encodeToString("admin:adminPass".getBytes());
3537

3638
@Autowired protected MockMvc mockMvc;
3739
@MockBean IChannelScroll channelScroll;
40+
@MockitoBean ArchiverService archiverService;
3841

3942
@Test
4043
void testProcessorCount() throws Exception {

0 commit comments

Comments
 (0)