diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/AbstractTargetEditorTest.java b/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/AbstractTargetEditorTest.java index 148ba370dd..c3600228dd 100644 --- a/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/AbstractTargetEditorTest.java +++ b/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/AbstractTargetEditorTest.java @@ -22,6 +22,8 @@ import java.io.InputStream; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; +import java.util.Arrays; +import java.util.List; import java.util.stream.Collectors; import org.eclipse.core.filebuffers.FileBuffers; @@ -52,12 +54,7 @@ public abstract class AbstractTargetEditorTest { protected File tempFile; protected void checkProposals(String[] expectedProposals, ICompletionProposal[] actualProposals, int offset) { - assertEquals("Proposal lengths are not equal at offset " + offset + ". Actual: " - + proposalListToString(actualProposals), expectedProposals.length, actualProposals.length); - for (int i = 0; i < actualProposals.length; i++) { - assertEquals("Proposal at index " + i + " did not match expected at offset " + offset, - actualProposals[i].getDisplayString(), expectedProposals[i]); - } + assertEquals(Arrays.asList(expectedProposals), toProposalStrings(actualProposals)); } @Before @@ -102,18 +99,11 @@ protected String proposalListToString(ICompletionProposal[] proposals) { if (proposals == null) { return "null"; } - if (proposals.length == 0) { - return "[]"; - } - StringBuilder builder = new StringBuilder(); - builder.append('['); - for (ICompletionProposal proposal : proposals) { - builder.append(proposal.getDisplayString()); - builder.append(", "); - } - builder.setLength(builder.length() - 2); - builder.append(']'); - return builder.toString(); + return "[" + String.join(",", toProposalStrings(proposals)) + "]"; + } + + private static List toProposalStrings(ICompletionProposal[] proposals) { + return Arrays.stream(proposals).map(ICompletionProposal::getDisplayString).toList(); } public static ITextFileBuffer getTextFileBufferFromFile(File file) { diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/Bug528706CompletionWithMultilineTagsTest.java b/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/Bug528706CompletionWithMultilineTagsTest.java index a83a6122be..a7bbae7138 100644 --- a/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/Bug528706CompletionWithMultilineTagsTest.java +++ b/ui/org.eclipse.pde.genericeditor.extension.tests/src/org/eclipse/pde/genericeditor/extension/tests/Bug528706CompletionWithMultilineTagsTest.java @@ -13,6 +13,7 @@ *******************************************************************************/ package org.eclipse.pde.genericeditor.extension.tests; +import org.eclipse.core.runtime.Platform; import org.eclipse.jface.text.ITextViewer; import org.junit.Before; import org.junit.Test; @@ -49,8 +50,7 @@ public void testTagValueCompletionAsAMultiline() { @Test public void testTagValueCompletionAfterAMultiline() { - checkProposals(new String[] { "x86", "x86_64" }, - contentAssist.computeCompletionProposals(textViewer, 181 + 1), 181); + checkProposals(Platform.knownOSArchValues(), contentAssist.computeCompletionProposals(textViewer, 181), 181); } @Test diff --git a/ui/org.eclipse.pde.genericeditor.extension.tests/testing-files/target-files/MultilineTagTestCaseTarget.txt b/ui/org.eclipse.pde.genericeditor.extension.tests/testing-files/target-files/MultilineTagTestCaseTarget.txt index acf466094d..016d14cffd 100644 --- a/ui/org.eclipse.pde.genericeditor.extension.tests/testing-files/target-files/MultilineTagTestCaseTarget.txt +++ b/ui/org.eclipse.pde.genericeditor.extension.tests/testing-files/target-files/MultilineTagTestCaseTarget.txt @@ -17,6 +17,6 @@ linu -x + \ No newline at end of file