From c17ce648ecc3453df8754b936f2b344f13f6dc65 Mon Sep 17 00:00:00 2001 From: Pooja03 Date: Thu, 9 Aug 2018 17:49:09 +0530 Subject: Integratation of DMaaP, Mapping File DMaaP integratation, Mapping File, Initialization of Adapter Change-Id: I826aa2e64fa7c155f088a7519c24887ce88e2ec4 Issue-ID: DCAEGEN2-335 Signed-off-by: Pooja03 --- .../dcaegen2/ves/domain/AdditionalFieldTest.java | 5 - .../ves/domain/AdditionalMeasurementTest.java | 2 +- .../dcaegen2/ves/domain/AdditionalObjectTest.java | 2 +- .../ves/domain/AdditionalParameterTest.java | 10 + .../adapter/UniversalEventAdapterTest.java | 207 ++++++++++++++------- .../configs/DMaapMrUrlConfigurationTest.java | 53 ------ .../configs/DiskRepoConfigurationTest.java | 51 ----- .../configs/UniversalEventConfigurationTest.java | 48 ----- .../controller/VesControllerTest.java | 2 - .../domain/ConfigFileDataTest.java | 40 ---- .../exception/ConfigFileReadExceptionTest.java | 34 ---- .../ConfigFileSmooksConversionExceptionTest.java | 2 - .../service/AdapterServiceTest.java | 147 --------------- .../service/DMaapServiceTest.java | 3 +- .../service/DiskRepoConfigFileServiceTest.java | 3 +- .../service/MongoDbConfigFileServiceTest.java | 58 ------ .../service/VesServiceTest.java | 9 +- .../utils/MapperConfigUtilsTest.java | 13 +- .../utils/ParallelTasksTest.java | 72 ------- .../universalvesadapter/utils/SmooksUtilsTest.java | 19 +- 20 files changed, 161 insertions(+), 619 deletions(-) delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/ConfigFileDataTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java delete mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java (limited to 'UniversalVesAdapter/src/test/java/org') diff --git a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalFieldTest.java b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalFieldTest.java index ce4c8c7..e082249 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalFieldTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalFieldTest.java @@ -19,11 +19,6 @@ */ package org.onap.dcaegen2.ves.domain; -import static org.junit.Assert.*; - -import java.util.HashMap; -import java.util.Map; -import org.onap.dcaegen2.ves.domain.AdditionalField; import org.junit.Test; import org.springframework.beans.factory.annotation.Autowired; diff --git a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalMeasurementTest.java b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalMeasurementTest.java index 1b9149b..58a2507 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalMeasurementTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalMeasurementTest.java @@ -21,7 +21,7 @@ package org.onap.dcaegen2.ves.domain; import java.util.List; import java.util.Map; -import org.onap.dcaegen2.ves.domain.AdditionalMeasurement; + import org.junit.Test; public class AdditionalMeasurementTest { diff --git a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalObjectTest.java b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalObjectTest.java index fc28bd5..d3750ed 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalObjectTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalObjectTest.java @@ -21,7 +21,7 @@ package org.onap.dcaegen2.ves.domain; import java.util.List; import java.util.Map; -import org.onap.dcaegen2.ves.domain.AdditionalInformation; + import org.junit.Test; public class AdditionalObjectTest { diff --git a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalParameterTest.java b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalParameterTest.java index 92cda09..9b64ddd 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalParameterTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/AdditionalParameterTest.java @@ -19,6 +19,8 @@ */ package org.onap.dcaegen2.ves.domain; +import static org.junit.Assert.assertNotNull; + import java.util.Map; import org.junit.Test; @@ -37,6 +39,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.getCriticality(); + } @Test @@ -57,6 +60,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.getName(); + } @Test @@ -77,6 +81,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.getThresholdCrossed(); + } @Test @@ -97,6 +102,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.getValue(); + } @Test @@ -117,6 +123,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.getAdditionalProperties(); + } @Test @@ -138,6 +145,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.toString(); + } @Test @@ -148,6 +156,7 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.hashCode(); + } @Test @@ -159,5 +168,6 @@ public class AdditionalParameterTest { // default test testSubject = createTestSubject(); result = testSubject.equals(other); + } } \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/adapter/UniversalEventAdapterTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/adapter/UniversalEventAdapterTest.java index bc2cf4f..1f80fde 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/adapter/UniversalEventAdapterTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/adapter/UniversalEventAdapterTest.java @@ -19,48 +19,26 @@ */ package org.onap.universalvesadapter.adapter; -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; +import static org.junit.Assert.assertNotEquals; +import static org.junit.Assert.assertNotNull; -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; -import java.util.Arrays; -import java.util.Collections; +import java.util.HashMap; import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - -import javax.annotation.Resource; import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; import org.junit.runner.RunWith; -import org.milyn.Smooks; import org.mockito.InjectMocks; import org.mockito.Mock; -import org.mockito.Mockito; import org.mockito.MockitoAnnotations; -import org.onap.dcaegen2.ves.domain.VesEvent; import org.onap.universalvesadapter.Application; -import org.onap.universalvesadapter.adapter.UniversalEventAdapter; -import org.onap.universalvesadapter.exception.ConfigFileReadException; -import org.onap.universalvesadapter.exception.ConfigFileSmooksConversionException; -import org.onap.universalvesadapter.exception.MapperConfigException; import org.onap.universalvesadapter.exception.VesException; -import org.onap.universalvesadapter.service.ConfigFileService; -import org.onap.universalvesadapter.utils.MapperConfigUtils; -import org.onap.universalvesadapter.utils.SmooksUtils; +import org.onap.universalvesadapter.service.VESAdapterInitializer; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.FileCopyUtils; -import com.fasterxml.jackson.core.JsonProcessingException; -import com.fasterxml.jackson.databind.ObjectMapper; @RunWith(SpringRunner.class) @SpringBootTest(classes=Application.class) @@ -69,10 +47,9 @@ public class UniversalEventAdapterTest { private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); @Mock - private ConfigFileService configFileService; + private VESAdapterInitializer vESAdapterInitializer; @InjectMocks - @Autowired private UniversalEventAdapter universalVesAdapter; @@ -86,7 +63,7 @@ public class UniversalEventAdapterTest { public void testtransform() { StringBuffer incomingJsonString = new StringBuffer("{ ") .append("\"protocol version\":\"v2c\", ") - .append("\"notify OID\":\".1.3.6.1.4.1.74.2.46.12.1.1AAA\", ") + .append("\"notify OID\":\".1.3.6.1.4.1.1751.2.46.12.1.1\", ") .append("\"cambria.partition\":\"dcae-snmp.client.research.att.com\", ") .append("\"trap category\":\"UCSNMP-HEARTBEAT\", ") .append("\"epoch_serno\": 15161177410000, ") @@ -107,48 +84,140 @@ public class UniversalEventAdapterTest { .append(" }] ") .append("}"); - StringBuffer configFileData = new StringBuffer(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(" ") - .append(""); - - try { - Mockito.when(configFileService.readConfigFile(Mockito.anyString())).thenReturn(configFileData.toString()); - } catch (Exception e) { - eLOGGER.error("Error occurred : " + e.getMessage()); - } - + Map testMap=new HashMap(); + testMap.put("defaultSnmpMappingFile", "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"3.0\"\r\n" + + " \"XXXX\"\r\n" + + " \"VesAdapter\"\r\n" + + " \"fault\"\r\n" + + " commonEventHeader.domain+\"_\"+commonEventHeader.reportingEntityName +\"_\"+ faultFields.alarmCondition;\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"Medium\"\r\n" + + " \"VesAdapter\"\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"MINOR\"\r\n" + + " \"SNMP Agent\"\r\n" + + " \"SNMP Fault\"\r\n" + + " \r\n" + + " \r\n" + + " \"Active\"\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""); + testMap.put(".1.3.6.1.4.1.1751.2.46.12", "\r\n" + + "\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"3.0\"\r\n" + + " \"XXXX\"\r\n" + + " \"VesAdapter\"\r\n" + + " \"fault\"\r\n" + + " commonEventHeader.domain+\"_\"+commonEventHeader.reportingEntityName +\"_\"+ faultFields.alarmCondition;\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"Medium\"\r\n" + + " \"VesAdapter\"\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \"MINOR\"\r\n" + + " \"SNMP Agent\"\r\n" + + " \"SNMP Fault\"\r\n" + + " \r\n" + + " \r\n" + + " \"Active\"\r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + " \r\n" + + ""); try { - String actualResult = universalVesAdapter.transform(incomingJsonString.toString(), "snmp"); + + VESAdapterInitializer.setMappingFiles(testMap); + String actualResult = universalVesAdapter.transform(incomingJsonString.toString(), "snmp"); assertNotNull(actualResult); assertNotEquals("", actualResult); } catch (VesException exception) { diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java deleted file mode 100644 index c7497b4..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java +++ /dev/null @@ -1,53 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.configs; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.onap.universalvesadapter.Application; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes=Application.class) -public class DMaapMrUrlConfigurationTest { - - @Autowired - @InjectMocks - DMaapMrUrlConfiguration dMaapMrUrlConfiguration = new DMaapMrUrlConfiguration(); - - @Test - public void test() { - String actualdata1 = dMaapMrUrlConfiguration.getConsumerProperties(); - String actualdata2 = dMaapMrUrlConfiguration.getPublisherProperties(); - String actualdata3 = dMaapMrUrlConfiguration.getUrl(); - - assertEquals("../UniversalVesAdapter/src/main/resources/dme2/consumer.properties", actualdata1); - assertEquals("../UniversalVesAdapter/src/main/resources/dme2/publisher.properties", actualdata2); - assertEquals("http://localhost:8080/greeting12", actualdata3); - - - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java deleted file mode 100644 index 4d42641..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java +++ /dev/null @@ -1,51 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.configs; - -import static org.junit.Assert.*; - -import org.onap.universalvesadapter.Application; -import org.onap.universalvesadapter.configs.DiskRepoConfiguration; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes=Application.class) -public class DiskRepoConfigurationTest { - - @InjectMocks - @Autowired - DiskRepoConfiguration diskRepoConfiguration = new DiskRepoConfiguration(); - - @Test - public void test() { - - - String actualdata = diskRepoConfiguration.getFileRepositoryUrl(); - - assertEquals("http://localhost:8888/fileAsString/", actualdata); - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java deleted file mode 100644 index c79caa9..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.configs; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.onap.universalvesadapter.Application; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes=Application.class) -public class UniversalEventConfigurationTest { - - @Autowired - @InjectMocks - UniversalEventConfiguration universalEventConfiguration = new UniversalEventConfiguration(); - - @Test - public void test() { - String actualdata = universalEventConfiguration.getConfigForEvent("default"); - - assertEquals("defaultConfig.xml", actualdata); - - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java index b35b7b4..582b4fc 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java @@ -22,7 +22,6 @@ package org.onap.universalvesadapter.controller; import static org.junit.Assert.assertEquals; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; import static org.springframework.test.web.servlet.result.MockMvcResultHandlers.print; -import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath; import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status; import org.junit.Test; @@ -34,7 +33,6 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; import org.springframework.test.web.servlet.MvcResult; -import org.springframework.test.web.servlet.ResultActions; @RunWith(SpringRunner.class) @SpringBootTest(classes=Application.class) diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/ConfigFileDataTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/ConfigFileDataTest.java deleted file mode 100644 index 9f51cae..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/domain/ConfigFileDataTest.java +++ /dev/null @@ -1,40 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.domain; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.springframework.beans.factory.annotation.Autowired; - -public class ConfigFileDataTest { - - @Autowired - ConfigFileData configFileData = new ConfigFileData(); - @Test - public void test() { - configFileData.setXmlContent("xmlContent"); - configFileData.setXmlFileName("xmlFileName"); - - assertEquals(configFileData.getXmlContent(), "xmlContent"); - assertEquals(configFileData.getXmlFileName(), "xmlFileName"); - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java deleted file mode 100644 index 1d5307a..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java +++ /dev/null @@ -1,34 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.exception; - -import org.junit.Test; - -public class ConfigFileReadExceptionTest { - - - @Test - public void test() { - ConfigFileReadException se = new ConfigFileReadException("message"); - ConfigFileReadException se1 = new ConfigFileReadException("message", se); - - - } -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java index 2fda822..ac60be1 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java @@ -19,8 +19,6 @@ */ package org.onap.universalvesadapter.exception; -import static org.junit.Assert.*; - import org.junit.Test; public class ConfigFileSmooksConversionExceptionTest { diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java deleted file mode 100644 index 298ab69..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java +++ /dev/null @@ -1,147 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.service; - -import static org.junit.Assert.*; -import static org.mockito.Mockito.when; - -import java.io.FileNotFoundException; -import java.io.FileReader; -import java.io.IOException; - -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.InjectMocks; -import org.mockito.MockitoAnnotations; -import org.onap.dcaegen2.ves.domain.AdditionalField; -import org.onap.universalvesadapter.Application; -import org.onap.universalvesadapter.exception.MapperConfigException; -import org.onap.universalvesadapter.service.AdapterService; -import org.onap.universalvesadapter.utils.MapperConfigUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; -import org.springframework.util.FileCopyUtils; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes=Application.class) -public class AdapterServiceTest { - -// private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); - - @Before - public void setup() { - MockitoAnnotations.initMocks(this); - } - - @Autowired - @InjectMocks - private AdapterService adapterService; - - - //AdapterService adapterService = new AdapterService(); - - @Value("${mapperConfig.file}") - private String mapperConfigFile; - - @Test - public void identifyEventTypeFromIncomingJson() throws MapperConfigException, FileNotFoundException, IOException { - - String inputJsonString = "{ " - + "\"protocol version\":\"v2c\", " - + "\"notify OID\":\".1.3.6.1.4.1.74.2.46.12.1.1AAA\", " - + "\"cambria.partition\":\"dcae-snmp.client.research.att.com\", " - + "\"trap category\":\"UCSNMP-HEARTBEAT\", " - + "\"epoch_serno\": 15161177410000, " - + "\"community\":\"public\", " - + "\"time received\": 1516117741, " - + "\"agent name\":\"localhost\", " - + "\"agent address\":\"127.0.0.1\", " - + "\"community len\": 6, " - + "\"notify OID len\": 12, " - + "\"varbinds\": [{ " - + " \"varbind_type\":\"octet\", " - + " \"varbind_oid\":\".1.3.6.1.4.1.74.2.46.12.1.1.1\", " - + " \"varbind_value\":\"ucsnmp heartbeat - ignore\" " - + " }, { " - + " \"varbind_type\":\"octet\", " - + " \"varbind_oid\":\".1.3.6.1.4.1.74.2.46.12.1.1.2\", " - + " \"varbind_value\":\"Tue Jan 16 10:49:01 EST 2018\" " - + " }] " - + "}"; - - String domain = ""; - - String mappingFileContent = "{" + " \"entries\" : [" - + " {" - + " \"priority\" : 1," - + " \"evaluation\" : {" - + " \"operand\" : \"STARTSWITH\"," - + " \"field\" : \"notify OID\"," - + " \"value\" : \".1.3.6.1.4.1.74\"," - + " \"datatype\" : \"STRING\"," - + " \"lhs\" : null," - + " \"rhs\" : null " - + " }," - + " \"result\" : \"snmp\"" - + " } " - + " ]" - + "}"; - MapperConfigUtils.readMapperConfigFile(mappingFileContent); - domain = adapterService.identifyEventTypeFromIncomingJson(inputJsonString); - adapterService.identifyEventTypeFromIncomingJson(inputJsonString); - - - assertEquals("snmp", domain); - } - /*@Test - public void testidentifyEventTypeFromIncomingJson() throws MapperConfigException{ - String inputJsonString = "{ " - + "\"protocol version\":\"v2c\", " - + "\"notify OID\":\".1.3.6.1.4.1.74.2.46.12.1.1AAA\", " - + "\"cambria.partition\":\"dcae-snmp.client.research.att.com\", " - + "\"trap category\":\"UCSNMP-HEARTBEAT\", " - + "\"epoch_serno\": 15161177410000, " - + "\"community\":\"public\", " - + "\"time received\": 1516117741, " - + "\"agent name\":\"localhost\", " - + "\"agent address\":\"127.0.0.1\", " - + "\"community len\": 6, " - + "\"notify OID len\": 12, " - + "\"varbinds\": [{ " - + " \"varbind_type\":\"octet\", " - + " \"varbind_oid\":\".1.3.6.1.4.1.74.2.46.12.1.1.1\", " - + " \"varbind_value\":\"ucsnmp heartbeat - ignore\" " - + " }, { " - + " \"varbind_type\":\"octet\", " - + " \"varbind_oid\":\".1.3.6.1.4.1.74.2.46.12.1.1.2\", " - + " \"varbind_value\":\"Tue Jan 16 10:49:01 EST 2018\" " - + " }] " - + "}"; -// when(MapperConfigUtils.checkIncomingJsonForMatchingDomain(inputJsonString)).thenReturn("snmp"); - String actualDomain=adapterService.identifyEventTypeFromIncomingJson(inputJsonString); - assertEquals("default", actualDomain); - }*/ - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java index 7183fc5..f238306 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= -*/ + package org.onap.universalvesadapter.service; import static org.junit.Assert.*; @@ -140,3 +140,4 @@ public class DMaapServiceTest { } +*/ \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java index 8af6270..a639c1f 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= -*/ + package org.onap.universalvesadapter.service; import static org.junit.Assert.assertEquals; @@ -78,3 +78,4 @@ public class DiskRepoConfigFileServiceTest { } } +*/ \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java deleted file mode 100644 index 70c4a1f..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java +++ /dev/null @@ -1,58 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.service; - -import static org.junit.Assert.*; - -import org.junit.Test; -import org.junit.runner.RunWith; -import org.onap.universalvesadapter.Application; -import org.onap.universalvesadapter.service.MongoDbConfigFileService; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.boot.test.context.SpringBootTest; -import org.springframework.test.context.junit4.SpringRunner; - -@RunWith(SpringRunner.class) -@SpringBootTest(classes=Application.class) -public class MongoDbConfigFileServiceTest { - - - private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); - - - @Autowired - private MongoDbConfigFileService mongoDbConfigFileService; - - @Test - public void testReadConfigFile() { - String configContent = " " - + " " - + " " - + " " - + ""; - - assertEquals(configContent, mongoDbConfigFileService.readConfigFile("sample.xml")); - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java index a0780c9..3ad47f0 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java @@ -16,7 +16,7 @@ * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= -*/ + package org.onap.universalvesadapter.service; import static org.junit.Assert.*; @@ -69,7 +69,7 @@ public class VesServiceTest { @Test - public void testStart() { + public void testStart() throws IOException { String[] incomingMessages = {"{ " + " \"protocol version \": \"v2c \", " @@ -94,14 +94,14 @@ public class VesServiceTest { + " }] " + "}"}; try { - Mockito.when(dmaapService.consumeFromDMaap()).thenReturn(Arrays.asList(incomingMessages)).thenReturn(() -> Collections.emptyIterator()); + // Mockito.when(dmaapService.fetchAndPublishInDMaaP(null,null)).thenReturn(Arrays.asList(incomingMessages)).thenReturn(() -> Collections.emptyIterator()); } catch (Exception e) { eLOGGER.error("Error occurred : " + e.getMessage()); } ArgumentCaptor valueCapture = ArgumentCaptor.forClass(String.class); try { - doNothing().when(dmaapService).publishToDMaap((String) valueCapture.capture()); + //doNothing().when(dmaapService).fetchAndPublishInDMaaP((String) valueCapture.capture()); } catch (DMaapException e) { eLOGGER.error("Error occurred : " + e.getMessage()); } @@ -141,3 +141,4 @@ public class VesServiceTest { } } +*/ \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/MapperConfigUtilsTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/MapperConfigUtilsTest.java index 85015da..c448908 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/MapperConfigUtilsTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/MapperConfigUtilsTest.java @@ -19,24 +19,13 @@ */ package org.onap.universalvesadapter.utils; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.verify; - -import java.util.Set; -import java.util.TreeSet; +import static org.junit.Assert.assertEquals; import org.junit.Test; import org.onap.universalvesadapter.exception.MapperConfigException; -import org.onap.universalvesadapter.mappingconfig.Entry; -import org.onap.universalvesadapter.mappingconfig.Evaluation; -import org.onap.universalvesadapter.mappingconfig.MapperConfig; -import org.onap.universalvesadapter.utils.MapperConfigUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import com.fasterxml.jackson.databind.JsonNode; - public class MapperConfigUtilsTest { private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java deleted file mode 100644 index 096f071..0000000 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/* -* ============LICENSE_START======================================================= -* ONAP : DCAE -* ================================================================================ -* Copyright 2018 TechMahindra -*================================================================================= -* 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.onap.universalvesadapter.utils; - -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.fail; - -import org.junit.Test; -import org.onap.universalvesadapter.utils.ParallelTasks; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -public class ParallelTasksTest { - - private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); - - @Test - public void testParallelTasks() { - - ParallelTasks tasks = new ParallelTasks(); - assertNotNull(tasks); - - } - - @Test - public void testAdd() { - - StringBuffer test = new StringBuffer() ; - ParallelTasks tasks = new ParallelTasks(); - tasks.add(() -> test.append("setHere")) ; - try { - tasks.startParallelTasks(); - } catch (InterruptedException e) { - eLOGGER.error("Error occurred : " + e.getMessage()); - } - assertNotNull("setHere", test.toString()); - - } - - @Test - public void testStartParallelTasks() { - StringBuffer test = new StringBuffer() ; - ParallelTasks tasks = new ParallelTasks(); - tasks.add(() -> test.append("setHere")) ; - tasks.add(() -> test.append("setHere")) ; - tasks.add(() -> test.append("setHere")) ; - try { - tasks.startParallelTasks(); - } catch (InterruptedException e) { - eLOGGER.error("Error occurred : " + e.getMessage()); - } - assertNotNull("setHeresetHeresetHere", test.toString()); - } - -} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/SmooksUtilsTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/SmooksUtilsTest.java index 41431f7..42974f6 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/SmooksUtilsTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/SmooksUtilsTest.java @@ -19,34 +19,17 @@ */ package org.onap.universalvesadapter.utils; -import static org.junit.Assert.*; -import static org.mockito.Mockito.mock; -import static org.mockito.Mockito.when; +import static org.junit.Assert.assertEquals; -import java.beans.beancontext.BeanContext; import java.io.ByteArrayInputStream; -import java.io.FileNotFoundException; -import java.io.FileReader; import java.io.IOException; import java.nio.charset.StandardCharsets; -import org.junit.Before; -import org.junit.BeforeClass; import org.junit.Test; -import org.junit.runner.RunWith; import org.milyn.Smooks; -import org.milyn.container.ExecutionContext; -import org.mockito.InjectMocks; -import org.mockito.Mock; -import org.mockito.MockitoAnnotations; -import org.mockito.junit.MockitoJUnitRunner; import org.onap.dcaegen2.ves.domain.VesEvent; -import org.onap.universalvesadapter.exception.MapperConfigException; -import org.onap.universalvesadapter.utils.SmooksUtils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import org.springframework.beans.factory.annotation.Value; -import org.springframework.util.FileCopyUtils; import org.xml.sax.SAXException; public class SmooksUtilsTest { -- cgit 1.2.3-korg