diff options
10 files changed, 219 insertions, 415 deletions
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 index 01f32d244..86bae9887 100644 --- 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 @@ -24,27 +24,24 @@ package org.onap.sdnc.dg.loader; +import com.att.eelf.configuration.EELFLogger; +import com.att.eelf.configuration.EELFManager; 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<ServiceRegistration> registrations = new LinkedList<ServiceRegistration>(); + private List<ServiceRegistration> registrations = new LinkedList<>(); private static final EELFLogger log = - EELFManager.getInstance().getLogger(DGLoaderActivator.class); + EELFManager.getInstance().getLogger(DGLoaderActivator.class); @Override public void start(BundleContext ctx) throws Exception { - - - } @Override @@ -53,7 +50,6 @@ public class DGLoaderActivator implements BundleActivator { 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 index 77415478a..104f5a2ea 100644 --- 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 @@ -9,119 +9,28 @@ * 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.onap.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.SvcLogicException; -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 static final Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); - private static final String STRING_ENCODING = "utf-8"; - private final SvcLogicStore store; - - public DGXMLActivate(String propfile) throws DGXMLException, SvcLogicException { - if (StringUtils.isBlank(propfile)) { - throw new DGXMLException(propfile + " Profile file is not defined"); - } - this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } - - protected DGXMLActivate(SvcLogicStore store) { - this.store = store; - } - - public void activateDg(String activateFilePath) { - logger.info( - "******************** Activating DG into Database *****************************"); - try { - List<String> errors = new ArrayList<>(); - if (this.store != null) { - File activateFile = new File(activateFilePath); - if (activateFile.isFile()) { - List<String> fileLines = FileUtils.readLines(activateFile, STRING_ENCODING); - tryActivateDG(errors, fileLines); - } else { - throw new DGXMLException(activateFile + " is not a valid Activate file Path"); - } - } else { - throw new DGXMLException("Failed to initialise SvcLogicStore"); - } - - if (errors.isEmpty()) { - throw new DGXMLException(errors.toString()); - } - } catch (Exception e) { - logger.error("Failed to activate DG", e); - } - } - - private void tryActivateDG(List<String> errors, List<String> fileLines) { - if (fileLines != null) { - for (String line : fileLines) { - if (line != null && !line.trim().startsWith("#")) { - String[] lineArray = line.trim().split(":"); - doActivateDG(errors, line, lineArray); - } - } - } - } - - private void doActivateDG(List<String> errors, String line, String[] lineArray) { - try { - if (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); - tryActivateStore(line, graph); - } - } - } catch (Exception e) { - logger.error("Failed to Activate " + line, e); - errors.add("Failed to Activate " + line + ", " + e.getMessage()); - } - } - - private void tryActivateStore(String line, SvcLogicGraph graph) throws SvcLogicException, DGXMLException { - if (graph != null) { - logger.info( - "Found Graph :" + line + " Activating ..."); - this.store.activate(graph); - } else { - throw new DGXMLException("Failed to fetch from Database"); - } - } + private static final Logger logger = LoggerFactory.getLogger(DGXMLActivate.class); + private DGXMLActivate(){} public static void main(String[] args) { try { @@ -136,8 +45,8 @@ public class DGXMLActivate { "Sufficient inputs for DGXMLActivate are missing <activatefile> <dbPropertyfile>"); } - DGXMLActivate dgXmlActivate = new DGXMLActivate(propertyPath); - dgXmlActivate.activateDg(activateFile); + DGXMLActivator activator = new DGXMLActivator(propertyPath); + activator.activateDg(activateFile); } catch (Exception e) { logger.error("Arguments missing", e); } finally { diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivator.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivator.java new file mode 100644 index 000000000..d5340f5b6 --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLActivator.java @@ -0,0 +1,101 @@ +package org.onap.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.SvcLogicException; +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 DGXMLActivator { + + private static final Logger logger = LoggerFactory.getLogger(DGXMLActivator.class); + private static final String STRING_ENCODING = "utf-8"; + private final SvcLogicStore store; + + public DGXMLActivator(String propertiesFile) throws DGXMLException, SvcLogicException { + if (StringUtils.isBlank(propertiesFile)) { + throw new DGXMLException(propertiesFile + " Profile file is not defined"); + } + this.store = SvcLogicStoreFactory.getSvcLogicStore(propertiesFile); + } + + protected DGXMLActivator(SvcLogicStore store) { + this.store = store; + } + + public void activateDg(String activateFilePath) { + logger.info( + "******************** Activating DG into Database *****************************"); + try { + List<String> errors = new ArrayList<>(); + if (this.store != null) { + File activateFile = new File(activateFilePath); + if (activateFile.isFile()) { + List<String> fileLines = FileUtils.readLines(activateFile, STRING_ENCODING); + tryActivateDG(errors, fileLines); + } else { + throw new DGXMLException(activateFile + " is not a valid Activate file Path"); + } + } else { + throw new DGXMLException("Failed to initialise SvcLogicStore"); + } + + if (errors.isEmpty()) { + throw new DGXMLException(errors.toString()); + } + } catch (Exception e) { + logger.error("Failed to activate DG", e); + } + } + + private void tryActivateDG(List<String> errors, List<String> fileLines) { + if (fileLines != null) { + for (String line : fileLines) { + if (line != null && !line.trim().startsWith("#")) { + String[] lineArray = line.trim().split(":"); + doActivateDG(errors, line, lineArray); + } + } + } + } + + private void doActivateDG(List<String> errors, String line, String[] lineArray) { + try { + if (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); + tryActivateStore(line, graph); + } + } + } catch (Exception e) { + logger.error("Failed to Activate " + line, e); + errors.add("Failed to Activate " + line + ", " + e.getMessage()); + } + } + + private void tryActivateStore(String line, SvcLogicGraph graph) throws SvcLogicException, DGXMLException { + if (graph != null) { + logger.info( + "Found Graph :" + line + " Activating ..."); + this.store.activate(graph); + } else { + throw new DGXMLException("Failed to fetch from Database"); + } + } + +} 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 index 0b072c4a5..5aaf8bb6d 100644 --- 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 @@ -24,87 +24,19 @@ package org.onap.sdnc.dg.loader; -import java.io.File; -import java.io.IOException; -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.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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DGXMLLoad { - private static final Logger logger = LoggerFactory.getLogger(DGXMLLoad.class); - public static final String STRING_ENCODING = "utf-8"; + private static final Logger logger = LoggerFactory.getLogger(DGXMLLoader.class); - private final SvcLogicStore store; - - public DGXMLLoad(String propfile) throws DGXMLException, SvcLogicException { - if (StringUtils.isBlank(propfile)) { - throw new DGXMLException(propfile + " Profile file is not defined"); - } - this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); - } - - protected DGXMLLoad(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) { - try { - logger.info( - "******************** Loading DG into Database *****************************"); - List<String> errors = new ArrayList<>(); - if (this.store != null) { - File xmlDir = new File(xmlPath); - if (xmlDir.isDirectory()) { - String[] extensions = new String[]{"xml", "XML"}; - List<File> files = (List<File>) FileUtils.listFiles(xmlDir, extensions, true); - tryLoadXmls(errors, files); - } else { - throw new DGXMLException(xmlPath + " is not a valid XML Directory"); - } - } else { - throw new DGXMLException("Failed to initialise SvcLogicStore"); - } - - if (!errors.isEmpty()) { - throw new DGXMLException(errors.toString()); - } - } catch (Exception e) { - logger.error("Failed to load DGXML directories", e); - } - } - - private void tryLoadXmls(List<String> errors, List<File> files) throws IOException { - for (File file : files) { - logger.info("Loading DG XML file :" + file.getCanonicalPath()); - try { - SvcLogicParser.load(file.getCanonicalPath(), store); - } catch (Exception e) { - logger.error("Failed to load XML " + file.getCanonicalPath(), e); - errors.add("Failed to load XML " + file.getCanonicalPath() - + ", Exception : " + e.getMessage()); - } - } - } + private DGXMLLoad(){} public static void main(String[] args) { try { String xmlPath; String propertyPath; - if (args != null && args.length >= 2) { xmlPath = args[0]; propertyPath = args[1]; @@ -112,10 +44,10 @@ public class DGXMLLoad { throw new DGXMLException( "Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <dbPropertyfile>"); } - DGXMLLoad dgXMLLoadDB = new DGXMLLoad(propertyPath); - dgXMLLoadDB.loadDGXMLDir(xmlPath); + DGXMLLoader loader = new DGXMLLoader(propertyPath); + loader.loadDGXMLDir(xmlPath); } catch (Exception e) { - logger.error("Arguments missing", e); + logger.error("Arguments missing", e); } 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 index 17fe9a57d..4b064c3c2 100644 --- 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 @@ -24,151 +24,14 @@ package org.onap.sdnc.dg.loader; -import java.io.File; -import java.io.IOException; -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.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; import org.slf4j.Logger; import org.slf4j.LoggerFactory; public class DGXMLLoadNActivate { private static final Logger logger = LoggerFactory.getLogger(DGXMLLoadNActivate.class); - private static final String STRING_ENCODING = "utf-8"; - - private final SvcLogicStore store; - - public DGXMLLoadNActivate(String propfile) throws DGXMLException, SvcLogicException { - if (StringUtils.isBlank(propfile)) { - throw new DGXMLException(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) { - try { - logger.info( - "******************** Loading DG into Database *****************************"); - List<String> errors = new ArrayList<>(); - if (this.store != null) { - File xmlDir = new File(xmlPath); - if (xmlDir.isDirectory()) { - String[] extensions = new String[]{"xml", "XML"}; - List<File> files = (List<File>) FileUtils.listFiles(xmlDir, extensions, true); - tryLoadXmls(errors, files); - } else { - throw new DGXMLException(xmlPath + " is not a valid XML Directory"); - } - } else { - throw new DGXMLException("Failed to initialise SvcLogicStore"); - } - - if (!errors.isEmpty()) { - throw new DGXMLException(errors.toString()); - } - } catch (Exception e) { - logger.error("Failed to load DGXML directories", e); - } - } - - private void tryLoadXmls(List<String> errors, List<File> files) throws IOException { - for (File file : files) { - logger.info("Loading DG XML file :" + file.getCanonicalPath()); - try { - SvcLogicParser.load(file.getCanonicalPath(), this.store); - } catch (Exception e) { - logger.error("Failed to load XML " + file.getCanonicalPath(), e); - errors.add("Failed to load XML " + file.getCanonicalPath() - + ", Exception : " + e.getMessage()); - } - } - } - - public void activateDg(String activateFilePath) { - logger.info( - "******************** Activating DG into Database *****************************"); - try { - List<String> errors = new ArrayList<>(); - if (this.store != null) { - File activateFile = new File(activateFilePath); - if (activateFile.isFile()) { - List<String> fileLines = FileUtils.readLines(activateFile, STRING_ENCODING); - tryActivateDG(errors, fileLines); - } else { - throw new DGXMLException(activateFile + " is not a valid Activate file Path"); - } - } else { - throw new DGXMLException("Failed to initialise SvcLogicStore"); - } - - if (!errors.isEmpty()) { - throw new DGXMLException(errors.toString()); - } - } catch (Exception e) { - logger.error("Failed to activade DG", e); - } - } - - private void tryActivateDG(List<String> errors, List<String> fileLines) { - if (fileLines != null) { - for (String line : fileLines) { - if (line != null && !line.trim().startsWith("#")) { - String[] lineArray = line.trim().split(":"); - doActivateDG(errors, line, lineArray); - } - } - } - } - - private void doActivateDG(List<String> errors, String line, String[] lineArray) { - 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); - tryActivateStore(line, graph); - } - } - } catch (Exception e) { - logger.error("Failed to Activate " + line, e); - errors.add("Failed to Activate " + line + ", " + e.getMessage()); - } - } - - private void tryActivateStore(String line, SvcLogicGraph graph) throws SvcLogicException, DGXMLException { - if (graph != null) { - logger.info("Found Graph :" + line + " Activating ..."); - store.activate(graph); - } else { - throw new DGXMLException("Failed to fetch from Database"); - } - } + private DGXMLLoadNActivate() {} public static void main(String[] args) { try { @@ -185,9 +48,12 @@ public class DGXMLLoadNActivate { "Sufficient inputs for DGXMLLoadNActivate are missing <xmlpath> <activatefile> <dbPropertyfile>"); } - DGXMLLoadNActivate dgXMLLoadDB = new DGXMLLoadNActivate(propertyPath); - dgXMLLoadDB.loadDGXMLDir(xmlPath); - dgXMLLoadDB.activateDg(activateFile); + DGXMLActivator activator = new DGXMLActivator(propertyPath); + DGXMLLoader loader = new DGXMLLoader(propertyPath); + + loader.loadDGXMLDir(xmlPath); + activator.activateDg(activateFile); + } catch (Exception e) { logger.error("Arguments missing", e); } finally { diff --git a/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoader.java b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoader.java new file mode 100644 index 000000000..c85b22d1a --- /dev/null +++ b/appc-directed-graph/dg-loader/provider/src/main/java/org/onap/sdnc/dg/loader/DGXMLLoader.java @@ -0,0 +1,78 @@ +package org.onap.sdnc.dg.loader; + +import java.io.File; +import java.io.IOException; +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.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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + +public class DGXMLLoader { + + private static final Logger logger = LoggerFactory.getLogger(DGXMLLoader.class); + public static final String STRING_ENCODING = "utf-8"; + + private final SvcLogicStore store; + + public DGXMLLoader(String propfile) throws DGXMLException, SvcLogicException { + if (StringUtils.isBlank(propfile)) { + throw new DGXMLException(propfile + " Profile file is not defined"); + } + this.store = SvcLogicStoreFactory.getSvcLogicStore(propfile); + } + + protected DGXMLLoader(SvcLogicStore store) { + this.store = store; + } + + public void loadDGXMLFile(String dgXMLpath) throws SvcLogicException { + if (dgXMLpath != null) { + SvcLogicParser.load(dgXMLpath, this.store); + } + } + + public void loadDGXMLDir(String xmlPath) { + try { + logger.info( + "******************** Loading DG into Database *****************************"); + List<String> errors = new ArrayList<>(); + if (this.store != null) { + File xmlDir = new File(xmlPath); + if (xmlDir.isDirectory()) { + String[] extensions = new String[]{"xml", "XML"}; + List<File> files = (List<File>) FileUtils.listFiles(xmlDir, extensions, true); + tryLoadXmls(errors, files); + } else { + throw new DGXMLException(xmlPath + " is not a valid XML Directory"); + } + } else { + throw new DGXMLException("Failed to initialise SvcLogicStore"); + } + + if (!errors.isEmpty()) { + throw new DGXMLException(errors.toString()); + } + } catch (Exception e) { + logger.error("Failed to load DGXML directories", e); + } + } + + private void tryLoadXmls(List<String> errors, List<File> files) throws IOException { + for (File file : files) { + logger.info("Loading DG XML file :" + file.getCanonicalPath()); + try { + SvcLogicParser.load(file.getCanonicalPath(), store); + } catch (Exception e) { + logger.error("Failed to load XML " + file.getCanonicalPath(), e); + errors.add("Failed to load XML " + file.getCanonicalPath() + + ", Exception : " + e.getMessage()); + } + } + } +} 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 index ea83213fc..a0ce3fac7 100644 --- 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 @@ -44,7 +44,7 @@ public class DGLoaderTest { // 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) { + if (args.length >= 2) { jsonPath = args[0]; xmlPath = args[1]; } @@ -52,8 +52,7 @@ public class DGLoaderTest { application.generateXMLFromJSON(jsonPath, xmlPath, propertyPath); File dir = new File("src/test/resources/xml"); String extensions[] = new String[] {"xml", "XML"}; - List<File> files = new ArrayList<File>(); - files = (List<File>) FileUtils.listFiles(dir, extensions, true); + List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true); assertNotNull(files.get(0)); assertNotNull(files.get(0).getName()); } @@ -64,8 +63,7 @@ public class DGLoaderTest { DGXMLGenerator.main(args); File dir = new File("src/test/resources/xml"); String extensions[] = new String[] {"xml", "XML"}; - List<File> files = new ArrayList<File>(); - files = (List<File>) FileUtils.listFiles(dir, extensions, true); + List<File> files = (List<File>) FileUtils.listFiles(dir, extensions, true); assertNotNull(files.get(0)); assertNotNull(files.get(0).getName()); } @@ -74,7 +72,7 @@ public class DGLoaderTest { 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(); + DGXMLLoader dgXMLLoad = new MockDGXMLLoader(); dgXMLLoad.loadDGXMLFile(xmlPath); } @@ -82,7 +80,7 @@ public class DGLoaderTest { public void testDGLoaderWithDir() throws Exception { String propertyPath = "src/test/resources/dummy.properties"; String xmlPath = "src/test/resources/xml"; - DGXMLLoad dgXMLLoad = new MockDGXMLLoad(); + DGXMLLoader dgXMLLoad = new MockDGXMLLoader(); Whitebox.invokeMethod(dgXMLLoad, "loadDGXMLDir", xmlPath); } @@ -90,16 +88,16 @@ public class DGLoaderTest { 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); + DGXMLLoader dgXMLLoader = new MockDGXMLLoader(); + Whitebox.invokeMethod(dgXMLLoader, "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); + DGXMLActivator dgXMLActivator = new MockDGXMLActivator(); + dgXMLActivator.activateDg(activateFilePath); } @@ -107,43 +105,9 @@ public class DGLoaderTest { 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); - - } + DGXMLActivator dgXMLActivator = new MockDGXMLActivator(); + dgXMLActivator.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 @@ -158,19 +122,12 @@ public class DGLoaderTest { @Test(expected = Exception.class) public void testDGActivateConstructorThrowsException() throws Exception { String somePath = ""; - DGXMLActivate dgXMLActivate = new DGXMLActivate(somePath); + DGXMLActivator dgXMLActivator = new DGXMLActivator(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); + DGXMLLoader dgXMLLoader = new DGXMLLoader(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/MockDGXMLActivator.java index 09de23285..4e0a74b17 100644 --- 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/MockDGXMLActivator.java @@ -26,10 +26,10 @@ package org.onap.sdnc.dg.loader; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -public class MockDGXMLActivate extends DGXMLActivate { +public class MockDGXMLActivator extends DGXMLActivator { private final static SvcLogicStore storeChild = MockSvcLogicFactory.getMockSvcLogicStore();; - MockDGXMLActivate() throws Exception { + MockDGXMLActivator() 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 deleted file mode 100644 index dd3590a78..000000000 --- a/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoadNActivate.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.onap.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/MockDGXMLLoad.java b/appc-directed-graph/dg-loader/provider/src/test/java/org/onap/sdnc/dg/loader/MockDGXMLLoader.java index bbca6af6d..37f1aa15f 100644 --- 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/MockDGXMLLoader.java @@ -26,11 +26,11 @@ package org.onap.sdnc.dg.loader; import org.onap.ccsdk.sli.core.sli.SvcLogicStore; -public class MockDGXMLLoad extends DGXMLLoad { +public class MockDGXMLLoader extends DGXMLLoader { private final static SvcLogicStore storeChild = MockSvcLogicFactory.getMockSvcLogicStore();; - MockDGXMLLoad() throws Exception { + MockDGXMLLoader() throws Exception { super(storeChild); } |