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

Fix failing tests #650

Merged
merged 2 commits into from
Nov 8, 2020
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
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ private void _testSingleMatchFilteringWithPathAlternate1(boolean exclude) throws
FilteringGeneratorDelegate gen = new FilteringGeneratorDelegate(_createGenerator(w),
tf,
Inclusion.INCLUDE_ALL_AND_PATH,
false // multipleMatches
true // multipleMatches
);
//final String JSON = "{'a':123,'array':[1,2],'ob':{'value0':2,'value':[3],'value2':'foo'},'b':true}";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,14 +80,6 @@ public TokenFilter includeElement(int index) {
protected boolean _includeScalar() { return false; }
}

static class NoArraysFilter extends TokenFilter
{
@Override
public TokenFilter filterStartArray() {
return null;
}
}

static class NoObjectsFilter extends TokenFilter
{
@Override
Expand Down Expand Up @@ -423,32 +415,18 @@ public void testNoMatchFiltering6() throws Exception
assertEquals(0, p.getMatchCount());
}

public void testValueOmitsFieldName1() throws Exception
{
String jsonString = aposToQuotes("{'a':123,'array':[1,2]}");
JsonParser p0 = JSON_F.createParser(jsonString);
FilteringParserDelegate p = new FilteringParserDelegate(p0,
new NoArraysFilter(),
Inclusion.INCLUDE_NON_NULL,
true // multipleMatches
);
String result = readAndWrite(JSON_F, p);
assertEquals(aposToQuotes("{'a':123}"), result);
assertEquals(0, p.getMatchCount());
}

public void testValueOmitsFieldName2() throws Exception
{
String jsonString = aposToQuotes("['a',{'value0':3,'b':{'value':4}}]");
String jsonString = aposToQuotes("['a',{'value0':3,'b':{'value':4}},123]");
JsonParser p0 = JSON_F.createParser(jsonString);
FilteringParserDelegate p = new FilteringParserDelegate(p0,
new NoObjectsFilter(),
Inclusion.INCLUDE_NON_NULL,
true // multipleMatches
);
String result = readAndWrite(JSON_F, p);
assertEquals(aposToQuotes("['a']"), result);
assertEquals(1, p.getMatchCount());
assertEquals(aposToQuotes("['a',123]"), result);
assertEquals(2, p.getMatchCount());
}

public void testIndexMatchWithPath1() throws Exception
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package com.fasterxml.jackson.failing.filter;

import com.fasterxml.jackson.core.BaseTest;
import com.fasterxml.jackson.core.JsonFactory;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.filter.FilteringParserDelegate;
import com.fasterxml.jackson.core.filter.TokenFilter;
import com.fasterxml.jackson.core.filter.TokenFilter.Inclusion;

public class BasicParserFilteringTest extends BaseTest {

private final JsonFactory JSON_F = new JsonFactory();

static class NoArraysFilter extends TokenFilter
{
@Override
public TokenFilter filterStartArray() {
return null;
}
}

// for [core#649]
public void testValueOmitsFieldName1() throws Exception
{
String jsonString = aposToQuotes("{'a':123,'array':[1,2]}");
JsonParser p0 = JSON_F.createParser(jsonString);
FilteringParserDelegate p = new FilteringParserDelegate(p0,
new NoArraysFilter(),
Inclusion.INCLUDE_NON_NULL,
true // multipleMatches
);
String result = readAndWrite(JSON_F, p);
assertEquals(aposToQuotes("{'a':123}"), result);
assertEquals(0, p.getMatchCount());
}
}