Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
  package org.kie.workbench.common.services.refactoring.backend.server.query;
  
  import java.util.HashMap;
  import java.util.HashSet;
  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