Package org.drools.guvnor.client.rpc

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


   
    @Test
    public void testValidatePackageConfiguration() throws SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();

        PackageConfigData packageConfigData = createPackageConfigData( true );

        PackageItem packageItem = mock( PackageItem.class );
        initDroolsHeaderCheck( packageItem );
        when( packageItem.isArchived() ).thenReturn( false );
        when( this.rulesRepository.loadPackage( packageConfigData.name ) ).thenReturn( packageItem );
View Full Code Here


        BRMSSuggestionCompletionLoader suggestionCompletionLoader = mock( BRMSSuggestionCompletionLoader.class );
        doReturn( suggestionCompletionLoader ).when( localRepositoryPackageOperations ).createBRMSSuggestionCompletionLoader();
    }

    private PackageConfigData createPackageConfigData(boolean isArchived) {
        PackageConfigData packageConfigData = new PackageConfigData();
        packageConfigData.name = "name";
        packageConfigData.header = "header";
        packageConfigData.archived = isArchived;
        packageConfigData.description = "description";
        packageConfigData.externalURI = "externalUri";
View Full Code Here

    TreePanelListener treePanelListener = new TreePanelListenerAdapter() {
      public void onClick(TreeNode node, EventObject e) {
        if (node.getUserObject() instanceof PackageConfigData
            && !"global".equals(((PackageConfigData) node.getUserObject()).name)) {
          PackageConfigData pc = (PackageConfigData) node.getUserObject();
          RulePackageSelector.currentlySelectedPackage = pc.name;

          String uuid = pc.uuid;
          centertabbedPanel.openPackageEditor(uuid, new Command() {
            public void execute() {
              // refresh the package tree.
              refreshPackageTree();
            }
          });
        } else if (node.getUserObject() instanceof Object[]) {
          Object[] uo = (Object[]) node.getUserObject();
          final String[] fmts = (String[]) uo[0];
          final PackageConfigData pc = (PackageConfigData) node.getParentNode().getUserObject();
          RulePackageSelector.currentlySelectedPackage = pc.name;
          String key = key(fmts, pc);
          if (!centertabbedPanel.showIfOpen(key)) {

            final AssetItemGrid list = new AssetItemGrid(new EditItemEvent() {
View Full Code Here

        it.updateExternalURI( "ext" );
        DroolsHeader.updateDroolsHeader( "header",
                                                  it );
        impl.getRulesRepository().save();

        PackageConfigData data = repositoryPackageService.loadPackageConfig( uuid );
        assertNotNull( data );

        assertEquals( RulesRepository.DEFAULT_PACKAGE,
                      data.getName() );
        assertEquals( "header",
                      data.getHeader() );
        assertEquals( "ext",
                      data.getExternalURI() );

        assertNotNull( data.getUuid() );
        assertFalse( data.isSnapshot() );

        assertNotNull( data.getDateCreated() );
        Date original = data.getLastModified();

        Thread.sleep( 100 );

        repositoryPackageService.createPackageSnapshot( RulesRepository.DEFAULT_PACKAGE,
                                                        "TEST SNAP 2.0",
                                                        false,
                                                        "ya" );
        PackageItem loaded = impl.getRulesRepository().loadPackageSnapshot( RulesRepository.DEFAULT_PACKAGE,
                                                                            "TEST SNAP 2.0" );

        data = repositoryPackageService.loadPackageConfig( loaded.getUUID() );
        assertTrue( data.isSnapshot() );
        assertEquals( "TEST SNAP 2.0",
                      data.getSnapshotName() );
        assertFalse( original.equals( data.getLastModified() ) );
        assertEquals( "ya",
                      data.getCheckinComment() );
    }
View Full Code Here

    public void testArchiveAndUnarchivePackageAndHeader() throws Exception {
        ServiceImplementation impl = getServiceImplementation();
        RepositoryPackageService repositoryPackageService = getRepositoryPackageService();
        String uuid = repositoryPackageService.createPackage( "testArchiveAndUnarchivePackageAndHeader",
                                                              "a desc" );
        PackageConfigData data = repositoryPackageService.loadPackageConfig( uuid );
        PackageItem it = impl.getRulesRepository().loadPackageByUUID( uuid );
        data.setArchived( true );

        AssetItem rule1 = it.addAsset( "rule_1",
                                       "" );
        rule1.updateFormat( AssetFormats.DRL );
        rule1.updateContent( "rule 'rule1' \n when \np : Person() \n then \np.setAge(42); \n end" );
        rule1.archiveItem( true );
        rule1.checkin( "" );
        impl.getRulesRepository().save();

        repositoryPackageService.savePackage( data );
        data = repositoryPackageService.loadPackageConfig( uuid );
        it = impl.getRulesRepository().loadPackage( data.getName() );
        assertTrue( data.isArchived() );
        assertTrue( it.loadAsset( "drools" ).isArchived() );
        assertTrue( it.loadAsset( "rule_1" ).isArchived() );

        data.setArchived( false );

        repositoryPackageService.savePackage( data );
        data = repositoryPackageService.loadPackageConfig( uuid );
        it = impl.getRulesRepository().loadPackage( data.getName() );
        assertFalse( data.isArchived() );
        assertFalse( it.loadAsset( "drools" ).isArchived() );
        assertTrue( it.loadAsset( "rule_1" ).isArchived() );

        data.setArchived( true );

        repositoryPackageService.savePackage( data );
        data = repositoryPackageService.loadPackageConfig( uuid );
        it = impl.getRulesRepository().loadPackage( data.getName() );
        assertTrue( data.isArchived() );
        assertTrue( it.loadAsset( "drools" ).isArchived() );
        assertTrue( it.loadAsset( "rule_1" ).isArchived() );

    }
View Full Code Here

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

        data.setDescription( "new desc" );
        data.setHeader( "wa" );
        data.setExternalURI( "new URI" );
        repositoryPackageService.savePackage(data);

        ValidatedResponse res = repositoryPackageService.validatePackageConfiguration( data );
        assertNotNull( res );
        assertTrue( res.hasErrors );
        assertNotNull( res.errorMessage );

        data = repositoryPackageService.loadPackageConfig( uuid );
        assertEquals( "new desc",
                      data.getDescription() );
        assertEquals( "wa",
                      data.getHeader() );
        assertEquals( "new URI",
                      data.getExternalURI() );

        data.setHeader( "" );
        res = repositoryPackageService.validatePackageConfiguration( data );
        if ( res.hasErrors ) {
            System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
            System.out.println( res.errorMessage );
            System.out.println( "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!" );
View Full Code Here

        repositoryPackageOperations.setRulesRepository( rulesRepository );
    }

    @Test
    public void testPackageNameSorting() {
        PackageConfigData c1 = new PackageConfigData( "org.foo" );
        PackageConfigData c2 = new PackageConfigData( "org.foo.bar" );

        List<PackageConfigData> ls = new ArrayList<PackageConfigData>();
        ls.add( c2 );
        ls.add( c1 );
        this.repositoryPackageOperations.sortPackages( ls );
View Full Code Here

    @Test
    public void testSavePackageArhived() throws SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();

        PackageConfigData packageConfigData = createPackageConfigData( false );
        PackageItem packageItem = mock( PackageItem.class );
        Calendar calendar = GregorianCalendar.getInstance();
        when( packageItem.getLastModified() ).thenReturn( calendar );
        initDroolsHeaderCheck( packageItem );
        when( packageItem.isArchived() ).thenReturn( true );
        when( this.rulesRepository.loadPackage( packageConfigData.getName() ) ).thenReturn( packageItem );
        doNothing().when( localRepositoryPackageOperations ).updateCategoryRules( packageConfigData,
                                                                                  packageItem );
        doNothing().when( localRepositoryPackageOperations ).handleUnarchivedForSavePackage( packageConfigData,
                                                                                             packageItem,
                                                                                             calendar );
        initSpyingAndMockingOnSuggestionCompletionLoader( localRepositoryPackageOperations );
        localRepositoryPackageOperations.savePackage( packageConfigData );
        verify( packageItem ).updateExternalURI( packageConfigData.getExternalURI() );
        verify( packageItem ).updateDescription( packageConfigData.getDescription() );
        verify( packageItem ).archiveItem( packageConfigData.isArchived() );
        verify( packageItem ).checkin( packageConfigData.getDescription() );
        verify( localRepositoryPackageOperations ).handleUnarchivedForSavePackage( packageConfigData,
                                                                                   packageItem,
                                                                                   calendar );
    }
View Full Code Here

    @Test
    public void testSavePackageUnarhived() throws SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();

        PackageConfigData packageConfigData = createPackageConfigData( true );

        PackageItem packageItem = mock( PackageItem.class );
        initDroolsHeaderCheck( packageItem );
        when( packageItem.isArchived() ).thenReturn( false );
        when( this.rulesRepository.loadPackage( packageConfigData.getName() ) ).thenReturn( packageItem );
        doNothing().when( localRepositoryPackageOperations ).updateCategoryRules( packageConfigData,
                                                                                  packageItem );
        doNothing().when( localRepositoryPackageOperations ).handleArchivedForSavePackage( packageConfigData,
                                                                                             packageItem );
        initSpyingAndMockingOnSuggestionCompletionLoader( localRepositoryPackageOperations );
        localRepositoryPackageOperations.savePackage( packageConfigData );
        verify( packageItem ).updateExternalURI( packageConfigData.getExternalURI() );
        verify( packageItem ).updateDescription( packageConfigData.getDescription() );
        verify( packageItem ).archiveItem( packageConfigData.isArchived() );
        verify( packageItem ).checkin( packageConfigData.getDescription() );
        verify( localRepositoryPackageOperations ).handleArchivedForSavePackage( packageConfigData,
                                                                                   packageItem );
    }
View Full Code Here

   
    @Test
    public void testValidatePackageConfiguration() throws SerializationException {
        RepositoryPackageOperations localRepositoryPackageOperations = initSpyingOnRealRepositoryPackageOperations();

        PackageConfigData packageConfigData = createPackageConfigData( true );

        PackageItem packageItem = mock( PackageItem.class );
        initDroolsHeaderCheck( packageItem );
        when( packageItem.isArchived() ).thenReturn( false );
        when( this.rulesRepository.loadPackage( packageConfigData.getName() ) ).thenReturn( packageItem );
        doNothing().when( localRepositoryPackageOperations ).updateCategoryRules( packageConfigData,
                                                                                  packageItem );
        doNothing().when( localRepositoryPackageOperations ).handleArchivedForSavePackage( packageConfigData,
                                                                                             packageItem );
        initSpyingAndMockingOnSuggestionCompletionLoader( localRepositoryPackageOperations );
        localRepositoryPackageOperations.validatePackageConfiguration( packageConfigData );
        verify( packageItem, never() ).updateExternalURI( "");
        verify( packageItem, never() ).updateDescription( packageConfigData.getDescription() );
        verify( packageItem, never() ).archiveItem( packageConfigData.isArchived() );
        verify( packageItem, never() ).checkin( packageConfigData.getDescription() );
        verify( localRepositoryPackageOperations, never() ).handleArchivedForSavePackage( packageConfigData,
                                                                                   packageItem );
    }
View Full Code Here

TOP

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

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.