Package org.apache.maven.index

Examples of org.apache.maven.index.ArtifactInfoGroup


    public boolean addArtifactInfo( Map<String, ArtifactInfoGroup> result, ArtifactInfo artifactInfo )
    {
        String key = getGroupKey( artifactInfo );

        ArtifactInfoGroup group = result.get( key );

        if ( group == null )
        {
            group = new ArtifactInfoGroup( key, comparator );

            result.put( key, group );
        }

        return group.addArtifactInfo( artifactInfo );
    }
View Full Code Here


            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() );

            Iterator<ArtifactInfoGroup> it = r.values().iterator();

            ArtifactInfoGroup ig1 = it.next();
            assertEquals( r.toString(), "org.slf4j", ig1.getGroupKey() );

            ArtifactInfoGroup ig2 = it.next();
            assertEquals( r.toString(), "org.testng", ig2.getGroupKey() );
        }

        {
            // a lower case search
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "logger", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );
            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() );

            Iterator<ArtifactInfoGroup> it = r.values().iterator();

            ArtifactInfoGroup ig1 = it.next();
            assertEquals( r.toString(), "org.slf4j", ig1.getGroupKey() );

            ArtifactInfoGroup ig2 = it.next();
            assertEquals( r.toString(), "org.testng", ig2.getGroupKey() );
        }

        {
            // explicit class name wildcard without terminator
            // Since 4.0 query starting with * is illegal
            // Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "*.Logger", SearchType.SCORED );
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, ".Logger", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );
            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() );
            Iterator<ArtifactInfoGroup> it = r.values().iterator();
            ArtifactInfoGroup ig1 = it.next();
            assertEquals( r.toString(), "org.slf4j", ig1.getGroupKey() );
            ArtifactInfoGroup ig2 = it.next();
            assertEquals( r.toString(), "org.testng", ig2.getGroupKey() );
        }

        {
            // explicit class name wildcard with terminator
            // Since 4.0 query starting with * is illegal
            // Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "*.Logger ", SearchType.SCORED );
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, ".Logger ", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );
            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() );
            Iterator<ArtifactInfoGroup> it = r.values().iterator();
            ArtifactInfoGroup ig1 = it.next();
            assertEquals( r.toString(), "org.slf4j", ig1.getGroupKey() );
            ArtifactInfoGroup ig2 = it.next();
            assertEquals( r.toString(), "org.testng", ig2.getGroupKey() );
        }

        {
            // a class name wildcard
            // Since 4.0 query starting with * is illegal
            // Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "*Logger", SearchType.SCORED );
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "Logger", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );
            Map<String, ArtifactInfoGroup> r = response.getResults();
            // Results are less, since no PREFIX searches anymore!
            // assertEquals( r.toString(), 3, r.size() );
            assertEquals( r.toString(), 2, r.size() );

            Iterator<ArtifactInfoGroup> it = r.values().iterator();

            // Results are less, since no PREFIX searches anymore!
            // ArtifactInfoGroup ig1 = it.next();
            // assertEquals( r.toString(), "commons-logging", ig1.getGroupKey() ); // Jdk14Logger and LogKitLogger

            ArtifactInfoGroup ig2 = it.next();
            assertEquals( r.toString(), "org.slf4j", ig2.getGroupKey() );

            ArtifactInfoGroup ig3 = it.next();
            assertEquals( r.toString(), "org.testng", ig3.getGroupKey() );
        }

        {
            // exact class name
            Query q =
                nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "org/apache/commons/logging/LogConfigurationException",
                    SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );

            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() ); // jcl104-over-slf4j and commons-logging
        }

        {
            // implicit class name pattern
            Query q =
                nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "org.apache.commons.logging.LogConfigurationException",
                    SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );

            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() ); // jcl104-over-slf4j and commons-logging
        }

        {
            // exact class name
            Query q =
                nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "org.apache.commons.logging.LogConfigurationException",
                    SearchType.EXACT );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );

            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() ); // jcl104-over-slf4j and commons-logging
        }

        {
            // package name prefix
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "org.apache.commons.logging", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );

            Map<String, ArtifactInfoGroup> r = response.getResults();
            assertEquals( r.toString(), 2, r.size() ); // jcl104-over-slf4j and commons-logging
        }

        {
            // Since 4.0, queries cannot start with '*'
            // Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "*slf4j*Logg*", SearchType.SCORED );
            Query q = nexusIndexer.constructQuery( MAVEN.CLASSNAMES, "slf4j.Logg*", SearchType.SCORED );
            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );
            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );

            Map<String, ArtifactInfoGroup> r = response.getResults();
            // Error is fixed, see below
            assertEquals( r.toString(), 1, r.size() );

            {
                ArtifactInfoGroup ig = r.values().iterator().next();
                ArrayList<ArtifactInfo> list1 = new ArrayList<ArtifactInfo>( ig.getArtifactInfos() );
                assertEquals( r.toString(), 2, list1.size() );

                ArtifactInfo ai1 = list1.get( 0 );
                assertEquals( "org.slf4j", ai1.groupId );
                assertEquals( "slf4j-api", ai1.artifactId );
View Full Code Here

            Map<String, ArtifactInfoGroup> r = response.getResults();

            assertEquals( 1, r.size() );

            ArtifactInfoGroup ig = r.values().iterator().next();

            assertEquals( "commons-logging : commons-logging", ig.getGroupKey() );

            assertEquals( ig.getArtifactInfos().toString(), 6, ig.getArtifactInfos().size() );
        }

        {
            // numbers and "-" in the name
            Query q = nexusIndexer.constructQuery( MAVEN.ARTIFACT_ID, "jcl104-over-slf4*", SearchType.SCORED );

            GroupedSearchRequest request = new GroupedSearchRequest( q, new GAGrouping() );

            GroupedSearchResponse response = nexusIndexer.searchGrouped( request );
            Map<String, ArtifactInfoGroup> r = response.getResults();

            assertEquals( 1, r.size() );

            ArtifactInfoGroup ig = r.values().iterator().next();

            assertEquals( ig.getArtifactInfos().toString(), 1, ig.getArtifactInfos().size() );

            assertEquals( "org.slf4j : jcl104-over-slf4j", ig.getGroupKey() );
        }
    }
View Full Code Here

TOP

Related Classes of org.apache.maven.index.ArtifactInfoGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.