Search in sources :

Example 1 with AddBundleCompletionProposal

use of org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal in project bndtools by bndtools.

the class ImportPackageQuickFixProcessorTest method proposalsFor.

private AddBundleCompletionProposal[] proposalsFor(IInvocationContext context, List<? extends IProblemLocation> locs) {
    final AtomicReference<IJavaCompletionProposal[]> ref = new AtomicReference<>();
    IProblemLocation[] locArray = new IProblemLocation[locs.size()];
    assertThatCode(() -> {
        ref.set(sut.getCorrections(context, locs.toArray(locArray)));
    }).doesNotThrowAnyException();
    final IJavaCompletionProposal[] props = ref.get();
    if (props == null) {
        return null;
    }
    assertThat(props).as("proposals").hasOnlyElementsOfType(AddBundleCompletionProposal.class);
    AddBundleCompletionProposal[] retval = new AddBundleCompletionProposal[props.length];
    int i = 0;
    for (IJavaCompletionProposal prop : props) {
        retval[i++] = (AddBundleCompletionProposal) prop;
    }
    return retval;
}
Also used : AddBundleCompletionProposal(org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal) AtomicReference(java.util.concurrent.atomic.AtomicReference) IProblemLocation(org.eclipse.jdt.ui.text.java.IProblemLocation) IJavaCompletionProposal(org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)

Example 2 with AddBundleCompletionProposal

use of org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal in project bndtools by bndtools.

the class ImportPackageQuickFixProcessorTest method getCorrections_whenVersionedBundleAlreadyIncluded_returnsNull.

@Test
public void getCorrections_whenVersionedBundleAlreadyIncluded_returnsNull() {
    Attrs attrs = new Attrs();
    attrs.put("version", "1.0.2");
    addToBuildPath(new VersionedClause("my.second.bundle", attrs));
    AddBundleCompletionProposal[] props = proposalsForImport("`org.osgi'.framework.*");
    assertThat(props).hasSize(1).haveExactly(1, suggestsBundle("my.test.bundle"));
}
Also used : VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) Attrs(aQute.bnd.header.Attrs) AddBundleCompletionProposal(org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal) Test(org.junit.Test)

Example 3 with AddBundleCompletionProposal

use of org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal in project bndtools by bndtools.

the class ImportPackageQuickFixProcessorTest method getCorrections_forBundleInThreeRepos_describesBundles.

@Test
public void getCorrections_forBundleInThreeRepos_describesBundles() {
    addBundleToRepo("Repo 2", "my.test.bundle", new VersionedClause("org.osgi.framework", new Attrs()));
    addBundleToRepo(WORKSPACE_REPO, "my.test.bundle", new VersionedClause("org.osgi.framework", new Attrs()));
    AddBundleCompletionProposal[] props = proposalsForImport("`org.osgi.framework'.*");
    assertThat(props).haveExactly(1, allOf(suggestsBundle("my.test.bundle", "Repo 1", WORKSPACE_REPO, "Repo 2"), withRelevance(ADD_BUNDLE_WORKSPACE)));
}
Also used : VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) Attrs(aQute.bnd.header.Attrs) AddBundleCompletionProposal(org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal) Test(org.junit.Test)

Example 4 with AddBundleCompletionProposal

use of org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal in project bndtools by bndtools.

the class ImportPackageQuickFixProcessorTest method getCorrections_forWorkspaceOnlyImport_whenWorkspaceFails_logsErrorOnce_andReturnsNull.

@Test
public void getCorrections_forWorkspaceOnlyImport_whenWorkspaceFails_logsErrorOnce_andReturnsNull() {
    Exception ex = makeSUTgetWSRepo_throwException();
    AddBundleCompletionProposal[] props = proposalsForImport("`my.workspace.only.pkg'.*");
    assertThat(props).as("proposals").isNull();
    verify(logger, times(1)).logError("Error trying to fetch the repository for the current workspace", ex);
}
Also used : AddBundleCompletionProposal(org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal) CoreException(org.eclipse.core.runtime.CoreException) Test(org.junit.Test)

Example 5 with AddBundleCompletionProposal

use of org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal in project bndtools by bndtools.

the class ImportPackageQuickFixProcessorTest method getCorrections_forBundleInTwoRepos_describesBundles.

@Test
public void getCorrections_forBundleInTwoRepos_describesBundles() {
    addBundleToRepo("Repo 2", "my.test.bundle", new VersionedClause("org.osgi.framework", new Attrs()));
    AddBundleCompletionProposal[] props = proposalsForImport("`org.osgi.framework'.*");
    assertThat(props).haveExactly(1, suggestsBundle("my.test.bundle", "Repo 1", "Repo 2"));
}
Also used : VersionedClause(aQute.bnd.build.model.clauses.VersionedClause) Attrs(aQute.bnd.header.Attrs) AddBundleCompletionProposal(org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal) Test(org.junit.Test)

Aggregations

AddBundleCompletionProposal (org.bndtools.core.editors.ImportPackageQuickFixProcessor.AddBundleCompletionProposal)5 Test (org.junit.Test)4 VersionedClause (aQute.bnd.build.model.clauses.VersionedClause)3 Attrs (aQute.bnd.header.Attrs)3 AtomicReference (java.util.concurrent.atomic.AtomicReference)1 CoreException (org.eclipse.core.runtime.CoreException)1 IJavaCompletionProposal (org.eclipse.jdt.ui.text.java.IJavaCompletionProposal)1 IProblemLocation (org.eclipse.jdt.ui.text.java.IProblemLocation)1