Skip to content
Open
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
4 changes: 2 additions & 2 deletions CI.Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ node ("docker-light") {
withMaven(maven: "Basis",
mavenLocalRepo: mavenLocalRepo,
publisherStrategy: "EXPLICIT") {
sh "mvn clean verify"
sh "mvn -Paggregate-coverage clean verify"
}

}
Expand All @@ -35,7 +35,7 @@ node ("docker-light") {
apt-get install -y git && \
pushd /source && \
git config --global --add safe.directory /source && \
/opt/maven-basis/bin/mvn --batch-mode clean install sonar:sonar $mySonarOpts; \
/opt/maven-basis/bin/mvn --batch-mode -Paggregate-coverage clean install sonar:sonar $mySonarOpts; \
maven_ret=\\\$?; \
echo && \
echo [INFO] Set file permissions to UID and GID of jenkins user for cleanup. && \
Expand Down
20 changes: 20 additions & 0 deletions DEVELOPER.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,26 @@ If we remove a field via deprecation, the field can still be passed in, but we w
#### Building and Releasing
To be updated..

#### Coverage

Run `mvn -Paggregate-coverage clean verify` from the repository root to generate
`coverage/target/site/jacoco-aggregate/index.html` and `jacoco.xml`.
For a library-only build, use `mvn -Paggregate-coverage -pl coverage -am clean verify`.

The report combines coverage for annotations, model, JSON, common, and API classes
with execution data from their tests. This includes model classes exercised by
JSON/API tests, which module-local reports cannot credit. Distribution artifacts
and examples are not included in the aggregate library report.

Both Jenkins pipelines enable this profile.
The CI Sonar build also enables it after its Docker-side `clean`; every analyzed
module imports the same aggregate XML via `sonar.coverage.jacoco.xmlReportPaths`.
The report-only module is skipped by Sonar and deployment. Ordinary builds and
release builds do not include it unless the profile is explicitly enabled.

Do not skip tests or define `coverage.skip`/`jacoco.skip` when collecting coverage.
The inherited coverage profile activates only when `coverage.skip` is absent,
even if that property would otherwise be set to `false`.

#### Internal Releasing

Expand Down
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ node ("docker-light") {
withMaven(maven: "Basis",
mavenLocalRepo: mavenLocalRepo,
publisherStrategy: "EXPLICIT") {
sh "mvn clean verify"
sh "mvn -Paggregate-coverage clean verify"
}

}
Expand Down
2 changes: 1 addition & 1 deletion all/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-all</artifactId>
<name>rosette-api-all</name>
Expand Down
2 changes: 1 addition & 1 deletion annotations/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-annotations</artifactId>
<name>rosette-api-annotations</name>
Expand Down
2 changes: 1 addition & 1 deletion api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api</artifactId>
<name>rosette-api</name>
Expand Down
2 changes: 1 addition & 1 deletion common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-common</artifactId>
<name>rosette-api-common</name>
Expand Down
85 changes: 85 additions & 0 deletions coverage/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
Copyright 2026 Babel Street Rosette Ltd.

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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-coverage</artifactId>
<name>rosette-api-coverage</name>
<packaging>pom</packaging>
<description>Aggregate library coverage, including model classes exercised by downstream tests.</description>
<properties>
<sonar.skip>true</sonar.skip>
<maven.deploy.skip>true</maven.deploy.skip>
</properties>
<!-- Direct dependencies determine report contents and order this module after library tests. -->
<dependencies>
<dependency>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-annotations</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-model</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-json</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-common</artifactId>
<version>${project.version}</version>
</dependency>
<dependency>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.jacoco</groupId>
<artifactId>jacoco-maven-plugin</artifactId>
<version>${jacoco-maven-plugin.version}</version>
<executions>
<execution>
<id>aggregate-report</id>
<phase>verify</phase>
<goals>
<goal>report-aggregate</goal>
</goals>
<configuration>
<outputDirectory>${project.build.directory}/site/jacoco-aggregate</outputDirectory>
<formats>
<format>XML</format>
<format>HTML</format>
</formats>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
2 changes: 1 addition & 1 deletion examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-examples</artifactId>
Expand Down
2 changes: 1 addition & 1 deletion json/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-json</artifactId>
<name>rosette-api-json</name>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2024 Basis Technology Corp.
* Copyright 2024 Babel Street Rosette Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -28,6 +28,7 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;

import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityComparisonMethod;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityFieldInfo;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityProperties;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityRecords;
Expand All @@ -54,10 +55,14 @@ public RecordSimilarityRequest deserialize(JsonParser jsonParser, Deserializatio
.right(parseRecords(node.get(recordsField).get("right"), fields, jsonParser))
.build();
}
final JsonNode comparisonMethodNode = node.get("comparisonMethod");
final RecordSimilarityComparisonMethod comparisonMethod = comparisonMethodNode == null ? null
: deserializationContext.readTreeAsValue(comparisonMethodNode, RecordSimilarityComparisonMethod.class);
return RecordSimilarityRequest.builder()
.fields(fields)
.properties(properties)
.records(records)
.comparisonMethod(comparisonMethod)
.build();
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2022 Basis Technology Corp.
* Copyright 2022 Babel Street Rosette Ltd.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand All @@ -17,6 +17,7 @@
package com.basistech.rosette.apimodel;

import com.basistech.rosette.apimodel.jackson.ApiModelMixinModule;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityComparisonMethod;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityFieldInfo;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityProperties;
import com.basistech.rosette.apimodel.recordsimilarity.RecordSimilarityRecords;
Expand All @@ -32,8 +33,11 @@
import com.basistech.util.LanguageCode;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectReader;
import com.fasterxml.jackson.databind.node.ObjectNode;
import org.junit.jupiter.api.Test;

import java.util.List;
Expand Down Expand Up @@ -263,19 +267,114 @@ void testDeserialization() throws JsonProcessingException {

@Test
void testSerialization() throws JsonProcessingException {
final JsonNode expectedJson = MAPPER.readTree(EXPECTED_JSON);
final ObjectNode expectedJson = (ObjectNode) MAPPER.readTree(EXPECTED_JSON);
expectedJson.put("comparisonMethod", "one_to_one");
final JsonNode actualJson = MAPPER.valueToTree(EXPECTED_REQUEST);
assertEquals(expectedJson, actualJson);

final JsonNode expectedParamJson = MAPPER.readTree(EXPECTED_JSON_WITH_PARAMS);
final ObjectNode expectedParamJson = (ObjectNode) MAPPER.readTree(EXPECTED_JSON_WITH_PARAMS);
expectedParamJson.put("comparisonMethod", "one_to_one");
final JsonNode actualParamJson = MAPPER.valueToTree(EXPECTED_REQUEST_WITH_PARAMS);
assertEquals(expectedParamJson, actualParamJson);

final JsonNode expectedUniverseJson = MAPPER.readTree(EXPECTED_JSON_WITH_UNIVERSE);
final ObjectNode expectedUniverseJson = (ObjectNode) MAPPER.readTree(EXPECTED_JSON_WITH_UNIVERSE);
expectedUniverseJson.put("comparisonMethod", "one_to_one");
final JsonNode actualUniverseJson = MAPPER.valueToTree(EXPECTED_REQUEST_WITH_UNIVERSE);
assertEquals(expectedUniverseJson, actualUniverseJson);
}

@Test
void testComparisonMethodDefaultsAcrossConstructionPaths() {
final RecordSimilarityRequest legacyConstructor = new RecordSimilarityRequest(null,
EXPECTED_REQUEST.getFields(), EXPECTED_REQUEST.getProperties(), EXPECTED_REQUEST.getRecords());
final RecordSimilarityRequest nullConstructor = new RecordSimilarityRequest(null,
EXPECTED_REQUEST.getFields(), EXPECTED_REQUEST.getProperties(), EXPECTED_REQUEST.getRecords(), null);
final RecordSimilarityRequest nullBuilder = RecordSimilarityRequest.builder()
.fields(EXPECTED_REQUEST.getFields())
.properties(EXPECTED_REQUEST.getProperties())
.records(EXPECTED_REQUEST.getRecords())
.comparisonMethod(null)
.build();

assertEquals(RecordSimilarityComparisonMethod.ONE_TO_ONE, EXPECTED_REQUEST.getComparisonMethod());
for (RecordSimilarityRequest request : List.of(legacyConstructor, nullConstructor, nullBuilder)) {
assertEquals(EXPECTED_REQUEST, request);
assertEquals(MAPPER.valueToTree(EXPECTED_REQUEST), MAPPER.valueToTree(request));
}
}

@Test
void testComparisonMethodDeserializationDefaults() throws JsonProcessingException {
final RecordSimilarityRequest absent = MAPPER.readValue(EXPECTED_JSON, RecordSimilarityRequest.class);
assertEquals(RecordSimilarityComparisonMethod.ONE_TO_ONE, absent.getComparisonMethod());
assertEquals(EXPECTED_REQUEST, absent);

final ObjectNode json = (ObjectNode) MAPPER.readTree(EXPECTED_JSON);
json.putNull("comparisonMethod");
final RecordSimilarityRequest explicitNull = MAPPER.readValue(json.toString(), RecordSimilarityRequest.class);
assertEquals(RecordSimilarityComparisonMethod.ONE_TO_ONE, explicitNull.getComparisonMethod());
assertEquals(EXPECTED_REQUEST, explicitNull);
}

@Test
void testComparisonMethodRoundTrip() throws JsonProcessingException {
final Map<RecordSimilarityComparisonMethod, String> wireNames = Map.of(
RecordSimilarityComparisonMethod.ONE_TO_ONE, "one_to_one",
RecordSimilarityComparisonMethod.ONE_TO_N, "one_to_n",
RecordSimilarityComparisonMethod.N_TO_M, "n_to_m");
for (RecordSimilarityComparisonMethod method : RecordSimilarityComparisonMethod.values()) {
final RecordSimilarityRequest request = RecordSimilarityRequest.builder()
.fields(EXPECTED_REQUEST.getFields())
.properties(EXPECTED_REQUEST.getProperties())
.records(EXPECTED_REQUEST.getRecords())
.comparisonMethod(method)
.build();
final RecordSimilarityRequest constructorRequest = new RecordSimilarityRequest(null,
request.getFields(), request.getProperties(), request.getRecords(), method);
assertEquals(constructorRequest, request);
assertEquals(method, request.getComparisonMethod());

final String json = MAPPER.writeValueAsString(request);
assertEquals(wireNames.get(method), MAPPER.readTree(json).get("comparisonMethod").asText());
assertEquals(request, MAPPER.readValue(json, RecordSimilarityRequest.class));
}
}

@Test
void testInvalidComparisonMethodThrows() throws JsonProcessingException {
final ObjectNode json = (ObjectNode) MAPPER.readTree(EXPECTED_JSON);
json.put("comparisonMethod", "unsupported_method");
assertThrows(JsonProcessingException.class,
() -> MAPPER.readValue(json.toString(), RecordSimilarityRequest.class));
}

@Test
void testComparisonMethodReaderRejectsNumbers() throws JsonProcessingException {
final ObjectNode json = (ObjectNode) MAPPER.readTree(EXPECTED_JSON);
json.put("comparisonMethod", 1);
final ObjectReader reader = MAPPER.readerFor(RecordSimilarityRequest.class)
.with(DeserializationFeature.FAIL_ON_NUMBERS_FOR_ENUMS);

assertThrows(JsonProcessingException.class, () -> reader.readValue(json.toString()));

json.put("comparisonMethod", "one_to_one");
assertEquals(EXPECTED_REQUEST, reader.readValue(json.toString()));
}

@Test
void testComparisonMethodReaderAllowsUnknownValuesAsNull() throws JsonProcessingException {
final ObjectNode json = (ObjectNode) MAPPER.readTree(EXPECTED_JSON);
json.put("comparisonMethod", "future_method");
final ObjectReader reader = MAPPER.readerFor(RecordSimilarityRequest.class)
.with(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);

final RecordSimilarityRequest request = reader.readValue(json.toString());
assertEquals(RecordSimilarityComparisonMethod.ONE_TO_ONE, request.getComparisonMethod());
assertEquals(EXPECTED_REQUEST, request);
assertThrows(JsonProcessingException.class,
() -> MAPPER.readValue(json.toString(), RecordSimilarityRequest.class));
}

@Test
void testSingleValueDeserializationBackwardCompat() throws JsonProcessingException {
// Old-format JSON uses bare single values instead of arrays; deserializers must produce single-element lists.
Expand Down
2 changes: 1 addition & 1 deletion model/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<parent>
<groupId>com.basistech.rosette</groupId>
<artifactId>rosette-api-java-binding</artifactId>
<version>1.39.0-SNAPSHOT</version>
<version>1.40.0-SNAPSHOT</version>
</parent>
<artifactId>rosette-api-model</artifactId>
<name>rosette-api-model</name>
Expand Down
Loading