Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

upgrade jackson #1051

Merged
merged 5 commits into from
Jun 9, 2023
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
8 changes: 4 additions & 4 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,22 +61,22 @@
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.12.6</version>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.12.6</version>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.12.6</version>
<version>2.14.0</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-yaml</artifactId>
<version>2.12.6</version>
<version>2.14.0</version>
</dependency>
</dependencies>
</dependencyManagement>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,18 +3,20 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.google.common.collect.ImmutableMap;
import com.hubspot.jinjava.Jinjava;
import com.hubspot.jinjava.JinjavaConfig;
import com.hubspot.jinjava.LegacyOverrides;
import com.hubspot.jinjava.interpret.JinjavaInterpreter;
import com.hubspot.jinjava.interpret.OutputTooBigException;
import com.hubspot.jinjava.objects.collections.SizeLimitingPyMap;
import java.util.AbstractMap;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.apache.commons.lang3.RandomStringUtils;
import org.junit.Test;

public class PyishObjectMapperTest {
Expand All @@ -29,7 +31,7 @@ public void itSerializesMapWithNullKeysAsEmptyString() {
}

@Test
public void itSerializesMapEntrySet() throws JsonProcessingException {
public void itSerializesMapEntrySet() {
SizeLimitingPyMap map = new SizeLimitingPyMap(new HashMap<>(), 10);
map.put("foo", "bar");
map.put("bar", ImmutableMap.of("foobar", new ArrayList<>()));
Expand All @@ -39,7 +41,7 @@ public void itSerializesMapEntrySet() throws JsonProcessingException {
}

@Test
public void itSerializesMapEntrySetWithLimit() throws JsonProcessingException {
public void itSerializesMapEntrySetWithLimit() {
SizeLimitingPyMap map = new SizeLimitingPyMap(new HashMap<>(), 10);
map.put("foo", "bar");
map.put("bar", ImmutableMap.of("foobar", new ArrayList<>()));
Expand Down Expand Up @@ -85,7 +87,24 @@ public void itLimitsDepth() {
JinjavaInterpreter.pushCurrent(jinjava.newInterpreter());
assertThatThrownBy(() -> PyishObjectMapper.getAsPyishStringOrThrow(original))
.as("The string to be serialized is larger than the max output size")
.isInstanceOf(LengthLimitingJsonProcessingException.class);
.isInstanceOf(JsonMappingException.class)
.hasMessageContaining("Max length of 10000 chars reached");
} finally {
JinjavaInterpreter.popCurrent();
}
}

@Test
public void itLimitsOutputSize() {
String input = RandomStringUtils.random(10002);
try {
Jinjava jinjava = new Jinjava(
JinjavaConfig.newBuilder().withMaxOutputSize(10000).build()
);
JinjavaInterpreter.pushCurrent(jinjava.newInterpreter());
assertThatThrownBy(() -> PyishObjectMapper.getAsPyishString(input))
.isInstanceOf(OutputTooBigException.class)
.hasMessageContaining("over limit of 10000 bytes");
} finally {
JinjavaInterpreter.popCurrent();
}
Expand Down