| /******************************************************************************* |
| * Copyright (c) 2010 SAP AG, Walldorf. |
| * All rights reserved. This program and the accompanying materials |
| * are made available under the terms of the Eclipse Public License v1.0 |
| * which accompanies this distribution, and is available at |
| * http://www.eclipse.org/legal/epl-v10.html |
| * |
| * Contributors: |
| * SAP AG - initial API and implementation |
| *******************************************************************************/ |
| package org.eclipse.platform.discovery.ui.test.comp.internal;
|
|
|
| import java.util.ArrayList; |
| import java.util.Arrays; |
| import java.util.Collections; |
| import java.util.HashMap; |
| import java.util.HashSet; |
| import java.util.List; |
| import java.util.Map; |
| import java.util.Set; |
| |
| import org.easymock.EasyMock; |
| import org.eclipse.core.runtime.NullProgressMonitor; |
| import org.eclipse.platform.discovery.core.internal.ISearchSession; |
| import org.eclipse.platform.discovery.runtime.api.GroupingHierarchy; |
| import org.eclipse.platform.discovery.runtime.api.IDestinationsProvider; |
| import org.eclipse.platform.discovery.runtime.api.ISearchDestination; |
| import org.eclipse.platform.discovery.runtime.api.ISearchProvider; |
| import org.eclipse.platform.discovery.runtime.api.ISearchSubdestination; |
| import org.eclipse.platform.discovery.runtime.internal.DestinationCategoryNotFoundException; |
| import org.eclipse.platform.discovery.runtime.internal.ISearchProviderConfiguration; |
| import org.eclipse.platform.discovery.runtime.internal.ProviderNotFoundException; |
| import org.eclipse.platform.discovery.runtime.internal.model.descriptions.IDestinationCategoryDescription; |
| import org.eclipse.platform.discovery.runtime.internal.model.descriptions.IDestinationsProviderDescription; |
| import org.eclipse.platform.discovery.runtime.internal.model.descriptions.IObjectTypeDescription; |
| import org.eclipse.platform.discovery.runtime.internal.model.descriptions.ISearchProviderDescription; |
| import org.eclipse.platform.discovery.testutils.utils.abbot.matchers.EnhancedTextMatcher; |
| import org.eclipse.platform.discovery.testutils.utils.abbot.matchers.SiblingTextMatcher; |
| import org.eclipse.platform.discovery.ui.api.IViewUiContext; |
| import org.eclipse.platform.discovery.ui.internal.plugin.DiscoveryUIMessages; |
| import org.eclipse.platform.discovery.util.api.env.IDiscoveryEnvironment; |
| import org.eclipse.platform.discovery.util.api.env.IErrorHandler; |
| import org.eclipse.platform.discovery.util.api.longop.ILongOperationRunner; |
| import org.eclipse.platform.discovery.util.internal.session.ISessionManager; |
| import org.eclipse.swt.SWT; |
| import org.eclipse.swt.widgets.Button; |
| import org.eclipse.swt.widgets.Combo; |
| import org.eclipse.swt.widgets.Display; |
| import org.eclipse.swt.widgets.Label; |
| import org.eclipse.swt.widgets.Text; |
| import org.eclipse.swt.widgets.Tree; |
| import org.eclipse.swt.widgets.TreeItem; |
| import org.eclipse.ui.forms.widgets.FormToolkit; |
| |
| import abbot.swt.finder.generic.MultipleFoundException; |
| import abbot.swt.finder.generic.NotFoundException; |
|
|
|
|
| public abstract class SearchConsoleTestFixture extends DicoveryViewTestFixture
|
| {
|
| private static final String TEST_SEARCH_DEST_PROVIDER_PREFERENCE_PAGE_ID = "org.eclipse.platform.discovery.ui.test.comp.page1";
|
|
|
| protected final static int VIEWERS_OFFSET = 60;
|
|
|
| protected IObjectTypeDescription objectType1;
|
| protected IObjectTypeDescription objectType2;
|
| protected IObjectTypeDescription objectType3; |
| protected IObjectTypeDescription objectTypeNoDestinations; |
|
|
| protected final String OBJECT_TYPE_ID1 = "org.eclipse.platform.discovery.objecttype1";
|
| protected final String OBJECT_TYPE_ID2 = "org.eclipse.platform.discovery.objecttype2";
|
| protected final String OBJECT_TYPE_ID3 = "org.eclipse.platform.discovery.objecttype3"; |
| protected final String OBJECT_TYPE_NO_DESTINATIONS_ID = "org.eclipse.platform.discovery.nodestinations_objecttype";
|
| protected final String OBJECT_TYPE_NAME_1 = "First object type";
|
| protected final String OBJECT_TYPE_NAME_2 = "Second object type";
|
| protected final String OBJECT_TYPE_NAME_3 = "Third object type"; |
| protected final String OBJECT_TYPE_NO_DESTINATIONS_NAME = "Destination-less object type"; |
|
|
|
|
| protected IDestinationsProviderDescription destProviderDescr_cat1;
|
| protected IDestinationsProviderDescription destProviderDescr_cat2;
|
| protected IDestinationsProviderDescription destProviderDescr_cat3;
|
|
|
| protected IDestinationsProvider destProvider_cat1;
|
| protected IDestinationsProvider destProvider_cat2;
|
| protected IDestinationsProvider destProvider_cat3;
|
|
|
| protected ISearchDestination destination1;
|
| protected ISearchDestination destination2;
|
| protected ISearchDestination destination3;
|
| protected ISearchDestination destination4;
|
| protected ISearchDestination destination5;
|
| protected final String DESTINATION_NAME1 = "First destination";
|
| protected final String DESTINATION_NAME2 = "Second destination";
|
| protected final String DESTINATION_NAME3 = "Third destination";
|
| protected final String DESTINATION_NAME4 = "Fourth destination";
|
| protected final String DESTINATION_NAME5 = "Fifth destination";
|
|
|
| protected IDestinationCategoryDescription category1;
|
| protected IDestinationCategoryDescription category2;
|
| protected IDestinationCategoryDescription category3;
|
| protected final static String CATEGORY_ID_1 = "category1";
|
| protected final static String CATEGORY_ID_2 = "category2";
|
| protected final static String CATEGORY_ID_3 = "category3";
|
| protected final static String CATEGORY_NAME_1 = "First category";
|
| protected final static String CATEGORY_NAME_2 = "Second category";
|
| protected final static String CATEGORY_NAME_3 = "Third category";
|
|
|
| protected ISearchSubdestination subdestination1;
|
| protected ISearchSubdestination subdestination2;
|
| protected static final String SUBDESTINATION_NAME_1 = "Subdestination 1";
|
| protected static final String SUBDESTINATION_NAME_2 = "Subdestination 2";
|
| protected Map<ISearchSubdestination, Boolean> subdestinationsActivityMap;
|
|
|
| protected ISearchProviderDescription supportingTextSearchProviderDescription;
|
| protected ISearchProviderDescription unsupportingTextSearchProviderDescription; |
| protected ISearchProviderDescription searchProviderForObjTypeWithNoDestinations_Description; |
| protected final static String SUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID = "SUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID";
|
| protected final static String UNSUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID = "UNSUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID"; |
| protected final static String SEARCH_PROVIDER_NO_DESTINATIONS_ID = "SEARCH_PROVIDER_NO_DESTINATIONS_ID"; |
|
|
| protected ISearchProvider supportingTextSearchProviderInstance;
|
| protected ISearchProvider unsupportingTextSearchProviderInstance; |
| protected ISearchProvider searchProviderForObjTypeWithNoDestinations_Instance; |
|
|
| protected ISearchProviderConfiguration searchProviderConfiguration;
|
|
|
| protected GroupingHierarchy groupingHierarchy1;
|
| protected GroupingHierarchy groupingHierarchy2;
|
|
|
| protected IErrorHandler errorHandler;
|
| protected ILongOperationRunner operationRunner;
|
| protected IDiscoveryEnvironment environment;
|
| protected ISessionManager<ISearchSession> sessionManager;
|
| protected NullProgressMonitor nullProgressMonitor;
|
| protected FormToolkit formToolkit;
|
| protected IViewUiContext viewUiContext;
|
|
|
|
|
| @SuppressWarnings("unchecked")
|
| @Override
|
| public Display setUpPDE() throws Exception
|
| {
|
| super.setUpPDE();
|
|
|
| getDisplay().syncExec(new Runnable()
|
| {
|
| @Override
|
| public void run()
|
| {
|
| formToolkit = new FormToolkit(getDisplay());
|
| }
|
| });
|
|
|
| errorHandler = createThreadSafeNiceMock(IErrorHandler.class);
|
| operationRunner = createThreadSafeNiceMock(ILongOperationRunner.class);
|
| environment = createThreadSafeNiceMock(IDiscoveryEnvironment.class);
|
| sessionManager = createThreadSafeNiceMock(ISessionManager.class);
|
| nullProgressMonitor = new NullProgressMonitor();
|
| EasyMock.expect(environment.errorHandler()).andStubReturn(errorHandler);
|
| EasyMock.expect(environment.operationRunner()).andStubReturn(operationRunner);
|
| EasyMock.expect(environment.progressMonitor()).andStubReturn(nullProgressMonitor);
|
|
|
| viewUiContext = EasyMock.createMock(IViewUiContext.class);
|
| EasyMock.expect(viewUiContext.getSecondColumnPosition()).andStubReturn(60);
|
| EasyMock.expect(viewUiContext.controlsSpacing()).andStubReturn(60);
|
| EasyMock.replay(environment, viewUiContext);
|
|
|
| setupObjectTypes();
|
| setupDestinations();
|
| setupDestinationProviders();
|
| setupDestinationCategories();
|
| setupSubdestinations();
|
| setupGroupingHierarchy();
|
| setupProviderInstances();
|
| setupProviderDescriptions();
|
| searchProviderConfiguration = createTestSearchProviderConfig();
|
|
|
| return getDisplay();
|
| }
|
|
|
|
|
| private void setupObjectTypes()
|
| {
|
| objectType1 = createThreadSafeNiceMock(IObjectTypeDescription.class);
|
| EasyMock.expect(objectType1.getId()).andStubReturn(OBJECT_TYPE_ID1);
|
| EasyMock.expect(objectType1.getDisplayName()).andStubReturn(OBJECT_TYPE_NAME_1);
|
|
|
| objectType2 = createThreadSafeNiceMock(IObjectTypeDescription.class);
|
| EasyMock.expect(objectType2.getId()).andStubReturn(OBJECT_TYPE_ID2);
|
| EasyMock.expect(objectType2.getDisplayName()).andStubReturn(OBJECT_TYPE_NAME_2);
|
|
|
| objectType3 = createThreadSafeNiceMock(IObjectTypeDescription.class);
|
| EasyMock.expect(objectType3.getId()).andStubReturn(OBJECT_TYPE_ID3);
|
| EasyMock.expect(objectType3.getDisplayName()).andStubReturn(OBJECT_TYPE_NAME_3); |
| |
| objectTypeNoDestinations = createThreadSafeNiceMock(IObjectTypeDescription.class); |
| EasyMock.expect(objectTypeNoDestinations.getId()).andStubReturn(OBJECT_TYPE_NO_DESTINATIONS_ID); |
| EasyMock.expect(objectTypeNoDestinations.getDisplayName()).andStubReturn(OBJECT_TYPE_NO_DESTINATIONS_NAME);
|
|
|
| EasyMock.replay(objectType1, objectType2, objectType3, objectTypeNoDestinations);
|
| }
|
|
|
| private void setupDestinations()
|
| {
|
| destination1 = createThreadSafeNiceMock(ISearchDestination.class);
|
| EasyMock.expect(destination1.getDisplayName()).andStubReturn(DESTINATION_NAME1);
|
| destination2 = createThreadSafeNiceMock(ISearchDestination.class);
|
| EasyMock.expect(destination2.getDisplayName()).andStubReturn(DESTINATION_NAME2);
|
| destination3 = createThreadSafeNiceMock(ISearchDestination.class);
|
| EasyMock.expect(destination3.getDisplayName()).andStubReturn(DESTINATION_NAME3);
|
| destination4 = createThreadSafeNiceMock(ISearchDestination.class);
|
| EasyMock.expect(destination4.getDisplayName()).andStubReturn(DESTINATION_NAME4);
|
| destination5 = createThreadSafeNiceMock(ISearchDestination.class);
|
| EasyMock.expect(destination5.getDisplayName()).andStubReturn(DESTINATION_NAME5);
|
|
|
| EasyMock.replay(destination1, destination2, destination3, destination4, destination5);
|
| }
|
|
|
| private void setupSubdestinations()
|
| {
|
| subdestination1 = createThreadSafeNiceMock(ISearchSubdestination.class);
|
| EasyMock.expect(subdestination1.getDisplayName()).andStubReturn(SUBDESTINATION_NAME_1);
|
| subdestination2 = createThreadSafeNiceMock(ISearchSubdestination.class);
|
| EasyMock.expect(subdestination2.getDisplayName()).andStubReturn(SUBDESTINATION_NAME_2);
|
| EasyMock.replay(subdestination1, subdestination2);
|
|
|
| subdestinationsActivityMap = new HashMap<ISearchSubdestination, Boolean>();
|
| subdestinationsActivityMap.put(subdestination1, false);
|
| subdestinationsActivityMap.put(subdestination2, false);
|
| }
|
|
|
| protected Text getKeywordsSearchText() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Text) FINDER.find(new SiblingTextMatcher(DiscoveryUIMessages.SEARCH_KEYWORD_LABEL, null, Text.class));
|
| }
|
|
|
| protected Label getSubdestinationsButton() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Label) FINDER.find(new SiblingTextMatcher(DiscoveryUIMessages.SEARCH_KEYWORD_LABEL, null, Label.class));
|
| }
|
|
|
| protected Button getSearchButton() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Button) FINDER.find(new EnhancedTextMatcher(DiscoveryUIMessages.SEARCH_BUTTON_LABEL, Button.class));
|
| }
|
|
|
|
|
| private ISearchProviderConfiguration createTestSearchProviderConfig()
|
| {
|
| return new ISearchProviderConfiguration()
|
| {
|
| public void activateSubdestination(IObjectTypeDescription searchObjectType, IDestinationCategoryDescription destinationCategory,
|
| ISearchProviderDescription searchProviderDescription, ISearchSubdestination subDestination,
|
| boolean activate)
|
| {
|
| subdestinationsActivityMap.put(subDestination, new Boolean(activate));
|
|
|
| }
|
|
|
| public ISearchProviderDescription getActiveSearchProvider(IObjectTypeDescription objectType,
|
| IDestinationCategoryDescription destinationCategory) throws ProviderNotFoundException
|
| { |
| if (destinationCategory==null) |
| { |
| if(objectType.getId().equals(objectTypeNoDestinations.getId())) { |
| return searchProviderForObjTypeWithNoDestinations_Description; |
| }else{ |
| throw new ProviderNotFoundException("Provider not found"); |
| } |
| } |
| if (objectType.getId().equals(objectType2.getId()) && (destinationCategory.getId().equals(CATEGORY_ID_2)))
|
| {
|
| return supportingTextSearchProviderDescription;
|
| } |
| if (objectType.getId().equals(objectType1.getId()) && (destinationCategory.getId().equals(CATEGORY_ID_1)))
|
| {
|
| return unsupportingTextSearchProviderDescription;
|
| } |
| if (objectType.getId().equals(objectType3.getId()) && (destinationCategory.getId().equals(CATEGORY_ID_3)))
|
| {
|
| return supportingTextSearchProviderDescription;
|
| }
|
|
|
| throw new ProviderNotFoundException("Provider not found");
|
| }
|
|
|
| public List<IDestinationCategoryDescription> getAvailableDestinationCategoriesForObjectType(IObjectTypeDescription objectType)
|
| {
|
| if (objectType.getId().equals(objectType1.getId()))
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category1 });
|
| } else if (objectType.getId().equals(objectType2.getId()))
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category2 });
|
| } else if (objectType.getId().equals(objectType3.getId()))
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category3 });
|
| } |
| |
| return Collections.emptyList();
|
| }
|
|
|
| public List<ISearchSubdestination> getAvailableSearchSubdestinations(IObjectTypeDescription objectType,
|
| IDestinationCategoryDescription destinationCategory, ISearchProviderDescription searchProvider)
|
| {
|
| if (objectType.getId().equals(OBJECT_TYPE_ID1))
|
| {
|
| return Arrays.asList(subdestination1, subdestination2);
|
| }
|
| return new ArrayList<ISearchSubdestination>();
|
| }
|
|
|
| public List<IDestinationCategoryDescription> getDestinationCategories()
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category1, category2 ,category3});
|
| }
|
|
|
| public List<IDestinationCategoryDescription> getDestinationCategoriesForDestination(ISearchDestination destination)
|
| throws DestinationCategoryNotFoundException
|
| {
|
| if (destination.equals(destination1))
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category1 });
|
| } if (destination.equals(destination5))
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category3 });
|
| }else
|
| {
|
| return Arrays.asList(new IDestinationCategoryDescription[] { category2 });
|
| }
|
| }
|
|
|
| public boolean isSubdestinationActive(ISearchSubdestination subdestination, IObjectTypeDescription objectType,
|
| IDestinationCategoryDescription destCategory, ISearchProviderDescription searchProvider)
|
| {
|
| return subdestinationsActivityMap.get(subdestination);
|
| }
|
|
|
| public List<ISearchProviderDescription> getAvailableSearchProviderDescriptions(IObjectTypeDescription searchObjectType)
|
| {
|
| fail("Unexpected invocation");
|
| return null;
|
| }
|
|
|
| public List<IObjectTypeDescription> getObjectTypes()
|
| {
|
| return Arrays.asList(new IObjectTypeDescription[] { objectType1, objectType2, objectType3, objectTypeNoDestinations });
|
| }
|
|
|
| public List<IDestinationsProviderDescription> getDestinationProvidersForCategory(IDestinationCategoryDescription category)
|
| {
|
| if (category.equals(category1))
|
| {
|
| return Arrays.asList(new IDestinationsProviderDescription[]{destProviderDescr_cat1});
|
| } if (category.equals(category2))
|
| {
|
| return Arrays.asList(new IDestinationsProviderDescription[]{destProviderDescr_cat2});
|
| }else
|
| {
|
| return Arrays.asList(new IDestinationsProviderDescription[]{destProviderDescr_cat3});
|
| }
|
| }
|
|
|
| public List<ISearchDestination> getSearchDestinations(IDestinationCategoryDescription category,
|
| IDestinationsProvider providerDescription)
|
| {
|
| return new ArrayList<ISearchDestination>(providerDescription.getSearchDestinations());
|
| }
|
|
|
| public List<IDestinationsProviderDescription> getAvailableDestinationProviders()
|
| {
|
| return Arrays.asList(new IDestinationsProviderDescription[]{destProviderDescr_cat1, destProviderDescr_cat2, destProviderDescr_cat3});
|
| }
|
| };
|
| }
|
|
|
| private void setupGroupingHierarchy()
|
| {
|
| groupingHierarchy1 = new GroupingHierarchy("Grouping 1", "Grouping 1");
|
| groupingHierarchy2 = new GroupingHierarchy("Grouping 2", "Grouping 2");
|
| }
|
|
|
| @SuppressWarnings({ "unchecked", "rawtypes" })
|
| private void setupProviderInstances()
|
| {
|
| final Set<GroupingHierarchy> h = new HashSet<GroupingHierarchy>();
|
| h.add(groupingHierarchy1);
|
| h.add(groupingHierarchy2);
|
| supportingTextSearchProviderInstance = EasyMock.createMock(ISearchProvider.class);
|
| EasyMock.expect(supportingTextSearchProviderInstance.getGroupingHierarchies((ISearchDestination)EasyMock.anyObject(), (Set)EasyMock.anyObject())).andStubReturn(h);
|
|
|
| unsupportingTextSearchProviderInstance = EasyMock.createMock(ISearchProvider.class);
|
| EasyMock.expect(unsupportingTextSearchProviderInstance.getGroupingHierarchies((ISearchDestination)EasyMock.anyObject(), (Set)EasyMock.anyObject())).andStubReturn(new HashSet<GroupingHierarchy>()); |
| |
| searchProviderForObjTypeWithNoDestinations_Instance = EasyMock.createMock(ISearchProvider.class);
|
| EasyMock.expect(searchProviderForObjTypeWithNoDestinations_Instance.getGroupingHierarchies((ISearchDestination)EasyMock.anyObject(), (Set)EasyMock.anyObject())).andStubReturn(new HashSet<GroupingHierarchy>()); |
|
|
| EasyMock.replay(supportingTextSearchProviderInstance, unsupportingTextSearchProviderInstance, searchProviderForObjTypeWithNoDestinations_Instance); |
|
|
| }
|
|
|
| private void setupProviderDescriptions()
|
| {
|
| supportingTextSearchProviderDescription = createThreadSafeNiceMock(ISearchProviderDescription.class);
|
| EasyMock.expect(supportingTextSearchProviderDescription.supportsTextSearch()).andStubReturn(true);
|
| EasyMock.expect(supportingTextSearchProviderDescription.getId()).andStubReturn(SUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID);
|
| EasyMock.expect(supportingTextSearchProviderDescription.createInstance()).andStubReturn(supportingTextSearchProviderInstance); |
| EasyMock.expect(supportingTextSearchProviderDescription.getSupportedDestinationCategories()).andStubReturn( |
| new HashSet<IDestinationCategoryDescription>(Arrays.asList(category2, category3))); |
|
|
|
|
| unsupportingTextSearchProviderDescription = createThreadSafeNiceMock(ISearchProviderDescription.class);
|
| EasyMock.expect(unsupportingTextSearchProviderDescription.supportsTextSearch()).andStubReturn(false);
|
| EasyMock.expect(unsupportingTextSearchProviderDescription.getId()).andStubReturn(UNSUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID);
|
| EasyMock.expect(unsupportingTextSearchProviderDescription.createInstance()).andStubReturn(unsupportingTextSearchProviderInstance); |
| EasyMock.expect(supportingTextSearchProviderDescription.getSupportedDestinationCategories()).andStubReturn( |
| new HashSet<IDestinationCategoryDescription>(Arrays.asList(category1))); |
| |
| searchProviderForObjTypeWithNoDestinations_Description = createThreadSafeNiceMock(ISearchProviderDescription.class); |
| EasyMock.expect(searchProviderForObjTypeWithNoDestinations_Description.supportsTextSearch()).andStubReturn(true); |
| EasyMock.expect(searchProviderForObjTypeWithNoDestinations_Description.getId()).andStubReturn(SEARCH_PROVIDER_NO_DESTINATIONS_ID); |
| EasyMock.expect(searchProviderForObjTypeWithNoDestinations_Description.createInstance()).andStubReturn(searchProviderForObjTypeWithNoDestinations_Instance); |
| EasyMock.expect(searchProviderForObjTypeWithNoDestinations_Description.getSupportedDestinationCategories()).andStubReturn(new HashSet<IDestinationCategoryDescription>()); |
|
|
|
|
| EasyMock.replay(supportingTextSearchProviderDescription, unsupportingTextSearchProviderDescription, searchProviderForObjTypeWithNoDestinations_Description);
|
| }
|
|
|
| private void setupDestinationCategories()
|
| {
|
| category1 = createThreadSafeNiceMock(IDestinationCategoryDescription.class);
|
| EasyMock.expect(category1.getId()).andStubReturn(CATEGORY_ID_1);
|
| EasyMock.expect(category1.getDisplayName()).andStubReturn(CATEGORY_NAME_1); |
| EasyMock.expect(category1.getDestinationProviderIds()).andStubReturn(list(UNSUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID));
|
| |
| category2 = createThreadSafeNiceMock(IDestinationCategoryDescription.class);
|
| EasyMock.expect(category2.getId()).andStubReturn(CATEGORY_ID_2);
|
| EasyMock.expect(category2.getDisplayName()).andStubReturn(CATEGORY_NAME_2); |
| EasyMock.expect(category2.getDestinationProviderIds()).andStubReturn(list(SUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID));
|
|
|
| category3 = createThreadSafeNiceMock(IDestinationCategoryDescription.class);
|
| EasyMock.expect(category3.getId()).andStubReturn(CATEGORY_ID_3);
|
| EasyMock.expect(category3.getDisplayName()).andStubReturn(CATEGORY_NAME_3); |
| EasyMock.expect(category3.getDestinationProviderIds()).andStubReturn(list(SUPPORTING_TEXT_SEARCH_SEARCH_PROVIDER_ID));
|
|
|
| EasyMock.replay(category1, category2, category3);
|
| }
|
|
|
| private List<String> list(String... strings) { |
| return Arrays.asList(strings); |
| } |
| |
| |
| protected void selectFirstPossibleDestination(final Tree destinationsTree)
|
| {
|
| final TreeItem[] treeItems = treeTester.getItems(destinationsTree);
|
| treeItemTester.actionClick(treeItems[0]);
|
| treeItemTester.key(SWT.ARROW_DOWN);
|
| // UI changes after destination selection sometimes occur a bit slow. Wait some time to let them happen
|
| waitFor(100);
|
| }
|
|
|
| private void setupDestinationProviders()
|
| {
|
| destProvider_cat1 = createThreadSafeNiceMock(IDestinationsProvider.class);
|
| EasyMock.expect(destProvider_cat1.getSearchDestinations()).andStubReturn(new HashSet<ISearchDestination>(Arrays.asList(new ISearchDestination[] { destination1, destination2 })));
|
| destProviderDescr_cat1 = createThreadSafeNiceMock(IDestinationsProviderDescription.class);
|
| EasyMock.expect(destProviderDescr_cat1.createProvider()).andStubReturn(destProvider_cat1);
|
| EasyMock.expect(destProviderDescr_cat1.getPreferencePageId()).andStubReturn(TEST_SEARCH_DEST_PROVIDER_PREFERENCE_PAGE_ID);
|
|
|
| destProvider_cat2 = createThreadSafeNiceMock(IDestinationsProvider.class);
|
| EasyMock.expect(destProvider_cat2.getSearchDestinations()).andStubReturn(new HashSet<ISearchDestination>(Arrays.asList(new ISearchDestination[] { destination3, destination4 })));
|
| destProviderDescr_cat2 = createThreadSafeNiceMock(IDestinationsProviderDescription.class);
|
| EasyMock.expect(destProviderDescr_cat2.createProvider()).andStubReturn(destProvider_cat2);
|
| EasyMock.expect(destProviderDescr_cat2.getPreferencePageId()).andStubReturn(null);
|
|
|
| destProvider_cat3 = createThreadSafeNiceMock(IDestinationsProvider.class);
|
| EasyMock.expect(destProvider_cat3.getSearchDestinations()).andStubReturn(new HashSet<ISearchDestination>(Arrays.asList(new ISearchDestination[] { destination5 })));
|
| destProviderDescr_cat3 = createThreadSafeNiceMock(IDestinationsProviderDescription.class);
|
| EasyMock.expect(destProviderDescr_cat3.createProvider()).andStubReturn(destProvider_cat3);
|
| EasyMock.expect(destProviderDescr_cat3.getPreferencePageId()).andStubReturn(null);
|
|
|
| EasyMock.replay(destProvider_cat1, destProvider_cat2, destProvider_cat3, destProviderDescr_cat1, destProviderDescr_cat2, destProviderDescr_cat3);
|
| }
|
|
|
| protected Combo getObjectTypesCombo() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Combo) FINDER.find(new SiblingTextMatcher(DiscoveryUIMessages.SEARCH_FOR_LIST_VIEWER_LABEL, null, Combo.class));
|
| }
|
|
|
| protected Combo getGroupByCombo() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Combo) FINDER.find(new SiblingTextMatcher(DiscoveryUIMessages.GROUP_BY_LABEL, null, Combo.class));
|
| }
|
|
|
| protected Tree getDestinationCategoriesTree() throws NotFoundException, MultipleFoundException
|
| {
|
| return (Tree) FINDER.find(new SiblingTextMatcher(DiscoveryUIMessages.SEARCH_IN_LIST_VIEWER_LABEL, null, Tree.class));
|
| }
|
|
|
| @Override
|
| public void tearDownPDE() throws Exception
|
| {
|
| super.tearDownPDE();
|
| }
|
|
|
| protected static <T> T createThreadSafeNiceMock(final Class<T> clazz)
|
| {
|
| final T mock = EasyMock.createNiceMock(clazz);
|
| EasyMock.makeThreadSafe(mock, true);
|
| return mock;
|
| }
|
| }
|