summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/test/java/org
diff options
context:
space:
mode:
authorm.kowalski3 <m.kowalski3@partner.samsung.com>2019-05-31 14:58:52 +0200
committerOren Kleks <orenkle@amdocs.com>2019-06-02 06:21:26 +0000
commit3cdd515788e42ae60ec2dc05340c2494261288d3 (patch)
tree655d9b9ff2c4b6c52f401dc8a06aa9bd42f42229 /common-app-api/src/test/java/org
parent604f96f5154a475041efbfc7c9f4c428f210d030 (diff)
Improve unit tests for ESTimeBasedEvent
Issue-ID: SDC-2327 Signed-off-by: Marcin Kowalski <m.kowalski3@partner.samsung.com> Change-Id: I4e53f5f4cf14c5b44d72b10de53e5641e75a98b1
Diffstat (limited to 'common-app-api/src/test/java/org')
-rw-r--r--common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java204
1 files changed, 96 insertions, 108 deletions
diff --git a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java
index 4d5d97b7fa..10da662827 100644
--- a/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java
+++ b/common-app-api/src/test/java/org/openecomp/sdc/common/datastructure/ESTimeBasedEventTest.java
@@ -1,117 +1,105 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * SDC
+ * ================================================================================
+ * Modifications Copyright (c) 2019 Samsung
+ * ================================================================================
+ * 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============================================
+ * ===================================================================
+ *
+ */
+
package org.openecomp.sdc.common.datastructure;
-import java.util.Map;
+import static org.junit.Assert.assertEquals;
+import java.util.Map;
+import org.codehaus.jettison.json.JSONException;
import org.junit.Test;
public class ESTimeBasedEventTest {
- private ESTimeBasedEvent createTestSubject() {
- return new ESTimeBasedEvent();
- }
-
-
-
-
- @Test
- public void testCalculateYearIndexSuffix() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.calculateYearIndexSuffix();
- }
-
-
- @Test
- public void testCalculateMonthIndexSuffix() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.calculateMonthIndexSuffix();
- }
-
-
- @Test
- public void testCalculateDayIndexSuffix() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.calculateDayIndexSuffix();
- }
-
-
- @Test
- public void testCalculateHourIndexSuffix() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.calculateHourIndexSuffix();
- }
-
-
- @Test
- public void testCalculateMinuteIndexSuffix() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.calculateMinuteIndexSuffix();
- }
-
-
-
-
-
- @Test
- public void testGetTimestamp() throws Exception {
- ESTimeBasedEvent testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getTimestamp();
- }
-
-
- @Test
- public void testSetTimestamp() throws Exception {
- ESTimeBasedEvent testSubject;
- String timestamp = "";
-
- // default test
- testSubject = createTestSubject();
- testSubject.setTimestamp(timestamp);
- }
-
-
- @Test
- public void testGetFields() throws Exception {
- ESTimeBasedEvent testSubject;
- Map<String, Object> result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getFields();
- }
-
-
- @Test
- public void testSetFields() throws Exception {
- ESTimeBasedEvent testSubject;
- Map<String, Object> fields = null;
-
- // default test
- testSubject = createTestSubject();
- testSubject.setFields(fields);
- }
+ private ESTimeBasedEvent createTestSubject() {
+ return new ESTimeBasedEvent();
+ }
+
+
+ @Test
+ public void testCalculateYearIndexSuffix() {
+ createTestSubject().calculateYearIndexSuffix();
+ }
+
+
+ @Test
+ public void testCalculateMonthIndexSuffix() {
+ createTestSubject().calculateMonthIndexSuffix();
+ }
+
+
+ @Test
+ public void testCalculateDayIndexSuffix() {
+ createTestSubject().calculateDayIndexSuffix();
+ }
+
+
+ @Test
+ public void testCalculateHourIndexSuffix() {
+ createTestSubject().calculateHourIndexSuffix();
+ }
+
+
+ @Test
+ public void testCalculateMinuteIndexSuffix() {
+ createTestSubject().calculateMinuteIndexSuffix();
+ }
+
+
+ @Test
+ public void testGetTimestamp() {
+ createTestSubject().getTimestamp();
+ }
+
+
+ @Test
+ public void testSetTimestamp() {
+ createTestSubject().setTimestamp("");
+ }
+
+
+ @Test
+ public void testGetFields() {
+ createTestSubject().getFields();
+ }
+
+
+ @Test
+ public void testSetFields() {
+ createTestSubject().setFields(null);
+ }
+
+ @Test
+ public void testCreateEventFromJson() throws JSONException {
+ //given
+ String stringJson =
+ "{\n \"TIMESTAMP\" : \"2000-05-01 20:00:00.000 z\",\n \"event_type\" : \"activation\" }";
+ //when
+ ESTimeBasedEvent esTimeBasedEvent = ESTimeBasedEvent.createEventFromJson(stringJson);
+ Map<String, Object> fields = esTimeBasedEvent.getFields();
+ //then
+ assertEquals(esTimeBasedEvent.timestamp, "2000-05-01 20:00:00.000 z");
+ assertEquals(fields.get("event_type"), "activation");
+ }
+
} \ No newline at end of file