• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

devonfw / IDEasy / 12890704917

21 Jan 2025 03:52PM UTC coverage: 68.444% (+0.3%) from 68.126%
12890704917

push

github

web-flow
#972: add CustomToolJsonDeserializer to prevent jackson error (#974)

2785 of 4459 branches covered (62.46%)

Branch coverage included in aggregate %.

7201 of 10131 relevant lines covered (71.08%)

3.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

94.44
cli/src/main/java/com/devonfw/tools/ide/json/JsonMapping.java
1
package com.devonfw.tools.ide.json;
2

3
import com.devonfw.tools.ide.repo.CustomToolJson;
4
import com.devonfw.tools.ide.repo.CustomToolJsonDeserializer;
5
import com.devonfw.tools.ide.repo.CustomToolJsonSerializer;
6
import com.devonfw.tools.ide.repo.CustomToolsJson;
7
import com.devonfw.tools.ide.repo.CustomToolsJsonDeserializer;
8
import com.devonfw.tools.ide.repo.CustomToolsJsonSerializer;
9
import com.devonfw.tools.ide.url.model.file.json.ToolDependency;
10
import com.devonfw.tools.ide.version.VersionIdentifier;
11
import com.devonfw.tools.ide.version.VersionRange;
12
import com.fasterxml.jackson.annotation.JsonInclude;
13
import com.fasterxml.jackson.databind.DeserializationFeature;
14
import com.fasterxml.jackson.databind.ObjectMapper;
15
import com.fasterxml.jackson.databind.SerializationFeature;
16
import com.fasterxml.jackson.databind.module.SimpleModule;
17
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
18

19
/**
20
 * Simple factory for Jackson {@link ObjectMapper} to read and write JSON with centralized mapping configuration.
21
 */
22
public class JsonMapping {
×
23

24
  /**
25
   * @return a new instance of {@link ObjectMapper} pre-configured for reasonable JSON mapping.
26
   */
27
  public static ObjectMapper create() {
28

29
    ObjectMapper mapper = new ObjectMapper();
4✔
30
    mapper = mapper.registerModule(new JavaTimeModule());
6✔
31
    mapper = mapper.configure(SerializationFeature.WRITE_DATES_AS_TIMESTAMPS, false);
5✔
32
    mapper = mapper.enable(SerializationFeature.INDENT_OUTPUT);
4✔
33
    mapper = mapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
4✔
34
    mapper = mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
5✔
35
    SimpleModule customModule = new SimpleModule();
4✔
36
    customModule.addDeserializer(VersionIdentifier.class, new VersionIdentifierDeserializer());
7✔
37
    customModule.addDeserializer(VersionRange.class, new VersionRangeDeserializer());
7✔
38
    customModule.addDeserializer(ToolDependency.class, new ToolDependencyDeserializer());
7✔
39
    customModule.addDeserializer(CustomToolJson.class, new CustomToolJsonDeserializer());
7✔
40
    customModule.addDeserializer(CustomToolsJson.class, new CustomToolsJsonDeserializer());
7✔
41
    customModule.addSerializer(CustomToolJson.class, new CustomToolJsonSerializer());
7✔
42
    customModule.addSerializer(CustomToolsJson.class, new CustomToolsJsonSerializer());
7✔
43
    customModule.addKeyDeserializer(VersionRange.class, new VersionRangeKeyDeserializer());
7✔
44
    mapper = mapper.registerModule(customModule);
4✔
45
    return mapper;
2✔
46
  }
47

48
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc