Interface KafkaAsserts

All Known Implementing Classes:
Kafka

public interface KafkaAsserts
Interface describes methods responsible for helper assertions. Validates that all required methods are implemented.
  • Method Details

    • seeTopicIsEmpty

      void seeTopicIsEmpty(String topic)
      Asserts that the topic is empty.

      Uses await.

      Parameters:
      topic - topic name
      Throws:
      AssertionError - if the assertion fails
      KafkaHelperException - if the topic does not exist
    • seeTopicIsNotEmpty

      void seeTopicIsNotEmpty(String topic)
      Asserts that the topic is not empty

      Uses await.

      Parameters:
      topic - topic name
      Throws:
      AssertionError - if the assertion fails
      KafkaHelperException - if the topic does not exist
    • seeMessagesCountInTopicExactly

      void seeMessagesCountInTopicExactly(String topic, int expectedCount)
      Asserts that the number of messages in the topic is exactly the expected count.

      Uses await.

      Parameters:
      topic - topic name
      expectedCount - expected number of messages
      Throws:
      AssertionError - if the assertion fails
      KafkaHelperException - if the topic does not exist
    • seeMessagesHaveEqualText

      void seeMessagesHaveEqualText(String topic, String expectedText)
      Asserts that at least one message in the topic is equal to the expected text.

      Uses await until at least one message exists.

      Parameters:
      topic - topic name
      expectedText - expected message text
      Throws:
      AssertionError - if the assertion fails
      org.awaitility.core.ConditionTimeoutException - if the topic remains empty until the await timeout expires
      KafkaHelperException - if the topic does not exist or consumer timeout is reached
    • seeMessagesContainText

      void seeMessagesContainText(String topic, String expectedPart)
      Asserts that at least one of messages in topic contains the specified text.

      Uses await until at least one message exists.

      Parameters:
      topic - topic name
      expectedPart - expected text part
      Throws:
      AssertionError - if the assertion fails
      org.awaitility.core.ConditionTimeoutException - if the topic remains empty until the await timeout expires
      KafkaHelperException - if the topic does not exist or consumer timeout is reached
    • seeMessagesHaveEqualJson

      void seeMessagesHaveEqualJson(String topic, String expectedJson)
      Asserts that at least one of messages in topic is equal to the specified JSON with strict array ordering.

      Uses await until at least one message exists.

      Parameters:
      topic - topic name
      expectedJson - expected full JSON with strict array ordering
      Throws:
      AssertionError - if the assertion fails
      org.awaitility.core.ConditionTimeoutException - if the topic remains empty until the await timeout expires
      IllegalArgumentException - if the provided data is not valid JSON
      KafkaHelperException - if the topic does not exist or consumer timeout is reached
    • seeMessagesContainJson

      void seeMessagesContainJson(String topic, String expectedJsonPart)
      Asserts that at least one of messages in topic contains the specified JSON without strict array ordering.

      Uses await until at least one message exists.

      Parameters:
      topic - topic name
      expectedJsonPart - expected JSON subset (array order is ignored, but the number of elements must match if provided)
      Throws:
      AssertionError - if the assertion fails
      org.awaitility.core.ConditionTimeoutException - if the topic remains empty until the await timeout expires
      IllegalArgumentException - if the provided data is not valid JSON
      KafkaHelperException - if the topic does not exist or consumer timeout is reached
    • seeTopicExists

      void seeTopicExists(String topicName)
      Asserts that the topic exists.

      Uses await.

      Parameters:
      topicName - topic name
      Throws:
      AssertionError - if the assertion fails
      KafkaHelperException - if an Kafka error occurs