generator icon indicating copy to clipboard operation
generator copied to clipboard

No tests for java quarkus websocket client, if server is not provided in the params

Open batchu5 opened this issue 10 months ago • 5 comments

In the integration test for core websocket templates. As in JS testing, it would be nice to have an additional test for Java Quarkus when the server is not provided as a parameter. Because not providing the parameter results in an Error.

How to reproduce?

  1. Create an asyncapi file with the below content.

asyncapi: 3.0.0

info:
  title: Quarkus WebSocket API
  version: 1.0.0
  description: Simple WebSocket API with JWT security.

servers:
  production:
    host: api.example.com
    pathname: /ws
    protocol: wss
    description: Production WebSocket server
    security:
      - type: userPassword

channels:
  chat:
    address: /chat
    messages:
      chatMessage:
        $ref: '#/components/messages/ChatMessage'

operations:
  sendChatMessage:
    action: send
    channel:
      $ref: '#/channels/chat'
    messages:
      - $ref: '#/channels/chat/messages/chatMessage'

  receiveChatMessage:
    action: receive
    channel:
      $ref: '#/channels/chat'
    messages:
      - $ref: '#/channels/chat/messages/chatMessage'

components:
  securitySchemes:
    jwtAuth:
      type: http
      scheme: bearer
      bearerFormat: JWT
      description: Send JWT in `Authorization Bearer <token>` header.

  messages:
    ChatMessage:
      name: ChatMessage
      contentType: application/json
      payload:
        type: object
        required:
          - sender
          - content
        properties:
          sender:
            type: string
            example: alice
          content:
            type: string
            example: Hello world 
  1. Run the command node ./apps/generator/test/cli.js ./asyncapi.yaml ./packages/templates/clients/websocket/java/quarkus --force-write

  2. You will see the error similar to this

Image

batchu5 avatar Jan 29 '26 05:01 batchu5

Thanks for the detailed report and reproduction steps.I’d like to work on this issue and add the missing integration test for the Java Quarkus WebSocket client when the server parameter is not provided.

Amythystx avatar Jan 30 '26 02:01 Amythystx

@derberg @Adi-204 , please take a look at this!

batchu5 avatar Jan 30 '26 02:01 batchu5

hey @batchu5 you can create PR to add additional test-case of java template like JS.

Adi-204 avatar Feb 01 '26 07:02 Adi-204

@Adi-204 I checked other core templates, Python and Dart, also have server param as required: true in their respective .ageneratorrc config file, so I think I need to add this additional test to the runCommonTestsfunction. What do you say? Should I take this approach?

batchu5 avatar Feb 01 '26 10:02 batchu5

hey @batchu5 ok make sense to add it in runCommonTests function. Please go ahead and create PR.

Adi-204 avatar Feb 01 '26 11:02 Adi-204