public MessageRecordStream withCorrelationKey(final String correlationKey) { return valueFilter(v -> correlationKey.equals(v.getCorrelationKey())); }
public MessageRecordStream withMessageId(final String messageId) { return valueFilter(v -> messageId.equals(v.getMessageId())); }
public MessageRecordStream withName(final String name) { return valueFilter(v -> name.equals(v.getName())); }
public MessageRecordStream withTimeToLive(final long timeToLive) { return valueFilter(v -> v.getTimeToLive() == timeToLive); } }
@Test public void shouldDeleteMessageImmediatelyWithZeroTTL() { // given final ExecuteCommandResponse response = apiRule .createCmdRequest() .type(ValueType.MESSAGE, PUBLISH) .command() .put("name", "order canceled") .put("correlationKey", "order-123") .put("timeToLive", 0L) .done() .sendAndAwait(); // when brokerRule.getClock().addTime(MessageObserver.MESSAGE_TIME_TO_LIVE_CHECK_INTERVAL); // then final Record<MessageRecordValue> deletedEvent = testClient.receiveFirstMessageEvent(MessageIntent.DELETED); assertThat(deletedEvent.getKey()).isEqualTo(response.getKey()); assertThat(MsgPackUtil.asMsgPackReturnArray(deletedEvent.getValue().getPayload())) .isEqualTo(EMTPY_OBJECT); Assertions.assertThat(deletedEvent.getValue()) .hasName("order canceled") .hasCorrelationKey("order-123") .hasTimeToLive(0L) .hasMessageId(""); }
public MessageRecordStream withTimeToLive(final long timeToLive) { return valueFilter(v -> v.getTimeToLive() == timeToLive); } }
@Test public void shouldDeleteMessageImmediatelyWithZeroTTL() { // given final ExecuteCommandResponse response = apiRule .createCmdRequest() .type(ValueType.MESSAGE, PUBLISH) .command() .put("name", "order canceled") .put("correlationKey", "order-123") .put("timeToLive", 0L) .done() .sendAndAwait(); // when brokerRule.getClock().addTime(MessageObserver.MESSAGE_TIME_TO_LIVE_CHECK_INTERVAL); // then final Record<MessageRecordValue> deletedEvent = testClient.receiveFirstMessageEvent(MessageIntent.DELETED); assertThat(deletedEvent.getKey()).isEqualTo(response.getKey()); assertThat(MsgPackUtil.asMsgPackReturnArray(deletedEvent.getValue().getPayload())) .isEqualTo(EMTPY_OBJECT); Assertions.assertThat(deletedEvent.getValue()) .hasName("order canceled") .hasCorrelationKey("order-123") .hasTimeToLive(0L) .hasMessageId(""); }
/** * Verifies that the actual MessageRecordValue's timeToLive is equal to the given one. * @param timeToLive the given timeToLive to compare the actual MessageRecordValue's timeToLive to. * @return this assertion object. * @throws AssertionError - if the actual MessageRecordValue's timeToLive is not equal to the given one. */ public S hasTimeToLive(long timeToLive) { // check that actual MessageRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting timeToLive of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // check long actualTimeToLive = actual.getTimeToLive(); if (actualTimeToLive != timeToLive) { failWithMessage(assertjErrorMessage, actual, timeToLive, actualTimeToLive); } // return the current assertion for method chaining return myself; }
public MessageRecordStream withMessageId(final String messageId) { return valueFilter(v -> messageId.equals(v.getMessageId())); }
public MessageRecordStream withCorrelationKey(final String correlationKey) { return valueFilter(v -> correlationKey.equals(v.getCorrelationKey())); }
public MessageRecordStream withName(final String name) { return valueFilter(v -> name.equals(v.getName())); }
testClient.receiveFirstMessageEvent(MessageIntent.DELETED); assertThat(deletedEvent.getKey()).isEqualTo(response.getKey()); assertThat(MsgPackUtil.asMsgPackReturnArray(deletedEvent.getValue().getPayload())) .isEqualTo(EMTPY_OBJECT);
/** * Verifies that the actual MessageRecordValue's messageId is equal to the given one. * @param messageId the given messageId to compare the actual MessageRecordValue's messageId to. * @return this assertion object. * @throws AssertionError - if the actual MessageRecordValue's messageId is not equal to the given one. */ public S hasMessageId(String messageId) { // check that actual MessageRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting messageId of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualMessageId = actual.getMessageId(); if (!Objects.areEqual(actualMessageId, messageId)) { failWithMessage(assertjErrorMessage, actual, messageId, actualMessageId); } // return the current assertion for method chaining return myself; }
/** * Verifies that the actual MessageRecordValue's correlationKey is equal to the given one. * @param correlationKey the given correlationKey to compare the actual MessageRecordValue's correlationKey to. * @return this assertion object. * @throws AssertionError - if the actual MessageRecordValue's correlationKey is not equal to the given one. */ public S hasCorrelationKey(String correlationKey) { // check that actual MessageRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting correlationKey of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualCorrelationKey = actual.getCorrelationKey(); if (!Objects.areEqual(actualCorrelationKey, correlationKey)) { failWithMessage(assertjErrorMessage, actual, correlationKey, actualCorrelationKey); } // return the current assertion for method chaining return myself; }
/** * Verifies that the actual MessageRecordValue's name is equal to the given one. * @param name the given name to compare the actual MessageRecordValue's name to. * @return this assertion object. * @throws AssertionError - if the actual MessageRecordValue's name is not equal to the given one. */ public S hasName(String name) { // check that actual MessageRecordValue we want to make assertions on is not null. isNotNull(); // overrides the default error message with a more explicit one String assertjErrorMessage = "\nExpecting name of:\n <%s>\nto be:\n <%s>\nbut was:\n <%s>"; // null safe check String actualName = actual.getName(); if (!Objects.areEqual(actualName, name)) { failWithMessage(assertjErrorMessage, actual, name, actualName); } // return the current assertion for method chaining return myself; }
testClient.receiveFirstMessageEvent(MessageIntent.DELETED); assertThat(deletedEvent.getKey()).isEqualTo(response.getKey()); assertThat(MsgPackUtil.asMsgPackReturnArray(deletedEvent.getValue().getPayload())) .isEqualTo(EMTPY_OBJECT);