Skip to content

Commit

Permalink
Merge pull request #31 from ibrahim-atcha/master
Browse files Browse the repository at this point in the history
updates dependencies
  • Loading branch information
shaunstorey authored Mar 10, 2023
2 parents 23f100c + dc10ddd commit 54bb6aa
Show file tree
Hide file tree
Showing 47 changed files with 661 additions and 651 deletions.
22 changes: 15 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
plugins {
id "com.github.spotbugs" version "4.7.0" apply false
id "org.owasp.dependencycheck" version "6.1.5" apply false
id "java"
id "com.github.spotbugs" version "4.7.3" apply false
id "org.owasp.dependencycheck" version "8.1.2" apply false
id "io.github.gradle-nexus.publish-plugin" version "1.1.0"
}

Expand Down Expand Up @@ -30,12 +31,19 @@ subprojects {
mavenCentral()
}

test {
useJUnitPlatform()
}

dependencies {
testImplementation 'junit:junit:4.12',
'com.google.guava:guava:18.0',
'org.mockito:mockito-core:3.6.28',
'org.assertj:assertj-core:3.11.1',
'org.apache.commons:commons-lang3:3.4'
testImplementation 'org.junit.jupiter:junit-jupiter-api:5.9.2',
'org.junit.jupiter:junit-jupiter-params:5.9.2',
'org.junit.jupiter:junit-jupiter-engine:5.9.2',
'com.google.guava:guava:31.1-jre',
'org.mockito:mockito-core:5.1.1',
'org.mockito:mockito-junit-jupiter:5.1.1',
'org.assertj:assertj-core:3.24.2',
'org.apache.commons:commons-lang3:3.12.0'
}

jacocoTestCoverageVerification {
Expand Down
2 changes: 1 addition & 1 deletion traverson4j-core/build.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
dependencies {
api 'com.alibaba:fastjson:2.0.22'
api 'com.alibaba.fastjson2:fastjson2:2.0.0'
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.co.autotrader.traverson;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.http.AuthCredential;
import uk.co.autotrader.traverson.exception.IllegalHttpStatusException;
import uk.co.autotrader.traverson.http.*;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
package uk.co.autotrader.traverson.conversion;

import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.parser.Feature;
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONException;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.exception.ConversionException;

import java.io.InputStream;
Expand All @@ -19,7 +19,12 @@ public JSONObject convert(InputStream resource, Class<? extends JSONObject> retu
String resourceAsString = null;
try {
resourceAsString = new StringResourceConverter().convert(resource, String.class);
return JSONObject.parseObject(resourceAsString, Feature.OrderedField);

if (resourceAsString.isEmpty()) {
return null;
}

return JSON.parseObject(resourceAsString);
} catch (JSONException ex) {
throw new ConversionException("Failed to parse to JSONObject", resourceAsString, ex);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.co.autotrader.traverson.link;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.exception.UnknownRelException;

public class BasicLinkDiscoverer implements LinkDiscoverer {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.co.autotrader.traverson.link;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;

public interface LinkDiscoverer {
String findHref(JSONObject responseEntity, String rel);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.link.LinkDiscoverer;

import static java.util.Collections.emptyList;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;

import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.util.HashMap;
import java.util.Map;
Expand All @@ -17,7 +18,7 @@ public JSONArray findJSONArrayRelation(JSONObject halResource, String relationTy
}

Object maybeJsonArray = embeddedResources.get(relationType);
if (maybeJsonArray == null || !(maybeJsonArray instanceof JSONArray)) {
if (!(maybeJsonArray instanceof JSONArray)) {
return new JSONArray();
}

Expand All @@ -33,9 +34,9 @@ public String resolveLink(JSONObject jsonObject) {
public Map<String, SortedSet<String>> describeRelations(JSONObject resource) {
JSONObject embeddedResources = getEmbeddedSection(resource);

Map<String, SortedSet<String>> relations = new HashMap<String, SortedSet<String>>();
Map<String, SortedSet<String>> relations = new HashMap<>();
if (embeddedResources != null) {
SortedSet<String> sortedRels = new TreeSet<String>();
SortedSet<String> sortedRels = new TreeSet<>();
sortedRels.addAll(embeddedResources.keySet());
relations.put("'_embedded'", sortedRels);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.util.Map;
import java.util.SortedSet;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.link.LinkDiscoverer;

import java.util.Arrays;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.exception.UnknownRelException;
import uk.co.autotrader.traverson.link.LinkDiscoverer;

Expand All @@ -22,7 +22,7 @@ public String findHref(JSONObject resource, String rel) {
}

private SortedSet<String> sort(Set<String> set) {
SortedSet<String> sorted = new TreeSet<String>();
SortedSet<String> sorted = new TreeSet<>();
sorted.addAll(set);
return sorted;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;

import java.util.Map;
import java.util.SortedSet;
Expand All @@ -14,7 +14,7 @@ class LinksResolver implements HalEntityResolver {
@Override
public JSONArray findJSONArrayRelation(JSONObject halResource, String relationType) {
Object maybeJsonArray = getLinksSection(halResource).get(relationType);
if (maybeJsonArray == null || !(maybeJsonArray instanceof JSONArray)) {
if (!(maybeJsonArray instanceof JSONArray)) {
return new JSONArray();
}

Expand All @@ -28,7 +28,7 @@ public String resolveLink(JSONObject jsonObject) {

@Override
public Map<String, SortedSet<String>> describeRelations(JSONObject resource) {
SortedSet<String> sortedRels = new TreeSet<String>();
SortedSet<String> sortedRels = new TreeSet<>();
sortedRels.addAll(getLinksSection(resource).keySet());
return singletonMap("'_links'", sortedRels);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.exception.UnknownRelException;
import uk.co.autotrader.traverson.link.LinkDiscoverer;

Expand Down Expand Up @@ -52,7 +52,7 @@ private String findLink(JSONObject resource, String relName, int arrayIndex) {
}

private UnknownRelException createUnknownRelException(JSONObject resource, String relName, int arrayIndex) {
Map<String, SortedSet<String>> rels = new HashMap<String, SortedSet<String>>();
Map<String, SortedSet<String>> rels = new HashMap<>();
for (HalEntityResolver resolver : this.halEntityResolvers) {
rels.putAll(resolver.describeRelations(resource));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package uk.co.autotrader.traverson.link.hal;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson2.JSONArray;
import com.alibaba.fastjson2.JSONObject;
import uk.co.autotrader.traverson.exception.UnknownRelException;
import uk.co.autotrader.traverson.link.LinkDiscoverer;

Expand Down Expand Up @@ -56,7 +56,7 @@ private String findLink(JSONObject resource, String relName, String propertyName
}

private UnknownRelException createUnknownRelException(JSONObject resource, String relName, String propertyName, String propertyValue) {
Map<String, SortedSet<String>> rels = new HashMap<String, SortedSet<String>>();
Map<String, SortedSet<String>> rels = new HashMap<>();
for (HalEntityResolver resolver : this.halEntityResolvers) {
rels.putAll(resolver.describeRelations(resource));
}
Expand Down
Loading

0 comments on commit 54bb6aa

Please sign in to comment.