aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt/devicemanager/provider/src/test
diff options
context:
space:
mode:
authorhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-10 18:24:57 +0200
committerhighstreetherbert <herbert.eiselt@highstreet-technologies.com>2020-07-11 12:00:11 +0200
commitdb33789cc1551326082a0527e346a2d7d4d55599 (patch)
tree7bb56663800cd7add2b51ec567ed23d7448e718f /sdnr/wt/devicemanager/provider/src/test
parent23c27ddcd79913d11eac16eb42c5a43899de97a1 (diff)
Reformat sdnr devicemanager to ONAP code style
Reformat to ONAP code style Issue-ID: SDNC-1277 Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com> Change-Id: I5d3ef519bec8f3cd4316ea608c1e3eecabb8eb8d Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/devicemanager/provider/src/test')
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java418
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java79
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java33
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java2
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java15
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java12
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java11
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java14
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java45
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java4
-rw-r--r--sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java85
11 files changed, 341 insertions, 377 deletions
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
index 5528e1c76..cc49ea9bf 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestAai.java
@@ -50,228 +50,228 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.types.InventoryInformationD
public class TestAai {
- private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
- private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
- private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
- private static final int AAI_SERVER_PORT = 45454;
- private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n"
- + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n"
- + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n"
- + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n"
- + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n"
- + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n"
- + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n"
- + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n"
- + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
- + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
- + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
- + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
- + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
- + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + "";
-
- private static final String EXT_TEST_URL="https://testaai.onap.org:8443";
- private static final String EXT_TEST_KEY="test.key";
- private static final String EXT_TEST_PASSWD="test123";
- private static final String EXT_TEST_APPLICATIONID="SDNC";
- private static final long EXT_TEST_CONN_TIMEOUT=6000;
-
-
- private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n"
- + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
- + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
- + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" +
- // "aaiApplicationId=SDNR\n" +
- // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
- // "aaiPcks12ClientCertPassphrase=adminadmin\n" +
- // "aaiClientConnectionTimeout=30000\n" +
- "\n";
- private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="+EXT_TEST_KEY+"\n"
- + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd="+EXT_TEST_PASSWD+"\n"
- + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n"
- + "org.onap.ccsdk.sli.adaptors.aai.application="+EXT_TEST_APPLICATIONID+"\n"
- + "org.onap.ccsdk.sli.adaptors.aai.uri="+EXT_TEST_URL+"\n"
- + "connection.timeout="+EXT_TEST_CONN_TIMEOUT+"\n";
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
- private static ConfigurationFileRepresentation globalCfg;
+ private static final String CONFIGURATIONTESTFILE = "test.properties"; // for
+ private static final String ENABLEDAAI_TESTCONFIG_FILENAME = "test2.properties";
+ private static final File ENABLEDAAI_TESTCONFIG_FILE = new File(ENABLEDAAI_TESTCONFIG_FILENAME);
+ private static final int AAI_SERVER_PORT = 45454;
+ private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n"
+ + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[aots]\n"
+ + "userPassword=passwd\n" + "soapurladd=off\n" + "soapaddtimeout=10\n" + "soapinqtimeout=20\n"
+ + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n" + "assignedto=userid\n"
+ + "addtemplate=addreq.tmpl.xml\n" + "severitypassthrough=critical,major,minor,warning\n"
+ + "systemuser=user\n" + "prt-offset=1200\n" + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n"
+ + "#smtpUsername=\n" + "#smtpPassword=\n" + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n"
+ + "esCluster=sendateodl5\n" + "\n" + "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
+ + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
+ + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
+ + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + "";
- @Test
- public void test() {
+ private static final String EXT_TEST_URL = "https://testaai.onap.org:8443";
+ private static final String EXT_TEST_KEY = "test.key";
+ private static final String EXT_TEST_PASSWD = "test123";
+ private static final String EXT_TEST_APPLICATIONID = "SDNC";
+ private static final long EXT_TEST_CONN_TIMEOUT = 6000;
- String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
- ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
- AaiProviderClient provider = new AaiProviderClient(cfg, null);
+ private static final CharSequence TESTCONFIG_CONTENT_EXT = "[aai]\n" + "#keep comment\n"
+ + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:" + AAI_SERVER_PORT + "\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" +
+ // "aaiApplicationId=SDNR\n" +
+ // "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
+ // "aaiPcks12ClientCertPassphrase=adminadmin\n" +
+ // "aaiClientConnectionTimeout=30000\n" +
+ "\n";
+ private static final CharSequence TESTCONFIG_CONTENT_EXT2 = "org.onap.ccsdk.sli.adaptors.aai.ssl.key="
+ + EXT_TEST_KEY + "\n" + "org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=" + EXT_TEST_PASSWD + "\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=false\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.application=" + EXT_TEST_APPLICATIONID + "\n"
+ + "org.onap.ccsdk.sli.adaptors.aai.uri=" + EXT_TEST_URL + "\n" + "connection.timeout="
+ + EXT_TEST_CONN_TIMEOUT + "\n";
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+ private static ConfigurationFileRepresentation globalCfg;
- String mountPointName = "testDevice 01";
- String type = "Unit";
- String model = "Horizon Compact+";
- String vendor = "DragonWave-X";
- String ipv4 = "127.0.0.1";
- String ipv6 = "::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName, ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ @Test
+ public void test() {
- @Test
- public void test2() {
- try {
- Thread.sleep(3000);
- } catch (InterruptedException e1) {
- e1.printStackTrace();
- }
- AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
+ String testConfigurationFileName = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE).getAbsolutePath();
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
- String mountPointName = "testDevice 01";
- String type = "Unit";
- String model = "Horizon Compact+";
- String vendor = "DragonWave-X";
- String ipv4 = "127.0.0.1";
- String ipv6 = "::1";
- List<String> ifInfos = new ArrayList<>();
- ifInfos.add("LP-MWPS-RADIO");
- InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
- System.out.println("registering device");
- provider.onDeviceRegistered(mountPointName);
- provider.onDeviceRegistered(mountPointName, ii);
- try {
- Thread.sleep(5000);
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- System.out.println("unregistering device");
- provider.onDeviceUnregistered(mountPointName);
- System.out.println("finished");
- try {
- provider.close();
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
+ AaiProviderClient provider = new AaiProviderClient(cfg, null);
- @Test
- public void testExtendedProperties() {
- File testConfigurationFileName = new File("abbsads.properties");
- File extfile = new File("aaiclient.properties");
- if (testConfigurationFileName.exists()) {
- testConfigurationFileName.delete();
- }
- if (extfile.exists()) {
- extfile.delete();
- }
- try {
- Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT);
- } catch (IOException e) {
- e.printStackTrace();
- fail("problem writing a test config file: " + e.getMessage());
- }
- try {
- Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2);
- } catch (IOException e) {
- e.printStackTrace();
- fail("problem writing a second test config file: " + e.getMessage());
- }
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
- AaiConfig config = new AaiConfig(cfg);
- System.out.println(config.toString());
+ @Test
+ public void test2() {
+ try {
+ Thread.sleep(3000);
+ } catch (InterruptedException e1) {
+ e1.printStackTrace();
+ }
+ AaiProviderClient provider = new AaiProviderClient(globalCfg, null);
- assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL));
- assertEquals(EXT_TEST_KEY,config.getPcks12CertificateFilename());
- assertEquals(EXT_TEST_PASSWD,config.getPcks12CertificatePassphrase());
- assertEquals(EXT_TEST_APPLICATIONID,config.getHeaders().get("X-FromAppId"));
- assertEquals(EXT_TEST_CONN_TIMEOUT,config.getConnectionTimeout());
-
- if (testConfigurationFileName.exists()) {
- testConfigurationFileName.delete();
- }
- if (extfile.exists()) {
- extfile.delete();
- }
+ String mountPointName = "testDevice 01";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
+ List<String> ifInfos = new ArrayList<>();
+ ifInfos.add("LP-MWPS-RADIO");
+ InventoryInformationDcae ii = new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
+ System.out.println("registering device");
+ provider.onDeviceRegistered(mountPointName);
+ provider.onDeviceRegistered(mountPointName, ii);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException e) {
+ e.printStackTrace();
+ }
+ System.out.println("unregistering device");
+ provider.onDeviceUnregistered(mountPointName);
+ System.out.println("finished");
+ try {
+ provider.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
- }
+ @Test
+ public void testExtendedProperties() {
+ File testConfigurationFileName = new File("abbsads.properties");
+ File extfile = new File("aaiclient.properties");
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
+ try {
+ Files.asCharSink(testConfigurationFileName, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a test config file: " + e.getMessage());
+ }
+ try {
+ Files.asCharSink(extfile, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT_EXT2);
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("problem writing a second test config file: " + e.getMessage());
+ }
- @BeforeClass
- public static void initAaiTestWebserver() throws IOException {
- try {
- Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
- globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
- server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- AaiConfig config = new AaiConfig(globalCfg);
- server.createContext(config.getBaseUri(), new MyHandler());
- //server.createContext("/", new MyRootHandler());
- server.setExecutor(null); // creates a default executor
- server.start();
- System.out.println("http server started");
- }
+ ConfigurationFileRepresentation cfg = new ConfigurationFileRepresentation(testConfigurationFileName);
+ AaiConfig config = new AaiConfig(cfg);
+ System.out.println(config.toString());
- @AfterClass
- public static void stopTestWebserver() {
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped");
- }
- if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
- ENABLEDAAI_TESTCONFIG_FILE.delete();
- }
+ assertTrue(config.getBaseUrl().startsWith(EXT_TEST_URL));
+ assertEquals(EXT_TEST_KEY, config.getPcks12CertificateFilename());
+ assertEquals(EXT_TEST_PASSWD, config.getPcks12CertificatePassphrase());
+ assertEquals(EXT_TEST_APPLICATIONID, config.getHeaders().get("X-FromAppId"));
+ assertEquals(EXT_TEST_CONN_TIMEOUT, config.getConnectionTimeout());
- }
+ if (testConfigurationFileName.exists()) {
+ testConfigurationFileName.delete();
+ }
+ if (extfile.exists()) {
+ extfile.delete();
+ }
- static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println("req method: " + method);
- OutputStream os = null;
- try {
- String res = "";
- if (method.equals("GET")) {
- t.sendResponseHeaders(404, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("DELETE")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else if (method.equals("PUT")) {
- t.sendResponseHeaders(200, res.length());
- os = t.getResponseBody();
- os.write(res.getBytes());
- } else {
- t.sendResponseHeaders(404, 0);
- }
- System.out.println("req handled successful");
+ }
- } catch (Exception e) {
- System.out.println(e.getMessage());
- } finally {
- if (os != null) {
- os.close();
- }
- }
- }
- }
+ @BeforeClass
+ public static void initAaiTestWebserver() throws IOException {
+ try {
+ Files.asCharSink(ENABLEDAAI_TESTCONFIG_FILE, StandardCharsets.UTF_8).write(TESTCONFIG_CONTENT);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ //globalCfg=HtDevicemanagerConfiguration.getTestConfiguration(ENABLEDAAI_TESTCONFIG_FILENAME,true);
+ globalCfg = new ConfigurationFileRepresentation(ENABLEDAAI_TESTCONFIG_FILENAME);
+ server = HttpServer.create(new InetSocketAddress(AAI_SERVER_PORT), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ AaiConfig config = new AaiConfig(globalCfg);
+ server.createContext(config.getBaseUri(), new MyHandler());
+ //server.createContext("/", new MyRootHandler());
+ server.setExecutor(null); // creates a default executor
+ server.start();
+ System.out.println("http server started");
+ }
+
+ @AfterClass
+ public static void stopTestWebserver() {
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ if (ENABLEDAAI_TESTCONFIG_FILE.exists()) {
+ ENABLEDAAI_TESTCONFIG_FILE.delete();
+ }
+
+ }
+
+ static class MyHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println("req method: " + method);
+ OutputStream os = null;
+ try {
+ String res = "";
+ if (method.equals("GET")) {
+ t.sendResponseHeaders(404, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("DELETE")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else if (method.equals("PUT")) {
+ t.sendResponseHeaders(200, res.length());
+ os = t.getResponseBody();
+ os.write(res.getBytes());
+ } else {
+ t.sendResponseHeaders(404, 0);
+ }
+ System.out.println("req handled successful");
+
+ } catch (Exception e) {
+ System.out.println(e.getMessage());
+ } finally {
+ if (os != null) {
+ os.close();
+ }
+ }
+ }
+ }
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
index bba7d7889..ff01f9a2b 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDcae.java
@@ -51,56 +51,22 @@ public class TestDcae {
private static final String ENABLEDDCAE_TESTCONFIG_FILENAME = "test2.properties";
private static final File ENABLEDDCAE_TESTCONFIG_FILE = new File(ENABLEDDCAE_TESTCONFIG_FILENAME);
- private static final int DCAE_SERVER_PORT=45451;
+ private static final int DCAE_SERVER_PORT = 45451;
private static final String URI = "/abc";
- private static final String TESTCONFIG_CONTENT="[dcae]\n" +
- "dcaeUserCredentials=admin:admin\n" +
- "dcaeUrl=http://localhost:"+DCAE_SERVER_PORT+URI+"\n" +
- "dcaeHeartbeatPeriodSeconds=120\n" +
- "dcaeTestCollector=no\n" +
- "\n" +
- "[aots]\n" +
- "userPassword=passwd\n" +
- "soapurladd=off\n" +
- "soapaddtimeout=10\n" +
- "soapinqtimeout=20\n" +
- "userName=user\n" +
- "inqtemplate=inqreq.tmpl.xml\n" +
- "assignedto=userid\n" +
- "addtemplate=addreq.tmpl.xml\n" +
- "severitypassthrough=critical,major,minor,warning\n" +
- "systemuser=user\n" +
- "prt-offset=1200\n" +
- "soapurlinq=off\n" +
- "#smtpHost=\n" +
- "#smtpPort=\n" +
- "#smtpUsername=\n" +
- "#smtpPassword=\n" +
- "#smtpSender=\n" +
- "#smtpReceivers=\n" +
- "\n" +
- "[es]\n" +
- "esCluster=sendateodl5\n" +
- "\n" +
- "[aai]\n" +
- "#keep comment\n" +
- "aaiHeaders=[\"X-TransactionId: 9999\"]\n" +
- "aaiUrl=off\n" +
- "aaiUserCredentials=AAI:AAI\n" +
- "aaiDeleteOnMountpointRemove=true\n" +
- "aaiTrustAllCerts=false\n" +
- "aaiApiVersion=aai/v13\n" +
- "aaiPropertiesFile=aaiclient.properties\n" +
- "aaiApplicationId=SDNR\n" +
- "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n" +
- "aaiPcks12ClientCertPassphrase=adminadmin\n" +
- "aaiClientConnectionTimeout=30000\n" +
- "\n" +
- "[pm]\n" +
- "pmCluster=sendateodl5\n" +
- "pmEnabled=true\n" +
- "\n" +
- "";
+ private static final String TESTCONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n"
+ + "dcaeUrl=http://localhost:" + DCAE_SERVER_PORT + URI + "\n" + "dcaeHeartbeatPeriodSeconds=120\n"
+ + "dcaeTestCollector=no\n" + "\n" + "[aots]\n" + "userPassword=passwd\n" + "soapurladd=off\n"
+ + "soapaddtimeout=10\n" + "soapinqtimeout=20\n" + "userName=user\n" + "inqtemplate=inqreq.tmpl.xml\n"
+ + "assignedto=userid\n" + "addtemplate=addreq.tmpl.xml\n"
+ + "severitypassthrough=critical,major,minor,warning\n" + "systemuser=user\n" + "prt-offset=1200\n"
+ + "soapurlinq=off\n" + "#smtpHost=\n" + "#smtpPort=\n" + "#smtpUsername=\n" + "#smtpPassword=\n"
+ + "#smtpSender=\n" + "#smtpReceivers=\n" + "\n" + "[es]\n" + "esCluster=sendateodl5\n" + "\n" + "[aai]\n"
+ + "#keep comment\n" + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=off\n"
+ + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=true\n" + "aaiTrustAllCerts=false\n"
+ + "aaiApiVersion=aai/v13\n" + "aaiPropertiesFile=aaiclient.properties\n" + "aaiApplicationId=SDNR\n"
+ + "aaiPcks12ClientCertFile=/opt/logs/externals/data/stores/keystore.client.p12\n"
+ + "aaiPcks12ClientCertPassphrase=adminadmin\n" + "aaiClientConnectionTimeout=30000\n" + "\n" + "[pm]\n"
+ + "pmCluster=sendateodl5\n" + "pmEnabled=true\n" + "\n" + "";
private HttpServer server;
private ExecutorService httpThreadPool;
private ConfigurationFileRepresentation cfg;
@@ -112,20 +78,21 @@ public class TestDcae {
} catch (InterruptedException e1) {
e1.printStackTrace();
}
- DcaeProviderClient provider = new DcaeProviderClient(cfg,"mountpoint",null);
+ DcaeProviderClient provider = new DcaeProviderClient(cfg, "mountpoint", null);
String mountPointName = "testDevice 01";
- String type="Unit";
- String model="Horizon Compact+";
- String vendor="DragonWave-X";
- String ipv4="127.0.0.1";
- String ipv6="::1";
+ String type = "Unit";
+ String model = "Horizon Compact+";
+ String vendor = "DragonWave-X";
+ String ipv4 = "127.0.0.1";
+ String ipv6 = "::1";
List<String> ifInfos = new ArrayList<>();
ifInfos.add("LP-MWPS-RADIO");
new InventoryInformationDcae(type, model, vendor, ipv4, ipv6, ifInfos);
System.out.println("registering device");
boolean neDeviceAlarm = false;
- ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element", "problemName", InternalSeverity.Critical,123, InternalDateAndTime.getTestpattern());
+ ProblemNotificationXml notification = new ProblemNotificationXml(mountPointName, "network-element",
+ "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
provider.sendProblemNotification(mountPointName, notification, neDeviceAlarm);
try {
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
index ebcd51376..9b533b554 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevMgrPropertiesFile.java
@@ -23,11 +23,10 @@ package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-
+import com.google.common.io.Files;
import java.io.File;
import java.io.IOException;
import java.nio.charset.StandardCharsets;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -40,14 +39,12 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.toggleAlarmFilter.conf.Togg
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.io.Files;
-
public class TestDevMgrPropertiesFile {
private static final Logger LOG = LoggerFactory.getLogger(ArchiveCleanService.class);
private static final File FILENAME = new File("testdevmgrpropertiesfile.properties");
- private static final File AAIPROP_FILE=new File("testdevmgrpropertiesfileaaiclient.properties");
+ private static final File AAIPROP_FILE = new File("testdevmgrpropertiesfileaaiclient.properties");
private int hasChanged;
@Before
@@ -55,6 +52,7 @@ public class TestDevMgrPropertiesFile {
delete(FILENAME);
delete(AAIPROP_FILE);
}
+
@After
public void deinit() {
this.init();
@@ -94,7 +92,7 @@ public class TestDevMgrPropertiesFile {
hasChanged = 0;
cfg2.registerConfigChangedListener(() -> {
hasChanged++;
- LOG.info("file changed listener triggered: {}",hasChanged);
+ LOG.info("file changed listener triggered: {}", hasChanged);
});
AaiConfig aaiConfig = new AaiConfig(cfg2);
@@ -106,17 +104,17 @@ public class TestDevMgrPropertiesFile {
ToggleAlarmConfig toggleAlarmConfig = new ToggleAlarmConfig(cfg2);
assertNotNull(toggleAlarmConfig);
- LOG.info("Write new content. Changes {}",hasChanged);
+ LOG.info("Write new content. Changes {}", hasChanged);
writeFile(FILENAME, this.getContent2());
- int i=10;
- while(hasChanged == 0 && i-- > 0) {
+ int i = 10;
+ while (hasChanged == 0 && i-- > 0) {
LOG.info("Wait for Change indication.");
sleep(1000);
}
- LOG.info("Changes {}",hasChanged);
+ LOG.info("Changes {}", hasChanged);
- assertTrue("fileChanged counter "+hasChanged, hasChanged > 0);
+ assertTrue("fileChanged counter " + hasChanged, hasChanged > 0);
LOG.info("Test done");
}
@@ -130,22 +128,23 @@ public class TestDevMgrPropertiesFile {
}
public static void writeFile(File f, String content) {
- try {
+ try {
Files.asCharSink(f, StandardCharsets.UTF_8).write(content);
} catch (IOException e) {
fail(e.getMessage());
- };
+ } ;
sleep(500);
}
private void delete(File f) {
- if(f.exists()) {
+ if (f.exists()) {
f.delete();
}
}
private String getContent2() {
+ // @formatter:off
return "[dcae]\n" +
"dcaeUserCredentials=admin:admin\n" +
"dcaeUrl=http://localhost:45451/abc\n" +
@@ -196,9 +195,11 @@ public class TestDevMgrPropertiesFile {
"taEnabled=true\n" +
"taDelay=5555\n" +
"";
+ // @formatter:on
}
private String getContent1() {
+ // @formatter:off
return "[dcae]\n" +
"dcaeUserCredentials=admin:admin\n" +
"dcaeUrl=http://localhost:45/abc\n" +
@@ -245,8 +246,11 @@ public class TestDevMgrPropertiesFile {
"taEnabled=false\n" +
"taDelay=5555\n" +
"";
+ // @formatter:on
}
+
private String getAaiPropertiesConfig() {
+ // @formatter:off
return "org.onap.ccsdk.sli.adaptors.aai.ssl.key=keykey\"\"\n" +
"org.onap.ccsdk.sli.adaptors.aai.ssl.key.psswd=psswdpsswd\"\"\n" +
"org.onap.ccsdk.sli.adaptors.aai.host.certificate.ignore=\"false\"\n" +
@@ -254,6 +258,7 @@ public class TestDevMgrPropertiesFile {
"org.onap.ccsdk.sli.adaptors.aai.uri=uriu\"\"\n" +
"connection.timeout=60000\n" +
"read.timeout=60000";
+ // @formatter:on
}
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
index fe0e37ae3..0dbac340b 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDeviceMonitor.java
@@ -70,7 +70,7 @@ public class TestDeviceMonitor extends Mockito {
deviceMonitor.close();
File f = new File(CONFIGURATIONTESTFILE);
if (f.exists())
- f.delete();
+ f.delete();
}
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
index 03dfd763e..33373fb43 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestDevicemanager.java
@@ -80,12 +80,14 @@ public class TestDevicemanager extends Mockito {
@SuppressWarnings("unchecked")
ListenerRegistration<NetconfNodeConnectListener> lr1 = mock(ListenerRegistration.class);
//doNothing().when(lr1).close();
- when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class))).thenReturn(lr1);
+ when(netconfNodeStateService.registerNetconfNodeConnectListener(mock(NetconfNodeConnectListener.class)))
+ .thenReturn(lr1);
@SuppressWarnings("unchecked")
ListenerRegistration<NetconfNodeStateListener> lr2 = mock(ListenerRegistration.class);
//doNothing().when(lr2).close();
- when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class))).thenReturn(lr2);
+ when(netconfNodeStateService.registerNetconfNodeStateListener(mock(NetconfNodeStateListener.class)))
+ .thenReturn(lr2);
WebsocketmanagerService websocketmanagerService = mock(WebsocketmanagerService.class);
@@ -113,7 +115,7 @@ public class TestDevicemanager extends Mockito {
deviceManager.init();
- apiService = rpcProviderRegistry.getDeviceManagerApiService();
+ apiService = rpcProviderRegistry.getDeviceManagerApiService();
}
@@ -129,7 +131,8 @@ public class TestDevicemanager extends Mockito {
n.creationNotification(new NodeId("NodeTest1"), 1, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
- n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1", "AtrributeTest1", "NewTest1");
+ n.changeNotification(new NodeId("NodeTest1"), 2, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1",
+ "AtrributeTest1", "NewTest1");
n.deletionNotification(new NodeId("NodeTest1"), 3, InternalDateAndTime.getTestpatternDateAndTime(), "ObjTest1");
@@ -140,9 +143,7 @@ public class TestDevicemanager extends Mockito {
log.info("testFaultNotification");
MaintenanceBuilder mb = new MaintenanceBuilder();
- when(htDataBaseMaintenance
- .getMaintenance(""))
- .thenReturn(mb.build());
+ when(htDataBaseMaintenance.getMaintenance("")).thenReturn(mb.build());
FaultService n = deviceManager.getFaultService();
FaultlogBuilder faultLogEntityBuilder = new FaultlogBuilder();
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
index 5bef21e03..1102e91c1 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestMaintenanceTimeFilter.java
@@ -30,8 +30,10 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class TestMaintenanceTimeFilter {
- private static String DEFAULT1 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=1970-01-01T00:00Z[UTC], definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
- private static String DEFAULT2 = "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
+ private static String DEFAULT1 =
+ "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=1970-01-01T00:00Z[UTC], definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
+ private static String DEFAULT2 =
+ "EsMaintenanceFilter [start=1970-01-01T00:00Z[UTC], end=2018-01-01T10:00+05:00, definition=EsMaintenanceFilterDefinition [objectIdRef=, problem=], description=]";
@Test
public void testBasic() {
@@ -50,7 +52,7 @@ public class TestMaintenanceTimeFilter {
now = ZonedDateTime.parse("2018-05-01T10:00:00+05:00");
res = MaintenanceCalculator.isInPeriod(start, end, now);
System.out.println("Within: " + res);
- assertTrue("within period",res);
+ assertTrue("within period", res);
now = ZonedDateTime.parse("2019-05-01T10:00:00+05:00");
res = MaintenanceCalculator.isInPeriod(start, end, now);
@@ -76,11 +78,11 @@ public class TestMaintenanceTimeFilter {
now = MaintenanceCalculator.valueOf("2000-01-01T00:00Z");
res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "Interface1", "Problem1", now);
- assertTrue("within period",res);
+ assertTrue("within period", res);
now = MaintenanceCalculator.valueOf("2002-01-01T00:00Z");
res = MaintenanceCalculator.isONFObjectInMaintenance(mb.build(), "", "", now);
- assertFalse("outside period",res);
+ assertFalse("outside period", res);
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java
index f134012e3..bee1acaa4 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestNameSpace.java
@@ -28,18 +28,19 @@ import org.opendaylight.yangtools.yang.common.QName;
public class TestNameSpace {
private static final String QNAME_COREMODEL_NAMESPACE = "urn:onf:params:xml:ns:yang:core-model";
- private static final QName QNAME_COREMODEL = QName.create(QNAME_COREMODEL_NAMESPACE, "2017-03-20", "core-model").intern();
+ private static final QName QNAME_COREMODEL =
+ QName.create(QNAME_COREMODEL_NAMESPACE, "2017-03-20", "core-model").intern();
@Test
public void test() throws URISyntaxException {
QName qname = QName.create("(urn:o-ran:hardware:1.0?revision=2019-03-28)o-ran-hardware");
- System.out.println("QName getNamespace"+qname.getNamespace());
- assertEquals(qname.getNamespace().toString(),"urn:o-ran:hardware:1.0");
+ System.out.println("QName getNamespace" + qname.getNamespace());
+ assertEquals(qname.getNamespace().toString(), "urn:o-ran:hardware:1.0");
- System.out.println("QName getRevision"+qname.getRevision());
- assertEquals(qname.getRevision().get().toString(),"2019-03-28");
+ System.out.println("QName getRevision" + qname.getRevision());
+ assertEquals(qname.getRevision().get().toString(), "2019-03-28");
System.out.println(QNAME_COREMODEL.getNamespace().toString());
assertEquals(QNAME_COREMODEL.getNamespace().toString(), QNAME_COREMODEL_NAMESPACE);
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
index c900397b1..eab30a0ac 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestXmlNotification.java
@@ -58,13 +58,13 @@ public class TestXmlNotification {
public void testNoAlarm() {
ProblemNotificationXml notification;
- notification = new ProblemNotificationXml("TestMointpoint", "network-element",
- "problemName", InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element", "problemName",
+ InternalSeverity.Critical, 123, InternalDateAndTime.getTestpattern());
assertFalse("Critical", notification.isNoAlarmIndication());
- notification = new ProblemNotificationXml("TestMointpoint", "network-element",
- "problemName", InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern());
+ notification = new ProblemNotificationXml("TestMointpoint", "network-element", "problemName",
+ InternalSeverity.NonAlarmed, 123, InternalDateAndTime.getTestpattern());
assertTrue("NonAlarm", notification.isNoAlarmIndication());
@@ -74,7 +74,8 @@ public class TestXmlNotification {
public void testObjectCreationNotification() {
ObjectCreationNotificationXml notification;
- notification = new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1");
+ notification =
+ new ObjectCreationNotificationXml("TestMointpoint1", 1, InternalDateAndTime.getTestpattern(), "Id1");
}
@@ -82,7 +83,8 @@ public class TestXmlNotification {
public void testDeletionCreationNotification() {
ObjectDeletionNotificationXml notification;
- notification = new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2");
+ notification =
+ new ObjectDeletionNotificationXml("TestMointpoint2", 2, InternalDateAndTime.getTestpattern(), "Id2");
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java
index 6cbb561ee..62f440a4e 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/TestsNectconfDateTime.java
@@ -31,19 +31,10 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.test.util.NetconfTimeStampO
public class TestsNectconfDateTime {
- private static String[] testPatterPostive = {
- "2017-01-18T11:44:49.482-0500",
- "2017-01-18T11:44:49.482-05:00",
- "20170118114449.123Z",
- "20170118114449.1Z",
- "20170118114449.1-0500",
- "2017-01-23T13:32:38-05:00",
- "2017-01-23T13:32-05:00",
- "2017-01-18T11:44:49Z"
- };
- private static String[] testPatterProblem = {
- "2017-01-18T11:44:49"
- };
+ private static String[] testPatterPostive = {"2017-01-18T11:44:49.482-0500", "2017-01-18T11:44:49.482-05:00",
+ "20170118114449.123Z", "20170118114449.1Z", "20170118114449.1-0500", "2017-01-23T13:32:38-05:00",
+ "2017-01-23T13:32-05:00", "2017-01-18T11:44:49Z"};
+ private static String[] testPatterProblem = {"2017-01-18T11:44:49"};
private final static NetconfTimeStampOld netconfTimeConverterOld = NetconfTimeStampOld.getConverter();
@@ -58,24 +49,24 @@ public class TestsNectconfDateTime {
timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime);
timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime);
- System.out.println("No "+t+++" Pattern: "+testTime);
- System.out.println(" to old "+timeOld);
- System.out.println(" to new "+timeNew);
+ System.out.println("No " + t++ + " Pattern: " + testTime);
+ System.out.println(" to old " + timeOld);
+ System.out.println(" to new " + timeNew);
System.out.println();
- assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew));
+ assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew));
}
for (String testTime : testPatterProblem) {
timeNew = netconfTimeConverterNew.getTimeStampFromNetconf(testTime);
timeOld = netconfTimeConverterOld.getTimeStampFromNetconf(testTime);
- System.out.println("No "+t+++" Pattern: "+testTime);
- System.out.println(" to old "+timeOld);
- System.out.println(" to new "+timeNew);
+ System.out.println("No " + t++ + " Pattern: " + testTime);
+ System.out.println(" to old " + timeOld);
+ System.out.println(" to new " + timeNew);
System.out.println();
- assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew));
+ assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew));
}
}
@@ -88,12 +79,12 @@ public class TestsNectconfDateTime {
timeNew = netconfTimeConverterNew.getTimeStampFromNetconfAsMilliseconds(testTime);
timeOld = netconfTimeConverterOld.getTimeStampFromNetconfAsMilliseconds(testTime);
- System.out.println("No "+t+++" Pattern: "+testTime);
- System.out.println(" to old "+timeOld);
- System.out.println(" to new "+timeNew);
+ System.out.println("No " + t++ + " Pattern: " + testTime);
+ System.out.println(" to old " + timeOld);
+ System.out.println(" to new " + timeNew);
System.out.println();
- assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew));
+ assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew));
}
}
@@ -106,9 +97,9 @@ public class TestsNectconfDateTime {
String timeNew = netconfTimeConverterNew.getTimeStampAsNetconfString(now);
String timeOld = netconfTimeConverterOld.getTimeStampAsNetconfString(now);
- System.out.println("Old/New: "+timeOld+"/"+timeNew);
+ System.out.println("Old/New: " + timeOld + "/" + timeNew);
- assertTrue("Old/New implementation not same "+timeOld+"/"+timeNew, timeOld.equals(timeNew));
+ assertTrue("Old/New implementation not same " + timeOld + "/" + timeNew, timeOld.equals(timeNew));
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
index b05f7767c..14484d08b 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/mock/RpcProviderServiceMock.java
@@ -34,9 +34,9 @@ public class RpcProviderServiceMock implements RpcProviderService {
@Override
public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
T implementation) {
- System.out.println("Register class "+implementation);
+ System.out.println("Register class " + implementation);
if (implementation instanceof DevicemanagerService) {
- deviceManagerApi = (DevicemanagerService)implementation;
+ deviceManagerApi = (DevicemanagerService) implementation;
}
return null;
}
diff --git a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java
index c2bd1fbf8..104ad0364 100644
--- a/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java
+++ b/sdnr/wt/devicemanager/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/test/util/NetconfTimeStampOld.java
@@ -37,32 +37,25 @@ import org.slf4j.LoggerFactory;
* Format2 NETCONF - pattern from ietf-yang-types "2013-07-15" Pattern:
* "\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?(Z|[\+\-](\d{2}):(\d{2}))"
*
- * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom
- * 2016-07-01 Example1: 20170118114449.1Z Example2: 20170118114449.1-0500 Pattern:
- * "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef DateAndTime { description
- * "This primitive type defines the date and time according to the following structure:
- * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31'
- * day hh '00'..'23' hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second
- * (set to '.0' if EMS or NE cannot support this granularity) Z 'Z' indicates UTC (rather than local
- * time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time zone difference in hours Mm '00'..'59'
- * time zone difference in minutes."; type string; } Format4 E/// specific Example1:
- * 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00
+ * Format3 NETCONF DateAndTime CoreModel-CoreFoundationModule-TypeDefinitions vom 2016-07-01 Example1: 20170118114449.1Z
+ * Example2: 20170118114449.1-0500 Pattern: "\d{4}\d{2}\d{2}\d{2}\d{2}\d{2}.\d+?(Z|[\+\-](\d{2})(\d{2}))" typedef
+ * DateAndTime { description "This primitive type defines the date and time according to the following structure:
+ * 'yyyyMMddhhmmss.s[Z|{+|-}HHMm]' where: yyyy '0000'..'9999' year MM '01'..'12' month dd '01'..'31' day hh '00'..'23'
+ * hour mm '00'..'59' minute ss '00'..'59' second s '.0'..'.9' tenth of second (set to '.0' if EMS or NE cannot support
+ * this granularity) Z 'Z' indicates UTC (rather than local time) {+|-} '+' or '-' delta from UTC HH '00'..'23' time
+ * zone difference in hours Mm '00'..'59' time zone difference in minutes."; type string; } Format4 E/// specific
+ * Example1: 2017-01-23T13:32:38-05:00 Example2: 2017-01-23T13:32-05:00
*
* Input formats netconfTime as String according the formats given above
*
* Return format is String in ISO8601 Format for database and presentation.
*
- * Example formats:
- * 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00
- * 2) Microwave ONF. Examples 20170118114449.1Z, 20170118114449.1-0500
- * 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00
- * 3.2) Ericson. Example: 2017-01-23T13:32-05:00
- * Always 10 Groups,
- * 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset
- * signedhour 10:min
+ * Example formats: 1) ISO8601. Example 2017-01-18T11:44:49.482-05:00 2) Microwave ONF. Examples 20170118114449.1Z,
+ * 20170118114449.1-0500 3.1) Ericson. Example: 2017-01-23T13:32:38-05:00 3.2) Ericson. Example: 2017-01-23T13:32-05:00
+ * Always 10 Groups, 1:Year 2:Month 3:day 4:Hour 5:minute 6:optional sec 7:optional ms 8:optional Z or 9:offset
+ * signedhour 10:min
*
- * Template:
- * private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
+ * Template: private static final NetconfTimeStamp NETCONFTIME_CONVERTER = NetconfTimeStamp.getConverter();
*/
public class NetconfTimeStampOld {
@@ -75,7 +68,7 @@ public class NetconfTimeStampOld {
private static int MILLISECONDSDIGITS = 3; // Digits of milliseconds in dateFormatResult
private static String MILLISECONDZEROS = "000"; // String with zeros for milliseconds in dateFormatResult
private static final Pattern dateNetconfPatter = Pattern.compile(
- "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))");
+ "(\\d{4})-?(\\d{2})-?(\\d{2})T?(\\d{2}):?(\\d{2})(?:(?::?)(\\d{2}))?(?:.(\\d+))?(?:(Z)|([+-]\\d{2}):?(\\d{2}))");
/*
* ------------------------------------ Public function
@@ -84,11 +77,11 @@ public class NetconfTimeStampOld {
/**
* Use static access
*/
- private NetconfTimeStampOld() {
- }
+ private NetconfTimeStampOld() {}
/**
* Use this function to get the converter
+ *
* @return global converter
*/
public static NetconfTimeStampOld getConverter() {
@@ -106,12 +99,13 @@ public class NetconfTimeStampOld {
/**
* Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
-
+ *
* @return String with Date in NETCONF/YANG Format Version 1.0.
*/
public String getTimeStampAsNetconfString(Date date) {
return getRightFormattedDate(date.getTime());
}
+
/**
* Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
*
@@ -123,6 +117,7 @@ public class NetconfTimeStampOld {
/**
* Get time from date as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ *
* @param date specifying the date and time
* @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
*/
@@ -139,22 +134,21 @@ public class NetconfTimeStampOld {
* @throws IllegalArgumentException In case of no compliant time format definition for the string
* @throws ParseException Time parsing failed
*/
- public long getTimeStampFromNetconfAsMilliseconds(String netconfTime)
- throws IllegalArgumentException {
+ public long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException {
Matcher m = dateNetconfPatter.matcher(netconfTime);
// According to specified matches there have to be 10 parameter
if (m.matches() && m.groupCount() == 10) {
// Convert now
- synchronized(dateFormatConvert) {
- long utcMillis;
- try {
- utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
- - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
- return utcMillis;
- } catch (ParseException e) {
- throw new IllegalArgumentException("Parse problem for NETCONF data string: " + netconfTime);
- }
- }
+ synchronized (dateFormatConvert) {
+ long utcMillis;
+ try {
+ utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
+ - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
+ return utcMillis;
+ } catch (ParseException e) {
+ throw new IllegalArgumentException("Parse problem for NETCONF data string: " + netconfTime);
+ }
+ }
} else {
throw new IllegalArgumentException("No pattern for NETCONF data string: " + netconfTime);
}
@@ -164,8 +158,8 @@ public class NetconfTimeStampOld {
* Deliver String result.
*
* @param netconfTime as String according the formats given above
- * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed
- * input" the Input string with the prefix "Mailformed date" is delivered back.
+ * @return If successful: String in ISO8601 Format for database and presentation. If "wrong formed input" the Input
+ * string with the prefix "Mailformed date" is delivered back.
*/
public String getTimeStampFromNetconf(String netconfTime) {
Matcher m = dateNetconfPatter.matcher(netconfTime);
@@ -173,11 +167,12 @@ public class NetconfTimeStampOld {
if (m.matches() && m.groupCount() == 10) {
// Convert now
try {
- synchronized(dateFormatConvert) {
- long utcMillis = dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
- - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
- return getRightFormattedDate(utcMillis);
- }
+ synchronized (dateFormatConvert) {
+ long utcMillis =
+ dateFormatConvert.parse(getTimeAsNormalizedString(m, m.group(6), m.group(7))).getTime()
+ - getTimezoneOffsetMilliseconds(m.group(9), m.group(10));
+ return getRightFormattedDate(utcMillis);
+ }
} catch (ParseException e) {
LOG.info(e.getMessage());
} catch (IllegalArgumentException e) {
@@ -261,8 +256,8 @@ public class NetconfTimeStampOld {
long tenthOfSeconds = dateMillis % 1000 / 100L; // Extract 100 milliseconds
long base = dateMillis / 1000L * 1000L; // Cut milliseconds to 000
Date newDate = new Date(base + tenthOfSeconds);
- synchronized(dateFormatResult) {
- return dateFormatResult.format(newDate);
+ synchronized (dateFormatResult) {
+ return dateFormatResult.format(newDate);
}
}