### Question:
AuditProducerRoutingKeyResolver extends AbstractMessageHeadersRoutingKeyResolver { @Override public String resolve(Map<String, Object> headers) { return build(headers, HEADER_KEYS); }  @Override String resolve(Map<String, Object> headers); @Override String getPrefix(); final String ROUTING_KEY_PREFIX; final String[] HEADER_KEYS; }### Answer:
@Test public void testResolveRoutingKeyFromValidHeadersInAnyOrder() { Map<String, Object> headers = MapBuilder.<String, Object> map(RuntimeBundleInfoMessageHeaders.APP_NAME, "app-name") .with(RuntimeBundleInfoMessageHeaders.SERVICE_NAME, "service-name"); String routingKey = subject.resolve(headers); assertThat(routingKey).isEqualTo("engineEvents.service-name.app-name"); }
@Test public void testResolveRoutingKeyFromEmptyHeaders() { Map<String, Object> headers = MapBuilder.<String, Object> map(RuntimeBundleInfoMessageHeaders.APP_NAME, "") .with(RuntimeBundleInfoMessageHeaders.SERVICE_NAME, "service-name"); String routingKey = subject.resolve(headers); assertThat(routingKey).isEqualTo("engineEvents.service-name._"); }
@Test public void testResolveRoutingKeyFromNullHeaders() { Map<String, Object> headers = MapBuilder.<String, Object> map(RuntimeBundleInfoMessageHeaders.APP_NAME, null) .with(RuntimeBundleInfoMessageHeaders.SERVICE_NAME, "service-name"); String routingKey = subject.resolve(headers); assertThat(routingKey).isEqualTo("engineEvents.service-name._"); }
@Test public void testResolveRoutingKeyWithEscapedValues() { Map<String, Object> headers = MapBuilder.<String, Object> map(RuntimeBundleInfoMessageHeaders.APP_NAME, "app:na#me") .with(RuntimeBundleInfoMessageHeaders.SERVICE_NAME, "ser.vice*na me"); String routingKey = subject.resolve(headers); assertThat(routingKey).isEqualTo("engineEvents.ser-vice-na-me.app-na-me"); }
@Test public void testResolveRoutingKeyWithNonExistingHeaders() { Map<String, Object> headers = MapBuilder.<String, Object> emptyMap(); String routingKey = subject.resolve(headers); assertThat(routingKey).isEqualTo("engineEvents._._"); }