Package org.drools.guvnor.client.rpc

Examples of org.drools.guvnor.client.rpc.RepositoryService


    }

    public void testCategory() throws Exception {

        RepositoryService impl = getService();

        String[] originalCats = impl.loadChildCategories( "/" );

        Boolean result = impl.createCategory( "/",
                                              "TopLevel1",
                                              "a description" );
        assertTrue( result.booleanValue() );

        result = impl.createCategory( "/",
                                      "TopLevel2",
                                      "a description" );
        assertTrue( result.booleanValue() );

        String[] cats = impl.loadChildCategories( "/" );
        assertTrue( cats.length == originalCats.length + 2 );

        result = impl.createCategory( "",
                                      "Top3",
                                      "description" );
        assertTrue( result.booleanValue() );

        result = impl.createCategory( null,
                                      "Top4",
                                      "description" );
        assertTrue( result.booleanValue() );

    }
View Full Code Here


        assertTrue( it.loadAsset( "rule_1" ).isArchived() );

    }

    public void testPackageConfSave() throws Exception {
        RepositoryService impl = getService();
        String uuid = impl.createPackage( "testPackageConfSave",
                                          "a desc" );
        PackageConfigData data = impl.loadPackageConfig( uuid );

        data.description = "new desc";
        data.header = "wa";
        data.externalURI = "new URI";

        ValidatedResponse res = impl.savePackage( data );
        assertNotNull( res );
        assertTrue( res.hasErrors );
        assertNotNull( res.errorMessage );

        data = impl.loadPackageConfig( uuid );
        assertEquals( "new desc",
                      data.description );
        assertEquals( "wa",
                      data.header );
        assertEquals( "new URI",
                      data.externalURI );

        data.header = "";
        res = impl.savePackage( data );
        if ( res.hasErrors ) {
            System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
            System.out.println( res.errorMessage );
            System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
View Full Code Here

        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 );
View Full Code Here

        assertEquals( 1,
                      res.data.length );
    }

    public void testQuickFind() throws Exception {
        RepositoryService impl = getService();
        String cat = "testQuickFind";
        impl.createCategory( "/",
                             cat,
                             "qkfnd" );
        impl.createPackage( "testQuickFind",
                            "for testing quick find." );
        String uuid = impl.createNewRule( "testQuickFindmyRule1",
                                          "desc",
                                          cat,
                                          "testQuickFind",
                                          AssetFormats.DRL );
        TableDataResult res = impl.quickFindAsset( "testQuickFindmyRule",
                                                   false,
                                                   0,
                                                   20 );
        assertEquals( 1,
                      res.data.length );

        impl.createNewRule( "testQuickFindmyRule2",
                            "desc",
                            cat,
                            "testQuickFind",
                            AssetFormats.DRL );
        res = impl.quickFindAsset( "testQuickFindmyRule",
                                   false,
                                   0,
                                   20 );
        assertEquals( 2,
                      res.data.length );

        impl.copyAsset( uuid,
                        "testQuickFind",
                        "testQuickFindmyRule3" );
        res = impl.quickFindAsset( "testQuickFindmyRule",
                                   false,
                                   0,
                                   20 );
        assertEquals( 3,
                      res.data.length );

        res = impl.quickFindAsset( "testQuickFindm*Rule",
                                   false,
                                   0,
                                   20 );
        assertEquals( 3,
                      res.data.length );
View Full Code Here

    public String[] arr(String s) {
        return new String[]{s};
    }

    public void testStatus() throws Exception {
        RepositoryService impl = getService();
        String uuid = impl.createState( "testStatus1" );
        assertNotNull( uuid );

        String[] states = impl.listStates();
        assertTrue( states.length > 0 );

        impl.createState( "testStatus2" );
        String[] states2 = impl.listStates();
        assertEquals( states.length + 1,
                      states2.length );

        int match = 0;
        for ( int i = 0; i < states2.length; i++ ) {
            if ( states2[i].equals( "testStatus2" ) ) {
                match++;
            } else if ( states2[i].equals( "testStatus1" ) ) {
                match++;
            }
        }

        assertEquals( 2,
                      match );

        String packagUUID = impl.createPackage( "testStatus",
                                                "description" );
        String ruleUUID = impl.createNewRule( "testStatus",
                                              "desc",
                                              null,
                                              "testStatus",
                                              AssetFormats.DRL );
        String ruleUUID2 = impl.createNewRule( "testStatus2",
                                               "desc",
                                               null,
                                               "testStatus",
                                               AssetFormats.DRL );
        impl.createState( "testState" );

        RuleAsset asset = impl.loadRuleAsset( ruleUUID );
        assertEquals( StateItem.DRAFT_STATE_NAME,
                      asset.metaData.status );
        impl.changeState( ruleUUID,
                          "testState",
                          false );
        asset = impl.loadRuleAsset( ruleUUID );
        assertEquals( "testState",
                      asset.metaData.status );
        asset = impl.loadRuleAsset( ruleUUID2 );
        assertEquals( StateItem.DRAFT_STATE_NAME,
                      asset.metaData.status );

        impl.createState( "testState2" );
        impl.changeState( packagUUID,
                          "testState2",
                          true );

        PackageConfigData pkg = impl.loadPackageConfig( packagUUID );
        assertEquals( "testState2",
                      pkg.state );

        asset = impl.loadRuleAsset( ruleUUID2 );
        assertEquals( "testState2",
                      asset.metaData.status );

        impl.checkinVersion( asset );
        asset = impl.loadRuleAsset( asset.uuid );
        assertEquals( "testState2",
                      asset.metaData.status );

    }
View Full Code Here

                      asset.metaData.status );

    }

    public void testMovePackage() throws Exception {
        RepositoryService impl = getService();
        String[] cats = impl.loadChildCategories( "/" );
        if ( cats.length == 0 ) {
            impl.createCategory( "/",
                                 "la",
                                 "d" );
        }
        String sourcePkgId = impl.createPackage( "sourcePackage",
                                                 "description" );
        String destPkgId = impl.createPackage( "targetPackage",
                                               "description" );

        String cat = impl.loadChildCategories( "/" )[0];

        String uuid = impl.createNewRule( "testMovePackage",
                                          "desc",
                                          cat,
                                          "sourcePackage",
                                          AssetFormats.DRL );

        TableDataResult res = impl.listAssets( destPkgId,
                                               new String[]{"drl"},
                                               0,
                                               2,
                                               AssetItemGrid.RULE_LIST_TABLE_ID );
        assertEquals( 0,
                      res.data.length );

        impl.changeAssetPackage( uuid,
                                 "targetPackage",
                                 "yeah" );
        res = impl.listAssets( destPkgId,
                               new String[]{"drl"},
                               0,
                               2,
                               AssetItemGrid.RULE_LIST_TABLE_ID );

        assertEquals( 1,
                      res.data.length );

        res = impl.listAssets( sourcePkgId,
                               new String[]{"drl"},
                               0,
                               2,
                               AssetItemGrid.RULE_LIST_TABLE_ID );
View Full Code Here

                      res.data.length );

    }

    public void testCopyAsset() throws Exception {
        RepositoryService impl = getService();
        impl.createCategory( "/",
                             "templates",
                             "ya" );
        String uuid = impl.createNewRule( "testCopyAsset",
                                          "",
                                          "templates",
                                          RulesRepository.DEFAULT_PACKAGE,
                                          AssetFormats.DRL );
        String uuid2 = impl.copyAsset( uuid,
                                       RulesRepository.DEFAULT_PACKAGE,
                                       "testCopyAsset2" );
        assertNotSame( uuid,
                       uuid2 );

        RuleAsset asset = impl.loadRuleAsset( uuid2 );
        assertNotNull( asset );
        assertEquals( RulesRepository.DEFAULT_PACKAGE,
                      asset.metaData.packageName );
        assertEquals( "testCopyAsset2",
                      asset.metaData.name );
View Full Code Here

        assertEquals( "testCopyAsset2",
                      asset.metaData.name );
    }

    public void testSnapshot() throws Exception {
        RepositoryService impl = getService();
        impl.createCategory( "/",
                             "snapshotTesting",
                             "y" );
        impl.createPackage( "testSnapshot",
                            "d" );
        String uuid = impl.createNewRule( "testSnapshotRule",
                                          "",
                                          "snapshotTesting",
                                          "testSnapshot",
                                          AssetFormats.DRL );

        impl.createPackageSnapshot( "testSnapshot",
                                    "X",
                                    false,
                                    "ya" );
        SnapshotInfo[] snaps = impl.listSnapshots( "testSnapshot" );
        assertEquals( 1,
                      snaps.length );
        assertEquals( "X",
                      snaps[0].name );
        assertEquals( "ya",
                      snaps[0].comment );
        assertNotNull( snaps[0].uuid );
        PackageConfigData confSnap = impl.loadPackageConfig( snaps[0].uuid );
        assertEquals( "testSnapshot",
                      confSnap.name );

        impl.createPackageSnapshot( "testSnapshot",
                                    "Y",
                                    false,
                                    "we" );
        assertEquals( 2,
                      impl.listSnapshots( "testSnapshot" ).length );
        impl.createPackageSnapshot( "testSnapshot",
                                    "X",
                                    true,
                                    "we" );
        assertEquals( 2,
                      impl.listSnapshots( "testSnapshot" ).length );

        impl.copyOrRemoveSnapshot( "testSnapshot",
                                   "X",
                                   false,
                                   "Q" );
        assertEquals( 3,
                      impl.listSnapshots( "testSnapshot" ).length );

        try {
            impl.copyOrRemoveSnapshot( "testSnapshot",
                                       "X",
                                       false,
                                       "" );
            fail( "should not be able to copy snapshot to empty detination" );
        } catch ( SerializationException e ) {
            assertNotNull( e.getMessage() );
        }

        impl.copyOrRemoveSnapshot( "testSnapshot",
                                   "X",
                                   true,
                                   null );
        assertEquals( 2,
                      impl.listSnapshots( "testSnapshot" ).length );

    }
View Full Code Here

    }

    public void testRemoveCategory() throws Exception {

        RepositoryService impl = getService();
        String[] children = impl.loadChildCategories( "/" );
        impl.createCategory( "/",
                             "testRemoveCategory",
                             "foo" );

        impl.removeCategory( "testRemoveCategory" );
        String[] _children = impl.loadChildCategories( "/" );
        assertEquals( children.length,
                      _children.length );

    }
View Full Code Here

                      _children.length );

    }

    public void testRemoveAsset() throws Exception {
        RepositoryService impl = getService();
        String cat = "testRemoveAsset";
        impl.createCategory( "/",
                             cat,
                             "ya" );
        String pkgUUID = impl.createPackage( "testRemoveAsset",
                                             "" );

        String uuid = impl.createNewRule( "testRemoveAsset",
                                          "x",
                                          cat,
                                          "testRemoveAsset",
                                          "testRemoveAsset" );

        String uuid2 = impl.createNewRule( "testRemoveAsset2",
                                           "x",
                                           cat,
                                           "testRemoveAsset",
                                           "testRemoveAsset" );

        String uuid3 = impl.createNewRule( "testRemoveAsset3",
                                           "x",
                                           cat,
                                           "testRemoveAsset",
                                           "testRemoveAsset" );
        String uuid4 = impl.createNewRule( "testRemoveAsset4",
                                           "x",
                                           cat,
                                           "testRemoveAsset",
                                           "testRemoveAsset" );

        TableDataResult res = impl.listAssets( pkgUUID,
                                               arr( "testRemoveAsset" ),
                                               0,
                                               -1,
                                               AssetItemGrid.RULE_LIST_TABLE_ID );
        assertEquals( 4,
                      res.data.length );

        impl.removeAsset( uuid4 );

        res = impl.listAssets( pkgUUID,
                               arr( "testRemoveAsset" ),
                               0,
                               -1,
                               AssetItemGrid.RULE_LIST_TABLE_ID );
        assertEquals( 3,
View Full Code Here

TOP

Related Classes of org.drools.guvnor.client.rpc.RepositoryService

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.