Remove tests that do not actually test anything 67/50667/2
authorPawelSzalapski <pawel.szalapski@nokia.com>
Wed, 6 Jun 2018 12:30:05 +0000 (14:30 +0200)
committerPawelSzalapski <pawel.szalapski@nokia.com>
Wed, 6 Jun 2018 13:58:31 +0000 (15:58 +0200)
Testcases in this file are written in a way that they
always throw exceptions, information about this is logged
and the assertion is always true.

Change-Id: Icbb0b6d4df9782e3a05f8d31fc71886a12a0105a
Issue-ID: DCAEGEN2-524
Signed-off-by: PawelSzalapski <pawel.szalapski@nokia.com>
src/test/java/org/onap/dcae/vestest/TestEventReceipt.java

index 2e4053f..a3893ea 100644 (file)
@@ -7,9 +7,9 @@
  * Licensed under the Apache License, Version 2.0 (the "License");\r
  * you may not use this file except in compliance with the License.\r
  * You may obtain a copy of the License at\r
- * \r
+ *\r
  *      http://www.apache.org/licenses/LICENSE-2.0\r
- * \r
+ *\r
  * Unless required by applicable law or agreed to in writing, software\r
  * distributed under the License is distributed on an "AS IS" BASIS,\r
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
@@ -21,142 +21,26 @@ package org.onap.dcae.vestest;
 \r
 import static org.junit.Assert.assertEquals;\r
 \r
-\r
-import java.io.IOException;\r
-import java.util.UUID;\r
-\r
-import org.json.JSONException;\r
 import org.json.JSONObject;\r
-import org.junit.After;\r
-import org.junit.Before;\r
 import org.junit.Test;\r
 import org.onap.dcae.commonFunction.CommonStartup;\r
-import org.onap.dcae.commonFunction.CommonStartup.QueueFullException;\r
-import org.onap.dcae.commonFunction.CustomExceptionLoader;\r
 import org.onap.dcae.restapi.endpoints.EventReceipt;\r
-import org.onap.dcae.restapi.endpoints.Ui;\r
-\r
-import com.att.nsa.apiServer.endpoints.NsaBaseEndpoint;\r
-import com.att.nsa.drumlin.service.framework.context.DrumlinRequestContext;\r
-import com.att.nsa.drumlin.service.standards.HttpStatusCodes;\r
-import com.att.nsa.security.db.simple.NsaSimpleApiKey;\r
-\r
-import jline.internal.Log;\r
-\r
-public class TestEventReceipt extends NsaBaseEndpoint {\r
-\r
-       DrumlinRequestContext ctx;\r
-       JSONObject jsonObject;\r
-       Boolean flag = false;\r
-       String ev = "{\"event\": {\"commonEventHeader\": {      \"reportingEntityName\": \"VM name will be provided by ECOMP\", \"startEpochMicrosec\": 1477012779802988,\"lastEpochMicrosec\": 1477012789802988,\"eventId\": \"83\",\"sourceName\": \"Dummy VM name - No Metadata available\",\"sequence\": 83,\"priority\": \"Normal\",\"functionalRole\": \"vFirewall\",\"domain\": \"measurementsForVfScaling\",\"reportingEntityId\": \"VM UUID will be provided by ECOMP\",\"sourceId\": \"Dummy VM UUID - No Metadata available\",\"version\": 1.1},\"measurementsForVfScalingFields\": {\"measurementInterval\": 10,\"measurementsForVfScalingVersion\": 1.1,\"vNicUsageArray\": [{\"multicastPacketsIn\": 0,\"bytesIn\": 3896,\"unicastPacketsIn\": 0, \"multicastPacketsOut\": 0,\"broadcastPacketsOut\": 0,          \"packetsOut\": 28,\"bytesOut\": 12178,\"broadcastPacketsIn\": 0,\"packetsIn\": 58,\"unicastPacketsOut\": 0,\"vNicIdentifier\": \"eth0\"}]}}}";\r
-       \r
-\r
-       @Before\r
-       public void setUp() throws Exception {\r
-               \r
-\r
-       }\r
-\r
-       @After\r
-       public void tearDown() throws Exception {\r
-       }\r
-\r
-       @Test\r
-       public void testschemaFileVersion() {\r
-\r
-               String filename = null;\r
-               CommonStartup.schemaFileJson = new JSONObject(\r
-                               "{\"v1\":\"./etc/CommonEventFormat_27.2.json\",\"v2\":\"./etc/CommonEventFormat_27.2.json\",\"v3\":\"./etc/CommonEventFormat_27.2.json\",\"v4\":\"./etc/CommonEventFormat_27.2.json\",\"v5\":\"./etc/CommonEventFormat_28.4.1.json\"}");\r
-               filename = EventReceipt.schemaFileVersion("v5");\r
-\r
-               if (!filename.isEmpty()) {\r
-                       flag = true;\r
-               }\r
-               assertEquals(true, flag);\r
-       }\r
-\r
-       @Test\r
-       public void testrespondWithCustomMsginJson() {\r
-\r
-               CommonStartup.exceptionConfig = "./etc/ExceptionConfig.json";\r
-        CustomExceptionLoader.LoadMap();\r
-        \r
-        try {\r
-               EventReceipt.respondWithCustomMsginJson(null, HttpStatusCodes.k401_unauthorized, "Unauthorized user");\r
-        }\r
-        catch (Exception e)\r
-        {\r
-               //As context object is null, handling null pointer exception.\r
-               Log.debug("Response object creation failure");\r
-        }\r
-               assertEquals(true, true);\r
-       }\r
-\r
-       @Test\r
-       public void testschemaCheck() {\r
-\r
-               // schemaCheck(NsaSimpleApiKey retkey, int arrayFlag,JSONObject\r
-               // jsonObject, String vesVersion, FileReader fr, DrumlinRequestContext\r
-               // ctx, UUID uuid) throws JSONException, QueueFullException, IOException\r
-               Boolean flag = true;\r
-               NsaSimpleApiKey retkey = null;\r
-               int arrayFlag = 0;\r
-               \r
-               CommonStartup.authflag = 0;\r
-               CommonStartup.schemaValidatorflag = 1;\r
-\r
-               jsonObject = new org.json.JSONObject(ev);\r
-\r
-               String vesVersion = "v1";\r
-\r
-               DrumlinRequestContext ctx = null;\r
-\r
-               \r
-               UUID uuid = UUID.randomUUID();\r
-\r
-               try {\r
-                       flag = EventReceipt.schemaCheck(retkey, arrayFlag, jsonObject, vesVersion, ctx, uuid);\r
-               } catch (NullPointerException |JSONException | QueueFullException | IOException e) {\r
-                       \r
-                       Log.debug("Response object creation failure");\r
-               }\r
-               assertEquals(true, flag);\r
-       }\r
-\r
-       @Test\r
-       public void testgetUser() {\r
 \r
-       \r
-               Boolean flag = true;\r
-               String user;\r
-               \r
-               CommonStartup.authflag = 1;\r
-               CommonStartup.schemaValidatorflag = 1;\r
+public class TestEventReceipt {\r
 \r
-               jsonObject = new org.json.JSONObject(ev);\r
 \r
-               DrumlinRequestContext ctx = null;\r
+    @Test\r
+    public void shouldGetSchemaFileLocationBasedOnVersion() {\r
+        CommonStartup.schemaFileJson = new JSONObject("{\"v1\":\"filePath1\", \"v5\":\"filePath2\"}");\r
+        String schemaFilePath = EventReceipt.schemaFileVersion("v5");\r
+        assertEquals(schemaFilePath, "filePath2");\r
+    }\r
 \r
-               try {\r
-                       user = EventReceipt.getUser(ctx);\r
-               } catch (NullPointerException |JSONException e) {\r
-                       \r
-                       Log.debug("Response object creation failure");\r
-               }\r
-               assertEquals(true, flag);\r
-       }\r
-       \r
-       @Test\r
-       public void testUI() {\r
+    @Test\r
+    public void shouldByDefaultReturnV5SchemaFileLocation() {\r
+        CommonStartup.schemaFileJson = new JSONObject("{\"v1\":\"filePath1\", \"v5\":\"filePath2\"}");\r
+        String schemaFilePath = EventReceipt.schemaFileVersion("v2");\r
+        assertEquals(schemaFilePath, "filePath2");\r
+    }\r
 \r
-        try {\r
-               Ui.hello(null);\r
-        }\r
-        catch (Exception e)\r
-        {\r
-               //As context object is null, handling null pointer exception.\r
-               Log.debug("Response object creation failure");\r
-        }\r
-               assertEquals(true, true);\r
-       }\r
 }\r