Skip to content

Commit

Permalink
Warnings clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
cowtowncoder committed Feb 16, 2024
1 parent fa1acbb commit 72724b7
Show file tree
Hide file tree
Showing 16 changed files with 41 additions and 44 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ static class URLBean {

public void testSimpleBean() throws Exception
{
final String INPUT = aposToQuotes("{'name':{'first':'Bob','last':'Burger'},'x':13, 'option': 'Option1'}");
final String INPUT = a2q("{'name':{'first':'Bob','last':'Burger'},'x':13, 'option': 'Option1'}");
TestBean bean = JSON.std.beanFrom(TestBean.class, INPUT);

assertNotNull(bean);
Expand All @@ -83,7 +83,7 @@ public void testSimpleBean() throws Exception

public void testSimpleBeanCaseInsensitive() throws Exception
{
final String INPUT = aposToQuotes("{'NaMe':{'FIRST':'Bob','last':'Burger'},'x':13, 'optioN': 'opTIOn1'}");
final String INPUT = a2q("{'NaMe':{'FIRST':'Bob','last':'Burger'},'x':13, 'optioN': 'opTIOn1'}");
TestBean bean =
JSON.builder()
.enable(JSON.Feature.ACCEPT_CASE_INSENSITIVE_PROPERTIES)
Expand All @@ -101,7 +101,7 @@ public void testSimpleBeanCaseInsensitive() throws Exception

public void testUnknownProps() throws Exception
{
final String INPUT = aposToQuotes("{'first':'Bob','middle':'Eugene', 'last':'Smith'}");
final String INPUT = a2q("{'first':'Bob','middle':'Eugene', 'last':'Smith'}");

// First: fine if marked as such
NameBean name = JSON.std
Expand All @@ -125,7 +125,7 @@ public void testUnknownProps() throws Exception

public void testPOJOWithList() throws Exception
{
final String INPUT = aposToQuotes("{'names': [ { 'first':'John','last':'Smith' },"
final String INPUT = a2q("{'names': [ { 'first':'John','last':'Smith' },"
+"{'first':'Bob','last':'Burger' } ] }");
NameListBean list = JSON.std.beanFrom(NameListBean.class, INPUT);
assertNotNull(list);
Expand All @@ -137,7 +137,7 @@ public void testPOJOWithList() throws Exception

public void testPOJOWithMap() throws Exception
{
final String INPUT = aposToQuotes("{'stuff': { 'a':3, 'b':4 } }");
final String INPUT = a2q("{'stuff': { 'a':3, 'b':4 } }");
MapBean map = JSON.std.beanFrom(MapBean.class, INPUT);
assertNotNull(map);
assertNotNull(map.stuff);
Expand All @@ -147,7 +147,7 @@ public void testPOJOWithMap() throws Exception

public void testSimpleBeanCollections() throws Exception
{
final String INPUT = aposToQuotes("["
final String INPUT = a2q("["
+"{'name':{'first':'Bob','last':'Burger'},'x':13}"
+",{'x':-145,'name':{'first':'Billy','last':'Bacon'}}"
+"]");
Expand Down Expand Up @@ -182,7 +182,7 @@ private void _verifySimpleBeanCollections(List<TestBean> beans) {
// @since 2.10
public void testSimpleBeanMaps() throws Exception
{
final String INPUT = aposToQuotes("{ 'first':"
final String INPUT = a2q("{ 'first':"
+"{'name':{'first':'Bob','last':'Burger'},'x':13}"
+", 'second':{'x':-145,'name':{'first':'Billy','last':'Bacon'}}"
+"}");
Expand Down Expand Up @@ -277,7 +277,7 @@ public void testNameWithLeadingUppers() throws Exception
final String expURL = "http://foo";
URLBean bean = JSON.std
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.beanFrom(URLBean.class, aposToQuotes("{'URL':'"+expURL+"'}"));
.beanFrom(URLBean.class, a2q("{'URL':'"+expURL+"'}"));
assertEquals(expURL, bean.url);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,26 +22,26 @@ public void testPojoWithIsGetter() throws Exception

json = JSON.std.asString(new IsBean());
// by default, will use 'is-getter':
assertEquals(aposToQuotes("{'enabled':true,'value':42}"), json);
assertEquals(a2q("{'enabled':true,'value':42}"), json);

// but can disable
json = JSON.std
.without(JSON.Feature.USE_IS_GETTERS)
.asString(new IsBean());
assertEquals(aposToQuotes("{'value':42}"), json);
assertEquals(a2q("{'value':42}"), json);

// .... as well as using alternative
json = JSON.builder()
.disable(JSON.Feature.USE_IS_GETTERS)
.build()
.asString(new IsBean());
assertEquals(aposToQuotes("{'value':42}"), json);
assertEquals(a2q("{'value':42}"), json);

// and go back as well
json = JSON.std
.with(JSON.Feature.USE_IS_GETTERS)
.asString(new IsBean());
assertEquals(aposToQuotes("{'enabled':true,'value':42}"), json);
assertEquals(a2q("{'enabled':true,'value':42}"), json);
}

public void testFailOnDupMapKeys() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ public void testListOfMaps() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(ListHolder.class,
aposToQuotes("{'stuff':[{'a':4}, {'a':6}]}"));
a2q("{'stuff':[{'a':4}, {'a':6}]}"));
List<Map<String, Integer>> list = h.stuff;
assertNotNull(list);
assertEquals(2, list.size());
Expand All @@ -99,7 +99,7 @@ public void testInvalidListOfMaps() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(ListHolder.class,
aposToQuotes("{'stuff':{ 'a' : 3 }}"));
a2q("{'stuff':{ 'a' : 3 }}"));
} catch (JSONObjectException e) {
verifyException(e, "Unexpected token START_OBJECT");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public Map<String, Object> build() {

public void testMapOfLists() throws Exception
{
final String INPUT = aposToQuotes("{'stuff':{'a':[1, 2, 3], 'b' : [7, 2]}}");
final String INPUT = a2q("{'stuff':{'a':[1, 2, 3], 'b' : [7, 2]}}");
final JSON j = JSON.std
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS);
Expand All @@ -82,7 +82,7 @@ public void testInvalidMapOfLists() throws Exception
.with(JSON.Feature.FAIL_ON_UNKNOWN_BEAN_PROPERTY)
.with(JSON.Feature.USE_FIELDS)
.beanFrom(MapHolder.class,
aposToQuotes("{'stuff':[ 1 ]}"));
a2q("{'stuff':[ 1 ]}"));
} catch (JSONObjectException e) {
verifyException(e, "Unexpected token START_ARRAY");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static class Bean {

public void testAnySequence() throws Exception
{
final String INPUT = aposToQuotes("'hello world!' 127 true [ 1, 2, 3]\nnull { 'msg':'none'} ");
final String INPUT = a2q("'hello world!' 127 true [ 1, 2, 3]\nnull { 'msg':'none'} ");

// First, managed
ValueIterator<Object> it = JSON.std.anySequenceFrom(INPUT);
Expand Down Expand Up @@ -104,7 +104,7 @@ private void _verifyAnySequence(ValueIterator<Object> it) throws Exception

public void testBeanSequence() throws Exception
{
final String INPUT = aposToQuotes("{'id':1, 'msg':'foo'} {'id':2, 'msg':'Same'} null ");
final String INPUT = a2q("{'id':1, 'msg':'foo'} {'id':2, 'msg':'Same'} null ");

// First, managed
ValueIterator<Bean> it = JSON.std.beanSequenceFrom(Bean.class, INPUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -220,13 +220,13 @@ public void testNullForMiscScalars() throws Exception {

// Testing that `null` will not cause an exception, for now at least
public void testNullForPrimitiveProperties() throws Exception {
BooleanWrapper w = JSON.std.beanFrom(BooleanWrapper.class, aposToQuotes("{'value':null}"));
BooleanWrapper w = JSON.std.beanFrom(BooleanWrapper.class, a2q("{'value':null}"));
assertNotNull(w);
assertFalse(w.value);
}

public void testNullForScalarProperties() throws Exception {
DateWrapper w = JSON.std.beanFrom(DateWrapper.class, aposToQuotes("{'value':null}"));
DateWrapper w = JSON.std.beanFrom(DateWrapper.class, a2q("{'value':null}"));
assertNotNull(w);
assertNull(w.value);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public void testComposerWithPojo() throws Exception
.end()
.end()
.finish();
assertEquals(aposToQuotes("[{'first':'Bob'},{'name':{'first':'Bill'}}]"), json);
assertEquals(a2q("[{'first':'Bob'},{'name':{'first':'Bill'}}]"), json);
}

public void testComposerWithIndent() throws Exception
Expand All @@ -136,7 +136,7 @@ public void testComposerWithIndent() throws Exception
.put("name", "Bill")
.end()
.finish();
assertEquals(aposToQuotes("{\n"
assertEquals(a2q("{\n"
+" 'name' : 'Bill'\n"
+"}"),
json);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ public void testSerializeWithoutField() throws Exception
{
String json = JSON.std.without(JSON.Feature.USE_FIELDS)
.asString(new XY(1, 2));
assertEquals(aposToQuotes("{'y':2}"), json);
assertEquals(a2q("{'y':2}"), json);
}

public void testSerializeWithField() throws Exception
{
String json = JSON.std.with(JSON.Feature.USE_FIELDS)
.asString(new XY(1, 2));
assertEquals(aposToQuotes("{'x':1,'y':2}"), json);
assertEquals(a2q("{'x':1,'y':2}"), json);
}

public void testDeserializeWithField() throws Exception
{
XY result = JSON.std.with(JSON.Feature.USE_FIELDS)
.beanFrom(XY.class, aposToQuotes("{'x':3,'y':4}"));
.beanFrom(XY.class, a2q("{'x':3,'y':4}"));
assertEquals(4, result.getY());
assertEquals(3, result.x);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ public void testMethodsFromSuperclass() throws Exception
}

BaseImpl result = JSON.std.beanFrom(BaseImpl.class,
aposToQuotes("{ 'extra':5, 'value':-245 }"));
a2q("{ 'extra':5, 'value':-245 }"));
assertEquals(5, result.getExtra());
assertEquals(-245, result.getValue());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public void testSimpleBooleanArray() throws Exception {
}

public void testSimpleStringArray() throws Exception {
assertEquals(aposToQuotes("['abc','def']"), JSON.std.asString(new String[] { "abc", "def" }));
assertEquals(a2q("['abc','def']"), JSON.std.asString(new String[] { "abc", "def" }));
}

public void testNest() throws Exception
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,7 @@ public void testCustomBeanReader() throws Exception

// similarly with wrapper
CustomValueBean bean = json.beanFrom(CustomValueBean.class,
aposToQuotes("{ 'custom' : 137 }"));
a2q("{ 'custom' : 137 }"));
assertEquals(138, bean.custom.value);

// but also ensure we can change registered handler(s)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ static class NoOpModifier extends ReaderWriterModifier { }
public void testReadIgnoreProperty() throws Exception
{
// verify default read first
final String INPUT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String INPUT = a2q("{'first':'Bob','last':'Burger'}");
NameBean bean = JSON.std.beanFrom(NameBean.class, INPUT);
assertEquals("Bob", bean.getFirst());
assertEquals("Burger", bean.getLast());
Expand All @@ -67,7 +67,7 @@ public void testReadIgnoreProperty() throws Exception

public void testModifierPairForReading() throws Exception
{
final String INPUT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String INPUT = a2q("{'first':'Bob','last':'Burger'}");
NameBean bean = jsonWithModifiers(new NoOpModifier(), new MyPropertyModifier("last"))
.beanFrom(NameBean.class, INPUT);
assertEquals("Bob", bean.getFirst());
Expand All @@ -84,14 +84,14 @@ public void testWriteInReverseOrder() throws Exception
{
// verify default write first
final NameBean input = new NameBean("Bob", "Burger");
final String EXP_DEFAULT = aposToQuotes("{'first':'Bob','last':'Burger'}");
final String EXP_DEFAULT = a2q("{'first':'Bob','last':'Burger'}");

assertEquals(EXP_DEFAULT, JSON.std.asString(input));

// but then use customized POJO introspection
String json = jsonWithModifier(new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bob'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bob'}"), json);

// and last, to ensure no leakage of customizations
assertEquals(EXP_DEFAULT, JSON.std.asString(input));
Expand All @@ -103,11 +103,11 @@ public void testModifierPairForWriting() throws Exception

String json = jsonWithModifiers(new NoOpModifier(), new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bill'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bill'}"), json);

// and nulls fine too wrt chaining
json = jsonWithModifiers(null, new MyPropertyModifier("xxx"))
.asString(input);
assertEquals(aposToQuotes("{'last':'Burger','first':'Bill'}"), json);
assertEquals(a2q("{'last':'Burger','first':'Bill'}"), json);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ public Object read(JSONReader reader, JsonParser p) throws IOException {
String.valueOf(map.get("last")).toUpperCase());
};
});
final String input = aposToQuotes("{'first':'foo', 'last':'bar'}");
final String input = a2q("{'first':'foo', 'last':'bar'}");
NameBean result = jsonWithModifier(mod).beanFrom(NameBean.class, input);
assertEquals("FOO", result.getFirst());
assertEquals("BAR", result.getLast());
Expand All @@ -111,7 +111,7 @@ public Object read(JSONReader reader, JsonParser p) throws IOException {

public void testPOJOReaderDelegation() throws Exception
{
final String input = aposToQuotes("{'first':'Foo', 'last':'Bar'}");
final String input = a2q("{'first':'Foo', 'last':'Bar'}");
NameBean result = jsonWithModifier(new LowerCasingReaderModifier())
.beanFrom(NameBean.class, input);
assertEquals("foo", result.getFirst());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@

import com.fasterxml.jackson.jr.ob.JSON;

/**
* Created by Gulajava Ministudio on 11/18/15.
*/
public class JacksonJrRequestBodyConverter<T> implements Converter<T, RequestBody>
{
private static final MediaType MEDIA_TYPE = MediaType.parse("application/json; charset=UTF-8");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ private JrsValue nodeFrom(JsonParser p) throws IOException
{
Map<String, JrsValue> values = _map();
while (p.nextToken() != JsonToken.END_OBJECT) {
final String currentName = p.getCurrentName();
final String currentName = p.currentName();
p.nextToken();
values.put(currentName, nodeFrom(p));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public void testSimpleObject() throws Exception

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("a", p.getCurrentName());
assertEquals("a", p.currentName());

assertToken(JsonToken.START_ARRAY, p.nextToken());

Expand All @@ -25,7 +25,7 @@ public void testSimpleObject() throws Exception

assertToken(JsonToken.START_OBJECT, p.nextToken());
assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("b", p.getCurrentName());
assertEquals("b", p.currentName());
assertToken(JsonToken.VALUE_TRUE, p.nextToken());
assertToken(JsonToken.END_OBJECT, p.nextToken());

Expand All @@ -34,12 +34,12 @@ public void testSimpleObject() throws Exception
assertToken(JsonToken.END_ARRAY, p.nextToken());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("c", p.getCurrentName());
assertEquals("c", p.currentName());
assertToken(JsonToken.VALUE_NUMBER_INT, p.nextToken());
assertEquals(-2, p.getIntValue());

assertToken(JsonToken.FIELD_NAME, p.nextToken());
assertEquals("d", p.getCurrentName());
assertEquals("d", p.currentName());
assertToken(JsonToken.VALUE_NULL, p.nextToken());

assertToken(JsonToken.END_OBJECT, p.nextToken());
Expand Down

0 comments on commit 72724b7

Please sign in to comment.