java-extension/com.microsoft.java.test.plugin/src/main/java/com/microsoft/java/test/plugin/util/TestNavigationUtils.java
public static TestNavigationResult findTestOrTarget(List<Object> arguments, IProgressMonitor monitor)
            throws JavaModelException {
        if (arguments == null || arguments.size() < 2) {
            throw new IllegalArgumentException("Wrong arguments passed to findTestOrTarget().");
        }
        final String typeUri = (String) arguments.get(0);
        final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(typeUri);
        if (unit == null) {
            JUnitPlugin.logError("Failed to resolve compilation unit from " + typeUri);
            return null;
        }
        final IType primaryType = unit.findPrimaryType();
        final String typeName;
        Location location = null;
        if (primaryType != null) {
            typeName = primaryType.getElementName();
            location = JDTUtils.toLocation(primaryType, LocationType.NAME_RANGE);
        } else {
            typeName = unit.getElementName().substring(0, unit.getElementName().lastIndexOf(".java"));
        }
        final SearchEngine searchEngine = new SearchEngine();
        final boolean goToTest = (boolean) arguments.get(1);
        final String nameToSearch = goToTest ? typeName : guessTestSubjectName(typeName);
        final IJavaSearchScope scope = getSearchScope(goToTest);
        final IJavaProject javaProject = unit.getJavaProject();
        final Set<TestNavigationItem> items = new HashSet<>();
        searchEngine.searchAllTypeNames(
            null,
            SearchPattern.R_EXACT_MATCH,
            ("*" + nameToSearch + "*").toCharArray(),
            SearchPattern.R_PATTERN_MATCH,
            IJavaSearchConstants.CLASS,
            scope,
            new TestNavigationNameRequestor(items, javaProject, nameToSearch, typeName, goToTest),
            IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
            monitor
        );

        return new TestNavigationResult(items, location);
    }
/**
     * find test or test subject according to the given java source file uri.
     * @param arguments arguments
     * @param monitor monitor
     * @return the search result for test navigation
     * @throws JavaModelException
     */
find test or test subject according to the given java source file uri.
@param arguments arguments
@param monitor monitor
@return the search result for test navigation
@throws JavaModelException
find test or test subject according to the given java source file uri . @param arguments arguments @param monitor monitor @return the search result for test navigation @throws JavaModelException
public static TestNavigationResult findTestOrTarget(List<Object> arguments, IProgressMonitor monitor)
            throws JavaModelException {
        if (arguments == null || arguments.size() < 2) {
            throw new IllegalArgumentException("Wrong arguments passed to findTestOrTarget().");
        }
        final String typeUri = (String) arguments.get(0);
        final ICompilationUnit unit = JDTUtils.resolveCompilationUnit(typeUri);
        if (unit == null) {
            JUnitPlugin.logError("Failed to resolve compilation unit from " + typeUri);
            return null;
        }
        final IType primaryType = unit.findPrimaryType();
        final String typeName;
        Location location = null;
        if (primaryType != null) {
            typeName = primaryType.getElementName();
            location = JDTUtils.toLocation(primaryType, LocationType.NAME_RANGE);
        } else {
            typeName = unit.getElementName().substring(0, unit.getElementName().lastIndexOf(".java"));
        }
        final SearchEngine searchEngine = new SearchEngine();
        final boolean goToTest = (boolean) arguments.get(1);
        final String nameToSearch = goToTest ? typeName : guessTestSubjectName(typeName);
        final IJavaSearchScope scope = getSearchScope(goToTest);
        final IJavaProject javaProject = unit.getJavaProject();
        final Set<TestNavigationItem> items = new HashSet<>();
        searchEngine.searchAllTypeNames(
            null,
            SearchPattern.R_EXACT_MATCH,
            ("*" + nameToSearch + "*").toCharArray(),
            SearchPattern.R_PATTERN_MATCH,
            IJavaSearchConstants.CLASS,
            scope,
            new TestNavigationNameRequestor(items, javaProject, nameToSearch, typeName, goToTest),
            IJavaSearchConstants.WAIT_UNTIL_READY_TO_SEARCH,
            monitor
        );
        return new TestNavigationResult(items, location);
    }
public static TestNavigationResult findTestOrTarget ( List < Object > arguments , IProgressMonitor monitor ) throws JavaModelException { if ( arguments == null || arguments . size ( ) < 2 ) { throw new IllegalArgumentException ( "Wrong arguments passed to findTestOrTarget()." ) ; } final String typeUri = ( String ) arguments . get ( 0 ) ; final ICompilationUnit unit = JDTUtils . resolveCompilationUnit ( typeUri ) ; if ( unit == null ) { JUnitPlugin . logError ( "Failed to resolve compilation unit from " + typeUri ) ; return null ; } final IType primaryType = unit . findPrimaryType ( ) ; final String typeName ; Location location = null ; if ( primaryType != null ) { typeName = primaryType . getElementName ( ) ; location = JDTUtils . toLocation ( primaryType , LocationType . NAME_RANGE ) ; } else { typeName = unit . getElementName ( ) . substring ( 0 , unit . getElementName ( ) . lastIndexOf ( ".java" ) ) ; } final SearchEngine searchEngine = new SearchEngine ( ) ; final boolean goToTest = ( boolean ) arguments . get ( 1 ) ; final String nameToSearch = goToTest ? typeName : guessTestSubjectName ( typeName ) ; final IJavaSearchScope scope = getSearchScope ( goToTest ) ; final IJavaProject javaProject = unit . getJavaProject ( ) ; final Set < TestNavigationItem > items = new HashSet < > ( ) ; searchEngine . searchAllTypeNames ( null , SearchPattern . R_EXACT_MATCH , ( "*" + nameToSearch + "*" ) . toCharArray ( ) , SearchPattern . R_PATTERN_MATCH , IJavaSearchConstants . CLASS , scope , new TestNavigationNameRequestor ( items , javaProject , nameToSearch , typeName , goToTest ) , IJavaSearchConstants . WAIT_UNTIL_READY_TO_SEARCH , monitor ) ; return new TestNavigationResult ( items , location ) ; }
find test or test subject according to the given java source file uri.
find test or test subject according to the given java source file uri .