# When the queue contains x messages 
# only mocks the API response 
# Testing how the API behaves with a full queue are defined in the API 

Feature: Can the adapter receive messages?
  The adapter poll method works as expected

  Scenario: No messages are received successfully if the queue is empty
    Given valid config
    When the adapter instance is created
    When the auth method is called
    When a mock receive API response is configured to return 0 messages
    When the poll method is called
    Then a successful response is returned with 0 messages  

  Scenario: 2 messages are received successfully if the queue contains 2 messages
    Given valid config
    When the adapter instance is created
    When the auth method is called
    When a mock receive API response is configured to return 2 messages 
    When the poll method is called
    Then a successful response is returned with 2 messages
    Then the protocol "validate" method is called 2 times
    Then the protocol "decode" method is called 2 times

  Scenario: 10 messages are received successfully if the queue contains 10 messages
    Given valid config
    When the adapter instance is created
    When the auth method is called
    When a mock receive API response is configured to return 10 messages 
    When the poll method is called
    Then a successful response is returned with 10 messages
    Then the protocol "validate" method is called 10 times
    Then the protocol "decode" method is called 10 times

  Scenario: An invalid token returns a forbidden response 
    Given valid config 
    When the adapter instance is created 
    When the auth method is called 
    When a mock receive API response is configured to return an error
    When the poll method is called 
    Then an error response is returned with status 403