diff --git a/server/src/test/kotlin/org/javacs/kt/OverrideMemberTest.kt b/server/src/test/kotlin/org/javacs/kt/OverrideMemberTest.kt index e2f6c1f18..50f877a3d 100644 --- a/server/src/test/kotlin/org/javacs/kt/OverrideMemberTest.kt +++ b/server/src/test/kotlin/org/javacs/kt/OverrideMemberTest.kt @@ -9,6 +9,7 @@ import org.eclipse.lsp4j.TextDocumentPositionParams import org.junit.Test import org.hamcrest.core.Every.everyItem import org.hamcrest.Matchers.containsInAnyOrder +import org.hamcrest.Matchers.hasItems import org.hamcrest.Matchers.equalTo import org.hamcrest.Matchers.hasSize import org.junit.Assert.assertThat @@ -17,7 +18,7 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb val root = testResourcesRoot().resolve(workspaceRoot) val fileUri = root.resolve(file).toUri().toString() - + @Test fun `should show all overrides for class`() { val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(9, 8))).get() @@ -39,7 +40,7 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb padding + "override fun equals(other: Any?): Boolean { }", padding + "override fun hashCode(): Int { }", padding + "override fun toString(): String { }")) - + assertThat(ranges, everyItem(equalTo(range(9, 31, 9, 31)))) } @@ -63,14 +64,14 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb padding + "override fun equals(other: Any?): Boolean { }", padding + "override fun hashCode(): Int { }", padding + "override fun toString(): String { }")) - + assertThat(ranges, everyItem(equalTo(range(12, 56, 12, 56)))) } @Test fun `should show NO overrides for class where all other alternatives are already implemented`() { val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(15, 8))).get() - + assertThat(result, hasSize(0)) } @@ -93,10 +94,10 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb padding + "override fun equals(other: Any?): Boolean { }", padding + "override fun hashCode(): Int { }", padding + "override fun toString(): String { }")) - + assertThat(ranges, everyItem(equalTo(range(37, 25, 37, 25)))) } - + @Test fun `should find members in jdk object`() { val result = languageServer.getProtocolExtensionService().overrideMember(TextDocumentPositionParams(TextDocumentIdentifier(fileUri), position(39, 9))).get() @@ -106,41 +107,41 @@ class OverrideMemberTest : SingleFileTestFixture("overridemember", "OverrideMemb val newTexts = edits.map { it.newText } val ranges = edits.map { it.range } - assertThat(titles, containsInAnyOrder("override fun equals(other: Any?): Boolean { }", - "override fun hashCode(): Int { }", - "override fun toString(): String { }", - "override fun run() { }", - "override fun clone(): Any { }", - "override fun start() { }", - "override fun interrupt() { }", - "override fun isInterrupted(): Boolean { }", - "override fun countStackFrames(): Int { }", - "override fun getContextClassLoader(): ClassLoader { }", - "override fun setContextClassLoader(cl: ClassLoader) { }", - "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array) { }", - "override fun getId(): Long { }", - "override fun getState(): State { }", - "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }", - "override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }")) + assertThat(titles, hasItems("override fun equals(other: Any?): Boolean { }", + "override fun hashCode(): Int { }", + "override fun toString(): String { }", + "override fun run() { }", + "override fun clone(): Any { }", + "override fun start() { }", + "override fun interrupt() { }", + "override fun isInterrupted(): Boolean { }", + "override fun countStackFrames(): Int { }", + "override fun getContextClassLoader(): ClassLoader { }", + "override fun setContextClassLoader(cl: ClassLoader) { }", + "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array) { }", + "override fun getId(): Long { }", + "override fun getState(): State { }", + "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }", + "override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }")) val padding = System.lineSeparator() + System.lineSeparator() + " " - assertThat(newTexts, containsInAnyOrder(padding + "override fun equals(other: Any?): Boolean { }", - padding + "override fun hashCode(): Int { }", - padding + "override fun toString(): String { }", - padding + "override fun run() { }", - padding + "override fun clone(): Any { }", - padding + "override fun start() { }", - padding + "override fun interrupt() { }", - padding + "override fun isInterrupted(): Boolean { }", - padding + "override fun countStackFrames(): Int { }", - padding + "override fun getContextClassLoader(): ClassLoader { }", - padding + "override fun setContextClassLoader(cl: ClassLoader) { }", - padding + "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array) { }", - padding + "override fun getId(): Long { }", - padding + "override fun getState(): State { }", - padding + "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }", - padding + "override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }")) - + assertThat(newTexts, hasItems(padding + "override fun equals(other: Any?): Boolean { }", + padding + "override fun hashCode(): Int { }", + padding + "override fun toString(): String { }", + padding + "override fun run() { }", + padding + "override fun clone(): Any { }", + padding + "override fun start() { }", + padding + "override fun interrupt() { }", + padding + "override fun isInterrupted(): Boolean { }", + padding + "override fun countStackFrames(): Int { }", + padding + "override fun getContextClassLoader(): ClassLoader { }", + padding + "override fun setContextClassLoader(cl: ClassLoader) { }", + padding + "override fun getStackTrace(): (Array<(StackTraceElement..StackTraceElement?)>..Array) { }", + padding + "override fun getId(): Long { }", + padding + "override fun getState(): State { }", + padding + "override fun getUncaughtExceptionHandler(): UncaughtExceptionHandler { }", + padding + "override fun setUncaughtExceptionHandler(eh: UncaughtExceptionHandler) { }")) + assertThat(ranges, everyItem(equalTo(range(39, 25, 39, 25)))) } }