Skip to content

Commit

Permalink
Merge pull request #156 from Kobee1203/feature/145
Browse files Browse the repository at this point in the history
[serializer] Bump jackson version and fix JsonLdTypeFactory constructor #145
  • Loading branch information
Kobee1203 authored Sep 23, 2024
2 parents 955f56c + 7059a68 commit 66253df
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 18 deletions.
21 changes: 21 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,29 @@ All notable changes to this project will be documented in this file.

### Changed

- ⚠️ **Breaking change: requires java 17 or newer**
- Bump jackson-bom from 2.14.2 to 2.17.2
- Bump net.javacrumbs.json-unit:json-unit-assertj from 2.37.0 to 3.4.1
- Bump de.jutzig:github-release-plugin from 1.4.0 to 1.6.0
- Bump maven-it-extension.version from 0.12.0 to 0.13.1
- Bump org.jacoco:jacoco-maven-plugin from 0.8.9 to 0.8.12
- Bump junit-jupiter-engine.version from 5.9.3 to 5.11.0
- Bump ch.qos.logback:logback-classic from 1.4.7 to 1.5.6
- Bump org.apache.maven:maven-core from 3.9.1 to 3.9.7
- Bump org.apache.maven:maven-plugin-api from 3.9.1 to 3.9.9
- Bump org.apache.maven.plugins:maven-dependency-plugin from 3.5.0 to 3.8.0
- Bump org.apache.maven.plugins:maven-site-plugin from 3.12.1 to 3.20.0
- Bump org.apache.maven.plugins:maven-plugin-plugin from 3.8.1 to 3.15.0
- Bump org.apache.maven.plugin-tools:maven-plugin-annotations from 3.8.2 to 3.13.0
- Bump org.apache.maven.plugins:maven-assembly-plugin from 3.5.0 to 3.7.1
- Bump org.apache.maven.plugins:maven-surefire-plugin from 3.0.0 to 3.2.5
- Bump org.apache.maven.plugins:maven-failsafe-plugin from 3.0.0 to 3.2.5
- Bump junit-jupiter-engine.version from 5.9.2 to 5.9.3

### Fixed

[serializer] Bump jackson version and fix JsonLdTypeFactory constructor [#145](https://github.com/Kobee1203/schema-org-java/issues/145)

## [0.6.0] - 2023-04-23

### Added
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

import java.util.List;
import java.util.function.Predicate;
import java.util.stream.Collectors;

import static com.weedow.schemaorg.generator.model.handler.ModelHandlerTestUtils.*;
import static java.util.Map.entry;
Expand Down Expand Up @@ -63,11 +62,17 @@ void read() throws SchemaDefinitionReaderException {
"schema:OriginalMediaContent",
List.of("schema:MediaManipulationRatingEnumeration"),
comment("en",
"Content coded 'as original media content' in a [[MediaReview]], considered in the context of how it was published or shared.\n\n" +
"For a [[VideoObject]] to be 'original': No evidence the footage has been misleadingly altered or manipulated, though it may contain false or misleading claims.\n\n" +
"For an [[ImageObject]] to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.\n\n" +
"For an [[ImageObject]] with embedded text to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.\n\n" +
"For an [[AudioObject]] to be 'original': No evidence the audio has been misleadingly altered or manipulated, though it may contain false or misleading claims.\n"
"""
Content coded 'as original media content' in a [[MediaReview]], considered in the context of how it was published or shared.
For a [[VideoObject]] to be 'original': No evidence the footage has been misleadingly altered or manipulated, though it may contain false or misleading claims.
For an [[ImageObject]] to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.
For an [[ImageObject]] with embedded text to be 'original': No evidence the image has been misleadingly altered or manipulated, though it may still contain false or misleading claims.
For an [[AudioObject]] to be 'original': No evidence the audio has been misleadingly altered or manipulated, though it may contain false or misleading claims.
"""
),
label("en", "OriginalMediaContent"),
null, null, null, null, List.of(partOf("https://pending.schema.org")), List.of(source("https://github.com/schemaorg/schemaorg/issues/2450"))
Expand Down Expand Up @@ -229,10 +234,10 @@ void throw_exception_when_read_invalid_jsonld() {
Assertions.assertThatThrownBy(() -> schemaDefinitionReader.read(getClass().getResourceAsStream("/data/invalid-schemaorg.jsonld")))
.isInstanceOf(SchemaDefinitionReaderException.class)
.hasMessage("Could not read the JSON schema definition: Unrecognized token 'invalid': was expecting (JSON String, Number, Array, Object or token 'null', 'true' or 'false')\n" +
" at [Source: (String)\"invalid json\"; line: 1, column: 8]");
" at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 8]");
}

private static List<GraphItem> filter(SchemaDefinition schemaDefinition, Predicate<GraphItem> predicate) {
return schemaDefinition.getGraph().stream().filter(predicate).collect(Collectors.toList());
return schemaDefinition.getGraph().stream().filter(predicate).toList();
}
}
4 changes: 2 additions & 2 deletions maven-plugin/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@
<version>3.2.5</version>
<configuration>
<!-- ! currently needed to run integration tests. -->
<systemProperties>
<systemPropertyVariables>
<maven.version>${maven.version}</maven.version>
<maven.home>${maven.home}</maven.home>
</systemProperties>
</systemPropertyVariables>
</configuration>
<executions>
<execution>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
<!-- Dependencies -->
<lombok.version>1.18.26</lombok.version>
<logback-classic.version>1.5.6</logback-classic.version>
<jackson.version>2.15.0</jackson.version>
<jackson.version>2.17.2</jackson.version>
<handlebars-helpers.version>4.3.1</handlebars-helpers.version>
<commons-cli.version>1.5.0</commons-cli.version>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
package com.weedow.schemaorg.serializer.deserialization;

import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.type.TypeFactory;
import com.fasterxml.jackson.databind.util.LookupCache;
import com.fasterxml.jackson.databind.util.LRUMap;
import com.weedow.schemaorg.commons.generator.GeneratorConstants;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
Expand All @@ -21,7 +20,7 @@ public class JsonLdTypeFactory extends TypeFactory {
private final Map<String, Class<?>> types = new HashMap<>();

public JsonLdTypeFactory(Map<String, Class<?>> otherTypes) {
super((LookupCache<Object, JavaType>) null);
super(new LRUMap<>(16, DEFAULT_MAX_CACHE_SIZE));

try (InputStream schemaOrgJavaProperties = Thread.currentThread().getContextClassLoader().getResourceAsStream(GeneratorConstants.SCHEMA_ORG_PROP_FILENAME)) {
Properties properties = new Properties();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import org.schema.model.datatype.*;
import org.schema.model.impl.*;

import java.net.MalformedURLException;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.time.LocalTime;
Expand Down Expand Up @@ -201,13 +200,13 @@ void throws_exception_when_deserialize_invalid_data() {
Assertions.assertThatThrownBy(() -> jsonLdDeserializer.deserialize("{}"))
.isInstanceOf(JsonLdException.class)
.hasMessage("JSON-LD deserialization internal error: Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" +
" at [Source: (String)\"{}\"; line: 1, column: 2].")
" at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2].")
.hasCauseInstanceOf(JsonMappingException.class)
.hasMessage("JSON-LD deserialization internal error: Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" +
" at [Source: (String)\"{}\"; line: 1, column: 2].")
" at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2].")
.hasRootCauseInstanceOf(InvalidTypeIdException.class)
.hasRootCauseMessage("Could not resolve subtype of [simple type, class com.weedow.schemaorg.commons.model.JsonLdNode]: missing type id property '@type'\n" +
" at [Source: (String)\"{}\"; line: 1, column: 2]");
" at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]");
}

@Test
Expand Down

0 comments on commit 66253df

Please sign in to comment.