Search in sources :

Example 1 with ModuleSearchResult

use of org.eclipse.ceylon.cmr.api.ModuleSearchResult in project ceylon by eclipse.

the class LegacyImporter method findSuggestions.

private Set<ModuleDetails> findSuggestions(String pkg) {
    Set<ModuleDetails> suggestions = new TreeSet<>();
    ModuleVersionQuery query = new ModuleVersionQuery(null, "", null, ModuleQuery.Type.JVM);
    query.setJvmBinaryMajor(Versions.JVM_BINARY_MAJOR_VERSION);
    query.setJvmBinaryMinor(Versions.JVM_BINARY_MINOR_VERSION);
    query.setMemberName(pkg);
    query.setMemberSearchExact(true);
    query.setMemberSearchPackageOnly(true);
    ModuleSearchResult result = lookupRepoman.completeModules(query);
    for (ModuleDetails mvd : result.getResults()) {
        suggestions.add(mvd);
    }
    return suggestions;
}
Also used : TreeSet(java.util.TreeSet) ModuleDetails(org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails) ModuleVersionQuery(org.eclipse.ceylon.cmr.api.ModuleVersionQuery) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Example 2 with ModuleSearchResult

use of org.eclipse.ceylon.cmr.api.ModuleSearchResult in project ceylon by eclipse.

the class AbstractTest method testComplete.

protected void testComplete(String query, ModuleDetails[] expected, RepositoryManager manager, ModuleQuery.Type type, ModuleQuery.Retrieval retrieval, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor, String memberSearch) {
    ModuleQuery lookup = new ModuleQuery(query, type, retrieval);
    lookup.setJvmBinaryMajor(jvmBinaryMajor);
    lookup.setJvmBinaryMinor(jvmBinaryMinor);
    lookup.setJsBinaryMajor(jsBinaryMajor);
    lookup.setJsBinaryMinor(jsBinaryMinor);
    lookup.setMemberName(memberSearch);
    ModuleSearchResult result = manager.completeModules(lookup);
    compareSearchResults(expected, result);
}
Also used : ModuleQuery(org.eclipse.ceylon.cmr.api.ModuleQuery) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Example 3 with ModuleSearchResult

use of org.eclipse.ceylon.cmr.api.ModuleSearchResult in project ceylon by eclipse.

the class AbstractTest method testSearchResultsMember.

protected ModuleSearchResult testSearchResultsMember(String q, Type type, String members, boolean memberSearchExact, boolean memberSearchPackageOnly, ModuleDetails[] expected) throws Exception {
    ModuleQuery query = new ModuleQuery(q, type, Retrieval.ANY);
    query.setMemberName(members);
    query.setMemberSearchExact(memberSearchExact);
    query.setMemberSearchPackageOnly(memberSearchPackageOnly);
    RepositoryManager manager = getRepositoryManager();
    ModuleSearchResult results = manager.searchModules(query);
    compareSearchResults(expected, results);
    return results;
}
Also used : ModuleQuery(org.eclipse.ceylon.cmr.api.ModuleQuery) RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Example 4 with ModuleSearchResult

use of org.eclipse.ceylon.cmr.api.ModuleSearchResult in project ceylon by eclipse.

the class SmokeTestCase method testSearchModulesPaged.

@Test
public void testSearchModulesPaged() throws Exception {
    RepositoryManager repoManager = getRepositoryManager();
    // first page
    ModuleDetails[] expected = new ModuleDetails[] { com_acme_helloworld, hello };
    ModuleSearchResult results = testSearchResults("", Type.JVM, expected, 0l, 2l, repoManager);
    Assert.assertEquals(2, results.getCount());
    Assert.assertEquals(true, results.getHasMoreResults());
    Assert.assertEquals(0, results.getStart());
    // second page
    expected = new ModuleDetails[] { hello2_jvm, moduletest, old_jar };
    results = testSearchResults("", Type.JVM, expected, results.getStart() + results.getCount(), 3l, repoManager, results.getNextPagingInfo());
    Assert.assertEquals(3, results.getCount());
    Assert.assertEquals(true, results.getHasMoreResults());
    Assert.assertEquals(2, results.getStart());
    // third page
    expected = new ModuleDetails[] { older_jar, test_jar };
    results = testSearchResults("", Type.JVM, expected, results.getStart() + results.getCount(), 2l, repoManager, results.getNextPagingInfo());
    Assert.assertEquals(2, results.getCount());
    Assert.assertEquals(false, results.getHasMoreResults());
    Assert.assertEquals(5, results.getStart());
}
Also used : RepositoryManager(org.eclipse.ceylon.cmr.api.RepositoryManager) SimpleRepositoryManager(org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager) ModuleDetails(org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult) Test(org.junit.Test)

Example 5 with ModuleSearchResult

use of org.eclipse.ceylon.cmr.api.ModuleSearchResult in project ceylon by eclipse.

the class AbstractTest method testSearchResults.

protected ModuleSearchResult testSearchResults(String q, Type type, Retrieval retrieval, ModuleDetails[] expected, Long start, Long count, RepositoryManager manager, long[] pagingInfo, Integer jvmBinaryMajor, Integer jvmBinaryMinor, Integer jsBinaryMajor, Integer jsBinaryMinor) throws Exception {
    ModuleQuery query = new ModuleQuery(q, type, retrieval);
    query.setStart(start);
    query.setCount(count);
    query.setPagingInfo(pagingInfo);
    query.setJvmBinaryMajor(jvmBinaryMajor);
    query.setJvmBinaryMinor(jvmBinaryMinor);
    query.setJsBinaryMajor(jsBinaryMajor);
    query.setJsBinaryMinor(jsBinaryMinor);
    ModuleSearchResult results = manager.searchModules(query);
    compareSearchResults(expected, results);
    return results;
}
Also used : ModuleQuery(org.eclipse.ceylon.cmr.api.ModuleQuery) ModuleSearchResult(org.eclipse.ceylon.cmr.api.ModuleSearchResult)

Aggregations

ModuleSearchResult (org.eclipse.ceylon.cmr.api.ModuleSearchResult)9 ModuleDetails (org.eclipse.ceylon.cmr.api.ModuleSearchResult.ModuleDetails)5 ModuleQuery (org.eclipse.ceylon.cmr.api.ModuleQuery)3 RepositoryManager (org.eclipse.ceylon.cmr.api.RepositoryManager)3 Test (org.junit.Test)3 TreeSet (java.util.TreeSet)2 ModuleVersionQuery (org.eclipse.ceylon.cmr.api.ModuleVersionQuery)2 SimpleRepositoryManager (org.eclipse.ceylon.cmr.impl.SimpleRepositoryManager)2 CmrRepository (org.eclipse.ceylon.cmr.api.CmrRepository)1