content: /*
   * Copyright 2017-2025 Hyland Software, Inc. and its affiliates.
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * You may obtain a copy of the License at
   *
   *     http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
   * distributed under the License is distributed on an "AS IS" BASIS,
   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
   * See the License for the specific language governing permissions and
   * limitations under the License.
   */
  package org.activiti.cloud.services.messages.test.core;
  
  import static org.assertj.core.api.Assertions.assertThat;
  
  import org.activiti.cloud.services.messages.core.channels.MessageConnectorProcessor;
  import org.assertj.core.api.AbstractStringAssert;
  import org.junit.jupiter.api.Test;
  import org.springframework.beans.factory.annotation.Autowired;
  import org.springframework.boot.autoconfigure.SpringBootApplication;
  import org.springframework.boot.test.context.SpringBootTest;
  import org.springframework.cloud.stream.binder.test.TestChannelBinderConfiguration;
  import org.springframework.context.ApplicationContext;
  import org.springframework.context.annotation.Import;
  import org.springframework.integration.channel.DirectChannel;
  import org.springframework.integration.dsl.IntegrationFlow;
  
  @SpringBootTest(properties = "activiti.cloud.application.name=my-activiti-rb-app")
  @Import(TestChannelBinderConfiguration.class)
  public class MessageCoreAutoConfigurationTest {
  
      @Autowired
      private MessageConnectorProcessor messageConnectorProcessor;
  
      @Autowired
      private IntegrationFlow messageConnectorIntegrationFlow;
  
      @Autowired
      private ApplicationContext applicationContext;
  
      @Autowired
      private DirectChannel discardChannel;
  
      @SpringBootApplication
      static class Application {}
  
      @Test
      public void contextLoads() {
          assertThat(messageConnectorProcessor).isNotNull();
          assertThat(messageConnectorIntegrationFlow).isNotNull();
  
          assertProperty("spring.cloud.stream.bindings.messageConnectorInput.destination").isEqualTo("messageEvents");
          assertProperty("spring.cloud.stream.bindings.messageConnectorOutput.destination").isEqualTo("commandConsumer");
      }
  
      @Test
      void discardChannelSubscriberCount() {
          assertThat(discardChannel.getSubscriberCount()).isEqualTo(1);
      }
  
      private AbstractStringAssert<?> assertProperty(String name) {
          return assertThat(getProperty(name));
      }
  
      private String getProperty(String name) {
          return applicationContext.getEnvironment().getProperty(name);
      }
  }
  