From 30fe09bd17f6cea12e01bc3834ca4bca581a3d7d Mon Sep 17 00:00:00 2001 From: PatrikBuhr Date: Tue, 16 Apr 2019 14:15:12 +0000 Subject: Bugfix, serializing in DataRouterPublisher This fixes a bug introduced in c7b0c7014688c447d411f791a094440403e65228. The new property must be removed before publishing to data router. The consequense of the bug is that the DR rejects the publishing. Change-Id: Ib42cbed4decdba4c13678cea47dff35ca77679a5 Issue-ID: DCAEGEN2-1305 Signed-off-by: PatrikBuhr --- .../dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java | 3 +++ .../dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java | 6 +++++- 2 files changed, 8 insertions(+), 1 deletion(-) (limited to 'datafile-app-server') diff --git a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java index 05f04b30..950fbae9 100644 --- a/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java +++ b/datafile-app-server/src/main/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisher.java @@ -60,6 +60,7 @@ public class DataRouterPublisher { private static final String CONTENT_TYPE = "application/octet-stream"; private static final String NAME_JSON_TAG = "name"; private static final String INTERNAL_LOCATION_JSON_TAG = "internalLocation"; + private static final String CONTEXT_JSON_TAG = "context"; private static final String PUBLISH_TOPIC = "publish"; private static final String DEFAULT_FEED_ID = "1"; @@ -116,6 +117,8 @@ public class DataRouterPublisher { JsonElement metaData = new JsonParser().parse(CommonFunctions.createJsonBody(publishInfo)); metaData.getAsJsonObject().remove(NAME_JSON_TAG).getAsString(); metaData.getAsJsonObject().remove(INTERNAL_LOCATION_JSON_TAG); + metaData.getAsJsonObject().remove(CONTEXT_JSON_TAG); + put.addHeader(X_DMAAP_DR_META, metaData.toString()); put.setURI(getPublishUri(publishInfo.getName())); MappedDiagnosticContext.appendTraceInfo(put); diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java index 847d9624..03122ea2 100644 --- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java +++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/tasks/DataRouterPublisherTest.java @@ -148,7 +148,11 @@ class DataRouterPublisherTest { Header[] metaHeaders = actualPut.getHeaders(X_DMAAP_DR_META); Map metaHash = getMetaDataAsMap(metaHeaders); - assertEquals(11, metaHash.size()); + + // Note that the following line checks the number of properties that are sent to the data router. + // This should be 10 unless the API is updated. The class DataRouterPublisher removes + // info that should not be reported. + assertEquals(10, metaHash.size()); assertEquals(PRODUCT_NAME, metaHash.get("productName")); assertEquals(VENDOR_NAME, metaHash.get("vendorName")); assertEquals(LAST_EPOCH_MICROSEC, metaHash.get("lastEpochMicrosec")); -- cgit 1.2.3-korg