From 9cc12cb16e55f3800eb46c099d1d00e4982886ce Mon Sep 17 00:00:00 2001 From: Jonathan Lukas Date: Mon, 21 Oct 2024 07:42:34 +0200 Subject: [PATCH] all bean names should refer to operate (#117) (#119) (cherry picked from commit dde8c81a005b9752532ae737117ec30e03027084) --- .../spring/OperateClientConfiguration.java | 2 +- .../camunda/operate/spring/BeanNameTest.java | 34 +++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 extension/spring-boot-starter-camunda-operate/src/test/java/io/camunda/operate/spring/BeanNameTest.java diff --git a/extension/spring-boot-starter-camunda-operate/src/main/java/io/camunda/operate/spring/OperateClientConfiguration.java b/extension/spring-boot-starter-camunda-operate/src/main/java/io/camunda/operate/spring/OperateClientConfiguration.java index db8a601..f5054c7 100644 --- a/extension/spring-boot-starter-camunda-operate/src/main/java/io/camunda/operate/spring/OperateClientConfiguration.java +++ b/extension/spring-boot-starter-camunda-operate/src/main/java/io/camunda/operate/spring/OperateClientConfiguration.java @@ -57,7 +57,7 @@ public CloseableHttpClient operateHttpClient() { @Bean @ConditionalOnMissingBean - public Authentication authentication() { + public Authentication operateAuthentication() { if (properties.profile() == null) { throw new IllegalStateException("'operate.client.profile' is required"); } diff --git a/extension/spring-boot-starter-camunda-operate/src/test/java/io/camunda/operate/spring/BeanNameTest.java b/extension/spring-boot-starter-camunda-operate/src/test/java/io/camunda/operate/spring/BeanNameTest.java new file mode 100644 index 0000000..79f11ab --- /dev/null +++ b/extension/spring-boot-starter-camunda-operate/src/test/java/io/camunda/operate/spring/BeanNameTest.java @@ -0,0 +1,34 @@ +package io.camunda.operate.spring; + +import static org.assertj.core.api.Assertions.*; + +import io.camunda.operate.CamundaOperateClient; +import io.camunda.operate.CamundaOperateClientConfiguration; +import io.camunda.operate.auth.Authentication; +import java.util.stream.Stream; +import org.apache.hc.client5.http.impl.classic.CloseableHttpClient; +import org.junit.jupiter.api.DynamicTest; +import org.junit.jupiter.api.TestFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.context.ApplicationContext; + +@SpringBootTest(properties = "operate.client.profile=simple") +public class BeanNameTest { + @Autowired ApplicationContext applicationContext; + + @TestFactory + Stream shouldHaveBeanName() { + return Stream.of( + applicationContext.getBeanNamesForType(Authentication.class), + applicationContext.getBeanNamesForType(CamundaOperateClient.class), + applicationContext.getBeanNamesForType(CloseableHttpClient.class), + applicationContext.getBeanNamesForType(CamundaOperateClientConfiguration.class)) + .map(s -> DynamicTest.dynamicTest(s[0], () -> testBeanName(s))); + } + + private void testBeanName(String[] beanNames) { + assertThat(beanNames).hasSize(1); + assertThat(beanNames[0]).containsIgnoringCase("operate"); + } +}