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;
}
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"));
}
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)));
}
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);
}
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"));
}
Aggregations