Search in sources :

Example 1 with Message

use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.

the class QueueControllerIntegrationTest method shouldDeleteMessageFromQueue.

@Test
public void shouldDeleteMessageFromQueue() throws Exception {
    testEnvironment.publishMessage(EXCHANGE_NAME, QUEUE_IN_NAME);
    List<Message> messages = facade.getMessagesOfQueue(BROKER_NAME, QUEUE_IN_NAME, 1);
    assertThat(messages, hasSize(1));
    Message message = messages.get(0);
    mockMvc.perform(delete("/api/" + BROKER_NAME + "/queues/" + QUEUE_IN_NAME + "/messages").param("checksum", message.getChecksum())).andExpect(status().isOk());
    assertThat(facade.getMessagesOfQueue(BROKER_NAME, QUEUE_IN_NAME, 1), empty());
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) Test(org.junit.Test) AbstractControllerIntegrationTest(de.gessnerfl.rabbitmq.queue.management.controller.AbstractControllerIntegrationTest)

Example 2 with Message

use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.

the class QueueControllerTest method shouldDelegateCallToGetAllMessagesOfQueue.

@Test
public void shouldDelegateCallToGetAllMessagesOfQueue() {
    Message message = mock(Message.class);
    List<Message> messages = Arrays.asList(message);
    when(rabbitMqFacade.getMessagesOfQueue(BROKER, QUEUE, QueueController.DEFAULT_LIMIT)).thenReturn(messages);
    List<Message> result = sut.getQueueMessages(BROKER, QUEUE);
    assertSame(messages, result);
    verify(rabbitMqFacade).getMessagesOfQueue(BROKER, QUEUE, QueueController.DEFAULT_LIMIT);
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) Test(org.junit.Test)

Example 3 with Message

use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.

the class RabbitMqFacadeTest method shouldDelegateCallToGetQueueMessages.

@Test
public void shouldDelegateCallToGetQueueMessages() {
    Message message = mock(Message.class);
    List<Message> messages = Arrays.asList(message);
    when(operations.getMessagesOfQueue(DEFAULT_BROKER, QUEUE, MAX_NUMBER_MESSAGE)).thenReturn(messages);
    List<Message> result = sut.getMessagesOfQueue(DEFAULT_BROKER, QUEUE, MAX_NUMBER_MESSAGE);
    assertSame(messages, result);
    verify(operations).getMessagesOfQueue(DEFAULT_BROKER, QUEUE, MAX_NUMBER_MESSAGE);
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) Test(org.junit.Test)

Example 4 with Message

use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.

the class OperationsTest method shouldDelegateListOperation.

@Test
public void shouldDelegateListOperation() {
    Message message = mock(Message.class);
    List<Message> messages = Arrays.asList(message);
    when(queueListOperation.getMessagesFromQueue(BROKER_NAME, QUEUE_NAME, MAX_NUMBER_MESSAGE)).thenReturn(messages);
    List<Message> result = sut.getMessagesOfQueue(BROKER_NAME, QUEUE_NAME, MAX_NUMBER_MESSAGE);
    assertSame(messages, result);
    verify(queueListOperation).getMessagesFromQueue(BROKER_NAME, QUEUE_NAME, MAX_NUMBER_MESSAGE);
}
Also used : Message(de.gessnerfl.rabbitmq.queue.management.model.Message) Test(org.junit.Test)

Example 5 with Message

use of de.gessnerfl.rabbitmq.queue.management.model.Message in project rabbitmq-queue-management by gessnerfl.

the class MessageMapperTest method shouldMapAmqpBasicProperties.

@Test
public void shouldMapAmqpBasicProperties() {
    String contentType = "contentType";
    String contentEncoding = "contentEncoding";
    String headerKey = "headerKey";
    String headerValue = "headerValue";
    Map<String, Object> headers = new HashMap<>();
    headers.put(headerKey, headerValue);
    Integer deliveryMode = 12;
    Integer priority = 13;
    String correlationId = "correlationId";
    String replyTo = "replyTo";
    String expiration = "expiration";
    String messageId = "messageId";
    Date timestamp = new Date();
    String type = "type";
    String userId = "userId";
    String appId = "appId";
    String clusterId = "clusterId";
    AMQP.BasicProperties basicProperties = mock(AMQP.BasicProperties.class);
    when(basicProperties.getContentType()).thenReturn(contentType);
    when(basicProperties.getContentEncoding()).thenReturn(contentEncoding);
    when(basicProperties.getHeaders()).thenReturn(headers);
    when(basicProperties.getDeliveryMode()).thenReturn(deliveryMode);
    when(basicProperties.getPriority()).thenReturn(priority);
    when(basicProperties.getCorrelationId()).thenReturn(correlationId);
    when(basicProperties.getReplyTo()).thenReturn(replyTo);
    when(basicProperties.getExpiration()).thenReturn(expiration);
    when(basicProperties.getMessageId()).thenReturn(messageId);
    when(basicProperties.getTimestamp()).thenReturn(timestamp);
    when(basicProperties.getType()).thenReturn(type);
    when(basicProperties.getUserId()).thenReturn(userId);
    when(basicProperties.getAppId()).thenReturn(appId);
    when(basicProperties.getClusterId()).thenReturn(clusterId);
    Envelope envelope = mock(Envelope.class);
    GetResponse getResponse = mockResponse(envelope, basicProperties);
    Message result = sut.map(getResponse);
    BasicProperties basicPropertiesOfResult = result.getProperties();
    assertNotNull(basicPropertiesOfResult);
    assertEquals(contentType, basicPropertiesOfResult.getContentType());
    assertEquals(contentEncoding, basicPropertiesOfResult.getContentEncoding());
    assertThat(basicPropertiesOfResult.getHeaders().keySet(), Matchers.hasSize(1));
    assertThat(basicPropertiesOfResult.getHeaders(), Matchers.hasKey(headerKey));
    assertEquals(headerValue, basicPropertiesOfResult.getHeaders().get(headerKey));
    assertEquals(deliveryMode, basicPropertiesOfResult.getDeliveryMode());
    assertEquals(priority, basicPropertiesOfResult.getPriority());
    assertEquals(correlationId, basicPropertiesOfResult.getCorrelationId());
    assertEquals(replyTo, basicPropertiesOfResult.getReplyTo());
    assertEquals(expiration, basicPropertiesOfResult.getExpiration());
    assertEquals(messageId, basicPropertiesOfResult.getMessageId());
    assertEquals(timestamp, basicPropertiesOfResult.getTimestamp());
    assertEquals(type, basicPropertiesOfResult.getType());
    assertEquals(userId, basicPropertiesOfResult.getUserId());
    assertEquals(appId, basicPropertiesOfResult.getAppId());
    assertEquals(clusterId, basicPropertiesOfResult.getClusterId());
}
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