Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions libs/decision-engine/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

plugins {
alias(libs.plugins.kotlin.jvm)
`maven-publish`
}

description = "FinCore Decision Engine core: typed JSON predicate DSL, parser, deterministic evaluator"
Expand All @@ -29,3 +30,39 @@ java {
withSourcesJar()
withJavadocJar()
}

publishing {
publications {
create<MavenPublication>("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")
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -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))))
}
Loading