summaryrefslogtreecommitdiffstats
path: root/common-app-api/src/test/java/org/openecomp
diff options
context:
space:
mode:
Diffstat (limited to 'common-app-api/src/test/java/org/openecomp')
-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