本文整理汇总了Java中com.bazaarvoice.jolt.JsonUtils.classpathToObject方法的典型用法代码示例。如果您正苦于以下问题:Java JsonUtils.classpathToObject方法的具体用法?Java JsonUtils.classpathToObject怎么用?Java JsonUtils.classpathToObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.bazaarvoice.jolt.JsonUtils
的用法示例。
在下文中一共展示了JsonUtils.classpathToObject方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: runFixtureTests
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@Test
public void runFixtureTests() throws IOException {
String testFixture = "/json/utils/joltUtils-removeRecursive.json";
@SuppressWarnings("unchecked")
List<Map<String, Object>> tests = (List<Map<String, Object>>) JsonUtils.classpathToObject( testFixture );
for ( Map<String,Object> testUnit : tests ) {
Object data = testUnit.get( "input" );
String toRemove = (String) testUnit.get( "remove" );
Object expected = testUnit.get( "expected" );
JoltUtils.removeRecursive( data, toRemove );
Diffy.Result result = diffy.diff( expected, data );
if (!result.isEmpty()) {
Assert.fail( "Failed.\nhere is a diff:\nexpected: " + JsonUtils.toJsonString(result.expected) + "\n actual: " + JsonUtils.toJsonString(result.actual));
}
}
}
示例2: storeTestCases
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Iterator<Object[]> storeTestCases() {
String testFixture = "/json/utils/joltUtils-store-remove-compact.json";
@SuppressWarnings("unchecked")
List<Map<String, Object>> tests = (List<Map<String, Object>>) JsonUtils.classpathToObject( testFixture );
List<Object[]> testCases = new LinkedList<>();
for(Map<String, Object> testCase: tests) {
testCases.add(new Object[] {
testCase.get("description"),
testCase.get("source"),
((List)testCase.get("path")).toArray(),
testCase.get("value"),
testCase.get("output")
});
}
return testCases.iterator();
}
示例3: deepCopyTest
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@Test
public void deepCopyTest() throws Exception {
Object input = JsonUtils.classpathToObject( "/json/deepcopy/original.json" );
Map<String, Object> fiddle = (Map<String, Object>) DeepCopy.simpleDeepCopy( input );
JoltTestUtil.runDiffy( "Verify that the DeepCopy did in fact make a copy.", input, fiddle );
// The test is to make a deep copy, then manipulate the copy, and verify that the original did not change ;)
// copy and fiddle
List array = (List) fiddle.get( "array" );
array.add( "c" );
array.set( 1, 3 );
Map<String,Object> subMap = (Map<String,Object>) fiddle.get( "map" );
subMap.put("c", "c");
subMap.put("b", 3 );
// Verify that the input to the copy was unmodified
Object unmodified = JsonUtils.classpathToObject( "/json/deepcopy/original.json" );
JoltTestUtil.runDiffy( "Verify that the deepcopy was actually deep / input is unmodified", unmodified, input );
// Verify we made the modifications we wanted to.
Object expectedModified = JsonUtils.classpathToObject( "/json/deepcopy/modifed.json" );
JoltTestUtil.runDiffy( "Verify fiddled post deepcopy object looks correct / was modifed.", expectedModified, fiddle );
}
示例4: badFormatSpecs
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] badFormatSpecs() throws IOException {
return new Object[][] {
{JsonUtils.classpathToObject( "/json/chainr/specformat/bad_spec_arrayClassName.json" )},
{JsonUtils.classpathToObject( "/json/chainr/specformat/bad_spec_ClassName.json" )},
{JsonUtils.classpathToObject( "/json/chainr/specformat/bad_spec_NonTransformClass.json" )},
{JsonUtils.classpathToObject( "/json/chainr/specformat/bad_spec_empty.json" )}
};
}
示例5: fromToTests
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] fromToTests() {
Object chainrSpec = JsonUtils.classpathToObject( "/json/chainr/increments/spec.json" );
return new Object[][] {
{chainrSpec, 0, 1},
{chainrSpec, 0, 3},
{chainrSpec, 1, 3},
{chainrSpec, 1, 4}
};
}
示例6: toTests
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] toTests() {
Object chainrSpec = JsonUtils.classpathToObject( "/json/chainr/increments/spec.json" );
return new Object[][] {
{chainrSpec, 1},
{chainrSpec, 3}
};
}
示例7: failTests
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] failTests() {
Object chainrSpec = JsonUtils.classpathToObject( "/json/chainr/increments/spec.json" );
return new Object[][] {
{chainrSpec, 0, 0},
{chainrSpec, -2, 2},
{chainrSpec, 0, -2},
{chainrSpec, 1, 10000}
};
}
示例8: badTransforms
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] badTransforms() {
return new Object[][] {
{JsonUtils.classpathToObject( "/json/chainr/transforms/bad_transform_loadsExplodingTransform.json" )}
};
}
示例9: passingTestCases
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] passingTestCases() {
return new Object[][] {
{new Object(), JsonUtils.classpathToObject( "/json/chainr/transforms/loadsGoodTransform.json" )}
};
}
示例10: chainrBuilderFailsOnNullLoader
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@Test( expectedExceptions = IllegalArgumentException.class )
public void chainrBuilderFailsOnNullLoader() {
Object validSpec = JsonUtils.classpathToObject( "/json/chainr/transforms/loadsGoodTransform.json" );
new ChainrBuilder( validSpec ).loader( null );
}
示例11: badFormatSpecs
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@DataProvider
public Object[][] badFormatSpecs() throws IOException {
return new Object[][] {
{JsonUtils.classpathToObject( "/json/chainr/specloading/bad_spec_SpecTransform.json" )}
};
}
示例12: testChainrIncrementsFromTo
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@Test( dataProvider = "fromToTests")
public void testChainrIncrementsFromTo( Object chainrSpec, int start, int end ) throws IOException {
Chainr chainr = Chainr.fromSpec( chainrSpec );
Object expected = JsonUtils.classpathToObject( "/json/chainr/increments/" + start + "-" + end + ".json" );
Object actual = chainr.transform( start, end, new HashMap() );
JoltTestUtil.runDiffy( "failed incremental From-To Chainr", expected, actual );
}
示例13: testChainrIncrementsTo
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
@Test( dataProvider = "toTests")
public void testChainrIncrementsTo( Object chainrSpec, int end ) throws IOException {
Chainr chainr = Chainr.fromSpec( chainrSpec );
Object expected = JsonUtils.classpathToObject( "/json/chainr/increments/0-" + end + ".json" );
Object actual = chainr.transform( end, new HashMap() );
JoltTestUtil.runDiffy( "failed incremental To Chainr", expected, actual );
}
示例14: main
import com.bazaarvoice.jolt.JsonUtils; //导入方法依赖的package包/类
public static void main(String[] args) {
List chainrSpecJSON = JsonUtils.classpathToList( "/json/sample/spec.json" );
Chainr chainr = Chainr.fromSpec( chainrSpecJSON );
Object inputJSON = JsonUtils.classpathToObject( "/json/sample/input.json" );
Object transformedOutput = chainr.transform( inputJSON );
System.out.println( JsonUtils.toJsonString( transformedOutput ) );
}