Skip to content

Commit

Permalink
Merge pull request #87 from chillb0nes/master
Browse files Browse the repository at this point in the history
Major versions update
  • Loading branch information
wanglingsong authored Nov 30, 2023
2 parents 6e7f58d + b8248a3 commit 7e52135
Show file tree
Hide file tree
Showing 14 changed files with 425 additions and 228 deletions.
14 changes: 14 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
version: 2
updates:
- package-ecosystem: "maven"
directory: "/"
schedule:
interval: "daily"
groups:
major-updates:
update-types:
- "major"
minor-updates:
update-types:
- "minor"
- "patch"
35 changes: 35 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
# This workflow will build a Java project with Maven, and cache/restore any dependencies to improve the workflow execution time
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-java-with-maven

# This workflow uses actions that are not certified by GitHub.
# They are provided by a third-party and are governed by
# separate terms of service, privacy policy, and support
# documentation.

name: build

on:
push:
branches: [ "master" ]
pull_request:
branches: [ "master" ]

jobs:
build:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: maven
- name: Build with Maven
run: mvn -B package --file pom.xml

# Optional: Uploads the full dependency graph to GitHub to improve the quality of Dependabot alerts this repository can receive
- name: Update dependency graph
uses: advanced-security/maven-dependency-submission-action@571e99aab1055c2e71a1e2309b9691de18d6b7d6
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# JsonSurfer - Let's surf on Json!

[![Join the chat at https://gitter.im/jsurfer/JsonSurfer](https://badges.gitter.im/Join%20Chat.svg)](https://gitter.im/jsurfer/JsonSurfer?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
![](https://travis-ci.org/jsurfer/JsonSurfer.svg?branch=master) [![Coverage Status](https://coveralls.io/repos/jsurfer/JsonSurfer/badge.svg)](https://coveralls.io/r/jsurfer/JsonSurfer)
[![build](https://github.com/wanglingsong/JsonSurfer/actions/workflows/build.yml/badge.svg)](https://github.com/wanglingsong/JsonSurfer/actions/workflows/build.yml)
[![Coverage Status](https://coveralls.io/repos/jsurfer/JsonSurfer/badge.svg)](https://coveralls.io/r/jsurfer/JsonSurfer)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.github.jsurfer/jsurfer/badge.svg?style=plastic)](https://maven-badges.herokuapp.com/maven-central/com.github.jsurfer/jsurfer)


Expand Down
10 changes: 3 additions & 7 deletions jsurfer-all/src/test/java/org/jsfr/json/JacksonParserTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,9 @@
import java.io.ByteArrayInputStream;
import java.math.BigInteger;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Mockito.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;

/**
* Created by Leo on 2015/3/30.
Expand Down
45 changes: 18 additions & 27 deletions jsurfer-all/src/test/java/org/jsfr/json/JsonSurferTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,11 @@
import java.util.Iterator;
import java.util.Map;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.mockito.Matchers.any;
import static org.mockito.Matchers.anyObject;
import static org.mockito.Matchers.argThat;
import static org.mockito.Matchers.eq;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.isA;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.junit.Assert.*;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.*;
import static org.mockito.hamcrest.MockitoHamcrest.argThat;

public abstract class JsonSurferTest {

Expand Down Expand Up @@ -596,7 +587,7 @@ public void testSample2() throws Exception {
public void testStoppableParsing() throws Exception {
JsonPathListener mockListener = mock(JsonPathListener.class);
doNothing().when(mockListener)
.onValue(anyObject(), argThat(new TypeSafeMatcher<ParsingContext>() {
.onValue(any(), argThat(new TypeSafeMatcher<ParsingContext>() {

@Override
public boolean matchesSafely(ParsingContext parsingContext) {
Expand All @@ -614,7 +605,7 @@ public void describeTo(Description description) {
.bind("$.store.book[3]", mockListener)
.buildAndSurf(read("sample.json"));
verify(mockListener, times(1))
.onValue(anyObject(), any(ParsingContext.class));
.onValue(any(), any(ParsingContext.class));

}

Expand All @@ -625,7 +616,7 @@ public void testChildNodeWildcard() throws Exception {
.bind("$.store.*", mockListener)
.buildAndSurf(read("sample.json"));
verify(mockListener, times(3))
.onValue(anyObject(), any(ParsingContext.class));
.onValue(any(), any(ParsingContext.class));
}

@Test
Expand All @@ -635,15 +626,15 @@ public void testAnyIndex() throws Exception {
.bind("$.store.book[*]", mockListener)
.buildAndSurf(read("sample.json"));
verify(mockListener, times(4))
.onValue(anyObject(), any(ParsingContext.class));
.onValue(any(), any(ParsingContext.class));
}

@Test
public void testWildcardCombination() throws Exception {
JsonPathListener mockListener = mock(JsonPathListener.class);
surfer.configBuilder().bind("$.store.book[*].*", mockListener)
.buildAndSurf(read("sample.json"));
verify(mockListener, times(18)).onValue(anyObject(),
verify(mockListener, times(18)).onValue(any(),
any(ParsingContext.class));
}

Expand All @@ -659,10 +650,10 @@ public void testArraySlicing() throws Exception {
.bind("$[2:]", mock3)
.bind("$[:]", mock4)
.buildAndSurf(read("array.json"));
verify(mock1, times(2)).onValue(anyObject(), any(ParsingContext.class));
verify(mock2, times(2)).onValue(anyObject(), any(ParsingContext.class));
verify(mock3, times(3)).onValue(anyObject(), any(ParsingContext.class));
verify(mock4, times(5)).onValue(anyObject(), any(ParsingContext.class));
verify(mock1, times(2)).onValue(any(), any(ParsingContext.class));
verify(mock2, times(2)).onValue(any(), any(ParsingContext.class));
verify(mock3, times(3)).onValue(any(), any(ParsingContext.class));
verify(mock4, times(5)).onValue(any(), any(ParsingContext.class));
}

@Test
Expand Down Expand Up @@ -894,7 +885,7 @@ public void testPlugableProvider() throws Exception {
public void testErrorStrategySuppressException() throws Exception {

JsonPathListener mock = mock(JsonPathListener.class);
doNothing().doThrow(Exception.class).doThrow(Exception.class).when(mock).onValue(anyObject(), any(ParsingContext.class));
doNothing().doThrow(RuntimeException.class).doThrow(RuntimeException.class).when(mock).onValue(any(), any(ParsingContext.class));

surfer.configBuilder().bind("$.store.book[*]", mock)
.withErrorStrategy(new ErrorHandlingStrategy() {
Expand All @@ -909,20 +900,20 @@ public void handleExceptionFromListener(Exception e, ParsingContext context) {
}
})
.buildAndSurf(read("sample.json"));
verify(mock, times(4)).onValue(anyObject(), any(ParsingContext.class));
verify(mock, times(4)).onValue(any(), any(ParsingContext.class));
}

@Test
public void testErrorStrategyThrowException() throws Exception {

JsonPathListener mock = mock(JsonPathListener.class);
doNothing().doThrow(Exception.class).doThrow(Exception.class).when(mock).onValue(anyObject(), any(ParsingContext.class));
doNothing().doThrow(RuntimeException.class).doThrow(RuntimeException.class).when(mock).onValue(any(), any(ParsingContext.class));
try {
surfer.configBuilder().bind("$.store.book[*]", mock).buildAndSurf(read("sample.json"));
} catch (Exception e) {
// catch mock exception
}
verify(mock, times(2)).onValue(anyObject(), any(ParsingContext.class));
verify(mock, times(2)).onValue(any(), any(ParsingContext.class));
}

@Test
Expand Down
2 changes: 1 addition & 1 deletion jsurfer-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<artifactId>jsurfer-core</artifactId>

<properties>
<antlr.version>4.7.2</antlr.version>
<antlr.version>4.13.1</antlr.version>
</properties>

<profiles>
Expand Down
Loading

0 comments on commit 7e52135

Please sign in to comment.