TenantMessageFilter extends BaseMessageFilter { public static boolean verify(final ResourceIdentifier linkTarget, final Message msg) { final Object correlationId = MessageHelper.getCorrelationId(msg); if (correlationId == null) { LOG.trace("message has neither a message-id nor correlation-id"); return false; } else if (msg.getSubject() == null) { LOG.trace("message [correlation ID: {}] does not contain a subject", correlationId); return false; } else if (msg.getReplyTo() == null) { LOG.trace("message [correlation ID: {}] contains no reply-to address", correlationId); return false; } else { return true; } } private  TenantMessageFilter(); static boolean verify(final ResourceIdentifier linkTarget, final Message msg);  }
@Test public void testVerifyDetectsMissingSubject() { final Message msg = ProtonHelper.message(); msg.setMessageId("msg"); msg.setReplyTo("reply"); final ResourceIdentifier linkTarget = getResourceIdentifier(DEFAULT_TENANT); assertFalse(TenantMessageFilter.verify(linkTarget, msg)); }
@Test public void testVerifySucceedsForValidGetAction() { final Message msg = givenAMessageHavingProperties(TenantConstants.TenantAction.get); MessageHelper.addProperty(msg, MessageHelper.APP_PROPERTY_TENANT_ID, DEFAULT_TENANT); final ResourceIdentifier linkTarget = getResourceIdentifier(DEFAULT_TENANT); assertTrue(TenantMessageFilter.verify(linkTarget, msg)); }