From 781b1a6df324419c846c84ea983c18fc8362bfd3 Mon Sep 17 00:00:00 2001 From: Patrick Brady Date: Wed, 13 Dec 2017 11:19:06 -0800 Subject: Third part of onap rename This part of the commit changes the folder structure on all other folders of appc. Change-Id: I8acfa11cdfcdcd36be0e137245d1dd7324f1abd3 Signed-off-by: Patrick Brady Issue-ID: APPC-13 --- .../org/onap/sdnc/dg/loader/DGLoaderActivator.java | 58 +++++++ .../org/onap/sdnc/dg/loader/DGXMLActivate.java | 133 +++++++++++++++ .../org/onap/sdnc/dg/loader/DGXMLGenerator.java | 128 ++++++++++++++ .../java/org/onap/sdnc/dg/loader/DGXMLLoad.java | 115 +++++++++++++ .../onap/sdnc/dg/loader/DGXMLLoadNActivate.java | 175 +++++++++++++++++++ .../sdnc/dg/loader/DGLoaderActivator.java | 58 ------- .../openecomp/sdnc/dg/loader/DGXMLActivate.java | 133 --------------- .../openecomp/sdnc/dg/loader/DGXMLGenerator.java | 128 -------------- .../org/openecomp/sdnc/dg/loader/DGXMLLoad.java | 115 ------------- .../sdnc/dg/loader/DGXMLLoadNActivate.java | 175 ------------------- .../java/org/onap/sdnc/dg/loader/DGLoaderTest.java | 188 +++++++++++++++++++++ .../org/onap/sdnc/dg/loader/MockDGXMLActivate.java | 35 ++++ .../org/onap/sdnc/dg/loader/MockDGXMLLoad.java | 37 ++++ .../sdnc/dg/loader/MockDGXMLLoadNActivate.java | 34 ++++ .../sdnc/dg/loader/MockSvcLogicDblibStore.java | 86 ++++++++++ .../onap/sdnc/dg/loader/MockSvcLogicFactory.java | 36 ++++ .../org/openecomp/sdnc/dg/loader/DGLoaderTest.java | 188 --------------------- .../sdnc/dg/loader/MockDGXMLActivate.java | 35 ---- .../openecomp/sdnc/dg/loader/MockDGXMLLoad.java | 37 ---- .../sdnc/dg/loader/MockDGXMLLoadNActivate.java | 34 ---- .../sdnc/dg/loader/MockSvcLogicDblibStore.java | 86 ---------- .../sdnc/dg/loader/MockSvcLogicFactory.java | 36 ---- 22 files changed, 1025 insertions(+), 1025 deletions(-) create mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java create mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java create mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java create mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java create mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java create mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/DGLoaderTest.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLActivate.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoad.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoadNActivate.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicDblibStore.java delete mode 100644 appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicFactory.java (limited to 'appc-directed-graph/dg-loader/provider') diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java new file mode 100644 index 000000000..99f7f8b6c --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGLoaderActivator.java @@ -0,0 +1,58 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import java.util.LinkedList; +import java.util.List; + +import org.osgi.framework.BundleActivator; +import org.osgi.framework.BundleContext; +import org.osgi.framework.ServiceRegistration; + +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; + +public class DGLoaderActivator implements BundleActivator{ + + private List registrations = new LinkedList(); + + + private static final EELFLogger log = EELFManager.getInstance().getLogger(DGLoaderActivator.class); + + @Override + public void start(BundleContext ctx) throws Exception + { + + + + } + @Override + public void stop(BundleContext arg0) throws Exception + { + for (ServiceRegistration registration: registrations) + { + registration.unregister(); + registration = null; + } + + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java new file mode 100644 index 000000000..6af447742 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivate.java @@ -0,0 +1,133 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + + +public class DGXMLActivate { + + private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); + private final SvcLogicStore store; + public static String STRING_ENCODING = "utf-8"; + + public DGXMLActivate(String propfile) throws Exception{ + if(StringUtils.isBlank(propfile)){ + throw new Exception(propfile + " Profile file is not defined"); + } + this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } + + protected DGXMLActivate(SvcLogicStore store) { + this.store = store; + } + + + public void activateDg(String activateFilePath) throws Exception { + logger.info("******************** Activating DG into Database *****************************"); + try { + List errors = new ArrayList(); + if(this.store != null){ + File activateFile = new File(activateFilePath); + if(activateFile != null && activateFile.isFile()){ + List fileLines = FileUtils.readLines(activateFile,STRING_ENCODING); + if(fileLines != null ){ + for (String line : fileLines) { + if(line != null && ! line.trim().startsWith("#")){ + String lineArray[] = line.trim().split(":"); + try { + if(lineArray != null && lineArray.length >= 4){ + String module = lineArray[0]; + String rpc = lineArray[1]; + String version = lineArray[2]; + String mode = lineArray[3]; + if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc) + && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){ + logger.info("Activating DG :" + line); + SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode); + if(graph != null){ + logger.info("Found Graph :" + line + " Activating ..."); + this.store.activate(graph); + }else{ + throw new Exception("Failed to fetch from Database"); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + errors.add("Failed to Activate "+line + ", "+e.getMessage()); + } + } + } + } + }else{ + throw new Exception(activateFile + " is not a valid Activate file Path"); + } + }else{ + throw new Exception("Failed to initialise SvcLogicStore"); + } + + if(errors.size() > 0){ + throw new Exception(errors.toString()); + } + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + + public static void main(String[] args) { + try { + String activateFile = null; + String propertyPath = null; + + if(args != null && args.length >= 2){ + activateFile = args[0]; + propertyPath = args[1]; + }else{ + throw new Exception("Sufficient inputs for DGXMLActivate are missing "); + } + + DGXMLActivate dgXmlActivate = new DGXMLActivate(propertyPath); + dgXmlActivate.activateDg(activateFile); + } catch (Exception e) { + e.printStackTrace(); + }finally { + System.exit(1); + } + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java new file mode 100644 index 000000000..60fcd5ba8 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLGenerator.java @@ -0,0 +1,128 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import javax.script.Invocable; +import javax.script.ScriptEngine; +import javax.script.ScriptEngineManager; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.io.IOUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + + +public class DGXMLGenerator { + private final static Logger logger = LoggerFactory.getLogger(DGXMLGenerator.class); + + public static String STRING_ENCODING = "utf-8"; + public static String JS_INTERFACE_DG_CONVERTOR = "dgconverter"; + public static String JS_METHOD_GET_NODE_TO_XML = "getNodeToXml"; + public static String GENERATOR_TEMPLATE_FILE = "js/dg_xml2json.js"; + + public void generateXMLFromJSON(String jsonPath, String xmlpath, String propertyPath) throws Exception { + try{ + ScriptEngineManager manager = new ScriptEngineManager(); + ScriptEngine engine = manager.getEngineByName("JavaScript"); + if (!(engine instanceof Invocable)) { + logger.error("Invoking methods is not supported."); + return; + } + Invocable inv = (Invocable) engine; + // engine.eval(new FileReader(DGXMLGenerator.class.getClassLoader().getResource(GENERATOR_TEMPLATE_FILE).getPath())); + String js = IOUtils.toString(DGXMLGenerator.class.getClassLoader().getResourceAsStream(GENERATOR_TEMPLATE_FILE),STRING_ENCODING); + engine.eval(js); + + Object dgconverter = engine.get(JS_INTERFACE_DG_CONVERTOR); + + List files = new ArrayList(); + if(dgconverter != null){ + File jsonPathFile = new File(jsonPath); + if(jsonPathFile.isDirectory()){ + String[] extensions = new String[] { "json", "JSON" }; + files = (List) FileUtils.listFiles(jsonPathFile, extensions, true); + }else if(jsonPathFile.isFile()){ + files.add(jsonPathFile); + }else{ + throw new Exception("Failed to get the nature of the JSON path :"+ jsonPath); + } + + logger.info("JSON Files identified "+ files.size()); + + if(files.size() > 0){ + boolean isXmlPathDeleted = FileUtils.deleteQuietly(new File(xmlpath)); + logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :" + isXmlPathDeleted); + + for (File file : files) { + String dgJson = FileUtils.readFileToString(file,STRING_ENCODING); + logger.info("Generating XML from :" + file.getName()); + String xmlFileName = xmlpath +"/"+file.getName().replace(".json", ".xml"); + + Object dgXMl = inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson); + // Write the XML File + if(dgXMl != null){ + File xmlFile = new File(xmlFileName); + FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING); + logger.info("Generated XML File under :" + xmlFile.getCanonicalPath()); + } + } + + }else{ + logger.info("No JSON Files to generate XML"); + } + }else{ + logger.error("Couldn't get Java Script Engine.."); + } + }catch (Exception e) { + logger.error("Failed to generate generateXMLFromJSON :"+e.getMessage()); + } + } + + + public static void main(String[] args) { + try { + DGXMLGenerator application = new DGXMLGenerator(); + String jsonPath = null; + String xmlPath = null; + String propertyPath = null; + // Generate, GenerateLoad, GenerateLoadActivate + //args = new String[]{"src/main/resources/json","src/test/resources/xml"}; + logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]); + if(args != null && args.length >= 2){ + jsonPath = args[0]; + xmlPath = args[1]; + }else{ + throw new Exception("Sufficient inputs are missing "); + } + + application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); + logger.info("DGXML Conversion Completed..."); + } catch (Exception e) { + logger.error("Failed in DG XML Generation :"+e.getMessage()); + e.printStackTrace(); + } + + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java new file mode 100644 index 000000000..1b6116cc3 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoad.java @@ -0,0 +1,115 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; + +public class DGXMLLoad { + private final static Logger logger = LoggerFactory.getLogger(DGXMLLoad.class); + private final SvcLogicStore store; + public static String STRING_ENCODING = "utf-8"; + + public DGXMLLoad(String propfile) throws Exception{ + if(StringUtils.isBlank(propfile)){ + throw new Exception(propfile + " Profile file is not defined"); + } + this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } + + protected DGXMLLoad(SvcLogicStore store) throws Exception { + this.store=store; + } + + public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{ + if(dgXMLpath != null ){ + SvcLogicParser.load(dgXMLpath, this.store); + } + } + + private void loadDGXMLDir(String xmlPath) throws Exception { + try { + logger.info("******************** Loading DG into Database *****************************"); + List errors = new ArrayList(); + if(this.store != null){ + File xmlDir = new File(xmlPath); + if(xmlDir != null && xmlDir.isDirectory()){ + String[] extensions = new String[] { "xml", "XML" }; + List files = (List) FileUtils.listFiles(xmlDir, extensions, true); + for (File file : files) { + logger.info("Loading DG XML file :" + file.getCanonicalPath()); + try{ + SvcLogicParser.load(file.getCanonicalPath(), this.store); + }catch (Exception e) { + errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage()); + } + } + }else{ + throw new Exception(xmlPath + " is not a valid XML Directory"); + } + }else{ + throw new Exception("Failed to initialise SvcLogicStore"); + } + + if(errors.size() > 0){ + throw new Exception(errors.toString()); + } + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + public static void main(String[] args) { + try { + String xmlPath = null; + String propertyPath = null; + + if(args != null && args.length >= 2){ + xmlPath = args[0]; + propertyPath = args[1]; + }else{ + throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing "); + } + DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath); + dgXMLLoadDB.loadDGXMLDir(xmlPath); + } catch (Exception e) { + e.printStackTrace(); + }finally { + System.exit(1); + } + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java new file mode 100644 index 000000000..54f109177 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoadNActivate.java @@ -0,0 +1,175 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APP-C + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; + +import org.apache.commons.io.FileUtils; +import org.apache.commons.lang.StringUtils; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicParser; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; + +public class DGXMLLoadNActivate { + private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); + private final SvcLogicStore store; + public static String STRING_ENCODING = "utf-8"; + + public DGXMLLoadNActivate(String propfile) throws Exception{ + if(StringUtils.isBlank(propfile)){ + throw new Exception(propfile + " Profile file is not defined"); + } + this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } + + protected DGXMLLoadNActivate(SvcLogicStore store) { + this.store=store; + } + + public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{ + if(dgXMLpath != null ){ + SvcLogicParser.load(dgXMLpath, this.store); + } + } + + private void loadDGXMLDir(String xmlPath) throws Exception { + try { + logger.info("******************** Loading DG into Database *****************************"); + List errors = new ArrayList(); + if(this.store != null){ + File xmlDir = new File(xmlPath); + if(xmlDir.isDirectory()){ + String[] extensions = new String[] { "xml", "XML" }; + List files = (List) FileUtils.listFiles(xmlDir, extensions, true); + for (File file : files) { + logger.info("Loading DG XML file :" + file.getCanonicalPath()); + try{ + SvcLogicParser.load(file.getCanonicalPath(), this.store); + }catch (Exception e) { + errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage()); + } + } + }else{ + throw new Exception(xmlPath + " is not a valid XML Directory"); + } + }else{ + throw new Exception("Failed to initialise SvcLogicStore"); + } + + if(errors.size() > 0){ + throw new Exception(errors.toString()); + } + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + public void activateDg(String activateFilePath) throws Exception { + logger.info("******************** Activating DG into Database *****************************"); + try { + List errors = new ArrayList(); + if(this.store != null){ + File activateFile = new File(activateFilePath); + if(activateFile.isFile()){ + List fileLines = FileUtils.readLines(activateFile,STRING_ENCODING); + if(fileLines != null ){ + for (String line : fileLines) { + if(line != null && ! line.trim().startsWith("#")){ + String lineArray[] = line.trim().split(":"); + try { + if(lineArray != null && lineArray.length >= 4){ + String module = lineArray[0]; + String rpc = lineArray[1]; + String version = lineArray[2]; + String mode = lineArray[3]; + if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc) + && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){ + logger.info("Activating DG :" + line); + SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode); + if(graph != null){ + logger.info("Found Graph :" + line + " Activating ..."); + this.store.activate(graph); + }else{ + throw new Exception("Failed to fetch from Database"); + } + } + } + } catch (Exception e) { + e.printStackTrace(); + errors.add("Failed to Activate "+line + ", "+e.getMessage()); + } + } + } + } + }else{ + throw new Exception(activateFile + " is not a valid Activate file Path"); + } + }else{ + throw new Exception("Failed to initialise SvcLogicStore"); + } + + if(errors.size() > 0){ + throw new Exception(errors.toString()); + } + } catch (Exception e) { + logger.error(e.getMessage()); + } + } + + + public static void main(String[] args) { + try { + String xmlPath = null; + String propertyPath = null; + String activateFile = null; + + if(args != null && args.length >= 3){ + xmlPath = args[0]; + activateFile = args[1]; + propertyPath = args[2]; + }else{ + throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing "); + } + + //propertyPath = "/Users/bs2796/0Source/ecomp/bvc-3.2.2/others/properties/dblib.properties"; + //xmlPath = DGXMLLoadNActivate.class.getClassLoader().getResource(".").getPath() +"/xml" ; + + DGXMLLoadNActivate dgXMLLoadDB = new DGXMLLoadNActivate(propertyPath); + dgXMLLoadDB.loadDGXMLDir(xmlPath); + dgXMLLoadDB.activateDg(activateFile); + } catch (Exception e) { + e.printStackTrace(); + }finally { + System.exit(1); + } + } +} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java deleted file mode 100644 index 99f7f8b6c..000000000 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGLoaderActivator.java +++ /dev/null @@ -1,58 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import java.util.LinkedList; -import java.util.List; - -import org.osgi.framework.BundleActivator; -import org.osgi.framework.BundleContext; -import org.osgi.framework.ServiceRegistration; - -import com.att.eelf.configuration.EELFLogger; -import com.att.eelf.configuration.EELFManager; - -public class DGLoaderActivator implements BundleActivator{ - - private List registrations = new LinkedList(); - - - private static final EELFLogger log = EELFManager.getInstance().getLogger(DGLoaderActivator.class); - - @Override - public void start(BundleContext ctx) throws Exception - { - - - - } - @Override - public void stop(BundleContext arg0) throws Exception - { - for (ServiceRegistration registration: registrations) - { - registration.unregister(); - registration = null; - } - - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java deleted file mode 100644 index 6af447742..000000000 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLActivate.java +++ /dev/null @@ -1,133 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - - -public class DGXMLActivate { - - private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); - private final SvcLogicStore store; - public static String STRING_ENCODING = "utf-8"; - - public DGXMLActivate(String propfile) throws Exception{ - if(StringUtils.isBlank(propfile)){ - throw new Exception(propfile + " Profile file is not defined"); - } - this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } - - protected DGXMLActivate(SvcLogicStore store) { - this.store = store; - } - - - public void activateDg(String activateFilePath) throws Exception { - logger.info("******************** Activating DG into Database *****************************"); - try { - List errors = new ArrayList(); - if(this.store != null){ - File activateFile = new File(activateFilePath); - if(activateFile != null && activateFile.isFile()){ - List fileLines = FileUtils.readLines(activateFile,STRING_ENCODING); - if(fileLines != null ){ - for (String line : fileLines) { - if(line != null && ! line.trim().startsWith("#")){ - String lineArray[] = line.trim().split(":"); - try { - if(lineArray != null && lineArray.length >= 4){ - String module = lineArray[0]; - String rpc = lineArray[1]; - String version = lineArray[2]; - String mode = lineArray[3]; - if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc) - && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){ - logger.info("Activating DG :" + line); - SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode); - if(graph != null){ - logger.info("Found Graph :" + line + " Activating ..."); - this.store.activate(graph); - }else{ - throw new Exception("Failed to fetch from Database"); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - errors.add("Failed to Activate "+line + ", "+e.getMessage()); - } - } - } - } - }else{ - throw new Exception(activateFile + " is not a valid Activate file Path"); - } - }else{ - throw new Exception("Failed to initialise SvcLogicStore"); - } - - if(errors.size() > 0){ - throw new Exception(errors.toString()); - } - } catch (Exception e) { - logger.error(e.getMessage()); - } - } - - - public static void main(String[] args) { - try { - String activateFile = null; - String propertyPath = null; - - if(args != null && args.length >= 2){ - activateFile = args[0]; - propertyPath = args[1]; - }else{ - throw new Exception("Sufficient inputs for DGXMLActivate are missing "); - } - - DGXMLActivate dgXmlActivate = new DGXMLActivate(propertyPath); - dgXmlActivate.activateDg(activateFile); - } catch (Exception e) { - e.printStackTrace(); - }finally { - System.exit(1); - } - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java deleted file mode 100644 index 60fcd5ba8..000000000 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLGenerator.java +++ /dev/null @@ -1,128 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import javax.script.Invocable; -import javax.script.ScriptEngine; -import javax.script.ScriptEngineManager; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.io.IOUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - - -public class DGXMLGenerator { - private final static Logger logger = LoggerFactory.getLogger(DGXMLGenerator.class); - - public static String STRING_ENCODING = "utf-8"; - public static String JS_INTERFACE_DG_CONVERTOR = "dgconverter"; - public static String JS_METHOD_GET_NODE_TO_XML = "getNodeToXml"; - public static String GENERATOR_TEMPLATE_FILE = "js/dg_xml2json.js"; - - public void generateXMLFromJSON(String jsonPath, String xmlpath, String propertyPath) throws Exception { - try{ - ScriptEngineManager manager = new ScriptEngineManager(); - ScriptEngine engine = manager.getEngineByName("JavaScript"); - if (!(engine instanceof Invocable)) { - logger.error("Invoking methods is not supported."); - return; - } - Invocable inv = (Invocable) engine; - // engine.eval(new FileReader(DGXMLGenerator.class.getClassLoader().getResource(GENERATOR_TEMPLATE_FILE).getPath())); - String js = IOUtils.toString(DGXMLGenerator.class.getClassLoader().getResourceAsStream(GENERATOR_TEMPLATE_FILE),STRING_ENCODING); - engine.eval(js); - - Object dgconverter = engine.get(JS_INTERFACE_DG_CONVERTOR); - - List files = new ArrayList(); - if(dgconverter != null){ - File jsonPathFile = new File(jsonPath); - if(jsonPathFile.isDirectory()){ - String[] extensions = new String[] { "json", "JSON" }; - files = (List) FileUtils.listFiles(jsonPathFile, extensions, true); - }else if(jsonPathFile.isFile()){ - files.add(jsonPathFile); - }else{ - throw new Exception("Failed to get the nature of the JSON path :"+ jsonPath); - } - - logger.info("JSON Files identified "+ files.size()); - - if(files.size() > 0){ - boolean isXmlPathDeleted = FileUtils.deleteQuietly(new File(xmlpath)); - logger.info("Cleaning old DG XML under : " + xmlpath + ", delete status :" + isXmlPathDeleted); - - for (File file : files) { - String dgJson = FileUtils.readFileToString(file,STRING_ENCODING); - logger.info("Generating XML from :" + file.getName()); - String xmlFileName = xmlpath +"/"+file.getName().replace(".json", ".xml"); - - Object dgXMl = inv.invokeMethod(dgconverter, JS_METHOD_GET_NODE_TO_XML, dgJson); - // Write the XML File - if(dgXMl != null){ - File xmlFile = new File(xmlFileName); - FileUtils.writeStringToFile(xmlFile, dgXMl.toString(), STRING_ENCODING); - logger.info("Generated XML File under :" + xmlFile.getCanonicalPath()); - } - } - - }else{ - logger.info("No JSON Files to generate XML"); - } - }else{ - logger.error("Couldn't get Java Script Engine.."); - } - }catch (Exception e) { - logger.error("Failed to generate generateXMLFromJSON :"+e.getMessage()); - } - } - - - public static void main(String[] args) { - try { - DGXMLGenerator application = new DGXMLGenerator(); - String jsonPath = null; - String xmlPath = null; - String propertyPath = null; - // Generate, GenerateLoad, GenerateLoadActivate - //args = new String[]{"src/main/resources/json","src/test/resources/xml"}; - logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]); - if(args != null && args.length >= 2){ - jsonPath = args[0]; - xmlPath = args[1]; - }else{ - throw new Exception("Sufficient inputs are missing "); - } - - application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); - logger.info("DGXML Conversion Completed..."); - } catch (Exception e) { - logger.error("Failed in DG XML Generation :"+e.getMessage()); - e.printStackTrace(); - } - - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java deleted file mode 100644 index 1b6116cc3..000000000 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoad.java +++ /dev/null @@ -1,115 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; - -public class DGXMLLoad { - private final static Logger logger = LoggerFactory.getLogger(DGXMLLoad.class); - private final SvcLogicStore store; - public static String STRING_ENCODING = "utf-8"; - - public DGXMLLoad(String propfile) throws Exception{ - if(StringUtils.isBlank(propfile)){ - throw new Exception(propfile + " Profile file is not defined"); - } - this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } - - protected DGXMLLoad(SvcLogicStore store) throws Exception { - this.store=store; - } - - public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{ - if(dgXMLpath != null ){ - SvcLogicParser.load(dgXMLpath, this.store); - } - } - - private void loadDGXMLDir(String xmlPath) throws Exception { - try { - logger.info("******************** Loading DG into Database *****************************"); - List errors = new ArrayList(); - if(this.store != null){ - File xmlDir = new File(xmlPath); - if(xmlDir != null && xmlDir.isDirectory()){ - String[] extensions = new String[] { "xml", "XML" }; - List files = (List) FileUtils.listFiles(xmlDir, extensions, true); - for (File file : files) { - logger.info("Loading DG XML file :" + file.getCanonicalPath()); - try{ - SvcLogicParser.load(file.getCanonicalPath(), this.store); - }catch (Exception e) { - errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage()); - } - } - }else{ - throw new Exception(xmlPath + " is not a valid XML Directory"); - } - }else{ - throw new Exception("Failed to initialise SvcLogicStore"); - } - - if(errors.size() > 0){ - throw new Exception(errors.toString()); - } - } catch (Exception e) { - logger.error(e.getMessage()); - } - } - - public static void main(String[] args) { - try { - String xmlPath = null; - String propertyPath = null; - - if(args != null && args.length >= 2){ - xmlPath = args[0]; - propertyPath = args[1]; - }else{ - throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing "); - } - DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath); - dgXMLLoadDB.loadDGXMLDir(xmlPath); - } catch (Exception e) { - e.printStackTrace(); - }finally { - System.exit(1); - } - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java deleted file mode 100644 index 54f109177..000000000 --- a/appc-directed-graph/dg-loader/provider/src/main/java/org/openecomp/sdnc/dg/loader/DGXMLLoadNActivate.java +++ /dev/null @@ -1,175 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APP-C - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - -import org.apache.commons.io.FileUtils; -import org.apache.commons.lang.StringUtils; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; - -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicParser; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; - -public class DGXMLLoadNActivate { - private final static Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); - private final SvcLogicStore store; - public static String STRING_ENCODING = "utf-8"; - - public DGXMLLoadNActivate(String propfile) throws Exception{ - if(StringUtils.isBlank(propfile)){ - throw new Exception(propfile + " Profile file is not defined"); - } - this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } - - protected DGXMLLoadNActivate(SvcLogicStore store) { - this.store=store; - } - - public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException{ - if(dgXMLpath != null ){ - SvcLogicParser.load(dgXMLpath, this.store); - } - } - - private void loadDGXMLDir(String xmlPath) throws Exception { - try { - logger.info("******************** Loading DG into Database *****************************"); - List errors = new ArrayList(); - if(this.store != null){ - File xmlDir = new File(xmlPath); - if(xmlDir.isDirectory()){ - String[] extensions = new String[] { "xml", "XML" }; - List files = (List) FileUtils.listFiles(xmlDir, extensions, true); - for (File file : files) { - logger.info("Loading DG XML file :" + file.getCanonicalPath()); - try{ - SvcLogicParser.load(file.getCanonicalPath(), this.store); - }catch (Exception e) { - errors.add("Failed to load XML "+file.getCanonicalPath() + ", Exception : "+e.getMessage()); - } - } - }else{ - throw new Exception(xmlPath + " is not a valid XML Directory"); - } - }else{ - throw new Exception("Failed to initialise SvcLogicStore"); - } - - if(errors.size() > 0){ - throw new Exception(errors.toString()); - } - } catch (Exception e) { - logger.error(e.getMessage()); - } - } - - public void activateDg(String activateFilePath) throws Exception { - logger.info("******************** Activating DG into Database *****************************"); - try { - List errors = new ArrayList(); - if(this.store != null){ - File activateFile = new File(activateFilePath); - if(activateFile.isFile()){ - List fileLines = FileUtils.readLines(activateFile,STRING_ENCODING); - if(fileLines != null ){ - for (String line : fileLines) { - if(line != null && ! line.trim().startsWith("#")){ - String lineArray[] = line.trim().split(":"); - try { - if(lineArray != null && lineArray.length >= 4){ - String module = lineArray[0]; - String rpc = lineArray[1]; - String version = lineArray[2]; - String mode = lineArray[3]; - if(StringUtils.isNotBlank(module) && StringUtils.isNotBlank(rpc) - && StringUtils.isNotBlank(version) && StringUtils.isNotBlank(mode)){ - logger.info("Activating DG :" + line); - SvcLogicGraph graph = this.store.fetch(module, rpc, version, mode); - if(graph != null){ - logger.info("Found Graph :" + line + " Activating ..."); - this.store.activate(graph); - }else{ - throw new Exception("Failed to fetch from Database"); - } - } - } - } catch (Exception e) { - e.printStackTrace(); - errors.add("Failed to Activate "+line + ", "+e.getMessage()); - } - } - } - } - }else{ - throw new Exception(activateFile + " is not a valid Activate file Path"); - } - }else{ - throw new Exception("Failed to initialise SvcLogicStore"); - } - - if(errors.size() > 0){ - throw new Exception(errors.toString()); - } - } catch (Exception e) { - logger.error(e.getMessage()); - } - } - - - public static void main(String[] args) { - try { - String xmlPath = null; - String propertyPath = null; - String activateFile = null; - - if(args != null && args.length >= 3){ - xmlPath = args[0]; - activateFile = args[1]; - propertyPath = args[2]; - }else{ - throw new Exception("Sufficient inputs for DGXMLLoadNActivate are missing "); - } - - //propertyPath = "/Users/bs2796/0Source/ecomp/bvc-3.2.2/others/properties/dblib.properties"; - //xmlPath = DGXMLLoadNActivate.class.getClassLoader().getResource(".").getPath() +"/xml" ; - - DGXMLLoadNActivate dgXMLLoadDB = new DGXMLLoadNActivate(propertyPath); - dgXMLLoadDB.loadDGXMLDir(xmlPath); - dgXMLLoadDB.activateDg(activateFile); - } catch (Exception e) { - e.printStackTrace(); - }finally { - System.exit(1); - } - } -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java new file mode 100644 index 000000000..084929bc7 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/DGLoaderTest.java @@ -0,0 +1,188 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import static org.junit.Assert.*; + +import java.io.File; +import java.util.ArrayList; +import java.util.List; +import java.util.Properties; + +import org.apache.commons.io.FileUtils; +import org.eclipse.osgi.framework.internal.core.BundleContextImpl; +import org.eclipse.osgi.framework.internal.core.BundleHost; +import org.junit.Rule; +import org.junit.Test; +import org.mockito.Mockito; +import org.onap.ccsdk.sli.core.sli.ConfigurationException; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.osgi.framework.BundleContext; +import org.powermock.reflect.Whitebox; +import org.powermock.*; + +public class DGLoaderTest { + + @Test + public void testXMLGenerator() throws Exception { + DGXMLGenerator application = new DGXMLGenerator(); + String jsonPath = null; + String xmlPath = null; + String propertyPath = "somePath"; + // Generate, GenerateLoad, GenerateLoadActivate + String []args = new String[]{"src/test/resources/json","src/test/resources/xml"}; + //logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]); + if(args != null && args.length >= 2){ + jsonPath = args[0]; + xmlPath = args[1]; + } + + application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); + File dir=new File("src/test/resources/xml"); + String extensions[]=new String[] {"xml","XML"}; + List files = new ArrayList(); + files=(List) FileUtils.listFiles(dir, extensions, true); + assertNotNull(files.get(0)); + assertNotNull(files.get(0).getName()); + } + + @Test + public void testXMLGeneratorMain() throws Exception { + String []args = new String[]{"src/test/resources/json","src/test/resources/xml"}; + DGXMLGenerator.main(args); + File dir=new File("src/test/resources/xml"); + String extensions[]=new String[] {"xml","XML"}; + List files = new ArrayList(); + files=(List) FileUtils.listFiles(dir, extensions, true); + assertNotNull(files.get(0)); + assertNotNull(files.get(0).getName()); + } + + @Test + public void testDGLoader() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; + DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); + dgXMLLoad.loadDGXMLFile(xmlPath); + } + + @Test + public void testDGLoaderWithDir() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String xmlPath = "src/test/resources/xml"; + DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); + Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath); + } + + @Test + public void testDGLoaderWithDirThrowsException() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String xmlPath = "src/test/resources/xml/xml"; + DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); + Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath); + } + + @Test + public void testDGActivate() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String activateFilePath = "src/test/resources/dg_activate_test"; + DGXMLActivate dgXMLActivate = new MockDGXMLActivate(); + dgXMLActivate.activateDg(activateFilePath); + + } + + @Test + public void testDGActivateThrowsException() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String activateFilePath = "src/test/resources/someFile"; + DGXMLActivate dgXMLActivate = new MockDGXMLActivate(); + dgXMLActivate.activateDg(activateFilePath); + + } + + @Test + public void testDGLoadNActivate() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String activateFilePath = "src/test/resources/dg_activate_test"; + String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; + DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); + dgXMLLoadNActivate.loadDGXMLFile(xmlPath); + dgXMLLoadNActivate.activateDg(activateFilePath); + } + + @Test + public void testDGLoadNActivateThrowsException() throws Exception { + String propertyPath = "src/test/resources/dummy.properties"; + String activateFilePath = "src/test/resources/someFile"; + String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; + DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); + dgXMLLoadNActivate.loadDGXMLFile(xmlPath); + dgXMLLoadNActivate.activateDg(activateFilePath); + } + + @Test + public void testDGLoadNActivateloadDGXMLDir() throws Exception { + String xmlPath = "src/test/resources/xml"; + DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); + Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath); + } + + + public void testDGLoadNActivateloadDGXMLDirThrowsException() throws Exception { + String xmlPath = "src/test/resources/someDir"; + DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); + Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath); + } + + @Test + public void testDGLoaderActivator() throws Exception { + String xmlPath = "src/test/resources/xml"; + DGLoaderActivator dgLoaderActivator = new DGLoaderActivator(); + dgLoaderActivator.start(null); + dgLoaderActivator.stop(null); + assertTrue(true); + } + + @Test (expected=Exception.class) + public void testDGActivateConstructorThrowsException() throws Exception { + String somePath=""; + DGXMLActivate dgXMLActivate = new DGXMLActivate(somePath); + } + + @Test (expected=Exception.class) + public void testDGXMLLoadConstructorThrowsException() throws Exception { + String somePath=""; + DGXMLLoad dgXMLLoad = new DGXMLLoad(somePath); + } + + @Test (expected=Exception.class) + public void testDGLoadNActivateConstructorThrowsException() throws Exception { + String somePath=""; + DGXMLLoadNActivate dgXMLLoadNActivate = new DGXMLLoadNActivate(somePath); + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java new file mode 100644 index 000000000..41f1d09f8 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLActivate.java @@ -0,0 +1,35 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; + +public class MockDGXMLActivate extends DGXMLActivate { + private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; + MockDGXMLActivate() throws Exception { + super(storeChild); + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java new file mode 100644 index 000000000..27336d38d --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoad.java @@ -0,0 +1,37 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import org.mockito.internal.util.reflection.Whitebox; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; + +public class MockDGXMLLoad extends DGXMLLoad{ + + private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; + MockDGXMLLoad() throws Exception { + super(storeChild); + } + +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java new file mode 100644 index 000000000..f60e6ab12 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.java @@ -0,0 +1,34 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; + +public class MockDGXMLLoadNActivate extends DGXMLLoadNActivate { + private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; + MockDGXMLLoadNActivate() throws Exception { + super(storeChild); + } +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java new file mode 100644 index 000000000..fdfe0ab1b --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicDblibStore.java @@ -0,0 +1,86 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import java.util.Properties; + +import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicException; +import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; + +public class MockSvcLogicDblibStore implements SvcLogicStore { + + @Override + public boolean hasGraph(String module, String rpc, String version, + String mode) { + return true; + } + @Override + public SvcLogicGraph fetch(String module, String rpc, String version, + String mode) throws SvcLogicException { + SvcLogicGraph retVal=new SvcLogicGraph(); + retVal.setMode("sync"); + retVal.setModule("Appc"); + retVal.setRpc("unitTestDG"); + retVal.setVersion("4.0.0"); + return retVal; + + } + @Override + public void store(SvcLogicGraph graph) throws SvcLogicException { + + } + @Override + public void init(Properties props) throws SvcLogicException { + // TODO Auto-generated method stub + + } + @Override + public void registerNodeType(String nodeType) throws SvcLogicException { + // TODO Auto-generated method stub + + } + @Override + public void unregisterNodeType(String nodeType) throws SvcLogicException { + // TODO Auto-generated method stub + + } + @Override + public boolean isValidNodeType(String nodeType) throws SvcLogicException { + // TODO Auto-generated method stub + return true; + } + @Override + public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { + // TODO Auto-generated method stub + + } + @Override + public void activate(SvcLogicGraph graph) throws SvcLogicException { + // TODO Auto-generated method stub + + } +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java new file mode 100644 index 000000000..82f75a0f8 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockSvcLogicFactory.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP : APPC + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Copyright (C) 2017 Amdocs + * ============================================================================= + * 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. + * + * ECOMP is a trademark and service mark of AT&T Intellectual Property. + * ============LICENSE_END========================================================= + */ + +package org.openecomp.sdnc.dg.loader; + +import org.onap.ccsdk.sli.core.sli.SvcLogicStore; +import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; +import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; + +public class MockSvcLogicFactory extends SvcLogicStoreFactory { + static SvcLogicStore getMockSvcLogicStore() { + SvcLogicStore store=new MockSvcLogicDblibStore(); + return store; + } +} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/DGLoaderTest.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/DGLoaderTest.java deleted file mode 100644 index 084929bc7..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/DGLoaderTest.java +++ /dev/null @@ -1,188 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import static org.junit.Assert.*; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; - -import org.apache.commons.io.FileUtils; -import org.eclipse.osgi.framework.internal.core.BundleContextImpl; -import org.eclipse.osgi.framework.internal.core.BundleHost; -import org.junit.Rule; -import org.junit.Test; -import org.mockito.Mockito; -import org.onap.ccsdk.sli.core.sli.ConfigurationException; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.osgi.framework.BundleContext; -import org.powermock.reflect.Whitebox; -import org.powermock.*; - -public class DGLoaderTest { - - @Test - public void testXMLGenerator() throws Exception { - DGXMLGenerator application = new DGXMLGenerator(); - String jsonPath = null; - String xmlPath = null; - String propertyPath = "somePath"; - // Generate, GenerateLoad, GenerateLoadActivate - String []args = new String[]{"src/test/resources/json","src/test/resources/xml"}; - //logger.info("DGXML Conversion Started with arguments :"+ args[0] +":"+ args[1]); - if(args != null && args.length >= 2){ - jsonPath = args[0]; - xmlPath = args[1]; - } - - application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); - File dir=new File("src/test/resources/xml"); - String extensions[]=new String[] {"xml","XML"}; - List files = new ArrayList(); - files=(List) FileUtils.listFiles(dir, extensions, true); - assertNotNull(files.get(0)); - assertNotNull(files.get(0).getName()); - } - - @Test - public void testXMLGeneratorMain() throws Exception { - String []args = new String[]{"src/test/resources/json","src/test/resources/xml"}; - DGXMLGenerator.main(args); - File dir=new File("src/test/resources/xml"); - String extensions[]=new String[] {"xml","XML"}; - List files = new ArrayList(); - files=(List) FileUtils.listFiles(dir, extensions, true); - assertNotNull(files.get(0)); - assertNotNull(files.get(0).getName()); - } - - @Test - public void testDGLoader() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; - DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); - dgXMLLoad.loadDGXMLFile(xmlPath); - } - - @Test - public void testDGLoaderWithDir() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String xmlPath = "src/test/resources/xml"; - DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); - Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath); - } - - @Test - public void testDGLoaderWithDirThrowsException() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String xmlPath = "src/test/resources/xml/xml"; - DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); - Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir",xmlPath); - } - - @Test - public void testDGActivate() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String activateFilePath = "src/test/resources/dg_activate_test"; - DGXMLActivate dgXMLActivate = new MockDGXMLActivate(); - dgXMLActivate.activateDg(activateFilePath); - - } - - @Test - public void testDGActivateThrowsException() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String activateFilePath = "src/test/resources/someFile"; - DGXMLActivate dgXMLActivate = new MockDGXMLActivate(); - dgXMLActivate.activateDg(activateFilePath); - - } - - @Test - public void testDGLoadNActivate() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String activateFilePath = "src/test/resources/dg_activate_test"; - String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; - DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); - dgXMLLoadNActivate.loadDGXMLFile(xmlPath); - dgXMLLoadNActivate.activateDg(activateFilePath); - } - - @Test - public void testDGLoadNActivateThrowsException() throws Exception { - String propertyPath = "src/test/resources/dummy.properties"; - String activateFilePath = "src/test/resources/someFile"; - String xmlPath = "src/test/resources/xml/Appc_UniTest.xml"; - DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); - dgXMLLoadNActivate.loadDGXMLFile(xmlPath); - dgXMLLoadNActivate.activateDg(activateFilePath); - } - - @Test - public void testDGLoadNActivateloadDGXMLDir() throws Exception { - String xmlPath = "src/test/resources/xml"; - DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); - Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath); - } - - - public void testDGLoadNActivateloadDGXMLDirThrowsException() throws Exception { - String xmlPath = "src/test/resources/someDir"; - DGXMLLoadNActivate dgXMLLoadNActivate = new MockDGXMLLoadNActivate(); - Whitebox.invokeMethod(dgXMLLoadNActivate,"loadDGXMLDir",xmlPath); - } - - @Test - public void testDGLoaderActivator() throws Exception { - String xmlPath = "src/test/resources/xml"; - DGLoaderActivator dgLoaderActivator = new DGLoaderActivator(); - dgLoaderActivator.start(null); - dgLoaderActivator.stop(null); - assertTrue(true); - } - - @Test (expected=Exception.class) - public void testDGActivateConstructorThrowsException() throws Exception { - String somePath=""; - DGXMLActivate dgXMLActivate = new DGXMLActivate(somePath); - } - - @Test (expected=Exception.class) - public void testDGXMLLoadConstructorThrowsException() throws Exception { - String somePath=""; - DGXMLLoad dgXMLLoad = new DGXMLLoad(somePath); - } - - @Test (expected=Exception.class) - public void testDGLoadNActivateConstructorThrowsException() throws Exception { - String somePath=""; - DGXMLLoadNActivate dgXMLLoadNActivate = new DGXMLLoadNActivate(somePath); - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLActivate.java deleted file mode 100644 index 41f1d09f8..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLActivate.java +++ /dev/null @@ -1,35 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; - -public class MockDGXMLActivate extends DGXMLActivate { - private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; - MockDGXMLActivate() throws Exception { - super(storeChild); - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoad.java deleted file mode 100644 index 27336d38d..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoad.java +++ /dev/null @@ -1,37 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import org.mockito.internal.util.reflection.Whitebox; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; - -public class MockDGXMLLoad extends DGXMLLoad{ - - private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; - MockDGXMLLoad() throws Exception { - super(storeChild); - } - -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoadNActivate.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoadNActivate.java deleted file mode 100644 index f60e6ab12..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockDGXMLLoadNActivate.java +++ /dev/null @@ -1,34 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; - -public class MockDGXMLLoadNActivate extends DGXMLLoadNActivate { - private final static SvcLogicStore storeChild=MockSvcLogicFactory.getMockSvcLogicStore();; - MockDGXMLLoadNActivate() throws Exception { - super(storeChild); - } -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicDblibStore.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicDblibStore.java deleted file mode 100644 index fdfe0ab1b..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicDblibStore.java +++ /dev/null @@ -1,86 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import java.util.Properties; - -import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicException; -import org.onap.ccsdk.sli.core.sli.SvcLogicGraph; -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; - -public class MockSvcLogicDblibStore implements SvcLogicStore { - - @Override - public boolean hasGraph(String module, String rpc, String version, - String mode) { - return true; - } - @Override - public SvcLogicGraph fetch(String module, String rpc, String version, - String mode) throws SvcLogicException { - SvcLogicGraph retVal=new SvcLogicGraph(); - retVal.setMode("sync"); - retVal.setModule("Appc"); - retVal.setRpc("unitTestDG"); - retVal.setVersion("4.0.0"); - return retVal; - - } - @Override - public void store(SvcLogicGraph graph) throws SvcLogicException { - - } - @Override - public void init(Properties props) throws SvcLogicException { - // TODO Auto-generated method stub - - } - @Override - public void registerNodeType(String nodeType) throws SvcLogicException { - // TODO Auto-generated method stub - - } - @Override - public void unregisterNodeType(String nodeType) throws SvcLogicException { - // TODO Auto-generated method stub - - } - @Override - public boolean isValidNodeType(String nodeType) throws SvcLogicException { - // TODO Auto-generated method stub - return true; - } - @Override - public void delete(String module, String rpc, String version, String mode) throws SvcLogicException { - // TODO Auto-generated method stub - - } - @Override - public void activate(SvcLogicGraph graph) throws SvcLogicException { - // TODO Auto-generated method stub - - } -} diff --git a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicFactory.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicFactory.java deleted file mode 100644 index 82f75a0f8..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/openecomp/sdnc/dg/loader/MockSvcLogicFactory.java +++ /dev/null @@ -1,36 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP : APPC - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Copyright (C) 2017 Amdocs - * ============================================================================= - * 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. - * - * ECOMP is a trademark and service mark of AT&T Intellectual Property. - * ============LICENSE_END========================================================= - */ - -package org.openecomp.sdnc.dg.loader; - -import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -import org.onap.ccsdk.sli.core.sli.SvcLogicStoreFactory; -import org.onap.ccsdk.sli.core.sli.SvcLogicDblibStore; - -public class MockSvcLogicFactory extends SvcLogicStoreFactory { - static SvcLogicStore getMockSvcLogicStore() { - SvcLogicStore store=new MockSvcLogicDblibStore(); - return store; - } -} -- cgit 1.2.3-korg