-
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
33 changed files
with
444 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...SpecificationCompletionContributorTest.kt → ...SpecificationCompletionContributorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorJsonTest.kt → ...ificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...ificationCompletionContributorYamlTest.kt → ...ificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
114 changes: 114 additions & 0 deletions
114
...ncapi/plugin/idea/completion/v3/AbstractAsyncAPISpecificationCompletionContributorTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,114 @@ | ||
package com.asyncapi.plugin.idea.completion.v3 | ||
|
||
import com.intellij.codeInsight.completion.CompletionType | ||
import com.intellij.testFramework.fixtures.BasePlatformTestCase | ||
import junit.framework.TestCase | ||
|
||
/** | ||
* @author Pavel Bodiachevskii | ||
* @since 2.4.0 | ||
*/ | ||
abstract class AbstractAsyncAPISpecificationCompletionContributorTest: BasePlatformTestCase() { | ||
|
||
abstract fun fileExtension(): String | ||
|
||
abstract fun asyncAPIVersion(): String | ||
|
||
override fun getTestDataPath(): String = "src/test/testData/${fileExtension()}/completion/${asyncAPIVersion()}" | ||
|
||
protected open val `$ - c` = listOf( | ||
"\"channels\"", | ||
"\"components\"", | ||
"\"defaultContentType\"", | ||
) | ||
|
||
protected open val `$ - components - messages - UserSignedUp - p` = listOf( | ||
"\"contentType\"", | ||
"\"deprecated\"", | ||
"\"description\"", | ||
"\"examples\"" | ||
) | ||
|
||
protected open val `$ - info - i` = listOf( | ||
"\"description\"", | ||
"\"license\"", | ||
"\"termsOfService\"", | ||
"\"title\"", | ||
"\"version\"" | ||
) | ||
|
||
fun `test $ - (double quote)c(double quote)`() { | ||
configureMyFixture("\"c\".${fileExtension()}") | ||
|
||
/* | ||
TODO: to research why completion returns more variants only in tests. In IDEA everything is ok: | ||
expected: ["channels", "components", "defaultContentType", "externalDocs"] | ||
actual: ["channels", "components", "defaultContentType", "externalDocs", "id", "info", "servers", "tags"] | ||
*/ | ||
TestCase.assertTrue((myFixture.lookupElementStrings ?: emptyList<String>()).containsAll(`$ - c`)) | ||
} | ||
|
||
fun `test $ - c`() { | ||
configureMyFixture("c.${fileExtension()}") | ||
|
||
TestCase.assertEquals(`$ - c`.sorted(), (myFixture.lookupElementStrings?.sorted() ?: emptyList<String>())) | ||
} | ||
|
||
fun `test $ - components - messages - UserSignedUp - (double quote)p(double quote)`() { | ||
configureMyFixture("components -> messages -> UserSignedUp -> \"p\".${fileExtension()}") | ||
|
||
/* | ||
TODO: to research why completion returns more variants only in tests. In IDEA everything is ok: | ||
expected: ["contentType", "deprecated", "description", "examples"] | ||
actual: ["$ref", "bindings", "contentType", "correlationId", "deprecated", "description", "examples", "externalDocs", "headers", "name", "oneOf", "schemaFormat", "summary", "tags", "title", "traits"] | ||
*/ | ||
TestCase.assertTrue( | ||
(myFixture.lookupElementStrings ?: emptyList<String>()) | ||
.containsAll(`$ - components - messages - UserSignedUp - p`) | ||
) | ||
} | ||
|
||
fun `test $ - components - messages - UserSignedUp - (double quote)p`() { | ||
configureMyFixture("components -> messages -> UserSignedUp -> \"p.${fileExtension()}") | ||
|
||
TestCase.assertEquals( | ||
`$ - components - messages - UserSignedUp - p`.sorted().map { it.replace("\"", "") }, | ||
(myFixture.lookupElementStrings?.sorted() ?: emptyList<String>()) | ||
) | ||
} | ||
|
||
fun `test $ - components - messages - UserSignedUp - p`() { | ||
configureMyFixture("components -> messages -> UserSignedUp -> p.${fileExtension()}") | ||
|
||
TestCase.assertEquals( | ||
`$ - components - messages - UserSignedUp - p`.sorted(), | ||
(myFixture.lookupElementStrings?.sorted() ?: emptyList<String>()) | ||
) | ||
} | ||
|
||
fun `test $ - info - (double quote)i(double quote)`() { | ||
configureMyFixture("info -> \"i\".${fileExtension()}") | ||
|
||
/* | ||
TODO: to research why completion returns more variants only in tests. In IDEA everything is ok: | ||
expected: ["description", "license", "termsOfService", "title", "version"] | ||
actual: ["contact", "description", "license", "termsOfService", "title", "version"] | ||
*/ | ||
TestCase.assertTrue( | ||
(myFixture.lookupElementStrings ?: emptyList<String>()) | ||
.containsAll(`$ - info - i`) | ||
) | ||
} | ||
|
||
fun `test $ - info - i`() { | ||
configureMyFixture("info -> i.${fileExtension()}") | ||
|
||
TestCase.assertEquals(`$ - info - i`.sorted(), (myFixture.lookupElementStrings?.sorted() ?: emptyList<String>())) | ||
} | ||
|
||
private fun configureMyFixture(fileName: String) { | ||
myFixture.configureByFile(fileName) | ||
myFixture.complete(CompletionType.BASIC, 1) | ||
} | ||
|
||
} |
15 changes: 15 additions & 0 deletions
15
...capi/plugin/idea/completion/v3/_0_0/AsyncAPISpecificationCompletionContributorJsonTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.asyncapi.plugin.idea.completion.v3._0_0 | ||
|
||
import com.asyncapi.plugin.idea.completion.v3.AbstractAsyncAPISpecificationCompletionContributorTest | ||
|
||
/** | ||
* @author Pavel Bodiachevskii | ||
* @since 2.4.0 | ||
*/ | ||
class AsyncAPISpecificationCompletionContributorJsonTest: AbstractAsyncAPISpecificationCompletionContributorTest() { | ||
|
||
override fun fileExtension(): String = "json" | ||
|
||
override fun asyncAPIVersion(): String = "3.0.0" | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
...capi/plugin/idea/completion/v3/_0_0/AsyncAPISpecificationCompletionContributorYamlTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.asyncapi.plugin.idea.completion.v3._0_0 | ||
|
||
import com.asyncapi.plugin.idea.completion.v3.AbstractAsyncAPISpecificationCompletionContributorTest | ||
|
||
class AsyncAPISpecificationCompletionContributorYamlTest: AbstractAsyncAPISpecificationCompletionContributorTest() { | ||
|
||
override fun fileExtension(): String = "yaml" | ||
|
||
override fun asyncAPIVersion(): String = "3.0.0" | ||
|
||
override val `$ - c` = super.`$ - c`.sorted().map { it.replace("\"", "") } | ||
|
||
override val `$ - components - messages - UserSignedUp - p` = super.`$ - components - messages - UserSignedUp - p`.sorted().map { it.replace("\"", "") } | ||
|
||
override val `$ - info - i` = super.`$ - info - i`.sorted().map { it.replace("\"", "") } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"asyncapi": "3.0.0", | ||
"c"<caret> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"asyncapi": "3.0.0", | ||
c<caret> | ||
} |
47 changes: 47 additions & 0 deletions
47
src/test/testData/json/completion/3.0.0/components -> messages -> UserSignedUp -> "p".json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
{ | ||
"asyncapi": "3.0.0", | ||
"info": { | ||
"title": "Account Service", | ||
"version": "1.0.0", | ||
"description": "This service is in charge of processing user signups :rocket:" | ||
}, | ||
"channels": { | ||
"userSignedup": { | ||
"address": "user/signedup", | ||
"messages": { | ||
"userSignedupMessage": { | ||
"$ref": "#/components/messages/UserSignedUp" | ||
} | ||
} | ||
} | ||
}, | ||
"operations": { | ||
"processUserSignups": { | ||
"action": "receive", | ||
"channel": { | ||
"$ref": "#/channels/userSignedup" | ||
} | ||
} | ||
}, | ||
"components": { | ||
"messages": { | ||
"UserSignedUp": { | ||
"p"<caret> | ||
"payload": { | ||
"type": "object", | ||
"properties": { | ||
"displayName": { | ||
"type": "string", | ||
"description": "Name of the user" | ||
}, | ||
"email": { | ||
"type": "string", | ||
"format": "email", | ||
"description": "Email of the user" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
Oops, something went wrong.