Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  /*
   * Copyright 2015 JBoss Inc
   *
   * Licensed under the Apache License, Version 2.0 (the "License");
   * you may not use this file except in compliance with the License.
   * 
   *      http://www.apache.org/licenses/LICENSE-2.0
   *
   * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  * See the License for the specific language governing permissions and
  * limitations under the License.
 */
 
 package org.kie.workbench.common.services.refactoring.backend.server.query;
 
 import java.util.Map;
 import java.util.Set;
 import  javax.enterprise.inject.Instance;
 
 import  org.apache.lucene.analysis.Analyzer;
 import  org.junit.Before;
 import  org.junit.Test;
 import  org.kie.workbench.common.services.refactoring.model.index.terms.IndexTerm;
 import  org.kie.workbench.common.services.refactoring.model.index.terms.RuleAttributeIndexTerm;
 import  org.kie.workbench.common.services.refactoring.model.index.terms.RuleIndexTerm;
 import  org.kie.workbench.common.services.refactoring.service.RefactoringQueryService;
 
 import static org.apache.lucene.util.Version.*;
 import static org.junit.Assert.*;
 import static org.mockito.Mockito.*;
 
 
     private Instance<NamedQuerynamedQueriesProducer;
 
     private Set<NamedQueryqueries = new HashSet<NamedQuery>() {{
         addnew FindRulesQuery() {
             @Override
             public ResponseBuilder getResponseBuilder() {
                 return new DefaultResponseBuilderioService() );
             }
         } );
     }};
 
     @Before
     public void setupNamedQueriesProducer() {
          = mock( Instance.class );
         when( .iterator() ).thenReturn( .iterator() );
     }
 
     @Test
     public void testGetNamedQueries() throws IOExceptionInterruptedException {
         final RefactoringQueryService service = new RefactoringQueryServiceImplgetConfig(),
                                                                                   );
 
         final Set<StringqueryNames = service.getQueries();
         assertNotNullqueryNames );
         assertEquals( 1,
                       queryNames.size() );
         assertTruequeryNames.contains"FindRulesQuery" ) );
     }
 
     @Test(expected = IllegalArgumentException.class)
         final RefactoringQueryService service = new RefactoringQueryServiceImplgetConfig(),
                                                                                   );
         final Set<StringqueryNames = service.getQueries();
         assertNotNullqueryNames );
         assertEquals( 1,
                       queryNames.size() );
         assertTruequeryNames.contains"FindRulesQuery" ) );
 
         final Set<IndexTerm> terms = service.getTerms( "NonExistentNamedQuery" );
     }
 
     @Test
     public void testGetNamedQueryTerms() throws IOExceptionInterruptedException {
         final RefactoringQueryService service = new RefactoringQueryServiceImplgetConfig(),
                                                                                   );
         final Set<StringqueryNames = service.getQueries();
         assertNotNullqueryNames );
         assertEquals( 1,
                       queryNames.size() );
         assertTruequeryNames.contains"FindRulesQuery" ) );
 
         final Set<IndexTerm> terms = service.getTerms( "FindRulesQuery" );
        assertNotNull( terms );
        assertEquals( 1,
                      terms.size() );
        assertTrue( terms.iterator().next() instanceof RuleIndexTerm );
    }
    @Override
    protected TestIndexer getIndexer() {
        return new TestDrlFileIndexer();
    }
    @Override
    public Map<String, Analyzer> getAnalyzers() {
        return new HashMap<String, Analyzer>() {{
            put( RuleAttributeIndexTerm.TERM,
                 new RuleAttributeNameAnalyzer( LUCENE_40 ) );
        }};
    }
    @Override
        return new TestDrlFileTypeDefinition();
    }
    @Override
    protected String getRepositoryName() {
        return this.getClass().getSimpleName();
    }
New to GrepCode? Check out our FAQ X