adapter_poll.feature 1.78 KB
Newer Older
1 2 3 4 5 6 7
# 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

8
  Scenario: No messages are received successfully if the queue is empty
9 10 11 12 13 14 15
    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  

16
  Scenario: 2 messages are received successfully if the queue contains 2 messages
17 18 19 20 21 22 23 24 25
    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

26
  Scenario: 10 messages are received successfully if the queue contains 10 messages
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
    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