/* * Copyright 2016 Red Hat, Inc. and/or its affiliates. * * 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 static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; import java.io.IOException; import java.util.Collections; 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.backend.server.BaseIndexingTest; import org.kie.workbench.common.services.refactoring.backend.server.TestIndexer; import org.kie.workbench.common.services.refactoring.backend.server.drl.TestDrlFileIndexer; import org.kie.workbench.common.services.refactoring.backend.server.drl.TestDrlFileTypeDefinition; import org.kie.workbench.common.services.refactoring.backend.server.query.response.DefaultResponseBuilder; import org.kie.workbench.common.services.refactoring.backend.server.query.response.ResponseBuilder; import org.kie.workbench.common.services.refactoring.backend.server.query.standard.FindResourceReferencesQuery; public class RefactoringQueryServiceImplGeneralTest extends BaseIndexingTest<TestDrlFileTypeDefinition> { protected Set<NamedQuery> getQueries() { return new HashSet<NamedQuery>() {{ add( new FindResourceReferencesQuery() { @Override public ResponseBuilder getResponseBuilder() { return new DefaultResponseBuilder( ioService() ); } } ); }}; } @Test public void testGetNamedQueries() throws IOException, InterruptedException { final Set<String> queryNames = service.getQueries(); assertNotNull( queryNames ); assertEquals( 1, queryNames.size() ); assertTrue( queryNames.contains( "FindResourceReferencesQuery" ) ); } @Override protected TestIndexer getIndexer() { return new TestDrlFileIndexer(); } @Override public Map<String, Analyzer> getAnalyzers() { return Collections.<String, Analyzer>emptyMap(); } @Override protected TestDrlFileTypeDefinition getResourceTypeDefinition() { return new TestDrlFileTypeDefinition(); } @Override protected String getRepositoryName() { return this.getClass().getSimpleName(); } }