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/appc/tools/generator/api/CLI.java | 66 +++++++++++++ .../appc/tools/generator/api/ContextBuilder.java | 34 +++++++ .../onap/appc/tools/generator/api/MavenPlugin.java | 85 ++++++++++++++++ .../extensions/JsonContextBuilderImpl.java | 67 +++++++++++++ .../extensions/YangContextBuilderImpl.java | 97 +++++++++++++++++++ .../appc/tools/generator/impl/CodeGenWriter.java | 107 +++++++++++++++++++++ .../appc/tools/generator/impl/ModelGenerator.java | 71 ++++++++++++++ .../openecomp/appc/tools/generator/api/CLI.java | 66 ------------- .../appc/tools/generator/api/ContextBuilder.java | 34 ------- .../appc/tools/generator/api/MavenPlugin.java | 85 ---------------- .../extensions/JsonContextBuilderImpl.java | 67 ------------- .../extensions/YangContextBuilderImpl.java | 97 ------------------- .../appc/tools/generator/impl/CodeGenWriter.java | 107 --------------------- .../appc/tools/generator/impl/ModelGenerator.java | 71 -------------- .../org/onap/appc/tools/generator/api/CLITest.java | 57 +++++++++++ .../tools/generator/impl/CodeGenWriterTest.java | 22 +++++ .../appc/tools/generator/api/CLITest.java | 57 ----------- .../tools/generator/impl/CodeGenWriterTest.java | 22 ----- 18 files changed, 606 insertions(+), 606 deletions(-) create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/CLI.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/ContextBuilder.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/MavenPlugin.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/JsonContextBuilderImpl.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/YangContextBuilderImpl.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/CodeGenWriter.java create mode 100644 appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/ModelGenerator.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/ContextBuilder.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/MavenPlugin.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/JsonContextBuilderImpl.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/YangContextBuilderImpl.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/CodeGenWriter.java delete mode 100644 appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/ModelGenerator.java create mode 100644 appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/api/CLITest.java create mode 100644 appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/impl/CodeGenWriterTest.java delete mode 100644 appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java delete mode 100644 appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java (limited to 'appc-client/code-generator') diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/CLI.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/CLI.java new file mode 100644 index 000000000..e28b3706a --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/CLI.java @@ -0,0 +1,66 @@ +/*- + * ============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.appc.tools.generator.api; + +import org.onap.appc.tools.generator.impl.ModelGenerator; + +public class CLI { + public static void main(String... args) throws Exception { + String sourceFile = args[0]; + if(sourceFile == null) + throw new IllegalArgumentException("Source file is missing. Please add argument 'client '"); + + String destinationFile = args[1]; + if(destinationFile == null) + throw new IllegalArgumentException("Destination file name is missing. Please add argument 'client " + + sourceFile + + " '"); + + String templateFile = args[2]; + if(templateFile == null) + throw new IllegalArgumentException("template file name is missing. Please add argument 'client " + + sourceFile + + " "+destinationFile + + " '"); + + String builderName = args[3]; + if(builderName == null) + throw new IllegalArgumentException("builder FQDN is missing. Please add argument 'client " + + sourceFile + + " "+destinationFile + + " "+templateFile + + " '"); + String contextConfName = args[4]; + if(contextConfName == null) + throw new IllegalArgumentException("context conf file is missing. Please add argument 'client " + + sourceFile + + " "+destinationFile + + " "+templateFile + + " "+builderName + + " '"); + ModelGenerator generator = new ModelGenerator(); + generator.execute(sourceFile, destinationFile, templateFile, builderName, contextConfName); + } +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/ContextBuilder.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/ContextBuilder.java new file mode 100644 index 000000000..a1826f270 --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/ContextBuilder.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.onap.appc.tools.generator.api; + +import java.io.FileNotFoundException; +import java.io.IOException; +import java.util.Map; + +public interface ContextBuilder { + + Map buildContext(String sourceFile, String contextConf) throws IOException; +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/MavenPlugin.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/MavenPlugin.java new file mode 100644 index 000000000..9e160eed2 --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/api/MavenPlugin.java @@ -0,0 +1,85 @@ +/*- + * ============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.appc.tools.generator.api; + +import org.onap.appc.tools.generator.impl.ModelGenerator; +import org.apache.maven.plugin.AbstractMojo; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.apache.maven.plugins.annotations.LifecyclePhase; +import org.apache.maven.plugins.annotations.Mojo; +import org.apache.maven.plugins.annotations.Parameter; +import org.apache.maven.project.MavenProject; + +import java.io.IOException; +import java.nio.file.Paths; + +@Mojo( + name = "generate", + defaultPhase = LifecyclePhase.GENERATE_SOURCES +) +public class MavenPlugin extends AbstractMojo { + + @Parameter(property = "templateName", required = true) + private String templateName; + + @Parameter(property = "sourceFileName") + private String sourceFileName; + + @Parameter(property = "outputFileName") + private String outputFileName; + + @Parameter(property = "contextBuilderClassName", required = true) + private String contextBuilderClassName; + + @Parameter(property = "contextConfigFileName") + private String contextConfigFileName; + + @Parameter (property = "project") + private MavenProject project; + + @Override + public void execute() throws MojoExecutionException, MojoFailureException { + ModelGenerator generator = new ModelGenerator(); + try { + trace("\t === Called MavenPlugin on builder <" + contextBuilderClassName +">\n"); + generator.execute(sourceFileName,outputFileName,templateName,contextBuilderClassName,contextConfigFileName); + String workDirectory = getWorkDirectory(outputFileName); + project.addCompileSourceRoot(workDirectory); + } catch (Exception e) { + e.printStackTrace(); + throw new MojoExecutionException(e.getMessage()); + } + } + + private String getWorkDirectory(String outputFileName) throws IOException { + String workDirPath = Paths.get(outputFileName.toString()).getParent().toString(); + return workDirPath; + } + + private void trace(String message) { + getLog().info(message); + } +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/JsonContextBuilderImpl.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/JsonContextBuilderImpl.java new file mode 100644 index 000000000..6c408dd1d --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/JsonContextBuilderImpl.java @@ -0,0 +1,67 @@ +/*- + * ============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.appc.tools.generator.extensions; + +import org.onap.appc.tools.generator.api.ContextBuilder; +import com.fasterxml.jackson.databind.JsonNode; +import com.fasterxml.jackson.databind.ObjectMapper; +import com.fasterxml.jackson.databind.node.ObjectNode; + +import java.io.File; +import java.io.IOException; +import java.io.InputStream; +import java.util.HashMap; +import java.util.Map; +import java.util.Properties; + +public class JsonContextBuilderImpl implements ContextBuilder { + + @Override + public Map buildContext(String sourceFile, String contextConf) throws IOException { + //read json file + ObjectMapper mapper = new ObjectMapper(); + JsonNode model = mapper.readTree(new File(sourceFile)); + + //get context config file + Properties properties = new Properties(); + ClassLoader classloader = Thread.currentThread().getContextClassLoader(); + InputStream inputStream = classloader.getResourceAsStream(contextConf); + properties.load(inputStream); + + //get context related properties + ObjectNode metadata = mapper.createObjectNode(); + for (String key : properties.stringPropertyNames()) { + if (key.startsWith("ctx")) { + metadata.put(key.replaceFirst("ctx.", ""), properties.getProperty(key)); + } + } + + //create context and populate it + Map map = new HashMap<>(); + map.put("model", model); + map.put("metadata", metadata); + return map; + } +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/YangContextBuilderImpl.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/YangContextBuilderImpl.java new file mode 100644 index 000000000..67055c757 --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/extensions/YangContextBuilderImpl.java @@ -0,0 +1,97 @@ +/*- + * ============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.appc.tools.generator.extensions; + +import org.onap.appc.tools.generator.api.ContextBuilder; +import com.google.common.base.Optional; + +import org.opendaylight.yangtools.yang.model.api.Module; +import org.opendaylight.yangtools.yang.model.api.SchemaContext; +import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; +import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException; +import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver; +import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl; + +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.util.Map; +import java.util.HashMap; +import java.util.Set; + +public class YangContextBuilderImpl implements ContextBuilder { + + @Override + public Map buildContext(String sourceFile, String contextConf) throws FileNotFoundException { + try ( InputStream source = new FileInputStream(sourceFile) ) {} + catch ( IOException ex) { + throw new FileNotFoundException("YANG file <" + sourceFile + ">not found"); + } + + Optional sc = null; + try ( YangTextSchemaContextResolver yangContextResolver = + YangTextSchemaContextResolver.create("yang-context-resolver")) { + yangContextResolver.registerSource(new URL("file:///" + sourceFile)); + sc = yangContextResolver.getSchemaContext(); + } catch (SchemaSourceException | IOException | YangSyntaxErrorException e) { + e.printStackTrace(); + } + + Map map = new HashMap<>(); + if ( null != sc && sc.isPresent()) { + Set modules = sc.get().getModules(); + for (Module module : modules) { + ModuleEffectiveStatementImpl impl = (ModuleEffectiveStatementImpl) module; + map.put("module", module); + } + } + + return map; + } + + // @Override + // public Map buildContext(String sourceFile, String + // contextConf) throws FileNotFoundException { + // InputStream source = new FileInputStream(sourceFile); + // if (source == null) { + // throw new FileNotFoundException("YANG file <" + sourceFile + ">not found"); + // } + // + // SchemaContext mSchema = parse(Collections.singletonList(source)); + // + // Map map = new HashMap<>(); + // map.put("module", mSchema.getModules().iterator().next()); + // return map; + // } + // + // private SchemaContext parse(List sources) { + // YangParserImpl parser = new YangParserImpl(); + // Set modules = parser.parseYangModelsFromStreams(sources); + // return parser.resolveSchemaContext(modules); + // } + +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/CodeGenWriter.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/CodeGenWriter.java new file mode 100644 index 000000000..347c24c06 --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/CodeGenWriter.java @@ -0,0 +1,107 @@ +/*- + * ============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.appc.tools.generator.impl; + +import java.io.*; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +class CodeGenWriter extends Writer { + + private FileWriter fileWriter; + private boolean delimiterBeginFound; + private Path basePath; + private String outPath; + private boolean deleteFile; + private static final String DELIMITER = "__"; + private Pattern pattern; + + + CodeGenWriter(String destination) throws IOException { + super(destination); + fileWriter = new FileWriter(destination); + basePath = Paths.get(destination); + delimiterBeginFound = false; + outPath = ""; + deleteFile = false; + pattern = Pattern.compile(DELIMITER); + } + + @Override + public void write(char[] cbuf, int off, int len) throws IOException { + String bufferStr = new String(cbuf).substring(off, off + len); + Matcher matcher = pattern.matcher(bufferStr); + + boolean isMatch = matcher.find(); + if (!isMatch) { + if (!delimiterBeginFound) { + fileWriter.write(cbuf, off, len); + } + else { + outPath += bufferStr; + } + } + else { + if (!delimiterBeginFound) { + delimiterBeginFound = true; + } + else { + deleteFile = true; + Path fileName = getNewFileName(); + Files.createDirectories(fileName.getParent()); + openNewFileWriter(fileName.toString()); + delimiterBeginFound = false; + outPath = ""; + } + } + } + + @Override + public void flush() throws IOException { + fileWriter.flush(); + } + + @Override + public void close() throws IOException { + fileWriter.close(); + if (deleteFile) { + Files.deleteIfExists(basePath); + } + } + + private Path getNewFileName() { + String newRelativePath = this.outPath.replace(".", File.separator); + return Paths.get(basePath.getParent().toString(), newRelativePath + ".java"); + } + + private void openNewFileWriter(String fileName) throws IOException { + flush(); + close(); + fileWriter = new FileWriter(fileName); + } +} diff --git a/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/ModelGenerator.java b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/ModelGenerator.java new file mode 100644 index 000000000..2275fdac7 --- /dev/null +++ b/appc-client/code-generator/src/main/java/org/onap/appc/tools/generator/impl/ModelGenerator.java @@ -0,0 +1,71 @@ +/*- + * ============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.appc.tools.generator.impl; + +import org.onap.appc.tools.generator.api.ContextBuilder; +import freemarker.template.Configuration; +import freemarker.template.Template; +import freemarker.template.TemplateException; + +import java.io.IOException; +import java.io.Writer; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Map; + +public class ModelGenerator { + + public void execute(String sourceFile, String destinationFile, String templateFile, String builderName, String contextConfName) throws IOException, ReflectiveOperationException { + + ContextBuilder contextBuilder = (ContextBuilder) Class.forName(builderName).newInstance(); + Map context = contextBuilder.buildContext(sourceFile, contextConfName); + + Path destinationPath = Paths.get(destinationFile); + if (!Files.isDirectory(destinationPath)) + Files.createDirectories(destinationPath.getParent()); + else { + Files.createDirectories(destinationPath); + } + + this.generate(context, templateFile, destinationFile); + System.out.println("\tFile <" + destinationFile + "> prepared successfully"); + } + + private void generate(Map context, String templateFile, String destinationFile) throws ReflectiveOperationException { + try { + Configuration cfg = new Configuration(Configuration.VERSION_2_3_23); + cfg.setClassForTemplateLoading(ModelGenerator.class, "/"); + Template template = cfg.getTemplate(templateFile); + + Writer out = new CodeGenWriter(destinationFile); + template.process(context, out); + out.close(); + } catch (IOException | TemplateException e) { + throw new RuntimeException("Failed to generate file from template <" + templateFile + ">", e); + } + } + +} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java deleted file mode 100644 index e28b3706a..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/CLI.java +++ /dev/null @@ -1,66 +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.appc.tools.generator.api; - -import org.onap.appc.tools.generator.impl.ModelGenerator; - -public class CLI { - public static void main(String... args) throws Exception { - String sourceFile = args[0]; - if(sourceFile == null) - throw new IllegalArgumentException("Source file is missing. Please add argument 'client '"); - - String destinationFile = args[1]; - if(destinationFile == null) - throw new IllegalArgumentException("Destination file name is missing. Please add argument 'client " - + sourceFile - + " '"); - - String templateFile = args[2]; - if(templateFile == null) - throw new IllegalArgumentException("template file name is missing. Please add argument 'client " - + sourceFile - + " "+destinationFile - + " '"); - - String builderName = args[3]; - if(builderName == null) - throw new IllegalArgumentException("builder FQDN is missing. Please add argument 'client " - + sourceFile - + " "+destinationFile - + " "+templateFile - + " '"); - String contextConfName = args[4]; - if(contextConfName == null) - throw new IllegalArgumentException("context conf file is missing. Please add argument 'client " - + sourceFile - + " "+destinationFile - + " "+templateFile - + " "+builderName - + " '"); - ModelGenerator generator = new ModelGenerator(); - generator.execute(sourceFile, destinationFile, templateFile, builderName, contextConfName); - } -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/ContextBuilder.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/ContextBuilder.java deleted file mode 100644 index a1826f270..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/ContextBuilder.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.onap.appc.tools.generator.api; - -import java.io.FileNotFoundException; -import java.io.IOException; -import java.util.Map; - -public interface ContextBuilder { - - Map buildContext(String sourceFile, String contextConf) throws IOException; -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/MavenPlugin.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/MavenPlugin.java deleted file mode 100644 index 9e160eed2..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/api/MavenPlugin.java +++ /dev/null @@ -1,85 +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.appc.tools.generator.api; - -import org.onap.appc.tools.generator.impl.ModelGenerator; -import org.apache.maven.plugin.AbstractMojo; -import org.apache.maven.plugin.MojoExecutionException; -import org.apache.maven.plugin.MojoFailureException; -import org.apache.maven.plugins.annotations.LifecyclePhase; -import org.apache.maven.plugins.annotations.Mojo; -import org.apache.maven.plugins.annotations.Parameter; -import org.apache.maven.project.MavenProject; - -import java.io.IOException; -import java.nio.file.Paths; - -@Mojo( - name = "generate", - defaultPhase = LifecyclePhase.GENERATE_SOURCES -) -public class MavenPlugin extends AbstractMojo { - - @Parameter(property = "templateName", required = true) - private String templateName; - - @Parameter(property = "sourceFileName") - private String sourceFileName; - - @Parameter(property = "outputFileName") - private String outputFileName; - - @Parameter(property = "contextBuilderClassName", required = true) - private String contextBuilderClassName; - - @Parameter(property = "contextConfigFileName") - private String contextConfigFileName; - - @Parameter (property = "project") - private MavenProject project; - - @Override - public void execute() throws MojoExecutionException, MojoFailureException { - ModelGenerator generator = new ModelGenerator(); - try { - trace("\t === Called MavenPlugin on builder <" + contextBuilderClassName +">\n"); - generator.execute(sourceFileName,outputFileName,templateName,contextBuilderClassName,contextConfigFileName); - String workDirectory = getWorkDirectory(outputFileName); - project.addCompileSourceRoot(workDirectory); - } catch (Exception e) { - e.printStackTrace(); - throw new MojoExecutionException(e.getMessage()); - } - } - - private String getWorkDirectory(String outputFileName) throws IOException { - String workDirPath = Paths.get(outputFileName.toString()).getParent().toString(); - return workDirPath; - } - - private void trace(String message) { - getLog().info(message); - } -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/JsonContextBuilderImpl.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/JsonContextBuilderImpl.java deleted file mode 100644 index 6c408dd1d..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/JsonContextBuilderImpl.java +++ /dev/null @@ -1,67 +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.appc.tools.generator.extensions; - -import org.onap.appc.tools.generator.api.ContextBuilder; -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ObjectNode; - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Properties; - -public class JsonContextBuilderImpl implements ContextBuilder { - - @Override - public Map buildContext(String sourceFile, String contextConf) throws IOException { - //read json file - ObjectMapper mapper = new ObjectMapper(); - JsonNode model = mapper.readTree(new File(sourceFile)); - - //get context config file - Properties properties = new Properties(); - ClassLoader classloader = Thread.currentThread().getContextClassLoader(); - InputStream inputStream = classloader.getResourceAsStream(contextConf); - properties.load(inputStream); - - //get context related properties - ObjectNode metadata = mapper.createObjectNode(); - for (String key : properties.stringPropertyNames()) { - if (key.startsWith("ctx")) { - metadata.put(key.replaceFirst("ctx.", ""), properties.getProperty(key)); - } - } - - //create context and populate it - Map map = new HashMap<>(); - map.put("model", model); - map.put("metadata", metadata); - return map; - } -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/YangContextBuilderImpl.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/YangContextBuilderImpl.java deleted file mode 100644 index 67055c757..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/extensions/YangContextBuilderImpl.java +++ /dev/null @@ -1,97 +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.appc.tools.generator.extensions; - -import org.onap.appc.tools.generator.api.ContextBuilder; -import com.google.common.base.Optional; - -import org.opendaylight.yangtools.yang.model.api.Module; -import org.opendaylight.yangtools.yang.model.api.SchemaContext; -import org.opendaylight.yangtools.yang.model.parser.api.YangSyntaxErrorException; -import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceException; -import org.opendaylight.yangtools.yang.parser.repo.YangTextSchemaContextResolver; -import org.opendaylight.yangtools.yang.parser.stmt.rfc6020.effective.ModuleEffectiveStatementImpl; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.util.Map; -import java.util.HashMap; -import java.util.Set; - -public class YangContextBuilderImpl implements ContextBuilder { - - @Override - public Map buildContext(String sourceFile, String contextConf) throws FileNotFoundException { - try ( InputStream source = new FileInputStream(sourceFile) ) {} - catch ( IOException ex) { - throw new FileNotFoundException("YANG file <" + sourceFile + ">not found"); - } - - Optional sc = null; - try ( YangTextSchemaContextResolver yangContextResolver = - YangTextSchemaContextResolver.create("yang-context-resolver")) { - yangContextResolver.registerSource(new URL("file:///" + sourceFile)); - sc = yangContextResolver.getSchemaContext(); - } catch (SchemaSourceException | IOException | YangSyntaxErrorException e) { - e.printStackTrace(); - } - - Map map = new HashMap<>(); - if ( null != sc && sc.isPresent()) { - Set modules = sc.get().getModules(); - for (Module module : modules) { - ModuleEffectiveStatementImpl impl = (ModuleEffectiveStatementImpl) module; - map.put("module", module); - } - } - - return map; - } - - // @Override - // public Map buildContext(String sourceFile, String - // contextConf) throws FileNotFoundException { - // InputStream source = new FileInputStream(sourceFile); - // if (source == null) { - // throw new FileNotFoundException("YANG file <" + sourceFile + ">not found"); - // } - // - // SchemaContext mSchema = parse(Collections.singletonList(source)); - // - // Map map = new HashMap<>(); - // map.put("module", mSchema.getModules().iterator().next()); - // return map; - // } - // - // private SchemaContext parse(List sources) { - // YangParserImpl parser = new YangParserImpl(); - // Set modules = parser.parseYangModelsFromStreams(sources); - // return parser.resolveSchemaContext(modules); - // } - -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/CodeGenWriter.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/CodeGenWriter.java deleted file mode 100644 index 347c24c06..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/CodeGenWriter.java +++ /dev/null @@ -1,107 +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.appc.tools.generator.impl; - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - -class CodeGenWriter extends Writer { - - private FileWriter fileWriter; - private boolean delimiterBeginFound; - private Path basePath; - private String outPath; - private boolean deleteFile; - private static final String DELIMITER = "__"; - private Pattern pattern; - - - CodeGenWriter(String destination) throws IOException { - super(destination); - fileWriter = new FileWriter(destination); - basePath = Paths.get(destination); - delimiterBeginFound = false; - outPath = ""; - deleteFile = false; - pattern = Pattern.compile(DELIMITER); - } - - @Override - public void write(char[] cbuf, int off, int len) throws IOException { - String bufferStr = new String(cbuf).substring(off, off + len); - Matcher matcher = pattern.matcher(bufferStr); - - boolean isMatch = matcher.find(); - if (!isMatch) { - if (!delimiterBeginFound) { - fileWriter.write(cbuf, off, len); - } - else { - outPath += bufferStr; - } - } - else { - if (!delimiterBeginFound) { - delimiterBeginFound = true; - } - else { - deleteFile = true; - Path fileName = getNewFileName(); - Files.createDirectories(fileName.getParent()); - openNewFileWriter(fileName.toString()); - delimiterBeginFound = false; - outPath = ""; - } - } - } - - @Override - public void flush() throws IOException { - fileWriter.flush(); - } - - @Override - public void close() throws IOException { - fileWriter.close(); - if (deleteFile) { - Files.deleteIfExists(basePath); - } - } - - private Path getNewFileName() { - String newRelativePath = this.outPath.replace(".", File.separator); - return Paths.get(basePath.getParent().toString(), newRelativePath + ".java"); - } - - private void openNewFileWriter(String fileName) throws IOException { - flush(); - close(); - fileWriter = new FileWriter(fileName); - } -} diff --git a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/ModelGenerator.java b/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/ModelGenerator.java deleted file mode 100644 index 2275fdac7..000000000 --- a/appc-client/code-generator/src/main/java/org/openecomp/appc/tools/generator/impl/ModelGenerator.java +++ /dev/null @@ -1,71 +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.appc.tools.generator.impl; - -import org.onap.appc.tools.generator.api.ContextBuilder; -import freemarker.template.Configuration; -import freemarker.template.Template; -import freemarker.template.TemplateException; - -import java.io.IOException; -import java.io.Writer; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.Map; - -public class ModelGenerator { - - public void execute(String sourceFile, String destinationFile, String templateFile, String builderName, String contextConfName) throws IOException, ReflectiveOperationException { - - ContextBuilder contextBuilder = (ContextBuilder) Class.forName(builderName).newInstance(); - Map context = contextBuilder.buildContext(sourceFile, contextConfName); - - Path destinationPath = Paths.get(destinationFile); - if (!Files.isDirectory(destinationPath)) - Files.createDirectories(destinationPath.getParent()); - else { - Files.createDirectories(destinationPath); - } - - this.generate(context, templateFile, destinationFile); - System.out.println("\tFile <" + destinationFile + "> prepared successfully"); - } - - private void generate(Map context, String templateFile, String destinationFile) throws ReflectiveOperationException { - try { - Configuration cfg = new Configuration(Configuration.VERSION_2_3_23); - cfg.setClassForTemplateLoading(ModelGenerator.class, "/"); - Template template = cfg.getTemplate(templateFile); - - Writer out = new CodeGenWriter(destinationFile); - template.process(context, out); - out.close(); - } catch (IOException | TemplateException e) { - throw new RuntimeException("Failed to generate file from template <" + templateFile + ">", e); - } - } - -} diff --git a/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/api/CLITest.java b/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/api/CLITest.java new file mode 100644 index 000000000..4cd6bb5f5 --- /dev/null +++ b/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/api/CLITest.java @@ -0,0 +1,57 @@ +package org.onap.appc.tools.generator.api; + +import org.junit.Assert; +import org.junit.Test; + +public class CLITest { + @Test + public void missingSourceFileTest() { + CLI cli = new CLI(); + try { + String[] input = new String[1]; + cli.main(input); + } catch (Exception e) { + Assert.assertEquals("Source file is missing. Please add argument 'client '",e.getMessage()); + } + } + @Test + public void missingDestinationFileTest() { + CLI cli = new CLI(); + try { + String[] input = {"sourceFilePath",null}; + cli.main(input); + } catch (Exception e) { + Assert.assertEquals("Destination file name is missing. Please add argument 'client sourceFilePath '",e.getMessage()); + } + } + @Test + public void missingTemplateFileTest() { + CLI cli = new CLI(); + try { + String[] input = {"sourceFilePath","destinationPath",null}; + cli.main(input); + } catch (Exception e) { + Assert.assertEquals("template file name is missing. Please add argument 'client sourceFilePath destinationPath '",e.getMessage()); + } + } + @Test + public void missingBuilderNameTest() { + CLI cli = new CLI(); + try { + String[] input = {"sourceFilePath","destinationPath","templateFileName",null}; + cli.main(input); + } catch (Exception e) { + Assert.assertEquals("builder FQDN is missing. Please add argument 'client sourceFilePath destinationPath templateFileName '",e.getMessage()); + } + } + @Test + public void missingContextConfFileNameTest() { + CLI cli = new CLI(); + try { + String[] input = {"sourceFilePath","destinationPath","templateFileName","builderFQDN",null}; + cli.main(input); + } catch (Exception e) { + Assert.assertEquals(e.getMessage(),"context conf file is missing. Please add argument 'client sourceFilePath destinationPath templateFileName builderFQDN '"); + } + } +} diff --git a/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/impl/CodeGenWriterTest.java b/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/impl/CodeGenWriterTest.java new file mode 100644 index 000000000..e0669b836 --- /dev/null +++ b/appc-client/code-generator/src/test/java/org/onap/appc/tools/generator/impl/CodeGenWriterTest.java @@ -0,0 +1,22 @@ +package org.onap.appc.tools.generator.impl; + +import org.junit.Assert; +import org.junit.Test; + +import java.io.IOException; + + +public class CodeGenWriterTest { + @Test + public void writeTest() throws IOException { + CodeGenWriter codeGenWriter = new CodeGenWriter("destination"); + char[] cbuf = {'t','e','s','t'}; + int off = 1; + int len = 3; + codeGenWriter.write(cbuf,off,len); + codeGenWriter.flush(); + codeGenWriter.close(); + Assert.assertNotNull(codeGenWriter); + } + +} diff --git a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java deleted file mode 100644 index 4cd6bb5f5..000000000 --- a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/api/CLITest.java +++ /dev/null @@ -1,57 +0,0 @@ -package org.onap.appc.tools.generator.api; - -import org.junit.Assert; -import org.junit.Test; - -public class CLITest { - @Test - public void missingSourceFileTest() { - CLI cli = new CLI(); - try { - String[] input = new String[1]; - cli.main(input); - } catch (Exception e) { - Assert.assertEquals("Source file is missing. Please add argument 'client '",e.getMessage()); - } - } - @Test - public void missingDestinationFileTest() { - CLI cli = new CLI(); - try { - String[] input = {"sourceFilePath",null}; - cli.main(input); - } catch (Exception e) { - Assert.assertEquals("Destination file name is missing. Please add argument 'client sourceFilePath '",e.getMessage()); - } - } - @Test - public void missingTemplateFileTest() { - CLI cli = new CLI(); - try { - String[] input = {"sourceFilePath","destinationPath",null}; - cli.main(input); - } catch (Exception e) { - Assert.assertEquals("template file name is missing. Please add argument 'client sourceFilePath destinationPath '",e.getMessage()); - } - } - @Test - public void missingBuilderNameTest() { - CLI cli = new CLI(); - try { - String[] input = {"sourceFilePath","destinationPath","templateFileName",null}; - cli.main(input); - } catch (Exception e) { - Assert.assertEquals("builder FQDN is missing. Please add argument 'client sourceFilePath destinationPath templateFileName '",e.getMessage()); - } - } - @Test - public void missingContextConfFileNameTest() { - CLI cli = new CLI(); - try { - String[] input = {"sourceFilePath","destinationPath","templateFileName","builderFQDN",null}; - cli.main(input); - } catch (Exception e) { - Assert.assertEquals(e.getMessage(),"context conf file is missing. Please add argument 'client sourceFilePath destinationPath templateFileName builderFQDN '"); - } - } -} diff --git a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java b/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java deleted file mode 100644 index e0669b836..000000000 --- a/appc-client/code-generator/src/test/java/org/openecomp/appc/tools/generator/impl/CodeGenWriterTest.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.onap.appc.tools.generator.impl; - -import org.junit.Assert; -import org.junit.Test; - -import java.io.IOException; - - -public class CodeGenWriterTest { - @Test - public void writeTest() throws IOException { - CodeGenWriter codeGenWriter = new CodeGenWriter("destination"); - char[] cbuf = {'t','e','s','t'}; - int off = 1; - int len = 3; - codeGenWriter.write(cbuf,off,len); - codeGenWriter.flush(); - codeGenWriter.close(); - Assert.assertNotNull(codeGenWriter); - } - -} -- cgit 1.2.3-korg