--- /dev/null
+# Change Log
+All notable changes to this project will be documented in this file.
+
+The format is based on [Keep a Changelog](http://keepachangelog.com/)
+and this project adheres to [Semantic Versioning](http://semver.org/).
+
+## [1.0.3] - 2022/05/21
+ - [DCAEGEN2-3169] - CodeCoverage improvement for dcaegen2-platform-mod-genprocessor
+
<!--
============LICENSE_START=======================================================
Copyright (c) 2020 AT&T Intellectual Property. All rights reserved.
+Copyright (C) 2022 Huawei. 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.
</parent>
<groupId>org.onap.dcaegen2.platform.mod</groupId>
<artifactId>genprocessor</artifactId>
- <version>1.0.2-SNAPSHOT</version>
+ <version>1.0.3-SNAPSHOT</version>
<name>dcaegen2-platform-mod-genprocessor</name>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</files>
</inline>
</assembly>
- <runCmds>
- <runCmd>sed -i /etc/nginx/nginx.conf -e '/^user /d' && touch /var/run/nginx.pid && mkdir -p /www/data && chown -R nginx:nginx /www /etc/nginx /var/cache/nginx /var/log/nginx /var/run/nginx.pid</runCmd>
- </runCmds>
- <user>nginx</user>
+ <runCmds>
+ <runCmd>sed -i /etc/nginx/nginx.conf -e '/^user /d' && touch /var/run/nginx.pid && mkdir -p /www/data && chown -R nginx:nginx /www /etc/nginx /var/cache/nginx /var/log/nginx /var/run/nginx.pid</runCmd>
+ </runCmds>
+ <user>nginx</user>
<entryPoint>
<exec>
<arg>nginx</arg>
<assembly>
<descriptorRef>artifact-with-dependencies</descriptorRef>
</assembly>
- <runCmds>
- <runCmd>groupadd -g 1000 dcaemod && useradd --shell /bin/bash -u 1000 -g 1000 -m dcaemod</runCmd>
- </runCmds>
+ <runCmds>
+ <runCmd>groupadd -g 1000 dcaemod && useradd --shell /bin/bash -u 1000 -g 1000 -m dcaemod</runCmd>
+ </runCmds>
<workdir>/maven</workdir>
<env>
<GENPROC_WORKING_DIR>/work</GENPROC_WORKING_DIR>
<GENPROC_ONBOARDING_API_HOST>http://onboarding-api:8080/onboarding</GENPROC_ONBOARDING_API_HOST>
<GENPROC_SLEEP_SEC>10</GENPROC_SLEEP_SEC>
</env>
- <user>dcaemod</user>
+ <user>dcaemod</user>
<entryPoint>
<exec>
<arg>java</arg>
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019-2020 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 Huawei. 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.
return true;
}
}
- } catch (InterruptedException e) {
- throw new RuntimeException("Error while creating jar", e);
- } catch (IOException e) {
+ } catch (InterruptedException | IOException e) {
throw new RuntimeException("Error while creating jar", e);
}
String sleepstr = System.getenv("GENPROC_SLEEP_SEC");
long sleepdur = (sleepstr != null)? 1000 * Long.parseLong(sleepstr): 0;
do {
- try {
- main2(args);
- } catch (Exception e) {
- LOG.error(e.toString(), e);
- }
+ try {
+ main2(args);
+ } catch (Exception e) {
+ LOG.error(e.toString(), e);
+ }
Thread.sleep(sleepdur);
} while (sleepdur > 0);
return;
}
}
}
+
@JsonProperty("selfUrl")
public String selfUrl;
-}
\ No newline at end of file
+}
+
public List<CompShort> components;
}
+
return this.relationships;
}
-}
\ No newline at end of file
+}
+
}
}
-}
\ No newline at end of file
+}
+
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 Huawei. 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.
ccFile.addAttribute(attr);
}
- private static void addMethod(CtClass target, String methodCode) {
+ public static void addMethod(CtClass target, String methodCode) {
try {
CtMethod method = CtMethod.make(methodCode, target);
target.addMethod(method);
addMethod(target, createCodeRelationships(compSpec));
}
-}
\ No newline at end of file
+}
+
return String.format("%s-%s", compSpec.name, compSpec.version);
}
-}
\ No newline at end of file
+}
+
/*-
* ============LICENSE_START=======================================================
* Copyright (C) 2019 AT&T Intellectual Property. All rights reserved.
+ * Copyright (C) 2022 Huawei. 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.
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.FileWriter;
import java.net.URISyntaxException;
+import java.net.URL;
+import java.net.URLClassLoader;
import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedList;
import java.util.List;
import java.util.Set;
+import javassist.ClassPool;
+import javassist.CtClass;
import org.apache.nifi.components.PropertyDescriptor;
import org.apache.nifi.processor.ProcessContext;
import org.apache.nifi.processor.ProcessSession;
import org.onap.dcae.genprocessor.DCAEProcessor;
import org.onap.dcae.genprocessor.OnboardingAPIClient;
import org.onap.dcae.genprocessor.Utils;
+import org.onap.dcae.genprocessor.CompList;
+import org.onap.dcae.genprocessor.ProcessorBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
* Unit test for simple App.
*/
CompSpec cs = new CompSpec();
cs.unpackSelf(mx);
assertEquals(Utils.formatNameForJar(cs), "SomeJar-2.0");
+ try {
+ CompSpec.loadComponentSpec(new File("sandbox/temp.txt"));
+ } catch (RuntimeException e) {
+ // expected case
+ return;
+ }
+ fail("Exception is not thrown");
+ }
+
+ @Test
+ public void testGetNameForJavaClass() {
+ CompList.CompShort compShort = new CompList.CompShort();
+ compShort.name = "test";
+ compShort.getNameForJavaClass();
+ compShort.componentUrl = "6:invalidURI";
+ try {
+ compShort.getComponentUrlAsURI();
+ } catch (RuntimeException e) {
+ // expected case
+ return;
+ }
+ fail("Exception is not thrwon");
}
App.main(new String[] { "load" });
/* gen case */
App.main(new String[] { "gen" });
+
+ URL[] jarURLs = new URL[1];
+ try {
+ App.loadFromJars(jarURLs);
+ } catch (NullPointerException e) {
+ // expected case
+ return;
+ }
+ fail("Exception is not thrown");
+ }
+
+ @Test
+ public void testAddMethod() {
+ try {
+ ClassPool pool = ClassPool.getDefault();
+ CtClass base = pool.get(DCAEProcessor.class.getName());
+
+ CtClass cc = pool.makeClass(String.format("org.onap.dcae.%s", DCAEProcessor.class));
+ cc.setSuperclass(base);
+
+ ProcessorBuilder.addMethod(cc, "test");
+ } catch (Exception e) {
+ // expected case
+ return;
+ }
+ fail("Exception is not thrown");
}
}
+
--- /dev/null
+major=1\r
+minor=0\r
+patch=3\r
+base_version=${major}.${minor}.${patch}\r
+release_version=${base_version}\r
+snapshot_version=${base_version}-SNAPSHOT\r
major=1\r
minor=1\r
-patch=0\r
+patch=1\r
base_version=${major}.${minor}.${patch}\r
release_version=${base_version}\r
snapshot_version=${base_version}-SNAPSHOT\r