aboutsummaryrefslogtreecommitdiffstats
path: root/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
diff options
context:
space:
mode:
Diffstat (limited to 'datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java')
-rw-r--r--datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java131
1 files changed, 71 insertions, 60 deletions
diff --git a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
index 733aa3e8..cc40dc67 100644
--- a/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
+++ b/datafile-app-server/src/test/java/org/onap/dcaegen2/collectors/datafile/utils/JsonMessage.java
@@ -1,17 +1,21 @@
-/*
- * ============LICENSE_START======================================================================
- * Copyright (C) 2018-2019 Nordix Foundation. All rights reserved.
- * ===============================================================================================
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
- * in compliance with the License. You may obtain a copy of the License at
+/*-
+ * ============LICENSE_START=======================================================
+ * 2018-2019 Nordix Foundation. All rights reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
*
- * http://www.apache.org/licenses/LICENSE-2.0
+ * http://www.apache.org/licenses/LICENSE-2.0
*
- * Unless required by applicable law or agreed to in writing, software distributed under the License
- * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
- * or implied. See the License for the specific language governing permissions and limitations under
- * the License.
- * ============LICENSE_END========================================================================
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
*/
package org.onap.dcaegen2.collectors.datafile.utils;
@@ -57,35 +61,40 @@ public class JsonMessage {
}
additionalFieldsString.append("]");
}
- // @formatter:off
- return "{" + "\"event\":{"
- + "\"commonEventHeader\":{"
- + "\"domain\":\"notification\","
- + "\"eventId\":\"<<SerialNumber>>-reg\","
- + "\"eventName\":\"" + eventName + "\","
- + "\"eventType\":\"fileReady\","
- + "\"internalHeaderFields\":{},"
- + "\"lastEpochMicrosec\":1519837825682,"
- + "\"nfNamingCode\":\"5GRAN\","
- + "\"nfcNamingCode\":\"5DU\","
- + "\"priority\":\"Normal\","
- + "\"reportingEntityName\":\"5GRAN_DU\","
- + "\"sequence\":0,"
- + "\"sourceId\":\"<<SerialNumber>>\","
- + "\"sourceName\":\"5GRAN_DU\","
- + "\"timeZoneOffset\":\"UTC+05:00\","
- + "\"startEpochMicrosec\":\"1519837825682\","
- + "\"version\":3"
- + "},"
- + "\"notificationFields\":{"
+ return "{" //
+ + "\"event\":" //
+ + "{" //
+ + "\"commonEventHeader\":" //
+ + "{" //
+ + "\"domain\":\"notification\"," //
+ + "\"eventId\":\"<<SerialNumber>>-reg\"," //
+ + "\"eventName\":\"" + eventName + "\"," //
+ + "\"eventType\":\"fileReady\"," //
+ + "\"internalHeaderFields\":{}," //
+ + "\"lastEpochMicrosec\":1519837825682," //
+ + "\"nfNamingCode\":\"5GRAN\"," //
+ + "\"nfcNamingCode\":\"5DU\"," //
+ + "\"priority\":\"Normal\"," //
+ + "\"reportingEntityName\":\"5GRAN_DU\"," //
+ + "\"sequence\":0," //
+ + "\"sourceId\":\"<<SerialNumber>>\"," //
+ + "\"sourceName\":\"5GRAN_DU\"," //
+ + "\"timeZoneOffset\":\"UTC+05:00\"," //
+ + "\"startEpochMicrosec\":\"1519837825682\"," //
+ + "\"version\":3" //
+ + "}," //
+ + "\"notificationFields\":" //
+ + "{" //
+ getAsStringIfParameterIsSet("changeIdentifier", changeIdentifier,
changeType != null || notificationFieldsVersion != null || arrayOfAdditionalFields.size() > 0)
+ getAsStringIfParameterIsSet("changeType", changeType,
notificationFieldsVersion != null || arrayOfAdditionalFields.size() > 0)
+ getAsStringIfParameterIsSet("notificationFieldsVersion", notificationFieldsVersion,
arrayOfAdditionalFields.size() > 0)
- + additionalFieldsString.toString() + "}" + "}" + "}";
- // @formatter:on
+ + additionalFieldsString.toString() //
+ + "}" //
+ + "}" //
+ + "}";
}
private JsonMessage(final JsonMessageBuilder builder) {
@@ -105,16 +114,20 @@ public class JsonMessage {
@Override
public String toString() {
- return "{" + getAsStringIfParameterIsSet("name", name, true) + "\"hashMap\":{"
+ return "{" //
+ + getAsStringIfParameterIsSet("name", name, true) //
+ + "\"hashMap\":" //
+ + "{"
+ getAsStringIfParameterIsSet("location", location,
compression != null || fileFormatType != null || fileFormatVersion != null)
+ getAsStringIfParameterIsSet("compression", compression,
fileFormatType != null || fileFormatVersion != null)
+ getAsStringIfParameterIsSet("fileFormatType", fileFormatType, fileFormatVersion != null)
- + getAsStringIfParameterIsSet("fileFormatVersion", fileFormatVersion, false) + "}}";
+ + getAsStringIfParameterIsSet("fileFormatVersion", fileFormatVersion, false) //
+ + "}" //
+ + "}";
}
-
private AdditionalField(AdditionalFieldBuilder builder) {
this.name = builder.name;
this.location = builder.location;
@@ -214,35 +227,33 @@ public class JsonMessage {
/**
* Can be used to produce a correct test Json message. Tip! Check the formatting with
- * <a href="https://jsonformatter.org/">Json fomatter</a>
+ * <a href="https://jsonformatter.org/">Json formatter</a>
*
* @param args Not used
*/
public static void main(String[] args) {
- // @formatter:off
- AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder()
- .name("A20161224.1030-1045.bin.gz")
- .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz")
- .compression("gzip")
- .fileFormatType("org.3GPP.32.435#measCollec")
- .fileFormatVersion("V10")
+ AdditionalField additionalField = new JsonMessage.AdditionalFieldBuilder() //
+ .name("A20161224.1030-1045.bin.gz") //
+ .location("ftpes://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz") //
+ .compression("gzip") //
+ .fileFormatType("org.3GPP.32.435#measCollec") //
+ .fileFormatVersion("V10") //
.build();
- AdditionalField secondAdditionalField = new JsonMessage.AdditionalFieldBuilder()
- .name("A20161224.1030-1045.bin.gz")
- .location("sftp://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz")
- .compression("gzip")
- .fileFormatType("org.3GPP.32.435#measCollec")
- .fileFormatVersion("V10")
+ AdditionalField secondAdditionalField = new JsonMessage.AdditionalFieldBuilder() //
+ .name("A20161224.1030-1045.bin.gz") //
+ .location("sftp://192.168.0.101:22/ftp/rop/A20161224.1030-1045.bin.gz") //
+ .compression("gzip") //
+ .fileFormatType("org.3GPP.32.435#measCollec") //
+ .fileFormatVersion("V10") //
.build();
- JsonMessage message = new JsonMessage.JsonMessageBuilder()
- .eventName("Noti_NrRadio-Ericsson_FileReady")
- .changeIdentifier("PM_MEAS_FILES")
- .changeType("FileReady")
- .notificationFieldsVersion("2.0")
- .addAdditionalField(additionalField)
- .addAdditionalField(secondAdditionalField)
+ JsonMessage message = new JsonMessage.JsonMessageBuilder() //
+ .eventName("Noti_NrRadio-Ericsson_FileReady") //
+ .changeIdentifier("PM_MEAS_FILES") //
+ .changeType("FileReady") //
+ .notificationFieldsVersion("2.0") //
+ .addAdditionalField(additionalField) //
+ .addAdditionalField(secondAdditionalField) //
.build();
- // @formatter:on
System.out.println(message.toString());
}
}