use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.
the class QueueControllerIntegrationTest method shouldMoveMessageFromQueueInToQueueOut.
@Test
public void shouldMoveMessageFromQueueInToQueueOut() throws Exception {
testEnvironment.publishMessage(EXCHANGE_NAME, QUEUE_IN_NAME);
List<Message> messages = facade.getMessagesOfQueue(BROKER_NAME, QUEUE_IN_NAME, 1);
assertThat(messages, hasSize(1));
assertThat(facade.getMessagesOfQueue(BROKER_NAME, QUEUE_OUT_NAME, 1), empty());
Message message = messages.get(0);
mockMvc.perform(post("/api/" + BROKER_NAME + "/queues/" + QUEUE_IN_NAME + "/messages/move").param("checksum", message.getChecksum()).param("targetExchange", EXCHANGE_NAME).param("targetRoutingKey", QUEUE_OUT_NAME)).andExpect(status().isOk());
assertThat(facade.getMessagesOfQueue(BROKER_NAME, QUEUE_IN_NAME, 1), empty());
assertThat(facade.getMessagesOfQueue(BROKER_NAME, QUEUE_OUT_NAME, 1), hasSize(1));
}
use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.
the class MessageMapperTest method shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeadersDeepInMap.
@Test
public void shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeadersDeepInMap() {
String headerKey = "headerKey";
String subHeaderKey = "subHeaderKey";
String subHeaderValue = "subHeaderValue";
LongString longStringValue = mock(LongString.class);
when(longStringValue.toString()).thenReturn(subHeaderValue);
Map<String, Object> subHeaders = new HashMap<>();
subHeaders.put(subHeaderKey, longStringValue);
Map<String, Object> headers = new HashMap<>();
headers.put(headerKey, subHeaders);
AMQP.BasicProperties basicProperties = mock(AMQP.BasicProperties.class);
when(basicProperties.getHeaders()).thenReturn(headers);
Envelope envelope = mock(Envelope.class);
GetResponse getResponse = mockResponse(envelope, basicProperties);
Message result = sut.map(getResponse);
BasicProperties basicPropertiesOfResult = result.getProperties();
assertNotNull(basicPropertiesOfResult);
assertThat(basicPropertiesOfResult.getHeaders().keySet(), Matchers.hasSize(1));
assertThat(basicPropertiesOfResult.getHeaders(), Matchers.hasKey(headerKey));
assertThat(basicPropertiesOfResult.getHeaders().get(headerKey), Matchers.instanceOf(Map.class));
assertThat(((Map<String, Object>) basicPropertiesOfResult.getHeaders().get(headerKey)).keySet(), Matchers.hasSize(1));
assertThat(((Map<String, Object>) basicPropertiesOfResult.getHeaders().get(headerKey)), Matchers.hasKey(subHeaderKey));
assertEquals(subHeaderValue, ((Map) basicPropertiesOfResult.getHeaders().get(headerKey)).get(subHeaderKey));
}
use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.
the class MessageMapperTest method shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeaders.
@Test
public void shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeaders() {
String headerKey = "headerKey";
String headerValue = "headerValue";
LongString longStringValue = mock(LongString.class);
when(longStringValue.toString()).thenReturn(headerValue);
Map<String, Object> headers = new HashMap<>();
headers.put(headerKey, longStringValue);
AMQP.BasicProperties basicProperties = mock(AMQP.BasicProperties.class);
when(basicProperties.getHeaders()).thenReturn(headers);
Envelope envelope = mock(Envelope.class);
GetResponse getResponse = mockResponse(envelope, basicProperties);
Message result = sut.map(getResponse);
BasicProperties basicPropertiesOfResult = result.getProperties();
assertNotNull(basicPropertiesOfResult);
assertThat(basicPropertiesOfResult.getHeaders().keySet(), Matchers.hasSize(1));
assertThat(basicPropertiesOfResult.getHeaders(), Matchers.hasKey(headerKey));
assertEquals(headerValue, basicPropertiesOfResult.getHeaders().get(headerKey));
}
use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.
the class MessageMapperTest method shouldMapBasicMessageFields.
@Test
public void shouldMapBasicMessageFields() {
String checksum = "checksum";
Envelope envelope = mock(Envelope.class);
AMQP.BasicProperties basicProperties = mock(AMQP.BasicProperties.class);
GetResponse getResponse = mockResponse(envelope, basicProperties);
when(messageChecksum.createFor(basicProperties, DEFAULT_PAYLOAD)).thenReturn(checksum);
Message result = sut.map(getResponse);
assertEquals(DEFAULT_PAYLOAD, result.getBody());
assertEquals(checksum, result.getChecksum());
assertSame(envelope, result.getEnvelope());
assertNotNull(result.getProperties());
}
use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.
the class MessageMapperTest method shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeadersDeepInLists.
@Test
public void shouldMapRabbitMqSpecificTypesInAmqpBasicPropertiesHeadersDeepInLists() {
String headerKey = "headerKey";
String listValue = "listValue";
List<String> list = Arrays.asList(listValue);
Map<String, Object> headers = new HashMap<>();
headers.put(headerKey, list);
AMQP.BasicProperties basicProperties = mock(AMQP.BasicProperties.class);
when(basicProperties.getHeaders()).thenReturn(headers);
Envelope envelope = mock(Envelope.class);
GetResponse getResponse = mockResponse(envelope, basicProperties);
Message result = sut.map(getResponse);
BasicProperties basicPropertiesOfResult = result.getProperties();
assertNotNull(basicPropertiesOfResult);
assertThat(basicPropertiesOfResult.getHeaders().keySet(), Matchers.hasSize(1));
assertThat(basicPropertiesOfResult.getHeaders(), Matchers.hasKey(headerKey));
assertThat(basicPropertiesOfResult.getHeaders().get(headerKey), Matchers.instanceOf(List.class));
assertThat(((List<String>) basicPropertiesOfResult.getHeaders().get(headerKey)), Matchers.hasSize(1));
assertThat(((List<String>) basicPropertiesOfResult.getHeaders().get(headerKey)), Matchers.contains(listValue));
}
Aggregations