Skip to content

Commit

Permalink
all bean names should refer to operate (#117) (#119)
Browse files Browse the repository at this point in the history
(cherry picked from commit dde8c81)
  • Loading branch information
jonathanlukas authored Oct 21, 2024
1 parent 1b0fcde commit 9cc12cb
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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<DynamicTest> 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");
}
}

0 comments on commit 9cc12cb

Please sign in to comment.