Search in sources :

Example 6 with Message

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));
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) Test(org.junit.Test) AbstractControllerIntegrationTest(de.gessnerfl.rabbitmq.queue.management.controller.AbstractControllerIntegrationTest)

Example 7 with Message

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));
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) AMQP(com.rabbitmq.client.AMQP) BasicProperties(de.gessnerfl.rabbitmq.queue.management.model.BasicProperties) LongString(com.rabbitmq.client.LongString) LongString(com.rabbitmq.client.LongString) Envelope(com.rabbitmq.client.Envelope) GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Example 8 with Message

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));
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) AMQP(com.rabbitmq.client.AMQP) BasicProperties(de.gessnerfl.rabbitmq.queue.management.model.BasicProperties) LongString(com.rabbitmq.client.LongString) LongString(com.rabbitmq.client.LongString) Envelope(com.rabbitmq.client.Envelope) GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Example 9 with Message

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());
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) AMQP(com.rabbitmq.client.AMQP) LongString(com.rabbitmq.client.LongString) Envelope(com.rabbitmq.client.Envelope) GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Example 10 with Message

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));
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) AMQP(com.rabbitmq.client.AMQP) BasicProperties(de.gessnerfl.rabbitmq.queue.management.model.BasicProperties) LongString(com.rabbitmq.client.LongString) Envelope(com.rabbitmq.client.Envelope) GetResponse(com.rabbitmq.client.GetResponse) Test(org.junit.Test)

Aggregations

Message (de.gessnerfl.rabbitmq.queue.management.model.Message)11 Test (org.junit.Test)10 GetResponse (com.rabbitmq.client.GetResponse)6 AMQP (com.rabbitmq.client.AMQP)5 Envelope (com.rabbitmq.client.Envelope)5 LongString (com.rabbitmq.client.LongString)5 BasicProperties (de.gessnerfl.rabbitmq.queue.management.model.BasicProperties)4 AbstractControllerIntegrationTest (de.gessnerfl.rabbitmq.queue.management.controller.AbstractControllerIntegrationTest)2 Channel (com.rabbitmq.client.Channel)1 CloseableChannelWrapper (de.gessnerfl.rabbitmq.queue.management.connection.CloseableChannelWrapper)1 IOException (java.io.IOException)1