-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Loading status checks…
W-15702938 Added tests for AVRO and AVRO support in async2.6 (#1075)
* Added tests for AVRO and AVRO support in async2.6 * File changes * Made changes to test failing due to error message uneven between JVM & JS * Lowercase check in test * Some changes requested in PR
- Loading branch information
1 parent
cdc1e74
commit 613c8eb
Showing
9 changed files
with
193 additions
and
26 deletions.
There are no files selected for viewing
23 changes: 23 additions & 0 deletions
23
als-server/shared/src/test/resources/diagnostics/avro/async26-imports-invalid-avro.yaml
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,23 @@ | ||
asyncapi: 2.6.0 | ||
info: | ||
title: Market Data API | ||
version: 1.0.0 | ||
description: This API provides real-time market data updates. | ||
|
||
channels: | ||
m1: | ||
description: Pancho | ||
|
||
components: | ||
messages: | ||
m1: | ||
schemaFormat: application/vnd.apache.avro;version=1.9.0 | ||
payload: | ||
$ref: schemas/union-type-invalid-payload.avsc | ||
examples: | ||
- payload: | ||
name: John Doe | ||
address: | ||
zipcode: 1355 | ||
age: 20 | ||
favoriteProgrammingLanguage: Java |
15 changes: 15 additions & 0 deletions
15
als-server/shared/src/test/resources/diagnostics/avro/async26-imports-valid-avro.yaml
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 @@ | ||
asyncapi: 2.6.0 | ||
info: | ||
title: Market Data API | ||
version: 1.0.0 | ||
description: This API provides real-time market data updates. | ||
channels: | ||
m1: | ||
description: Pancho | ||
|
||
components: | ||
messages: | ||
m1: | ||
schemaFormat: application/vnd.apache.avro;version=1.9.0 | ||
payload: | ||
$ref: schemas/union-type-payload.avsc |
20 changes: 20 additions & 0 deletions
20
als-server/shared/src/test/resources/diagnostics/avro/schemas/avro-user/avrotoavro.avsc
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,20 @@ | ||
{ | ||
"type" : "record", | ||
"name" : "avrotoavro", | ||
"fields" : [ | ||
{"name": "user_user", "type": { | ||
"name": "user", | ||
"type": "record", | ||
"fields": [ | ||
{ | ||
"name": "username", | ||
"type": "string" | ||
}, | ||
{ | ||
"name": "age", | ||
"type": "int" | ||
} | ||
] | ||
}} | ||
] | ||
} |
20 changes: 20 additions & 0 deletions
20
...server/shared/src/test/resources/diagnostics/avro/schemas/union-type-invalid-payload.avsc
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,20 @@ | ||
{ | ||
"type": "record", | ||
"name": "Person", | ||
"fields": [ | ||
{"name": "name", "type": "string", "example": "Donkey"}, | ||
{"name": "age", "type": ["null", "int"], "default": null}, | ||
{ | ||
"name": "favoriteProgrammingLanguage", | ||
"type": {"name": "ProgrammingLanguage", "type": "enum", "symbols": ["JS", "Java", "Go", "Rust", "C"]} | ||
}, | ||
{ | ||
"name": "address", | ||
"type": { | ||
"name": "Address", | ||
"type": "record", | ||
"fields": [{"name": "zipcode", "type": "int"}, {"name": "zipcode", "type": "boolean"}] | ||
} | ||
} | ||
] | ||
} |
File renamed without changes.
20 changes: 20 additions & 0 deletions
20
als-server/shared/src/test/resources/diagnostics/avro/schemas/union-type-payload.avsc
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,20 @@ | ||
{ | ||
"type": "record", | ||
"name": "Person", | ||
"fields": [ | ||
{"name": "name", "type": "string", "example": "Donkey"}, | ||
{"name": "age", "type": ["null", "int"], "default": null}, | ||
{ | ||
"name": "favoriteProgrammingLanguage", | ||
"type": {"name": "ProgrammingLanguage", "type": "enum", "symbols": ["JS", "Java", "Go", "Rust", "C"]} | ||
}, | ||
{ | ||
"name": "address", | ||
"type": { | ||
"name": "Address", | ||
"type": "record", | ||
"fields": [{"name": "zipcode", "type": "int"}] | ||
} | ||
} | ||
] | ||
} |
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
27 changes: 27 additions & 0 deletions
27
...org/mulesoft/als/server/modules/diagnostic/support/async/Async26CleanDiagnosticTest.scala
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,27 @@ | ||
package org.mulesoft.als.server.modules.diagnostic.support.async | ||
|
||
import amf.core.client.common.validation.ProfileNames | ||
import org.mulesoft.als.server.client.scala.LanguageServerBuilder | ||
import org.mulesoft.als.server.modules.WorkspaceManagerFactoryBuilder | ||
import org.mulesoft.als.server.modules.diagnostic.BasicCleanDiagnosticTest | ||
import org.mulesoft.als.server.protocol.LanguageServer | ||
import org.mulesoft.als.server.{LanguageServerBaseTest, MockDiagnosticClientNotifier} | ||
|
||
import scala.concurrent.ExecutionContext | ||
|
||
class Async26CleanDiagnosticTest extends BasicCleanDiagnosticTest { | ||
|
||
test("async 2.6 with only one error") { | ||
withServer(buildServer()) { server => | ||
for { | ||
d <- requestCleanDiagnostic(server)(filePath("async26/async-api26-full.yaml")) | ||
} yield { | ||
server.shutdown() | ||
assert(d.size == 1) | ||
assert(d.head.diagnostics.size == 1) | ||
assert(d.head.diagnostics.head.message == "Property 'error' not supported in a ASYNC 2.6 webApi node") | ||
assert(d.head.profile == ProfileNames.ASYNC26) | ||
} | ||
} | ||
} | ||
} |
67 changes: 67 additions & 0 deletions
67
...ala/org/mulesoft/als/server/modules/diagnostic/support/avro/AvroCleanDiagnosticTest.scala
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,67 @@ | ||
package org.mulesoft.als.server.modules.diagnostic.support.avro | ||
|
||
import amf.core.client.common.validation.ProfileNames | ||
import org.mulesoft.als.server.modules.diagnostic.BasicCleanDiagnosticTest | ||
import org.mulesoft.lsp.feature.diagnostic.DiagnosticSeverity | ||
|
||
|
||
class AvroCleanDiagnosticTest extends BasicCleanDiagnosticTest { | ||
|
||
test("Async importing valid Avro") { | ||
withServer(buildServer()) { server => | ||
for { | ||
d <- requestCleanDiagnostic(server)(filePath("avro/async26-imports-valid-avro.yaml")) | ||
} yield { | ||
server.shutdown() | ||
d.foreach(filediag => assert(filediag.diagnostics.isEmpty)) | ||
assert(d.size == 2) | ||
assert(d.head.profile == ProfileNames.ASYNC26) | ||
} | ||
} | ||
} | ||
|
||
test("Async importing invalid Avro") { | ||
withServer(buildServer()) { server => | ||
for { | ||
d <- requestCleanDiagnostic(server)(filePath("avro/async26-imports-invalid-avro.yaml")) | ||
} yield { | ||
server.shutdown() | ||
assert(d.size == 2) | ||
val avroFileDiagnostics = d.find(d => d.uri.contains("avro/async26-imports-invalid-avro.yaml")) | ||
assert(avroFileDiagnostics.isDefined) | ||
assert(avroFileDiagnostics.get.diagnostics.length == 1) | ||
val errorMessage = avroFileDiagnostics.get.diagnostics.head.message.toLowerCase() | ||
assert(errorMessage.contains("duplicate") && errorMessage.contains("address")) | ||
assert(avroFileDiagnostics.get.diagnostics.head.severity.get == DiagnosticSeverity.Error) | ||
assert(avroFileDiagnostics.get.profile == ProfileNames.ASYNC26) | ||
} | ||
} | ||
} | ||
|
||
|
||
test("valid complex avro") { | ||
withServer(buildServer()) { server => | ||
for { | ||
d <- requestCleanDiagnostic(server)(filePath("avro/schemas/avro-user/avrotoavro.avsc")) | ||
} yield { | ||
server.shutdown() | ||
assert(d.size == 1) | ||
assert(d.head.diagnostics.isEmpty) | ||
assert(d.head.profile == ProfileNames.AVROSCHEMA) | ||
} | ||
} | ||
} | ||
|
||
test("valid avro with unions") { | ||
withServer(buildServer()) { server => | ||
for { | ||
d <- requestCleanDiagnostic(server)(filePath("avro/schemas/union-type-payload-error.avsc")) | ||
} yield { | ||
server.shutdown() | ||
assert(d.size == 1) | ||
assert(d.head.diagnostics.isEmpty) | ||
assert(d.head.profile == ProfileNames.AVROSCHEMA) | ||
} | ||
} | ||
} | ||
} |