assertFalse( res.hasErrors );
}
public void testListByFormat() throws Exception {
RepositoryService impl = getService();
String cat = "testListByFormat";
impl.createCategory( "/",
cat,
"ya" );
String pkgUUID = impl.createPackage( "testListByFormat",
"used for listing by format." );
String uuid = impl.createNewRule( "testListByFormat",
"x",
cat,
"testListByFormat",
"testListByFormat" );
String uuid2 = impl.createNewRule( "testListByFormat2",
"x",
cat,
"testListByFormat",
"testListByFormat" );
String uuid3 = impl.createNewRule( "testListByFormat3",
"x",
cat,
"testListByFormat",
"testListByFormat" );
String uuid4 = impl.createNewRule( "testListByFormat4",
"x",
cat,
"testListByFormat",
"testListByFormat" );
TableDataResult res = impl.listAssets( pkgUUID,
arr( "testListByFormat" ),
0,
-1,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 4,
res.data.length );
assertEquals( uuid,
res.data[0].id );
assertEquals( "testListByFormat",
res.data[0].values[0] );
res = impl.listAssets( pkgUUID,
arr( "testListByFormat" ),
0,
4,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 4,
res.data.length );
res = impl.listAssets( pkgUUID,
arr( "testListByFormat" ),
0,
2,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 2,
res.data.length );
assertEquals( uuid,
res.data[0].id );
assertEquals( 4,
res.total );
assertTrue( res.hasNext );
res = impl.listAssets( pkgUUID,
arr( "testListByFormat" ),
2,
2,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 2,
res.data.length );
assertEquals( uuid3,
res.data[0].id );
assertEquals( 4,
res.total );
assertFalse( res.hasNext );
uuid = impl.createNewRule( "testListByFormat5",
"x",
cat,
"testListByFormat",
"otherFormat" );
res = impl.listAssets( pkgUUID,
arr( "otherFormat" ),
0,
40,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 1,
res.data.length );
assertEquals( uuid,
res.data[0].id );
res = impl.listAssets( pkgUUID,
new String[]{"otherFormat", "testListByFormat"},
0,
40,
AssetItemGrid.RULE_LIST_TABLE_ID );
assertEquals( 5,
res.data.length );
TableDataResult result = impl.quickFindAsset( "testListByForma",
false,
0,
5 );
assertEquals( 5,
result.data.length );
assertNotNull( result.data[0].id );
assertTrue( result.data[0].values[0].startsWith( "testListByFormat" ) );
result = impl.quickFindAsset( "testListByForma",
false,
0,
4 );
assertEquals( 4,
result.data.length );