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
9 changes: 6 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
# - push / pull_request on the feature/3.0.x branch
# - manual workflow_dispatch
#
# Runs `mvn -B clean verify` which includes the JaCoCo coverage gate
# (90% line coverage, haltOnFailure=false) configured in the POM.
# Runs `./mvnw -B clean verify` which includes the JaCoCo coverage gate
# (90% line coverage, haltOnFailure=true) configured in the POM.
name: CI

on:
Expand Down Expand Up @@ -35,7 +35,10 @@ jobs:
cache: maven

- name: Build and verify with JaCoCo coverage gate
run: mvn -B --no-transfer-progress clean verify
run: ./mvnw -B --no-transfer-progress clean verify

- name: Inspect Jackson dependency tree
run: ./mvnw -B --no-transfer-progress dependency:tree -Dincludes=com.fasterxml.jackson.core:*,tools.jackson.core:*,com.fasterxml.jackson:*,tools.jackson:*

- name: Upload JaCoCo coverage report
if: always()
Expand Down
16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,15 +54,15 @@ Typical scenarios:
| Response models with risk semantics | Implemented | `AntiFraudResponse`, `AntiFraudImageResponse`, `BatchAntiFraudImageResponse`, `AntiFraudVideoResponse` |
| Risk detail / hit models | Implemented | `AntiFraudDetail`, `AntiFraudImageDetail`, `AntiFraudImageDetailHits`, `BatchAntiFraudImageItem` |
| HTTP transport client | Not yet implemented | OkHttp 4.9.3 is declared in the pom; no client class exists in this branch yet |
| Unit tests | Not yet present | JaCoCo 90% line-coverage gate is configured in the pom (non-failing) |
| Unit tests | 228 JUnit tests in the current CI run | JaCoCo enforces a 90% line-coverage threshold on its measured source lines |

## 3. Requirements & Compatibility

| Item | Requirement |
| :--- | :--- |
| JDK | 21+ |
| Maven | 3.0+ (Maven Wrapper `mvnw` is included) |
| Dependencies | okhttp 4.9.3, jackson-databind 2.17.2, slf4j-api 2.0.18, lombok (provided) |
| Maven | 4.0.0-rc-5 (Maven Wrapper `mvnw` is included) |
| Dependencies | okhttp 4.12.0, jackson-databind 3.2.4, slf4j-api 2.0.18, lombok (provided) |

Version lines:

Expand Down Expand Up @@ -120,7 +120,7 @@ The snapshot is served from the project's private repository; make sure the repo
Build a text-moderation request and serialize it to JSON:

```java
import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;
import com.ishumei.spring.boot.model.AntiFraudTextRequest;
import com.ishumei.spring.boot.model.AntiFraudTextRequestData;

Expand All @@ -133,7 +133,7 @@ data.setText("hello world");
data.setNickname("tester");
request.setData(data);

String json = new ObjectMapper().writeValueAsString(request);
String json = JsonMapper.builder().build().writeValueAsString(request);
```

Expected output (field order follows the model declaration):
Expand All @@ -156,7 +156,7 @@ Interpreting a Shumei risk response:
```java
import com.ishumei.spring.boot.model.AntiFraudResponse;

AntiFraudResponse response = new ObjectMapper().readValue(apiBody, AntiFraudResponse.class);
AntiFraudResponse response = JsonMapper.builder().build().readValue(apiBody, AntiFraudResponse.class);

boolean success = response.isSuccess(); // status == 0 && code == "1100"
boolean pass = response.isPass(); // success && riskLevel == "PASS"
Expand Down Expand Up @@ -187,11 +187,11 @@ request.getData().getImgs().add(new AntiFraudImageRequestItem()); // img / token

The build is configured with:

- JaCoCo coverage reporting plus a line-coverage check rule with a 90% minimum target (`haltOnFailure=false`, so the check reports rather than blocks).
- JaCoCo coverage reporting and a blocking 90% line-coverage check (`haltOnFailure=true`).
- Source and Javadoc jars attached at package time.
- A `central` release profile (GPG signing + Central publishing) reserved for official releases.

Note: this branch currently contains no test sources, so the coverage gate has nothing to measure yet.
The current CI report counts 12 of 12 instrumented source lines as covered (100%). Lombok-generated methods are outside that denominator, so this ratio does not mean every SDK behavior is covered.

## 10. Versioning & Branches

Expand Down
18 changes: 9 additions & 9 deletions README.zh-CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,16 +53,16 @@ ishumei-java-sdk 为数美(Shumei)反欺诈与内容审核 API 提供类型
| 视频反欺诈请求模型 | 已实现 | `AntiFraudVideoRequest` + `AntiFraudVideoRequestData` |
| 带风险语义的响应模型 | 已实现 | `AntiFraudResponse`、`AntiFraudImageResponse`、`BatchAntiFraudImageResponse`、`AntiFraudVideoResponse` |
| 风险详情/命中模型 | 已实现 | `AntiFraudDetail`、`AntiFraudImageDetail`、`AntiFraudImageDetailHits`、`BatchAntiFraudImageItem` |
| HTTP 传输客户端 | 未实现 | pom 已声明 OkHttp 4.9.3,但本分支尚无客户端类 |
| 单元测试 | 暂无 | pom 已配置 JaCoCo 90% 行覆盖率门禁(不阻断构建) |
| HTTP 传输客户端 | 未实现 | pom 已声明 OkHttp 4.12.0,但本分支尚无客户端类 |
| 单元测试 | 当前 CI 运行 228 个 JUnit 测试 | JaCoCo 对计入统计的源码行执行 90% 覆盖率门禁 |

## 3. 环境要求与兼容性

| 项目 | 要求 |
| :--- | :--- |
| JDK | 21+ |
| Maven | 3.0+(内置 Maven Wrapper `mvnw`) |
| 依赖 | okhttp 4.9.3、jackson-databind 2.17.2、slf4j-api 2.0.18、lombok(provided) |
| Maven | 4.0.0-rc-5(内置 Maven Wrapper `mvnw`) |
| 依赖 | okhttp 4.12.0、jackson-databind 3.2.4、slf4j-api 2.0.18、lombok(provided) |

版本线:

Expand Down Expand Up @@ -120,7 +120,7 @@ implementation 'io.github.easy4j:ishumei-java-sdk:3.0.x.x.20260630-SNAPSHOT'
构建文本审核请求并序列化为 JSON:

```java
import com.fasterxml.jackson.databind.ObjectMapper;
import tools.jackson.databind.json.JsonMapper;
import com.ishumei.spring.boot.model.AntiFraudTextRequest;
import com.ishumei.spring.boot.model.AntiFraudTextRequestData;

Expand All @@ -133,7 +133,7 @@ data.setText("hello world");
data.setNickname("tester");
request.setData(data);

String json = new ObjectMapper().writeValueAsString(request);
String json = JsonMapper.builder().build().writeValueAsString(request);
```

预期输出(字段顺序与模型声明顺序一致):
Expand All @@ -156,7 +156,7 @@ String json = new ObjectMapper().writeValueAsString(request);
```java
import com.ishumei.spring.boot.model.AntiFraudResponse;

AntiFraudResponse response = new ObjectMapper().readValue(apiBody, AntiFraudResponse.class);
AntiFraudResponse response = JsonMapper.builder().build().readValue(apiBody, AntiFraudResponse.class);

boolean success = response.isSuccess(); // status == 0 && code == "1100"
boolean pass = response.isPass(); // success && riskLevel == "PASS"
Expand Down Expand Up @@ -187,11 +187,11 @@ request.getData().getImgs().add(new AntiFraudImageRequestItem()); // 每个条

构建配置:

- JaCoCo 覆盖率报告 + 行覆盖率检查规则,最低目标 90%(`haltOnFailure=false`,只报告不阻断);
- JaCoCo 覆盖率报告与阻断构建的 90% 行覆盖率检查(`haltOnFailure=true`);
- package 阶段附加源码包与 Javadoc 包;
- 提供 `central` 发布 profile(GPG 签名 + Central 发布插件),仅用于正式发布。

说明:本分支当前没有测试源码,覆盖率门禁暂无数据可校验。
当前 CI 报告计入统计的 12 行源码全部覆盖(12/12,100%)。Lombok 生成的方法不在此分母中,不能据此认定 SDK 全部行为已覆盖。

## 10. 版本与分支

Expand Down
Empty file modified mvnw
100644 → 100755
Empty file.
9 changes: 7 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
<maven.version>4.0.0-rc-5</maven.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<!-- Dependency versions -->
<jackson-bom.version>3.2.1</jackson-bom.version>
<jackson-bom.version>3.2.4</jackson-bom.version>
<junit-jupiter.version>6.1.0</junit-jupiter.version>
<lombok.version>1.18.46</lombok.version>
<okhttp.version>4.12.0</okhttp.version>
Expand Down Expand Up @@ -144,7 +144,7 @@
<goal>check</goal>
</goals>
<configuration>
<haltOnFailure>false</haltOnFailure>
<haltOnFailure>true</haltOnFailure>
<rules>
<rule>
<element>BUNDLE</element>
Expand Down Expand Up @@ -179,6 +179,11 @@
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>3.5.2</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
Expand Down
52 changes: 52 additions & 0 deletions src/test/java/com/ishumei/spring/boot/model/JsonRoundTripTest.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package com.ishumei.spring.boot.model;

import tools.jackson.databind.json.JsonMapper;
import org.junit.jupiter.api.Test;

import static org.junit.jupiter.api.Assertions.*;

class JsonRoundTripTest {

@Test
void textRequestRoundTripPreservesWireFields() throws Exception {
JsonMapper mapper = JsonMapper.builder().build();
AntiFraudTextRequest request = new AntiFraudTextRequest();
request.setAccessKey("test-key");
request.setType("ECOM");
AntiFraudTextRequestData data = new AntiFraudTextRequestData();
data.setText("hello world");
data.setNickname("alice");
request.setData(data);

String json = mapper.writeValueAsString(request);
assertTrue(json.contains("\"appId\":\"default\""));
assertTrue(json.contains("\"text\":\"hello world\""));

AntiFraudTextRequest decoded = mapper.readValue(json, AntiFraudTextRequest.class);
assertEquals("default", decoded.getAppId());
assertEquals("test-key", decoded.getAccessKey());
assertEquals("ECOM", decoded.getType());
assertEquals("hello world", decoded.getData().getText());
assertEquals("alice", decoded.getData().getNickname());
}

@Test
void responseRoundTripPreservesRiskDecision() throws Exception {
JsonMapper mapper = JsonMapper.builder().build();
String json = "{\"code\":\"1100\",\"status\":0,\"riskLevel\":\"PASS\","
+ "\"requestId\":\"req-123\",\"score\":42,\"detail\":\"{}\","
+ "\"futureField\":\"ignored\"}";

AntiFraudResponse response = mapper.readValue(json, AntiFraudResponse.class);
assertTrue(response.isSuccess());
assertTrue(response.isPass());
assertEquals("req-123", response.getRequestId());
assertEquals("{}", response.getDetail());

AntiFraudResponse decoded = mapper.readValue(
mapper.writeValueAsString(response), AntiFraudResponse.class);
assertEquals("1100", decoded.getCode());
assertEquals(42, decoded.getScore());
assertEquals("PASS", decoded.getRiskLevel());
}
}
Loading