From 00a00a68862effd791ce3f127d0ddd5903598b89 Mon Sep 17 00:00:00 2001 From: Pooja03 Date: Wed, 28 Mar 2018 18:28:37 +0530 Subject: Added UniversalVesAdapter TestCases in the Mapper Adding remaining UniversalVesAdapter TestCases in Mapper Change-Id: Ic49bbbe2b4c4e242b1e91edfe565c7918e4b24e5 Issue-ID: DCAEGEN2-335 Signed-off-by: Pooja03 --- .../onap/dcaegen2/ves/domain/FaultFieldsTest.java | 2 +- .../configs/DMaapMrUrlConfigurationTest.java | 53 ++++++++++++++++ .../configs/DiskRepoConfigurationTest.java | 51 +++++++++++++++ .../configs/UniversalEventConfigurationTest.java | 48 +++++++++++++++ .../controller/VesControllerTest.java | 3 +- .../exception/ConfigFileReadExceptionTest.java | 34 ++++++++++ .../ConfigFileSmooksConversionExceptionTest.java | 37 +++++++++++ .../exception/DMaapExceptionTest.java | 32 ++++++++++ .../exception/MapperConfigExceptionTest.java | 32 ++++++++++ .../service/AdapterServiceTest.java | 66 ++++++++++++++++---- .../service/DMaapServiceTest.java | 3 +- .../service/DiskRepoConfigFileServiceTest.java | 29 ++++++--- .../service/MongoDbConfigFileServiceTest.java | 3 +- .../service/VesServiceTest.java | 6 +- .../utils/ParallelTasksTest.java | 72 ++++++++++++++++++++++ 15 files changed, 441 insertions(+), 30 deletions(-) create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/DMaapExceptionTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/MapperConfigExceptionTest.java create mode 100644 UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java (limited to 'UniversalVesAdapter/src/test/java/org/onap') diff --git a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/FaultFieldsTest.java b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/FaultFieldsTest.java index b77480c..89a6533 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/FaultFieldsTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/dcaegen2/ves/domain/FaultFieldsTest.java @@ -26,7 +26,7 @@ import java.util.List; import java.util.Map; import org.antlr.grammar.v3.ANTLRParser.action_return; -import org.apache.bcel.generic.NEW; +//import org.apache.bcel.generic.NEW; import org.junit.Test; public class FaultFieldsTest { diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java new file mode 100644 index 0000000..ac9274d --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DMaapMrUrlConfigurationTest.java @@ -0,0 +1,53 @@ +/* +* ============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("/src/main/resources/dme2/consumer.properties", actualdata1); + assertEquals("/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 new file mode 100644 index 0000000..4d42641 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/DiskRepoConfigurationTest.java @@ -0,0 +1,51 @@ +/* +* ============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 new file mode 100644 index 0000000..c79caa9 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/configs/UniversalEventConfigurationTest.java @@ -0,0 +1,48 @@ +/* +* ============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 786c22c..b35b7b4 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/controller/VesControllerTest.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.controller; +package org.onap.universalvesadapter.controller; import static org.junit.Assert.assertEquals; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -63,4 +63,3 @@ public class VesControllerTest { } -*/ \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java new file mode 100644 index 0000000..1d5307a --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileReadExceptionTest.java @@ -0,0 +1,34 @@ +/* +* ============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 new file mode 100644 index 0000000..2fda822 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/ConfigFileSmooksConversionExceptionTest.java @@ -0,0 +1,37 @@ +/* +* ============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 static org.junit.Assert.*; + +import org.junit.Test; + +public class ConfigFileSmooksConversionExceptionTest { + + + @Test + public void test() { + ConfigFileSmooksConversionException se = new ConfigFileSmooksConversionException("message"); + ConfigFileSmooksConversionException se1 = new ConfigFileSmooksConversionException("message", se); + + + } + +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/DMaapExceptionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/DMaapExceptionTest.java new file mode 100644 index 0000000..a99e6d1 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/DMaapExceptionTest.java @@ -0,0 +1,32 @@ +/* +* ============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 DMaapExceptionTest { + + @Test + public void test() { + DMaapException se = new DMaapException("message"); + DMaapException se1 = new DMaapException("message", se); + } + +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/MapperConfigExceptionTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/MapperConfigExceptionTest.java new file mode 100644 index 0000000..19dfd87 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/exception/MapperConfigExceptionTest.java @@ -0,0 +1,32 @@ +/* +* ============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 MapperConfigExceptionTest { + + @Test + public void test() { + MapperConfigException se = new MapperConfigException("message"); + MapperConfigException se1 = new MapperConfigException("message", se); + } + +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java index 4bdc7b5..720a7d1 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/AdapterServiceTest.java @@ -17,15 +17,21 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.service; +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; @@ -42,16 +48,25 @@ import org.springframework.util.FileCopyUtils; @SpringBootTest(classes=Application.class) public class AdapterServiceTest { - private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); +// private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); - @Autowired + @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() { + /* @Test + public void identifyEventTypeFromIncomingJson() throws MapperConfigException, FileNotFoundException, IOException { String inputJsonString = "{ " + "\"protocol version\":\"v2c\", " @@ -77,15 +92,42 @@ public class AdapterServiceTest { + "}"; String domain = ""; - try { + String mappingConfigFileData = FileCopyUtils.copyToString(new FileReader(mapperConfigFile)); MapperConfigUtils.readMapperConfigFile(mappingConfigFileData); domain = adapterService.identifyEventTypeFromIncomingJson(inputJsonString); - } catch (MapperConfigException | IOException exception) { - eLOGGER.error("Error occurred : ", exception ); - } + 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 7490dda..7183fc5 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DMaapServiceTest.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.service; +package org.onap.universalvesadapter.service; import static org.junit.Assert.*; import static org.mockito.Mockito.doNothing; @@ -140,4 +140,3 @@ 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 93c9e2f..8af6270 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/DiskRepoConfigFileServiceTest.java @@ -17,16 +17,17 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.service; +package org.onap.universalvesadapter.service; import static org.junit.Assert.assertEquals; -import static org.mockito.Mockito.when; - import java.net.URI; - +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; -import org.mockito.Matchers; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.mockito.Mockito; +import org.mockito.MockitoAnnotations; import org.onap.universalvesadapter.Application; import org.onap.universalvesadapter.exception.ConfigFileReadException; import org.onap.universalvesadapter.service.DiskRepoConfigFileService; @@ -34,7 +35,6 @@ 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.boot.test.mock.mockito.MockBean; import org.springframework.http.HttpStatus; import org.springframework.http.ResponseEntity; import org.springframework.test.context.junit4.SpringRunner; @@ -44,24 +44,37 @@ import org.springframework.web.client.RestTemplate; @SpringBootTest(classes = Application.class) public class DiskRepoConfigFileServiceTest { + @Mock + RestTemplate restTemplate; + + @InjectMocks @Autowired DiskRepoConfigFileService diskRepoConfigFileService; private final Logger eLOGGER = LoggerFactory.getLogger(this.getClass()); + + @Before + public void init() { + MockitoAnnotations.initMocks(this); + } + @Test public void testReadConfigFile() { String result = "test file"; + + ResponseEntity fileDataEntity = new ResponseEntity(result, HttpStatus.OK); + Mockito.when(restTemplate.getForEntity(Mockito.any(URI.class), Mockito.any(Class.class))).thenReturn(fileDataEntity); try { String readConfigFile = diskRepoConfigFileService.readConfigFile("testCase.xml"); assertEquals(result, readConfigFile); } catch (ConfigFileReadException exception) { - eLOGGER.error("Error occurred : ", exception ); + eLOGGER.error("Error occurred : ", exception); } } -}*/ +} diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java index ba70f05..70c4a1f 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/MongoDbConfigFileServiceTest.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.service; +package org.onap.universalvesadapter.service; import static org.junit.Assert.*; @@ -56,4 +56,3 @@ public class MongoDbConfigFileServiceTest { } } -*/ \ No newline at end of file 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 bc71834..a0780c9 100644 --- a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/service/VesServiceTest.java @@ -17,7 +17,7 @@ * limitations under the License. * ============LICENSE_END========================================================= */ -/*package org.onap.universalvesadapter.service; +package org.onap.universalvesadapter.service; import static org.junit.Assert.*; import static org.mockito.Mockito.doNothing; @@ -28,6 +28,7 @@ import java.util.Arrays; import java.util.Collections; import org.junit.Before; +import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.ArgumentCaptor; @@ -47,7 +48,7 @@ import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; import com.att.nsa.mr.client.MRConsumer; - +@Ignore @RunWith(SpringRunner.class) @SpringBootTest(classes = Application.class) public class VesServiceTest { @@ -140,4 +141,3 @@ public class VesServiceTest { } } -*/ \ No newline at end of file diff --git a/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java new file mode 100644 index 0000000..096f071 --- /dev/null +++ b/UniversalVesAdapter/src/test/java/org/onap/universalvesadapter/utils/ParallelTasksTest.java @@ -0,0 +1,72 @@ +/* +* ============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()); + } + +} -- cgit 1.2.3-korg