Skip to content

Commit

Permalink
feat: support FlowableIdGeneratorAutoConfiguration
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang committed Oct 25, 2023
1 parent 743f78d commit b26fc5a
Show file tree
Hide file tree
Showing 5 changed files with 95 additions and 1 deletion.
8 changes: 7 additions & 1 deletion cosid-spring-boot-starter/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,10 @@ java {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "data-jdbc-support", version.toString())
}
registerFeature("flowableSupport") {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "flowable-support", version.toString())
}
registerFeature("cloudSupport") {
usingSourceSet(sourceSets[SourceSet.MAIN_SOURCE_SET_NAME])
capability(group.toString(), "cloud-support", version.toString())
Expand All @@ -63,7 +67,9 @@ dependencies {

"proxySupportImplementation"(project(":cosid-proxy"))
"mongoSupportImplementation"(project(":cosid-mongo"))

"flowableSupportImplementation"(project(":cosid-flowable"))
"flowableSupportImplementation"(libs.flowableSpring)
"flowableSupportImplementation"(libs.flowableSpringBootAutoconfigure)
"mybatisSupportImplementation"(project(":cosid-mybatis"))
"dataJdbcSupportImplementation"(project(":cosid-spring-data-jdbc"))
api("org.springframework.boot:spring-boot-starter")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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 me.ahoo.cosid.spring.boot.starter.flowable;

import me.ahoo.cosid.flowable.FlowableIdGenerator;
import me.ahoo.cosid.spring.boot.starter.ConditionalOnCosIdEnabled;

import org.flowable.spring.SpringProcessEngineConfiguration;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.context.annotation.Bean;

/**
* Flowable IdGenerator Auto Configuration.
*
* @author ahoo wang
*/
@AutoConfiguration
@ConditionalOnCosIdEnabled
@ConditionalOnClass(FlowableIdGenerator.class)
public class FlowableIdGeneratorAutoConfiguration {

@Bean
public EngineConfigurationConfigurer<SpringProcessEngineConfiguration> engineConfigurationConfigurer() {
return new CosIdEngineConfigurationConfigurer();
}

static class CosIdEngineConfigurationConfigurer implements EngineConfigurationConfigurer<SpringProcessEngineConfiguration> {

@Override
public void configure(SpringProcessEngineConfiguration engineConfiguration) {
engineConfiguration.setIdGenerator(new FlowableIdGenerator());
}

Check warning on line 45 in cosid-spring-boot-starter/src/main/java/me/ahoo/cosid/spring/boot/starter/flowable/FlowableIdGeneratorAutoConfiguration.java

View check run for this annotation

Codecov / codecov/patch

cosid-spring-boot-starter/src/main/java/me/ahoo/cosid/spring/boot/starter/flowable/FlowableIdGeneratorAutoConfiguration.java#L44-L45

Added lines #L44 - L45 were not covered by tests
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,3 +18,4 @@ me.ahoo.cosid.spring.boot.starter.segment.CosIdProxySegmentAutoConfiguration
me.ahoo.cosid.spring.boot.starter.mybatis.CosIdMybatisAutoConfiguration
me.ahoo.cosid.spring.boot.starter.actuate.CosIdEndpointAutoConfiguration
me.ahoo.cosid.spring.boot.starter.jdbc.CosIdJdbcAutoConfiguration
me.ahoo.cosid.spring.boot.starter.flowable.FlowableIdGeneratorAutoConfiguration
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright [2021-present] [ahoo wang <ahoowang@qq.com> (https://github.com/Ahoo-Wang)].
* 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 me.ahoo.cosid.spring.boot.starter.flowable;

import me.ahoo.cosid.spring.boot.starter.machine.ConditionalOnCosIdMachineEnabled;

import org.assertj.core.api.AssertionsForInterfaceTypes;
import org.flowable.spring.boot.EngineConfigurationConfigurer;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.runner.ApplicationContextRunner;

class FlowableIdGeneratorAutoConfigurationTest {
private final ApplicationContextRunner contextRunner = new ApplicationContextRunner();

@Test
void contextLoads() {
this.contextRunner
.withPropertyValues(ConditionalOnCosIdMachineEnabled.ENABLED_KEY + "=true")
.withUserConfiguration(FlowableIdGeneratorAutoConfiguration.class)
.run(context -> {
AssertionsForInterfaceTypes.assertThat(context)
.hasSingleBean(FlowableIdGeneratorAutoConfiguration.class)
.hasSingleBean(EngineConfigurationConfigurer.class)
;
});
}
}
2 changes: 2 additions & 0 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,8 @@ mybatis = { module = "org.mybatis:mybatis", version.ref = "mybatis" }
mybatisSpringBoot = { module = "org.mybatis.spring.boot:mybatis-spring-boot-starter", version.ref = "mybatisSpringBoot" }
springDocStarterWebfluxUi = { module = "org.springdoc:springdoc-openapi-starter-webflux-ui", version.ref = "springDoc" }
flowableEngineCommon = { module = "org.flowable:flowable-engine-common", version.ref = "flowable" }
flowableSpring = { module = "org.flowable:flowable-spring", version.ref = "flowable" }
flowableSpringBootAutoconfigure = { module = "org.flowable:flowable-spring-boot-autoconfigure", version.ref = "flowable" }
junitPioneer = { module = "org.junit-pioneer:junit-pioneer", version.ref = "junitPioneer" }
hamcrest = { module = "org.hamcrest:hamcrest", version.ref = "hamcrest" }
mockk = { module = "io.mockk:mockk", version.ref = "mockk" }
Expand Down

0 comments on commit b26fc5a

Please sign in to comment.