Skip to content
Snippets Groups Projects
Commit b29fbf84 authored by Riabokon Stanislav(EPAM)[GCP]'s avatar Riabokon Stanislav(EPAM)[GCP]
Browse files

Merge branch 'gc-add-missing-attributes' into 'master'

Add missing attributes to schema changed event

See merge request !442
parents 4d1f01c5 848caeee
No related branches found
No related tags found
1 merge request!442Add missing attributes to schema changed event
Pipeline #164863 failed
......@@ -112,14 +112,12 @@ public class MessageBusImpl implements IMessageBus {
String data = new Gson().toJson(Collections.singletonList(schemaPubSubMsg));
Map<String, String> attributes = new HashMap<>();
attributes.put(DpsHeaders.ACCOUNT_ID, this.tenantInfo.getName());
attributes.put(DpsHeaders.DATA_PARTITION_ID,
this.headers.getPartitionIdWithFallbackToAccountId());
this.headers.addCorrelationIdIfMissing();
attributes.put(DpsHeaders.CORRELATION_ID, this.headers.getCorrelationId());
attributes.put(SchemaConstants.SERVICE_NAME, SchemaConstants.SCHEMA);
Map<String, String> headersMap = headers.getHeaders();
headersMap.put(DpsHeaders.ACCOUNT_ID, this.tenantInfo.getName());
headersMap.remove(DpsHeaders.AUTHORIZATION);
Map<String, String> attributes = new HashMap<>(headersMap);
return OqmMessage.builder()
.data(data)
.attributes(attributes)
......
......@@ -17,6 +17,13 @@
package org.opengroup.osdu.schema.impl.messagebus;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
import java.util.HashMap;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.InjectMocks;
......@@ -32,9 +39,6 @@ import org.opengroup.osdu.schema.configuration.EventMessagingPropertiesConfig;
import org.opengroup.osdu.schema.destination.provider.impl.OqmDestinationProvider;
import org.opengroup.osdu.schema.logging.AuditLogger;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.Mockito.*;
@RunWith(MockitoJUnitRunner.class)
public class MessageBusImplTest {
......@@ -84,9 +88,10 @@ public class MessageBusImplTest {
public void should_publishEventMessage_WhenFlagIsTrue() {
when(this.eventMessagingPropertiesConfig.isMessagingEnabled()).thenReturn(true);
when(this.tenantInfo.getName()).thenReturn(TENANT_NAME);
when(this.headers.getPartitionIdWithFallbackToAccountId()).thenReturn(DATA_PARTITION_ID);
doNothing().when(this.headers).addCorrelationIdIfMissing();
when(this.headers.getCorrelationId()).thenReturn(CORRELATION_ID);
HashMap<String, String> headersMap = new HashMap<>();
headersMap.put(DpsHeaders.DATA_PARTITION_ID, DATA_PARTITION_ID);
headersMap.put(DpsHeaders.CORRELATION_ID, CORRELATION_ID);
when(this.headers.getHeaders()).thenReturn(headersMap);
this.sut.publishMessage(SCHEMA_ID, EVENT_TYPE);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment