diff options
author | highstreetherbert <herbert.eiselt@highstreet-technologies.com> | 2020-07-10 17:18:59 +0200 |
---|---|---|
committer | highstreetherbert <herbert.eiselt@highstreet-technologies.com> | 2020-07-10 17:19:12 +0200 |
commit | 52d1616151680d46cceb62cba752465ffd75a298 (patch) | |
tree | 23e2681573d77ba906fd3cd1d0bbc249ec1fafef /sdnr/wt/data-provider/setup/src/test | |
parent | 23c27ddcd79913d11eac16eb42c5a43899de97a1 (diff) |
Reformat sdnr data-provider to ONAP code style
Reformat to ONAP code style
Issue-ID: SDNC-1275
Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Change-Id: I16230015ab8af278ec9f865690b9308d8fa2c78a
Signed-off-by: highstreetherbert <herbert.eiselt@highstreet-technologies.com>
Diffstat (limited to 'sdnr/wt/data-provider/setup/src/test')
5 files changed, 197 insertions, 229 deletions
diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java index 03629edaa..c7864560b 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java @@ -48,128 +48,111 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; * */ public class TestData { - private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" - + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" - + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n" - + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" - + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n" - + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject EVENTLOG_SEARCHHIT2= new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" - + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" - + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"3\",\n" - + "\"timeStamp\": \"2020-02-22T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" - + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connected\",\n" - + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final String CONFIG_CONTENT = "[dcae]\n" + - "dcaeUserCredentials=admin:admin\n" + - "dcaeUrl=off\n" + - "dcaeHeartbeatPeriodSeconds=120\n" + - "dcaeTestCollector=no\n" + - "\n" + - "[es]\n" + - "esCluster=sendateodl5\n" + - "#time limit to keep increasing data in database [in seconds]\n" + - "#60*60*24*30 (30days)\n" + - "esArchiveLimit=2592000\n" + - "#folder where removed data will be stored\n" + - "esArchiveFolder=./backup\n" + - "#interval to archive database [in seconds]\n" + - "#60*60*24 (1day)\n" + - "esArchiveInterval=86400\n" + - "\n" + - "[aai]\n" + - "#keep comment\n" + - "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + - "aaiUrl=http://localhost:81\n" + - "aaiUserCredentials=AAI:AAI\n" + - "aaiDeleteOnMountpointRemove=false\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" + - ""; - @Test - public void testComponentData() { - JSONArray hits = new JSONArray(); - hits.put(EVENTLOG_SEARCHHIT); - hits.put(EVENTLOG_SEARCHHIT2); - ComponentData data = new ComponentData(ComponentName.EVENTLOG,hits); - JSONArray out = data.toJsonArray(); - assertEquals(ComponentName.EVENTLOG, data.getName()); - JSONAssert.assertEquals(EVENTLOG_SEARCHHIT.toString(),out.getJSONObject(0).toString(),false); - JSONAssert.assertEquals(EVENTLOG_SEARCHHIT2.toString(),out.getJSONObject(1).toString(),false); - - } - @Test - public void testConfigData() { - ConfigData data = new ConfigData(CONFIG_CONTENT); - assertTrue(data.getLines().length>10); - } - @Test - public void testConfigName() { - ConfigName name = ConfigName.APIGATEWAY; - assertEquals("apigateway", name.getValue()); - try { - assertEquals(ConfigName.APIGATEWAY,ConfigName.getValueOf("apigateway")); - } catch (Exception e) { - fail(e.getMessage()); - } - - } - @Test - public void testDataContainer() { - DataContainer container = new DataContainer(); - assertEquals(Release.CURRENT_RELEASE,container.getRelease()); - assertNotNull(container.getCreated()); - - try { - container = DataContainer.load(new File("src/test/resources/test.bak.json")); - } catch (Exception e) { - fail(e.getMessage()); - } - assertNotNull(container); - assertEquals(Release.EL_ALTO,container.getRelease()); - assertNotNull(container.getCreated()); - assertTrue(container.getComponents().size()>0); - assertTrue(container.getConfigs().size()==0); - } - @Test - public void testReport() { - DataMigrationReport report = new DataMigrationReport(); - - assertFalse(report.completed()); - long myvar = 42; - String myvar2 = "come"; - report.log("%d was wrong",myvar); - report.error("%s to me",myvar2); - assertTrue(report.toString().contains("42 was wrong")); - assertTrue(report.toString().contains("come to me")); - report.setCompleted(true); - assertTrue(report.completed()); - - } - @Test - public void TestPluginFileCreation() { - - final String TESTFILE = "asi324po.sa"; - try { - MavenDatabasePluginInitFile.create(Release.FRANKFURT_R1, TESTFILE); - } catch (IOException e) { - fail(e.getMessage()); - } - File f = new File(TESTFILE); - if(f.exists()) { - f.delete(); - } - } - + private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" + + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" + + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n" + + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" + + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n" + + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject EVENTLOG_SEARCHHIT2 = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" + + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" + + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"3\",\n" + + "\"timeStamp\": \"2020-02-22T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" + + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connected\",\n" + + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final String CONFIG_CONTENT = "[dcae]\n" + "dcaeUserCredentials=admin:admin\n" + "dcaeUrl=off\n" + + "dcaeHeartbeatPeriodSeconds=120\n" + "dcaeTestCollector=no\n" + "\n" + "[es]\n" + + "esCluster=sendateodl5\n" + "#time limit to keep increasing data in database [in seconds]\n" + + "#60*60*24*30 (30days)\n" + "esArchiveLimit=2592000\n" + "#folder where removed data will be stored\n" + + "esArchiveFolder=./backup\n" + "#interval to archive database [in seconds]\n" + "#60*60*24 (1day)\n" + + "esArchiveInterval=86400\n" + "\n" + "[aai]\n" + "#keep comment\n" + + "aaiHeaders=[\"X-TransactionId: 9999\"]\n" + "aaiUrl=http://localhost:81\n" + + "aaiUserCredentials=AAI:AAI\n" + "aaiDeleteOnMountpointRemove=false\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" + ""; + + @Test + public void testComponentData() { + JSONArray hits = new JSONArray(); + hits.put(EVENTLOG_SEARCHHIT); + hits.put(EVENTLOG_SEARCHHIT2); + ComponentData data = new ComponentData(ComponentName.EVENTLOG, hits); + JSONArray out = data.toJsonArray(); + assertEquals(ComponentName.EVENTLOG, data.getName()); + JSONAssert.assertEquals(EVENTLOG_SEARCHHIT.toString(), out.getJSONObject(0).toString(), false); + JSONAssert.assertEquals(EVENTLOG_SEARCHHIT2.toString(), out.getJSONObject(1).toString(), false); + + } + + @Test + public void testConfigData() { + ConfigData data = new ConfigData(CONFIG_CONTENT); + assertTrue(data.getLines().length > 10); + } + + @Test + public void testConfigName() { + ConfigName name = ConfigName.APIGATEWAY; + assertEquals("apigateway", name.getValue()); + try { + assertEquals(ConfigName.APIGATEWAY, ConfigName.getValueOf("apigateway")); + } catch (Exception e) { + fail(e.getMessage()); + } + + } + + @Test + public void testDataContainer() { + DataContainer container = new DataContainer(); + assertEquals(Release.CURRENT_RELEASE, container.getRelease()); + assertNotNull(container.getCreated()); + + try { + container = DataContainer.load(new File("src/test/resources/test.bak.json")); + } catch (Exception e) { + fail(e.getMessage()); + } + assertNotNull(container); + assertEquals(Release.EL_ALTO, container.getRelease()); + assertNotNull(container.getCreated()); + assertTrue(container.getComponents().size() > 0); + assertTrue(container.getConfigs().size() == 0); + } + + @Test + public void testReport() { + DataMigrationReport report = new DataMigrationReport(); + + assertFalse(report.completed()); + long myvar = 42; + String myvar2 = "come"; + report.log("%d was wrong", myvar); + report.error("%s to me", myvar2); + assertTrue(report.toString().contains("42 was wrong")); + assertTrue(report.toString().contains("come to me")); + report.setCompleted(true); + assertTrue(report.completed()); + + } + + @Test + public void TestPluginFileCreation() { + + final String TESTFILE = "asi324po.sa"; + try { + MavenDatabasePluginInitFile.create(Release.FRANKFURT_R1, TESTFILE); + } catch (IOException e) { + fail(e.getMessage()); + } + File f = new File(TESTFILE); + if (f.exists()) { + f.delete(); + } + } + } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java index 4d5ebaa4a..05a2ffe7a 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java @@ -42,9 +42,9 @@ public class TestElAltoReleaseInformation { Set<ComponentName> components = ri.getComponents(); assertFalse(components.contains(ComponentName.CONNECTIONLOG)); assertTrue(components.contains(ComponentName.EVENTLOG)); - assertEquals("sdnevents",ri.getAlias(ComponentName.FAULTLOG)); - assertEquals("sdnevents_v1",ri.getIndex(ComponentName.FAULTLOG)); - assertNull(ri.getConverter(Release.EL_ALTO,ComponentName.CONNECTIONLOG)); + assertEquals("sdnevents", ri.getAlias(ComponentName.FAULTLOG)); + assertEquals("sdnevents_v1", ri.getIndex(ComponentName.FAULTLOG)); + assertNull(ri.getConverter(Release.EL_ALTO, ComponentName.CONNECTIONLOG)); assertNotNull(ri.getConverter(Release.EL_ALTO, ComponentName.FAULTCURRENT)); } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java index 07a60a0f1..d515e2a6b 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java @@ -38,100 +38,85 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.elalto.ElAltoReleaseIn */ public class TestElAltoToFrankfurtConversion { - private static final JSONObject FAULTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"faultlog\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" - + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"fault\": {\n" - + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" - + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" - + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject FAULTCURRENT_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"faultcurrent\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" - + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"faultCurrent\": {\n" - + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" - + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" - + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject INVENTORY_SEARCHHIT = new JSONObject( - "{\n" + "\"_index\": \"sdnevents_v1\",\n" + "\"_type\": \"inventoryequipment\",\n" - + "\"_id\": \"sim12600/a2.module-1.1.5.5\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" - + "\"_source\": {\n" + "\"treeLevel\": 2,\n" + "\"parentUuid\": \"CARD-1.1.5.0\",\n" - + "\"mountpoint\": \"sim12600\",\n" + "\"uuid\": \"a2.module-1.1.5.5\",\n" - + "\"containedHolder\": [\n" + "\"SUBRACK-1.55.0.0\"\n" + "],\n" + "\"manufacturerName\": null,\n" - + "\"manufacturerIdentifier\": \"ONF-Wireless-Transport\",\n" + "\"serial\": \"310330015\",\n" - + "\"date\": \"2013-04-13T00:00:00.0Z\",\n" + "\"version\": \"a2.module-newest\",\n" - + "\"description\": \"WS/p8.module/a2.module#5\",\n" + "\"partTypeId\": \"3EM23141AD01\",\n" - + "\"modelIdentifier\": \"CRPQABVFAA\",\n" + "\"typeName\": \"a2.module\"\n" + "}\n" + "}"); - private static final JSONObject REQUIREDNE_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" - + "\"_type\": \"required-networkelement\",\n" + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" - + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"mountId\": \"sim2230\",\n" + "\"host\": \"10.20.5.2\",\n" - + "\"port\": 2230,\n" + "\"username\": \"adsa\",\n" + "\"password\": \"asda\"\n" + "}\n" + "}"); - private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" - + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" - + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" - + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n" - + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" - + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n" - + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); - private static final JSONObject MAINTENANCE_SEARCHHIT = new JSONObject("{\n" + - "\"_index\": \"mwtn_v1\",\n" + - "\"_type\": \"maintenancemode\",\n" + - "\"_id\": \"sim2230\",\n" + - "\"_version\": 1,\n" + - "\"_score\": 1,\n" + - "\"_source\": {\n" + - "\"node\": \"sim2230\",\n" + - "\"filter\": [\n" + - "{\n" + - "\"definition\": {\n" + - "\"object-id-ref\": \"\",\n" + - "\"problem\": \"\"\n" + - "},\n" + - "\"description\": \"\",\n" + - "\"start\": \"\",\n" + - "\"end\": \"\"\n" + - "}\n" + - "],\n" + - "\"active\": false\n" + - "}\n" + - "}"); - @Test - public void test() { - ElAltoReleaseInformation ri = new ElAltoReleaseInformation(); - //faultlog - SearchHitConverter faultlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTLOG); - assertNotNull(faultlogConverter); - SearchHit frankfurtFaultlogEntry = faultlogConverter.convert(new SearchHit(FAULTLOG_SEARCHHIT)); - assertNotNull(frankfurtFaultlogEntry); - //faultcurrent - SearchHitConverter faultcurrentConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT); - assertNotNull(faultcurrentConverter); - SearchHit frankfurtFaultcurrentEntry = faultcurrentConverter.convert(new SearchHit(FAULTCURRENT_SEARCHHIT)); - assertNotNull(frankfurtFaultcurrentEntry); - //inventory - SearchHitConverter inventoryConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORY); - assertNotNull(inventoryConverter); - SearchHit frankfurtInventory = inventoryConverter.convert(new SearchHit(INVENTORY_SEARCHHIT)); - assertNotNull(frankfurtInventory); - //inventory - SearchHitConverter neConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.REQUIRED_NETWORKELEMENT); - assertNotNull(neConverter); - SearchHit frankfurtNE = neConverter.convert(new SearchHit(REQUIREDNE_SEARCHHIT)); - assertNotNull(frankfurtNE); - //eventlog - SearchHitConverter eventlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.EVENTLOG); - assertNotNull(eventlogConverter); - SearchHit frankfurtEvent = eventlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); - assertNull(frankfurtEvent); - //eventlog->connectionlog - SearchHitConverter conlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.CONNECTIONLOG); - assertNotNull(conlogConverter); - SearchHit frankfurtconlog = conlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); - assertNotNull(frankfurtconlog); - //maintenance - SearchHitConverter maintenanceConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.MAINTENANCE); - assertNotNull(maintenanceConverter); - SearchHit frankfurtmaint = maintenanceConverter.convert(new SearchHit(MAINTENANCE_SEARCHHIT)); - assertNotNull(frankfurtmaint); + private static final JSONObject FAULTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"faultlog\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" + + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"fault\": {\n" + + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" + + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" + + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject FAULTCURRENT_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"faultcurrent\",\n" + "\"_id\": \"sim12600/LP-MWS-TTP-01/unknownProblem1\",\n" + + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"faultCurrent\": {\n" + + "\"nodeName\": \"sim12600\",\n" + "\"counter\": \"1\",\n" + "\"timeStamp\": \"2017-01-01T00:00:00.0Z\",\n" + + "\"objectId\": \"LP-MWS-TTP-01\",\n" + "\"problem\": \"unknownProblem1\",\n" + + "\"severity\": \"Critical\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject INVENTORY_SEARCHHIT = + new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + "\"_type\": \"inventoryequipment\",\n" + + "\"_id\": \"sim12600/a2.module-1.1.5.5\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" + + "\"_source\": {\n" + "\"treeLevel\": 2,\n" + "\"parentUuid\": \"CARD-1.1.5.0\",\n" + + "\"mountpoint\": \"sim12600\",\n" + "\"uuid\": \"a2.module-1.1.5.5\",\n" + + "\"containedHolder\": [\n" + "\"SUBRACK-1.55.0.0\"\n" + "],\n" + "\"manufacturerName\": null,\n" + + "\"manufacturerIdentifier\": \"ONF-Wireless-Transport\",\n" + "\"serial\": \"310330015\",\n" + + "\"date\": \"2013-04-13T00:00:00.0Z\",\n" + "\"version\": \"a2.module-newest\",\n" + + "\"description\": \"WS/p8.module/a2.module#5\",\n" + "\"partTypeId\": \"3EM23141AD01\",\n" + + "\"modelIdentifier\": \"CRPQABVFAA\",\n" + "\"typeName\": \"a2.module\"\n" + "}\n" + "}"); + private static final JSONObject REQUIREDNE_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" + + "\"_type\": \"required-networkelement\",\n" + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" + + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"mountId\": \"sim2230\",\n" + "\"host\": \"10.20.5.2\",\n" + + "\"port\": 2230,\n" + "\"username\": \"adsa\",\n" + "\"password\": \"asda\"\n" + "}\n" + "}"); + private static final JSONObject EVENTLOG_SEARCHHIT = new JSONObject("{\n" + "\"_index\": \"sdnevents_v1\",\n" + + "\"_type\": \"eventlog\",\n" + "\"_id\": \"AXB7cJHlZ_FApnwi29xq\",\n" + "\"_version\": 1,\n" + + "\"_score\": 1,\n" + "\"_source\": {\n" + "\"event\": {\n" + + "\"nodeName\": \"SDN-Controller-465e2ae306ca\",\n" + "\"counter\": \"1\",\n" + + "\"timeStamp\": \"2020-02-25T08:22:19.8Z\",\n" + "\"objectId\": \"sim2230\",\n" + + "\"attributeName\": \"ConnectionStatus\",\n" + "\"newValue\": \"connecting\",\n" + + "\"type\": \"AttributeValueChangedNotificationXml\"\n" + "}\n" + "}\n" + "}"); + private static final JSONObject MAINTENANCE_SEARCHHIT = + new JSONObject("{\n" + "\"_index\": \"mwtn_v1\",\n" + "\"_type\": \"maintenancemode\",\n" + + "\"_id\": \"sim2230\",\n" + "\"_version\": 1,\n" + "\"_score\": 1,\n" + "\"_source\": {\n" + + "\"node\": \"sim2230\",\n" + "\"filter\": [\n" + "{\n" + "\"definition\": {\n" + + "\"object-id-ref\": \"\",\n" + "\"problem\": \"\"\n" + "},\n" + "\"description\": \"\",\n" + + "\"start\": \"\",\n" + "\"end\": \"\"\n" + "}\n" + "],\n" + "\"active\": false\n" + "}\n" + "}"); - } + @Test + public void test() { + ElAltoReleaseInformation ri = new ElAltoReleaseInformation(); + //faultlog + SearchHitConverter faultlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTLOG); + assertNotNull(faultlogConverter); + SearchHit frankfurtFaultlogEntry = faultlogConverter.convert(new SearchHit(FAULTLOG_SEARCHHIT)); + assertNotNull(frankfurtFaultlogEntry); + //faultcurrent + SearchHitConverter faultcurrentConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT); + assertNotNull(faultcurrentConverter); + SearchHit frankfurtFaultcurrentEntry = faultcurrentConverter.convert(new SearchHit(FAULTCURRENT_SEARCHHIT)); + assertNotNull(frankfurtFaultcurrentEntry); + //inventory + SearchHitConverter inventoryConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORY); + assertNotNull(inventoryConverter); + SearchHit frankfurtInventory = inventoryConverter.convert(new SearchHit(INVENTORY_SEARCHHIT)); + assertNotNull(frankfurtInventory); + //inventory + SearchHitConverter neConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.REQUIRED_NETWORKELEMENT); + assertNotNull(neConverter); + SearchHit frankfurtNE = neConverter.convert(new SearchHit(REQUIREDNE_SEARCHHIT)); + assertNotNull(frankfurtNE); + //eventlog + SearchHitConverter eventlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.EVENTLOG); + assertNotNull(eventlogConverter); + SearchHit frankfurtEvent = eventlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); + assertNull(frankfurtEvent); + //eventlog->connectionlog + SearchHitConverter conlogConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.CONNECTIONLOG); + assertNotNull(conlogConverter); + SearchHit frankfurtconlog = conlogConverter.convert(new SearchHit(EVENTLOG_SEARCHHIT)); + assertNotNull(frankfurtconlog); + //maintenance + SearchHitConverter maintenanceConverter = ri.getConverter(Release.FRANKFURT_R1, ComponentName.MAINTENANCE); + assertNotNull(maintenanceConverter); + SearchHit frankfurtmaint = maintenanceConverter.convert(new SearchHit(MAINTENANCE_SEARCHHIT)); + assertNotNull(frankfurtmaint); + + } } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java index 47a3a8f74..1d7a6eb6d 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java @@ -42,9 +42,9 @@ public class TestFrankfurtReleaseInformation { Set<ComponentName> components = ri.getComponents(); assertFalse(components.contains(ComponentName.INVENTORYTOPLEVEL)); assertTrue(components.contains(ComponentName.EVENTLOG)); - assertEquals("faultlog",ri.getAlias(ComponentName.FAULTLOG)); - assertEquals("faultlog-v2",ri.getIndex(ComponentName.FAULTLOG)); - assertNull(ri.getConverter(Release.FRANKFURT_R1,ComponentName.INVENTORYTOPLEVEL)); + assertEquals("faultlog", ri.getAlias(ComponentName.FAULTLOG)); + assertEquals("faultlog-v2", ri.getIndex(ComponentName.FAULTLOG)); + assertNull(ri.getConverter(Release.FRANKFURT_R1, ComponentName.INVENTORYTOPLEVEL)); assertNotNull(ri.getConverter(Release.FRANKFURT_R1, ComponentName.FAULTCURRENT)); } diff --git a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java index 1ec19117b..02877f0c8 100644 --- a/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java +++ b/sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java @@ -37,17 +37,17 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release; */ public class TestMigrationProvider { - private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json"; - public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer - .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) }; + private static final String FRANKFURT_BACKUP_FILE = "src/test/resources/test2.bak.json"; + public static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer + .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))}; @Test public void testCreateImport() { - DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null,true,5000); + DataMigrationProviderImpl provider = new DataMigrationProviderImpl(hosts, null, null, true, 5000); try { //create el alto db infrastructure - provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true,10000); + provider.initDatabase(Release.FRANKFURT_R1, 5, 1, "", true, 10000); //import data into database DataMigrationReport report = provider.importData(FRANKFURT_BACKUP_FILE, false, Release.FRANKFURT_R1); assertTrue(report.completed()); |