Skip to content

Commit

Permalink
feat: support FlowableIdGenerator (#456)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ahoo-Wang authored Oct 25, 2023
1 parent 218e489 commit 743f78d
Show file tree
Hide file tree
Showing 7 changed files with 103 additions and 2 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/integration-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,25 @@ jobs:
- name: Test CosId-Axon
run: ./gradlew cosid-axon:clean cosid-axon:check

cosid-flowable-test:
name: CosId Flowable Test
needs: [ cosid-core-test ]
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'adopt'
server-id: github
settings-path: ${{ github.workspace }}

- name: Test CosId-Flowable
run: ./gradlew cosid-flowable:clean cosid-flowable:check

cosid-mybatis-test:
name: CosId Mybatis Test
needs: [ cosid-core-test ]
Expand Down
6 changes: 6 additions & 0 deletions cosid-flowable/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
dependencies {
implementation(libs.flowableEngineCommon)
api(project(":cosid-core"))
testImplementation(project(":cosid-test"))

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
* Copyright [2021-present] [ahoo wang <[email protected]> (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.flowable;

import me.ahoo.cosid.provider.IdGeneratorProvider;
import me.ahoo.cosid.provider.LazyIdGenerator;

/**
* Flowable IdGenerator Based on CosId.
*/
public class FlowableIdGenerator implements org.flowable.common.engine.impl.cfg.IdGenerator {
/**
* The key of the system property that can be used to set the id generator name.
*/
public static final String ID_KEY = "cosid.flowable";
private static final String ID_NAME;
private static final LazyIdGenerator ID_GENERATOR;

static {
ID_NAME = System.getProperty(ID_KEY, IdGeneratorProvider.SHARE);
ID_GENERATOR = new LazyIdGenerator(ID_NAME);
}

public String getNextId() {
return ID_GENERATOR.generateAsString();
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/*
* Copyright [2021-present] [ahoo wang <[email protected]> (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.flowable;

import static me.ahoo.cosid.flowable.FlowableIdGenerator.ID_KEY;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.*;

import me.ahoo.cosid.provider.DefaultIdGeneratorProvider;
import me.ahoo.cosid.test.MockIdGenerator;

import org.junit.jupiter.api.Test;
import org.junitpioneer.jupiter.SetSystemProperty;

class FlowableIdGeneratorTest {

@SetSystemProperty(key = ID_KEY, value = "flowable")
@Test
void getNextId() {
DefaultIdGeneratorProvider.INSTANCE.set("flowable", MockIdGenerator.usePrefix("flowable_"));
String id = new FlowableIdGenerator().getNextId();
assertThat(id, startsWith("flowable_"));
}
}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
# limitations under the License.
#
group=me.ahoo.cosid
version=2.5.3
version=2.5.5
description=Universal, flexible, high-performance distributed ID generator.
website=https://github.com/Ahoo-Wang/CosId
issues=https://github.com/Ahoo-Wang/CosId/issues
Expand Down
4 changes: 3 additions & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ mybatis = "3.5.13"
mybatisSpringBoot = "3.0.2"
junitPioneer = "2.1.0"
axon = "4.8.4"
flowable = "6.8.0"
springDoc = "2.2.0"
hamcrest = "2.2"
mockk = "1.13.8"
Expand All @@ -23,12 +24,13 @@ spotbugs = "5.2.1"
springBootDependencies = { module = "org.springframework.boot:spring-boot-dependencies", version.ref = "springBoot" }
springCloudDependencies = { module = "org.springframework.cloud:spring-cloud-dependencies", version.ref = "springCloud" }
okhttpBom = { module = "com.squareup.okhttp3:okhttp-bom", version.ref = "okhttp" }
axonBom= { module = "org.axonframework:axon-bom", version.ref = "axon" }
axonBom = { module = "org.axonframework:axon-bom", version.ref = "axon" }
testcontainersBom = { module = "org.testcontainers:testcontainers-bom", version.ref = "testcontainers" }
guava = { module = "com.google.guava:guava", version.ref = "guava" }
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" }
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
1 change: 1 addition & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ include(":cosid-test")
include(":cosid-proxy")
include(":cosid-proxy-server")
include(":cosid-axon")
include(":cosid-flowable")
include(":cosid-mongo")
include(":cosid-spring-data-jdbc")
include(":code-coverage-report")
Expand Down

0 comments on commit 743f78d

Please sign in to comment.