aboutsummaryrefslogtreecommitdiffstats
path: root/datarouter-prov
diff options
context:
space:
mode:
authoreconwar <conor.ward@ericsson.com>2018-08-29 10:40:12 +0000
committereconwar <conor.ward@ericsson.com>2018-08-29 12:34:09 +0000
commit1c9247fa76d615fd1b09ed4106e73be67e4435fe (patch)
treead09f87b2ffedf543623b750635a6dbfbb98bb97 /datarouter-prov
parent04dd60b7f0ebdadd5af0a4147a3e601734d6e3dc (diff)
Add PublishRecord Unit Tests
Change-Id: I2140184646e3cd07a7e5a8cba25cd84886776cbc Signed-off-by: Conor Ward <conor.ward@ericsson.com> Issue-ID: DMAAP-101
Diffstat (limited to 'datarouter-prov')
-rw-r--r--datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java77
1 files changed, 77 insertions, 0 deletions
diff --git a/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java
new file mode 100644
index 00000000..eaeb91cc
--- /dev/null
+++ b/datarouter-prov/src/test/java/org/onap/dmaap/datarouter/provisioning/beans/PublishRecordTest.java
@@ -0,0 +1,77 @@
+/*******************************************************************************
+ * ============LICENSE_START==================================================
+ * * org.onap.dmaap
+ * * ===========================================================================
+ * * Copyright © 2017 AT&T Intellectual Property. 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
+ * *
+ * * 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====================================================
+ * *
+ * * ECOMP is a trademark and service mark of AT&T Intellectual Property.
+ * *
+ ******************************************************************************/
+package org.onap.dmaap.datarouter.provisioning.beans;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.onap.dmaap.datarouter.provisioning.utils.LOGJSONObject;
+
+import java.text.ParseException;
+import java.util.LinkedHashMap;
+
+public class PublishRecordTest {
+
+ private PublishRecord publishRecord;
+
+ @Before
+ public void setUp() throws ParseException {
+ String[] args = {"2018-08-29-10-10-10-543.", "PUB", "238465493.fileName",
+ "1", "/publish/1/fileName", "PUT", "application/octet-stream", "285",
+ "172.100.0.3", "user1", "301"};
+ publishRecord = new PublishRecord(args);
+ }
+
+ @Test
+ public void Validate_Contructor_Creates_Object_With_Get_Methods() {
+ Assert.assertEquals("fileName", publishRecord.getFeedFileid());
+ Assert.assertEquals("172.100.0.3", publishRecord.getRemoteAddr());
+ Assert.assertEquals("user1", publishRecord.getUser());
+ Assert.assertEquals(301, publishRecord.getStatus());
+ }
+
+ @Test
+ public void Validate_AsJsonObject_Correct_Json_Object_After_Set_Methods() {
+ publishRecord.setFeedFileid("fileName2");
+ publishRecord.setRemoteAddr("172.100.0.4");
+ publishRecord.setStatus(201);
+ publishRecord.setUser("user2");
+ LOGJSONObject publishRecordJson = createPublishRecordJson();
+ Assert.assertEquals(publishRecordJson.toString(), publishRecord.asJSONObject().toString());
+ }
+
+ private LOGJSONObject createPublishRecordJson() {
+ LinkedHashMap<String, Object> publishRecordMap = new LinkedHashMap<>();
+ publishRecordMap.put("statusCode", 201);
+ publishRecordMap.put("publishId", "238465493.fileName");
+ publishRecordMap.put("requestURI", "/publish/1/fileName");
+ publishRecordMap.put("sourceIP", "172.100.0.4");
+ publishRecordMap.put("method", "PUT");
+ publishRecordMap.put("contentType", "application/octet-stream");
+ publishRecordMap.put("endpointId", "user2");
+ publishRecordMap.put("type", "pub");
+ publishRecordMap.put("date", "2018-08-29T10:10:10.543Z");
+ publishRecordMap.put("contentLength", 285);
+ return new LOGJSONObject(publishRecordMap);
+ }
+}