Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

QPIDJMS-153-methods to access message/delivery annotation names #37

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1023,6 +1023,20 @@ MessageAnnotations getMessageAnnotations() {
return result;
}

public Set<Symbol> getMessageAnnotationNames() {
if(messageAnnotationsMap != null && !messageAnnotationsMap.isEmpty()) {
return messageAnnotationsMap.keySet();
}
return null;
}

public Set<Symbol> getDeliveryAnnotationNames() {
if(deliveryAnnotationsMap != null && !deliveryAnnotationsMap.isEmpty()) {
return deliveryAnnotationsMap.keySet();
}
return null;
}

void setMessageAnnotations(MessageAnnotations messageAnnotations) {
if (messageAnnotations != null) {
this.messageAnnotationsMap = messageAnnotations.getValue();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1763,6 +1763,50 @@ public void testGetMessageAnnotationsOnMessageWithEmptyAnnotationsMap() {
assertNull(underlyingAnnotations);
}

@Test
public void testGetMessageAnnotationNamesOnMessageWithAnnotationsMap() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
final Symbol symbol = Symbol.valueOf("x-opt-testKey1");
amqpMessageFacade.setMessageAnnotation(symbol, "testValue1");

Set<Symbol> msgAnnotationNames = amqpMessageFacade.getMessageAnnotationNames();
assertNotNull(msgAnnotationNames);
assertEquals(symbol.toString(), msgAnnotationNames.iterator().next().toString());
}

@Test
public void testGetMessageAnnotationNamesOnMessageWithEmptyAnnotationsMap() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();

Set<Symbol> msgAnnotationNames = amqpMessageFacade.getMessageAnnotationNames();
assertNull(msgAnnotationNames);
}

@Test
public void testGetDeliveryAnnotationNamesOnMessageWithEmptyAnnotationsMap() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
Map<Symbol, Object> deliveryAnnotationsMap = new HashMap<>();
DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(deliveryAnnotationsMap);
amqpMessageFacade.setDeliveryAnnotations(deliveryAnnotations);

Set<Symbol> deliveryAnnotationNames = amqpMessageFacade.getDeliveryAnnotationNames();
assertNull(deliveryAnnotationNames);
}

@Test
public void testGetDeliveryAnnotationNamesOnMessageWithAnnotationsMap() {
AmqpJmsMessageFacade amqpMessageFacade = createNewMessageFacade();
final Symbol symbol = Symbol.valueOf("testKey1");
Map<Symbol, Object> deliveryAnnotationsMap = new HashMap<>();
deliveryAnnotationsMap.put(symbol, "testValue1");
DeliveryAnnotations deliveryAnnotations = new DeliveryAnnotations(deliveryAnnotationsMap);
amqpMessageFacade.setDeliveryAnnotations(deliveryAnnotations);

Set<Symbol> deliveryAnnotationNames = amqpMessageFacade.getDeliveryAnnotationNames();
assertNotNull(deliveryAnnotationNames);
assertEquals(symbol.toString(), deliveryAnnotationNames.iterator().next().toString());
}

@Test
public void testRemoveMessageAnnotation() {
Symbol symbolKeyName = Symbol.valueOf("myTestSymbolName");
Expand Down