diff --git a/libs/decision-engine/build.gradle.kts b/libs/decision-engine/build.gradle.kts index adaa538..c7d0822 100644 --- a/libs/decision-engine/build.gradle.kts +++ b/libs/decision-engine/build.gradle.kts @@ -3,6 +3,7 @@ plugins { alias(libs.plugins.kotlin.jvm) + `maven-publish` } description = "FinCore Decision Engine core: typed JSON predicate DSL, parser, deterministic evaluator" @@ -29,3 +30,39 @@ java { withSourcesJar() withJavadocJar() } + +publishing { + publications { + create("maven") { + from(components["java"]) + groupId = "com.fincore" + artifactId = "decision-engine" + version = rootProject.version.toString() + pom { + name.set("FinCore Decision Engine") + description.set( + "Typed JSON predicate DSL, fail-closed parser and deterministic evaluator for " + + "FinCore Engine; embeddable without the decision service.", + ) + url.set("https://github.com/tiana-code/fincore-engine") + licenses { + license { + name.set("Business Source License 1.1") + url.set("https://github.com/tiana-code/fincore-engine/blob/main/LICENSE") + } + } + developers { + developer { + id.set("tiana-code") + name.set("Tiana") + } + } + scm { + connection.set("scm:git:https://github.com/tiana-code/fincore-engine.git") + developerConnection.set("scm:git:ssh://git@github.com/tiana-code/fincore-engine.git") + url.set("https://github.com/tiana-code/fincore-engine") + } + } + } + } +} diff --git a/libs/decision-engine/src/test/kotlin/com/fincore/decision/LibraryEmbeddingTest.kt b/libs/decision-engine/src/test/kotlin/com/fincore/decision/LibraryEmbeddingTest.kt new file mode 100644 index 0000000..4344d4f --- /dev/null +++ b/libs/decision-engine/src/test/kotlin/com/fincore/decision/LibraryEmbeddingTest.kt @@ -0,0 +1,41 @@ +// SPDX-License-Identifier: BUSL-1.1 +// SPDX-FileCopyrightText: 2026 FinCore Engine Authors + +package com.fincore.decision + +import com.fincore.decision.domain.DecimalValue +import com.fincore.decision.domain.EvaluationInput +import com.fincore.decision.eval.RuleEvaluator +import com.fincore.decision.parser.RuleParser +import io.kotest.matchers.shouldBe +import org.junit.jupiter.api.Test +import java.math.BigDecimal + +private const val RULE = + """{"condition":{"attr":"age","op":"gte","value":18},"outcome":{"label":"APPROVE"}}""" + +class LibraryEmbeddingTest { + private val parser = RuleParser() + private val evaluator = RuleEvaluator() + + @Test + fun `should approve through the public api when an adult is supplied`() { + val result = evaluator.evaluate(parser.parse(RULE), input("age", "20")) + + result.matched shouldBe true + result.outcome?.label shouldBe "APPROVE" + } + + @Test + fun `should not match through the public api when a minor is supplied`() { + val result = evaluator.evaluate(parser.parse(RULE), input("age", "16")) + + result.matched shouldBe false + result.outcome shouldBe null + } + + private fun input( + attr: String, + value: String, + ) = EvaluationInput(mapOf(attr to DecimalValue(BigDecimal(value)))) +}