<version>2.9.4</version>
</dependency>
+
+<dependency>
+ <groupId>hsqldb</groupId>
+ <artifactId>hsqldb</artifactId>
+ <version>1.8.0.10</version>
+ <scope>test</scope>
+</dependency>
+
+<!-- https://mvnrepository.com/artifact/xalan/xalan -->
+<dependency>
+ <groupId>xalan</groupId>
+ <artifactId>xalan</artifactId>
+ <version>2.7.2</version>
+</dependency>
+
+<!-- https://mvnrepository.com/artifact/xerces/xercesImpl -->
+<dependency>
+ <groupId>xerces</groupId>
+ <artifactId>xercesImpl</artifactId>
+ <version>2.11.0-atlassian-01</version>
+</dependency>
+
+<!-- https://mvnrepository.com/artifact/com.thoughtworks.xstream/xstream -->
+<dependency>
+ <groupId>com.thoughtworks.xstream</groupId>
+ <artifactId>xstream</artifactId>
+ <version>1.4.10</version>
+</dependency>
+
+
</dependencies>
<properties>
}
if (null != evaluation.getOperand()) {
- if (EnumUtils.isValidEnum(JoinOperator.class, evaluation.getOperand())) {
+ if (MapperConfigUtils.isValidEnum(JoinOperator.class, evaluation.getOperand())) {
// if(JOIN_OPERATOR.contains(evaluation.getOperand())){
switch (JoinOperator.valueOf(evaluation.getOperand())) {
case AND:
}
}
- if (EnumUtils.isValidEnum(ExpressionOperator.class, evaluation.getOperand())) {
+ if (MapperConfigUtils.isValidEnum(ExpressionOperator.class, evaluation.getOperand())) {
// if(EXPR_OPERATOR.contains(evaluation.getOperand())){
// currently it is assumed field being compared is first level
if (null != field && null != evaluation.getDatatype() && actualObj.has(field)) {
switch (ExpressionOperator.valueOf(evaluation.getOperand())) {
case EQUALS:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
} else
return false;
case STARTSWITH:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
} else
return false;
case ENDSWITH:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
} else
return false;
case CONTAINS:
- if (EnumUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
+ if (MapperConfigUtils.isValidEnum(DataType.class, evaluation.getDatatype())) {
switch (DataType.valueOf(evaluation.getDatatype())) {
case STRING:
if (null != actualObj.get(field))
return false;
}
+ /**
+ * <p>Checks if the specified name is a valid enum for the class.</p>
+ *
+ * <p>This method differs from {@link Enum#valueOf} in that checks if the name is
+ * a valid enum without needing to catch the exception.</p>
+ *
+ * @param <E> the type of the enumeration
+ * @param enumClass the class of the enum to query, not null
+ * @param enumName the enum name, null returns false
+ * @return true if the enum name is valid, otherwise false
+ */
+
+ public static <E extends Enum<E>> boolean isValidEnum(final Class<E> enumClass, final String enumName) {
+ if (enumName == null) {
+ return false;
+ }
+ try {
+ Enum.valueOf(enumClass, enumName);
+ return true;
+ } catch (final IllegalArgumentException ex) {
+ return false;
+ }
+ }
+
}
logging.level.org.springframework.web=ERROR
logging.level.org.onap.universalvesadapter=DEBUG
-dmaap.url=http://localhost:8091/greeting
+dmaap.url=http://localhost:8080/greeting12
snmpTrap.configFile=snmpTrapToVes.xml
universal.configFiles=snmp:snmpTrapToVes.xml,default:defaultConfig.xml
fileService.url=http://localhost:8888/fileAsString/
messagesInBatch=1000
+messagesInTimeInterval=5000
+mapperConfig.file=D:/DCAE User Story/Commits/newwww/mapper/UniversalVesAdapter/src/main/resources/MapperConfig.json
dmaap.consumer_props=/src/main/resources/dme2/consumer.properties
-dmaap.publisher_props=/src/main/resources/dme2/publisher.properties
-server.port=8091
\ No newline at end of file
+dmaap.publisher_props=/src/main/resources/dme2/publisher.properties
\ No newline at end of file
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 {
--- /dev/null
+/*
+* ============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);
+
+
+ }
+
+}
--- /dev/null
+/*
+* ============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);
+ }
+
+}
--- /dev/null
+/*
+* ============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);
+
+ }
+
+}
* 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;
}
-*/
\ No newline at end of file
--- /dev/null
+/*
+* ============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);
+
+
+ }
+}
--- /dev/null
+/*
+* ============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);
+
+
+ }
+
+}
--- /dev/null
+/*
+* ============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);
+ }
+
+}
--- /dev/null
+/*
+* ============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);
+ }
+
+}
* 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;
@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\", "
+ "}";
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);
+ }
+
+}
* 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;
}
-*/
\ No newline at end of file
* 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;
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;
@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<String> fileDataEntity = new ResponseEntity<String>(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);
}
}
-}*/
+}
* limitations under the License.
* ============LICENSE_END=========================================================
*/
-/*package org.onap.universalvesadapter.service;
+package org.onap.universalvesadapter.service;
import static org.junit.Assert.*;
}
}
-*/
\ No newline at end of file
* 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;
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;
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 {
}
}
-*/
\ No newline at end of file
--- /dev/null
+/*
+* ============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());
+ }
+
+}