aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/wt
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/wt')
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java93
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java40
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java136
-rw-r--r--sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java264
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java99
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java120
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java155
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java60
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java56
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java44
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java337
-rw-r--r--sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java14
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java47
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/PropertyService.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java118
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/Configuration.java2
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java402
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/exception/ConfigurationException.java2
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java86
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java59
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java51
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseConfig.java2
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java31
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java377
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/IsEsObject.java4
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java18
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java6
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java77
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java155
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java41
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java54
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java66
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java199
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java158
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java60
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java112
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilder.java128
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java70
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RangeQueryBuilder.java118
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RegexQueryBuilder.java38
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/SortOrder.java20
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java145
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterHealthRequest.java18
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterSettingsRequest.java41
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CountRequest.java12
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java19
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java27
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteIndexRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java35
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetIndexRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java64
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java10
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java10
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/NodeStatsRequest.java10
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/RefreshIndexRequest.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/SearchRequest.java16
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java148
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java240
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AcknowledgedResponse.java24
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AggregationEntries.java33
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java107
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java1
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterSettingsResponse.java2
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java6
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateIndexResponse.java6
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteByQueryResponse.java32
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteIndexResponse.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java44
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java63
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetResponse.java46
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/IndexResponse.java51
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java22
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java35
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/NodeStatsResponse.java161
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/RefreshIndexResponse.java20
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/SearchResponse.java104
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateByQueryResponse.java69
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateResponse.java61
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java5
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java109
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomPropertiesFile.java112
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java6
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java33
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java46
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java335
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/Environment.java30
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/ResourceFileLoader.java8
-rw-r--r--sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/StackTrace.java1
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java272
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java73
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java432
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java106
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java298
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java409
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java972
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java144
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java277
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java48
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java13
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java24
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java203
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java349
-rw-r--r--sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java14
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java6
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java10
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java4
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java6
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java6
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java104
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java17
-rw-r--r--sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java67
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java39
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java242
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java45
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java27
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java122
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java11
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java110
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java26
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java104
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java75
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java316
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java41
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java526
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java326
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java77
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java442
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java100
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java566
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java42
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java64
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java159
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java55
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java170
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java13
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java122
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java38
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java37
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java351
-rw-r--r--sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java434
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java180
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java994
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java35
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java283
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java2
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java440
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java65
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java78
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java14
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java94
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java6
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java77
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java4
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java251
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java12
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java150
-rw-r--r--sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java283
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java108
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java81
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java200
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java301
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java46
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java68
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java63
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java15
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java55
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java196
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java54
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java72
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java27
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java42
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java148
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java61
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java126
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java119
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java27
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java67
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java65
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java73
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java61
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java108
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java14
-rw-r--r--sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java76
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestData.java231
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoReleaseInformation.java6
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestElAltoToFrankfurtConversion.java173
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestFrankfurtReleaseInformation.java6
-rw-r--r--sdnr/wt/data-provider/setup/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/TestMigrationProvider.java10
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java6
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElementFactory.java8
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java34
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java42
-rw-r--r--sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java60
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java3
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java5
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java7
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java4
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java2
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java13
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java8
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java6
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java22
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java150
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java192
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java186
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java20
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java20
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java20
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java8
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java8
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java747
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java14
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java40
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java4
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java6
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java24
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java72
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java99
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java34
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java465
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java443
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java464
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java84
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java27
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java137
-rw-r--r--sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java137
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/DeviceManagerORanImpl.java2
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/NtsNetworkElement.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java2
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java17
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElementFactory.java4
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java2
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java11
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java107
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java17
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java72
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java10
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java4
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java80
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java68
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java58
-rw-r--r--sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java26
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java32
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java22
-rw-r--r--sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java4
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java12
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java26
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java6
-rw-r--r--sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java43
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java22
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java11
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java28
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java50
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java19
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java58
-rw-r--r--sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java11
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java13
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java20
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java176
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java9
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java46
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java19
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java14
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java10
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java6
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java8
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java27
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java18
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java9
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java11
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java9
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java4
-rw-r--r--sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java4
-rw-r--r--sdnr/wt/odlux/apps/apiDemo/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/configurationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/demoApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/eventLogApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/eventLogApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/faultApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/helpApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/inventoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/mediatorApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/minimumApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/apps/performanceHistoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/apps/performanceHistoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java4
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java4
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/IndexOdlBundle.java4
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java4
-rw-r--r--sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexOdluxBundle.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/OdluxBundleLoaderImpl.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/ResFilesServlet.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestBundleLoaderImpl.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestLoadResources.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestRedirect.java4
-rw-r--r--sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestResFileServlet.java4
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/Blueprint.java4
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManager.java14
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerProvider.java8
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerSocket.java28
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/AkkaConfig.java167
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/UserScopes.java40
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/websocket/SyncWebSocketClient.java172
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/AkkaConfigTest.java19
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/UserScopeTest.java14
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsockerProviderTest.java6
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketClientTest.java6
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketMessageTest.java13
-rw-r--r--sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketServerConnectTest.java4
339 files changed, 13241 insertions, 12896 deletions
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java
index 44cad5f12..0cdf79d43 100644
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/AaiServlet.java
@@ -27,58 +27,59 @@ import javax.servlet.http.HttpServletResponse;
public class AaiServlet extends BaseServlet {
- /**
- *
- */
- private static final long serialVersionUID = 5946205120796162644L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "AAI interface is offline";
- private static boolean trustAll = false;
- public AaiServlet() {
- super();
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 5946205120796162644L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "AAI interface is offline";
+ private static boolean trustAll = false;
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
+ public AaiServlet() {
+ super();
+ }
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isAAIOff();
- }
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
- @Override
- protected String getRemoteUrl(String uri) {
+ @Override
+ protected boolean isOff() {
+ return MyProperties.getInstance().isAAIOff();
+ }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.startsWith("aai")) {
- uri = uri.substring("aai".length());
- }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- String base = MyProperties.getInstance().getAAIBaseUrl();
- if (!base.endsWith("/")) {
- base += "/";
- }
+ @Override
+ protected String getRemoteUrl(String uri) {
- return base + uri;
- }
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ if (uri.startsWith("aai")) {
+ uri = uri.substring("aai".length());
+ }
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ String base = MyProperties.getInstance().getAAIBaseUrl();
+ if (!base.endsWith("/")) {
+ base += "/";
+ }
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
+ return base + uri;
+ }
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java
index a7173df28..dab7ad776 100644
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/BaseServlet.java
@@ -61,7 +61,9 @@ public abstract class BaseServlet extends HttpServlet {
protected abstract boolean isOff();
protected abstract boolean doTrustAll();
+
protected abstract void trustAll(boolean trust);
+
protected abstract String getRemoteUrl(String uri);
/**
@@ -74,7 +76,7 @@ public abstract class BaseServlet extends HttpServlet {
sc = SSLContext.getInstance("TLSv1.2");
if (trustall) {
if (trustCerts == null) {
- trustCerts = new TrustManager[] { new javax.net.ssl.X509TrustManager() {
+ trustCerts = new TrustManager[] {new javax.net.ssl.X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[] {};
@@ -89,7 +91,7 @@ public abstract class BaseServlet extends HttpServlet {
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
// do not check anything when trust all
}
- } };
+ }};
}
} else {
if (trustCerts != null) {
@@ -162,8 +164,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -188,8 +189,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -214,8 +214,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -240,8 +239,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -253,24 +251,24 @@ public abstract class BaseServlet extends HttpServlet {
private URLConnection getConnection(HttpServletRequest req, final String method) throws IOException {
- LOG.debug("{} Request to {}", method,req.getRequestURL());
+ LOG.debug("{} Request to {}", method, req.getRequestURL());
String surl = this.getRemoteUrl(req.getRequestURI());
- if("GET".equals(method)) {
+ if ("GET".equals(method)) {
Enumeration<?> params = req.getParameterNames();
- if(params!=null) {
+ if (params != null) {
String param;
- if(params.hasMoreElements()) {
- param=(String)params.nextElement();
- surl+="?"+param+"="+req.getParameter(param);
+ if (params.hasMoreElements()) {
+ param = (String) params.nextElement();
+ surl += "?" + param + "=" + req.getParameter(param);
}
- while(params.hasMoreElements()) {
- param=(String)params.nextElement();
- surl+="&"+param+"="+req.getParameter(param);
+ while (params.hasMoreElements()) {
+ param = (String) params.nextElement();
+ surl += "&" + param + "=" + req.getParameter(param);
}
}
}
LOG.debug("RemoteURL: {}", surl);
- if(surl==null) {
+ if (surl == null) {
return null;
}
URL url = new URL(surl);
@@ -288,7 +286,7 @@ public abstract class BaseServlet extends HttpServlet {
String s = "";
Enumeration<?> headers = req.getHeaderNames();
while (headers.hasMoreElements()) {
- String h = (String)headers.nextElement();
+ String h = (String) headers.nextElement();
String v = req.getHeader(h);
if (h != null && h.equals("Host")) {
v = url.getAuthority();
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java
index f08a7fffa..5db305ecb 100644
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/EsServlet.java
@@ -30,68 +30,74 @@ import org.slf4j.LoggerFactory;
public class EsServlet extends BaseServlet {
- /**
- *
- */
- private static final long serialVersionUID = -3996363343749995011L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "Database interface is offline";
- private static Logger LOG = LoggerFactory.getLogger(EsServlet.class);
-
- private static boolean trustAll = false;
-
- public EsServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- if (MyProperties.getInstance().corsEnabled()) {
- resp.addHeader("Access-Control-Allow-Origin", "*");
- resp.addHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
- resp.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
- }
- resp.setStatus(200);
- }
-
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- @Override
- protected boolean isOff() {
- return MyProperties.getInstance().isEsOff();
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
- if (uri != null && uri.length() > 0) {
- uri = uri.substring("/database".length());
- }
- return MyProperties.getInstance().getEsBaseUrl() + uri;
- }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
- @Override
- protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
- @Override
- protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-}
+ /**
+ *
+ */
+ private static final long serialVersionUID = -3996363343749995011L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "Database interface is offline";
+ private static Logger LOG = LoggerFactory.getLogger(EsServlet.class);
+
+ private static boolean trustAll = false;
+
+ public EsServlet() {
+ super();
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ if (MyProperties.getInstance().corsEnabled()) {
+ resp.addHeader("Access-Control-Allow-Origin", "*");
+ resp.addHeader("Access-Control-Allow-Methods", "GET,PUT,POST,DELETE");
+ resp.addHeader("Access-Control-Allow-Headers", "Content-Type, Authorization");
+ }
+ resp.setStatus(200);
+ }
+
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
+
+ @Override
+ protected boolean isOff() {
+ return MyProperties.getInstance().isEsOff();
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+ if (uri != null && uri.length() > 0) {
+ uri = uri.substring("/database".length());
+ }
+ return MyProperties.getInstance().getEsBaseUrl() + uri;
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+
+ @Override
+ protected void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPut(req, resp);
+ }
+
+ @Override
+ protected void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doDelete(req, resp);
+ }
+
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
+}
diff --git a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
index 36fce2081..d49b4dce2 100644
--- a/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
+++ b/sdnr/wt/apigateway/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/apigateway/MyProperties.java
@@ -35,137 +35,137 @@ import org.slf4j.LoggerFactory;
public class MyProperties {
- private static Logger LOG = LoggerFactory.getLogger(MyProperties.class);
- public static final String PROPFILE = "etc/apigateway.properties";
- private static final String DEFAULT_AAI_HEADERS = "[\"X-FromAppId:SDNR\",\"Authorization:Basic QUFJOkFBSQ==\"]";
- private static final String DEFAULT_CORSENABLED = "0";
- private static final String DEFAULT_TRUSTINSECURE = "0";
- private static final String DEFAULT_ESDATABASE = "http://sdnrdb:9200";
- private static final String DEFAULT_AAI = "off";
-
- @Override
- public String toString() {
- return "MyProperties [aaiBase=" + aaiBase + ", aaiHeaders=" + aaiHeaders + ", esBase=" + esBase
- + ", trustInsecure=" + trustInsecure + ", corsEnabled=" + corsEnabled + "]";
- }
-
- private static MyProperties mObj;
-
- private String aaiBase;
- private Map<String, String> aaiHeaders;
- private String esBase;
-
- private boolean trustInsecure;
-
- private boolean corsEnabled;
-
- public boolean isAAIOff() {
- return this.aaiBase == null ? true : this.aaiBase.equals("off");
- }
-
- public boolean isEsOff() {
- return this.esBase == null ? true : this.esBase.equals("off");
- }
-
- public String getAAIBaseUrl() {
- return this.aaiBase;
- }
-
- public String getEsBaseUrl() {
- return this.esBase;
- }
-
- public Map<String, String> getAAIHeaders() {
- return this.aaiHeaders;
- }
-
- public boolean trustInsecure() {
- return this.trustInsecure;
- }
-
- public boolean corsEnabled() {
- return this.corsEnabled;
- }
-
- public static MyProperties Instantiate() throws IOException, NumberFormatException {
- return Instantiate(new File(PROPFILE));
- }
-
- public static MyProperties Instantiate(File file) throws IOException, NumberFormatException {
-
- return Instantiate(file, false);
- }
-
- public static MyProperties Instantiate(File file, boolean force) throws IOException, NumberFormatException {
- if (mObj == null || force) {
- mObj = new MyProperties(file);
- LOG.debug("instantiated: {}", mObj.toString());
- }
- return mObj;
- }
-
- private MyProperties(File file) throws IOException, NumberFormatException {
- this.aaiBase = "off";
- this.trustInsecure = false;
- if (!file.exists()) {
- this.writeDefaults(file);
- }
- this.load(new FileInputStream(file));
- }
-
- public void load(InputStream in) throws IOException, NumberFormatException {
-
- Properties defaultProps = new Properties();
- defaultProps.load(in);
- in.close();
-
- this.aaiBase = defaultProps.getProperty("aai", DEFAULT_AAI);
- this.aaiHeaders = _parseHeadersMap(defaultProps.getProperty("aaiHeaders", DEFAULT_AAI_HEADERS));
- this.esBase = defaultProps.getProperty("database", DEFAULT_ESDATABASE);
- this.trustInsecure = Integer.parseInt(defaultProps.getProperty("insecure", DEFAULT_TRUSTINSECURE)) == 1;
- this.corsEnabled = Integer.parseInt(defaultProps.getProperty("cors", DEFAULT_CORSENABLED)) == 1;
- }
-
- private static Map<String, String> _parseHeadersMap(String s) {
- Map<String, String> r = new HashMap<>();
- try {
- JSONArray a = new JSONArray(s);
- if ( a.length() > 0) {
- for (int i = 0; i < a.length(); i++) {
- String item = a.getString(i);
- String[] hlp = item.split(":");
- if (hlp.length > 1) {
- r.put(hlp[0], hlp[1]);
- }
- }
- }
- } catch (Exception e) {
- LOG.warn("problem loading headers map: {}",e.getMessage());
- }
- return r;
- }
-
- private String writeDefaults(File f) throws IOException {
- StringBuilder sb = new StringBuilder();
- final String LR = "\n";
- FileWriter fw = new FileWriter(f);
- sb.append("aai=" + DEFAULT_AAI + LR);
- sb.append("aaiHeaders=" + DEFAULT_AAI_HEADERS + LR);
- sb.append("database=" + DEFAULT_ESDATABASE + LR);
- sb.append("insecure=" + DEFAULT_TRUSTINSECURE + LR);
- sb.append("cors=" + DEFAULT_CORSENABLED);
- try {
- fw.write(sb.toString());
- } catch (Exception e) {
- LOG.warn("problem writing default values to propertyfile {} : {}", f.getAbsolutePath() , e.getMessage());
- } finally {
- fw.close();
- }
- return sb.toString();
- }
-
- public static MyProperties getInstance() {
- return mObj;
- }
+ private static Logger LOG = LoggerFactory.getLogger(MyProperties.class);
+ public static final String PROPFILE = "etc/apigateway.properties";
+ private static final String DEFAULT_AAI_HEADERS = "[\"X-FromAppId:SDNR\",\"Authorization:Basic QUFJOkFBSQ==\"]";
+ private static final String DEFAULT_CORSENABLED = "0";
+ private static final String DEFAULT_TRUSTINSECURE = "0";
+ private static final String DEFAULT_ESDATABASE = "http://sdnrdb:9200";
+ private static final String DEFAULT_AAI = "off";
+
+ @Override
+ public String toString() {
+ return "MyProperties [aaiBase=" + aaiBase + ", aaiHeaders=" + aaiHeaders + ", esBase=" + esBase
+ + ", trustInsecure=" + trustInsecure + ", corsEnabled=" + corsEnabled + "]";
+ }
+
+ private static MyProperties mObj;
+
+ private String aaiBase;
+ private Map<String, String> aaiHeaders;
+ private String esBase;
+
+ private boolean trustInsecure;
+
+ private boolean corsEnabled;
+
+ public boolean isAAIOff() {
+ return this.aaiBase == null ? true : this.aaiBase.equals("off");
+ }
+
+ public boolean isEsOff() {
+ return this.esBase == null ? true : this.esBase.equals("off");
+ }
+
+ public String getAAIBaseUrl() {
+ return this.aaiBase;
+ }
+
+ public String getEsBaseUrl() {
+ return this.esBase;
+ }
+
+ public Map<String, String> getAAIHeaders() {
+ return this.aaiHeaders;
+ }
+
+ public boolean trustInsecure() {
+ return this.trustInsecure;
+ }
+
+ public boolean corsEnabled() {
+ return this.corsEnabled;
+ }
+
+ public static MyProperties Instantiate() throws IOException, NumberFormatException {
+ return Instantiate(new File(PROPFILE));
+ }
+
+ public static MyProperties Instantiate(File file) throws IOException, NumberFormatException {
+
+ return Instantiate(file, false);
+ }
+
+ public static MyProperties Instantiate(File file, boolean force) throws IOException, NumberFormatException {
+ if (mObj == null || force) {
+ mObj = new MyProperties(file);
+ LOG.debug("instantiated: {}", mObj.toString());
+ }
+ return mObj;
+ }
+
+ private MyProperties(File file) throws IOException, NumberFormatException {
+ this.aaiBase = "off";
+ this.trustInsecure = false;
+ if (!file.exists()) {
+ this.writeDefaults(file);
+ }
+ this.load(new FileInputStream(file));
+ }
+
+ public void load(InputStream in) throws IOException, NumberFormatException {
+
+ Properties defaultProps = new Properties();
+ defaultProps.load(in);
+ in.close();
+
+ this.aaiBase = defaultProps.getProperty("aai", DEFAULT_AAI);
+ this.aaiHeaders = _parseHeadersMap(defaultProps.getProperty("aaiHeaders", DEFAULT_AAI_HEADERS));
+ this.esBase = defaultProps.getProperty("database", DEFAULT_ESDATABASE);
+ this.trustInsecure = Integer.parseInt(defaultProps.getProperty("insecure", DEFAULT_TRUSTINSECURE)) == 1;
+ this.corsEnabled = Integer.parseInt(defaultProps.getProperty("cors", DEFAULT_CORSENABLED)) == 1;
+ }
+
+ private static Map<String, String> _parseHeadersMap(String s) {
+ Map<String, String> r = new HashMap<>();
+ try {
+ JSONArray a = new JSONArray(s);
+ if (a.length() > 0) {
+ for (int i = 0; i < a.length(); i++) {
+ String item = a.getString(i);
+ String[] hlp = item.split(":");
+ if (hlp.length > 1) {
+ r.put(hlp[0], hlp[1]);
+ }
+ }
+ }
+ } catch (Exception e) {
+ LOG.warn("problem loading headers map: {}", e.getMessage());
+ }
+ return r;
+ }
+
+ private String writeDefaults(File f) throws IOException {
+ StringBuilder sb = new StringBuilder();
+ final String LR = "\n";
+ FileWriter fw = new FileWriter(f);
+ sb.append("aai=" + DEFAULT_AAI + LR);
+ sb.append("aaiHeaders=" + DEFAULT_AAI_HEADERS + LR);
+ sb.append("database=" + DEFAULT_ESDATABASE + LR);
+ sb.append("insecure=" + DEFAULT_TRUSTINSECURE + LR);
+ sb.append("cors=" + DEFAULT_CORSENABLED);
+ try {
+ fw.write(sb.toString());
+ } catch (Exception e) {
+ LOG.warn("problem writing default values to propertyfile {} : {}", f.getAbsolutePath(), e.getMessage());
+ } finally {
+ fw.close();
+ }
+ return sb.toString();
+ }
+
+ public static MyProperties getInstance() {
+ return mObj;
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
index 0af4d69df..06bf2c17e 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestAaiServlet.java
@@ -34,53 +34,56 @@ import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpAaiServlet;
import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpEsServlet;
import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
-public class TestAaiServlet extends HelpServletBase{
+public class TestAaiServlet extends HelpServletBase {
- private static final int PORT = 40001;
- public TestAaiServlet() {
- super("/aai",PORT);
- }
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile,true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR
- + "cors=0";
- String tmpconfigcontent2 = "aai=http://" + HOST + ":" + PORT + LR + "aaiHeaders=[]" + LR + "database=off"+ LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpAaiServlet());
- // test disabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- String expectedResponse = "offline";
- testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
- testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
- testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
- testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
- if (tmpFile.exists())
- tmpFile.delete();
-
- }
- @Before
- public void init() throws IOException{
- HelpServletBase.initEsTestWebserver(PORT);
- }
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
+ private static final int PORT = 40001;
+
+ public TestAaiServlet() {
+ super("/aai", PORT);
+ }
+
+ @Test
+ public void test() throws ServletException, IOException {
+
+ String tmpFilename = "tmp.cfg";
+ File tmpFile = new File(tmpFilename);
+ if (tmpFile.exists())
+ tmpFile.delete();
+ MyProperties properties = MyProperties.Instantiate(tmpFile, true);
+ String query = "{\"query\":{\"match_all\":{}}}";
+ String tmpconfigcontent =
+ "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
+ String tmpconfigcontent2 = "aai=http://" + HOST + ":" + PORT + LR + "aaiHeaders=[]" + LR + "database=off" + LR
+ + "insecure=1" + LR + "cors=1";
+ this.setServlet(new HelpAaiServlet());
+ // test disabled message
+ properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
+ String expectedResponse = "offline";
+ testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
+
+ // initEsTestWebserver(port);
+ properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
+ testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
+ testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
+ testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
+ testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
+ testrequest(HTTPMETHOD_OPTIONS, query, "", false);
+ // stopTestWebserver();
+ if (tmpFile.exists())
+ tmpFile.delete();
+
+ }
+
+ @Before
+ public void init() throws IOException {
+ HelpServletBase.initEsTestWebserver(PORT);
+ }
+
+ @After
+ public void deinit() {
+ HelpServletBase.stopTestWebserver();
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
index d7b4c1511..bc6859ac1 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestDatabaseServlet.java
@@ -30,63 +30,65 @@ import org.onap.ccsdk.features.sdnr.wt.apigateway.test.helper.HelpServletBase;
import java.io.*;
import javax.servlet.ServletException;
-public class TestDatabaseServlet extends HelpServletBase{
-
- private static final int PORT = 40002;
-
- public TestDatabaseServlet() {
- super("/database",PORT);
- }
-
-
-
- final String LR = "\n";
-
-
-
- @Test
- public void test() throws ServletException, IOException {
-
- String tmpFilename = "tmp1.cfg";
- File tmpFile = new File(tmpFilename);
- if (tmpFile.exists())
- tmpFile.delete();
- MyProperties properties = MyProperties.Instantiate(tmpFile,true);
- String query = "{\"query\":{\"match_all\":{}}}";
- String tmpconfigcontent = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR
- + "cors=0";
- String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=http://" + HOST + ":" + PORT + LR
- + "insecure=1" + LR + "cors=1";
- this.setServlet(new HelpEsServlet());
- // test diabled message
- properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
- String expectedResponse = "offline";
- testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
- testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
- testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
- testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
-
- // initEsTestWebserver(port);
- properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
- testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
-
-
- if (tmpFile.exists())
- tmpFile.delete();
-
-
- }
- @Before
- public void init() throws IOException{
- HelpServletBase.initEsTestWebserver(PORT);
- }
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
+public class TestDatabaseServlet extends HelpServletBase {
+
+ private static final int PORT = 40002;
+
+ public TestDatabaseServlet() {
+ super("/database", PORT);
+ }
+
+
+
+ final String LR = "\n";
+
+
+
+ @Test
+ public void test() throws ServletException, IOException {
+
+ String tmpFilename = "tmp1.cfg";
+ File tmpFile = new File(tmpFilename);
+ if (tmpFile.exists())
+ tmpFile.delete();
+ MyProperties properties = MyProperties.Instantiate(tmpFile, true);
+ String query = "{\"query\":{\"match_all\":{}}}";
+ String tmpconfigcontent =
+ "aai=off" + LR + "aaiHeaders=[]" + LR + "database=off" + LR + "insecure=0" + LR + "cors=0";
+ String tmpconfigcontent2 = "aai=off" + LR + "aaiHeaders=[]" + LR + "database=http://" + HOST + ":" + PORT + LR
+ + "insecure=1" + LR + "cors=1";
+ this.setServlet(new HelpEsServlet());
+ // test diabled message
+ properties.load(new ByteArrayInputStream(tmpconfigcontent.getBytes()));
+ String expectedResponse = "offline";
+ testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
+
+ // initEsTestWebserver(port);
+ properties.load(new ByteArrayInputStream(tmpconfigcontent2.getBytes()));
+ testrequest(HTTPMETHOD_GET, query, HelpEsServlet.RESPONSE_GET, true);
+ testrequest(HTTPMETHOD_POST, query, HelpEsServlet.RESPONSE_POST, true);
+ testrequest(HTTPMETHOD_PUT, query, HelpEsServlet.RESPONSE_PUT, true);
+ testrequest(HTTPMETHOD_DELETE, query, HelpEsServlet.RESPONSE_DELETE, true);
+ testrequest(HTTPMETHOD_OPTIONS, query, "", false);
+ // stopTestWebserver();
+
+
+ if (tmpFile.exists())
+ tmpFile.delete();
+
+
+ }
+
+ @Before
+ public void init() throws IOException {
+ HelpServletBase.initEsTestWebserver(PORT);
+ }
+
+ @After
+ public void deinit() {
+ HelpServletBase.stopTestWebserver();
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
index 6efd06feb..6fad884ff 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/TestProperties.java
@@ -34,82 +34,83 @@ import org.onap.ccsdk.features.sdnr.wt.apigateway.MyProperties;
public class TestProperties {
- private static final boolean DEFAULT_CORSENABLED = false;
- private static final boolean DEFAULT_AAIOFF = true;
- private static final boolean DEFAULT_ESOFF = false;
- private static final boolean DEFAULT_TRUSTINSECURE = false;
- private static final String DEFAULT_AAIBASEURL = "off";
- private static Map<String, String> DEFAULT_AAIHEADERS = new HashMap<String, String>();
- private static final String DEFAULT_ESBASEURL = "http://sdnrdb:9200";
-
- private static final boolean CUSTOM_CORSENABLED = true;
- private static final boolean CUSTOM_AAIOFF = false;
- private static final boolean CUSTOM_ESOFF = false;
- private static final boolean CUSTOM_TRUSTINSECURE = true;
- private static final String CUSTOM_AAIBASEURL = "https://aai.tld:2214";
- private static Map<String, String> CUSTOM_AAIHEADERS = new HashMap<String, String>();
- private static final String CUSTOM_ESBASEURL = "http://localhost:9200";
-
- private static final String LR = "\n";
- final String tmpFilename = "tmp2.cfg";
-
- @Before
- @After
- public void init() {
- File f = new File(tmpFilename);
- if(f.exists()) {
- f.delete();
- }
- }
- @Test
- public void test() {
- DEFAULT_AAIHEADERS.put("X-FromAppId", "SDNR");
- DEFAULT_AAIHEADERS.put("Authorization", "Basic QUFJOkFBSQ==");
- CUSTOM_AAIHEADERS.put("X-FromAppId", "SDNC");
- CUSTOM_AAIHEADERS.put("Authorization", "Basic 1234");
- final String TESTPROPERTYFILECONTENT = "aai=" + CUSTOM_AAIBASEURL + LR + "aaiHeaders=[\"X-FromAppId:"
- + CUSTOM_AAIHEADERS.get("X-FromAppId") + "\",\"Authorization:" + CUSTOM_AAIHEADERS.get("Authorization")
- + "\"]" + LR + "database=" + CUSTOM_ESBASEURL + LR + "insecure=" + (CUSTOM_TRUSTINSECURE ? "1" : "0")
- + LR + "cors=" + (CUSTOM_CORSENABLED ? "1" : "0");
- File ftest = new File(tmpFilename);
- MyProperties prop = null;
- ftest = new File(tmpFilename);
- try {
- prop = MyProperties.Instantiate(ftest, true);
- } catch (Exception e) {
- fail("error instantiating properties");
- }
- assertNotNull("problem without exception instantiating properties", prop);
-
- assertEquals("default config file was not created", true, ftest.exists());
-
- // test default values
- assertEquals("default value is not correct", DEFAULT_CORSENABLED, prop.corsEnabled());
- assertEquals("default value is not correct", DEFAULT_AAIOFF, prop.isAAIOff());
- assertEquals("default value is not correct", DEFAULT_ESOFF, prop.isEsOff());
- assertEquals("default value is not correct", DEFAULT_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("default value is not correct", DEFAULT_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("default value is not correct", DEFAULT_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("default value is not correct", DEFAULT_ESBASEURL, prop.getEsBaseUrl());
-
- try {
- prop.load(new ByteArrayInputStream(TESTPROPERTYFILECONTENT.getBytes()));
- } catch (Exception e) {
- fail("error loading custom values into properties");
- }
-
- // test custom values
- assertEquals("custom value is not correct", CUSTOM_CORSENABLED, prop.corsEnabled());
- assertEquals("custom value is not correct", CUSTOM_AAIOFF, prop.isAAIOff());
- assertEquals("custom value is not correct", CUSTOM_ESOFF, prop.isEsOff());
- assertEquals("custom value is not correct", CUSTOM_TRUSTINSECURE, prop.trustInsecure());
- assertEquals("custom value is not correct", CUSTOM_AAIBASEURL, prop.getAAIBaseUrl());
- assertEquals("custom value is not correct", CUSTOM_AAIHEADERS, prop.getAAIHeaders());
- assertEquals("custom value is not correct", CUSTOM_ESBASEURL, prop.getEsBaseUrl());
-
- // delete autogenerated testfile
- ftest.delete();
-
- }
+ private static final boolean DEFAULT_CORSENABLED = false;
+ private static final boolean DEFAULT_AAIOFF = true;
+ private static final boolean DEFAULT_ESOFF = false;
+ private static final boolean DEFAULT_TRUSTINSECURE = false;
+ private static final String DEFAULT_AAIBASEURL = "off";
+ private static Map<String, String> DEFAULT_AAIHEADERS = new HashMap<String, String>();
+ private static final String DEFAULT_ESBASEURL = "http://sdnrdb:9200";
+
+ private static final boolean CUSTOM_CORSENABLED = true;
+ private static final boolean CUSTOM_AAIOFF = false;
+ private static final boolean CUSTOM_ESOFF = false;
+ private static final boolean CUSTOM_TRUSTINSECURE = true;
+ private static final String CUSTOM_AAIBASEURL = "https://aai.tld:2214";
+ private static Map<String, String> CUSTOM_AAIHEADERS = new HashMap<String, String>();
+ private static final String CUSTOM_ESBASEURL = "http://localhost:9200";
+
+ private static final String LR = "\n";
+ final String tmpFilename = "tmp2.cfg";
+
+ @Before
+ @After
+ public void init() {
+ File f = new File(tmpFilename);
+ if (f.exists()) {
+ f.delete();
+ }
+ }
+
+ @Test
+ public void test() {
+ DEFAULT_AAIHEADERS.put("X-FromAppId", "SDNR");
+ DEFAULT_AAIHEADERS.put("Authorization", "Basic QUFJOkFBSQ==");
+ CUSTOM_AAIHEADERS.put("X-FromAppId", "SDNC");
+ CUSTOM_AAIHEADERS.put("Authorization", "Basic 1234");
+ final String TESTPROPERTYFILECONTENT = "aai=" + CUSTOM_AAIBASEURL + LR + "aaiHeaders=[\"X-FromAppId:"
+ + CUSTOM_AAIHEADERS.get("X-FromAppId") + "\",\"Authorization:" + CUSTOM_AAIHEADERS.get("Authorization")
+ + "\"]" + LR + "database=" + CUSTOM_ESBASEURL + LR + "insecure=" + (CUSTOM_TRUSTINSECURE ? "1" : "0")
+ + LR + "cors=" + (CUSTOM_CORSENABLED ? "1" : "0");
+ File ftest = new File(tmpFilename);
+ MyProperties prop = null;
+ ftest = new File(tmpFilename);
+ try {
+ prop = MyProperties.Instantiate(ftest, true);
+ } catch (Exception e) {
+ fail("error instantiating properties");
+ }
+ assertNotNull("problem without exception instantiating properties", prop);
+
+ assertEquals("default config file was not created", true, ftest.exists());
+
+ // test default values
+ assertEquals("default value is not correct", DEFAULT_CORSENABLED, prop.corsEnabled());
+ assertEquals("default value is not correct", DEFAULT_AAIOFF, prop.isAAIOff());
+ assertEquals("default value is not correct", DEFAULT_ESOFF, prop.isEsOff());
+ assertEquals("default value is not correct", DEFAULT_TRUSTINSECURE, prop.trustInsecure());
+ assertEquals("default value is not correct", DEFAULT_AAIBASEURL, prop.getAAIBaseUrl());
+ assertEquals("default value is not correct", DEFAULT_AAIHEADERS, prop.getAAIHeaders());
+ assertEquals("default value is not correct", DEFAULT_ESBASEURL, prop.getEsBaseUrl());
+
+ try {
+ prop.load(new ByteArrayInputStream(TESTPROPERTYFILECONTENT.getBytes()));
+ } catch (Exception e) {
+ fail("error loading custom values into properties");
+ }
+
+ // test custom values
+ assertEquals("custom value is not correct", CUSTOM_CORSENABLED, prop.corsEnabled());
+ assertEquals("custom value is not correct", CUSTOM_AAIOFF, prop.isAAIOff());
+ assertEquals("custom value is not correct", CUSTOM_ESOFF, prop.isEsOff());
+ assertEquals("custom value is not correct", CUSTOM_TRUSTINSECURE, prop.trustInsecure());
+ assertEquals("custom value is not correct", CUSTOM_AAIBASEURL, prop.getAAIBaseUrl());
+ assertEquals("custom value is not correct", CUSTOM_AAIHEADERS, prop.getAAIHeaders());
+ assertEquals("custom value is not correct", CUSTOM_ESBASEURL, prop.getEsBaseUrl());
+
+ // delete autogenerated testfile
+ ftest.delete();
+
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
index 5c28c8544..f6987b2fa 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpAaiServlet.java
@@ -28,32 +28,36 @@ import javax.servlet.http.HttpServletResponse;
import org.onap.ccsdk.features.sdnr.wt.apigateway.AaiServlet;
-public class HelpAaiServlet extends AaiServlet implements IPublicServlet{
-
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
+public class HelpAaiServlet extends AaiServlet implements IPublicServlet {
+
+ public static final String RESPONSE_GET = "This is the response get";
+ public static final String RESPONSE_POST = "This is the response post";
+ public static final String RESPONSE_PUT = "This is the response put";
+ public static final String RESPONSE_DELETE = "This is the response delete";
+ public static final String RESPONSE_OPTIONS = "This is the response options";
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+
+ @Override
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPut(req, resp);
+ }
+
+ @Override
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doOptions(req, resp);
+ }
+
+ @Override
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doDelete(req, resp);
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
index a9cb06b10..901dd5810 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpEsServlet.java
@@ -30,30 +30,34 @@ import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
public class HelpEsServlet extends EsServlet implements IPublicServlet {
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
+ public static final String RESPONSE_GET = "This is the response get";
+ public static final String RESPONSE_POST = "This is the response post";
+ public static final String RESPONSE_PUT = "This is the response put";
+ public static final String RESPONSE_DELETE = "This is the response delete";
+ public static final String RESPONSE_OPTIONS = "This is the response options";
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+
+ @Override
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPut(req, resp);
+ }
+
+ @Override
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doOptions(req, resp);
+ }
+
+ @Override
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doDelete(req, resp);
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
index ea7690c75..ddab06add 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServlet.java
@@ -30,24 +30,28 @@ import org.onap.ccsdk.features.sdnr.wt.apigateway.EsServlet;
public class HelpServlet extends EsServlet {
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doOptions(req, resp);
- }
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+
+ @Override
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPut(req, resp);
+ }
+
+ @Override
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doOptions(req, resp);
+ }
+
+ @Override
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doDelete(req, resp);
+ }
}
diff --git a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
index f89ca4dcf..0bc42c342 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/HelpServletBase.java
@@ -51,172 +51,173 @@ import com.sun.net.httpserver.HttpServer;
public class HelpServletBase {
- public static final String HTTPMETHOD_GET = "GET";
- public static final String HTTPMETHOD_POST = "POST";
- public static final String HTTPMETHOD_PUT = "PUT";
- public static final String HTTPMETHOD_DELETE = "DELETE";
- public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- private IPublicServlet servlet;
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
-
- public final String HOST = "localhost";
- protected static int testPort;
- private final String baseUri;
- protected static final String LR = "\n";
-
- public HelpServletBase(String baseuri, int port) {
- this.baseUri=baseuri;
- testPort = port;
- }
-
- public void setServlet(IPublicServlet s)
- {
- this.servlet=s;
- }
-
- protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
- this.testrequest("/mwtn/test",method, data, expectedResponse, exact, null);
- }
- protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact) {
- this.testrequest(uri,method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact,
- Map<String, String> headersToCheck) {
-
- HttpServletRequest mockRequest = mock(HttpServletRequest.class);
- HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes());
- ServletInputStream inputStream= new ServletInputStream() {
- @Override
- public int read() throws IOException {
- return bis.read();
- }
- };
- Vector<String> headers=new Vector<String>();
- headers.addElement("Accept");
- headers.add("User-Agent");
- Enumeration<String> headerNames = headers.elements();
- try {
- when(mockRequest.getRequestURI()).thenReturn(this.baseUri+uri);
- when(mockRequest.getHeaderNames()).thenReturn(headerNames);
- when(mockRequest.getHeader("Accept")).thenReturn("application/json");
- when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
- when(mockRequest.getInputStream()).thenReturn(inputStream);
- when(mockResponse.getOutputStream()).thenReturn(printOut);
- System.out.println("do a " + method + " request");
- if (method == HTTPMETHOD_GET)
- this.servlet.doGet(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_POST)
- this.servlet.doPost(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_PUT)
- this.servlet.doPut(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_DELETE)
- this.servlet.doDelete(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_OPTIONS)
- this.servlet.doOptions(mockRequest, mockResponse);
- else
- fail("http request method " + method + " test not implemented");
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
-
- verify(mockResponse).setStatus(200);
- if (exact)
- assertEquals(expectedResponse, out.toString());
- else
- assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse));
- // currently unable to check extra headers
- if (headersToCheck != null) {
-
- }
- }
- @Before
- private void init() throws IOException{
-
-
- initEsTestWebserver(testPort);
- }
- @After
- private void deinit() {
- stopTestWebserver();
- }
-
- public static void initEsTestWebserver(int port) throws IOException {
- initEsTestWebserver(port, "/mwtn/test");
- }
- public static void initEsTestWebserver(int port,String baseUri) throws IOException {
- server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- server.createContext(baseUri, new MyHandler());
- //server.createContext("/", new MyRootHandler());
- server.setExecutor(null); // creates a default executor
- server.start();
- System.out.println("http server started");
- }
-
- public static void stopTestWebserver() {
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped" );
- }
- }
-
-
-
- public static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println(String.format("req received: %s %s" ,method,t.getRequestURI()));
- OutputStream os = null;
- try {
- if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_GET.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_GET.getBytes());
- } else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_POST.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_POST.getBytes());
- } else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_PUT.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_PUT.getBytes());
- } else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_DELETE.length());
- os = t.getResponseBody();
- os.write(HelpEsServlet.RESPONSE_DELETE.getBytes());
- } else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_OPTIONS.length());
- //os = t.getResponseBody();
- //os.write(RESPONSE_OPTIONS.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();
- }
- }
- }
- }
+ public static final String HTTPMETHOD_GET = "GET";
+ public static final String HTTPMETHOD_POST = "POST";
+ public static final String HTTPMETHOD_PUT = "PUT";
+ public static final String HTTPMETHOD_DELETE = "DELETE";
+ public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
+ private IPublicServlet servlet;
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+
+ public final String HOST = "localhost";
+ protected static int testPort;
+ private final String baseUri;
+ protected static final String LR = "\n";
+
+ public HelpServletBase(String baseuri, int port) {
+ this.baseUri = baseuri;
+ testPort = port;
+ }
+
+ public void setServlet(IPublicServlet s) {
+ this.servlet = s;
+ }
+
+ protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
+ this.testrequest("/mwtn/test", method, data, expectedResponse, exact, null);
+ }
+
+ protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact) {
+ this.testrequest(uri, method, data, expectedResponse, exact, null);
+ }
+
+ protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact,
+ Map<String, String> headersToCheck) {
+
+ HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+ HttpServletResponse mockResponse = mock(HttpServletResponse.class);
+
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes());
+ ServletInputStream inputStream = new ServletInputStream() {
+ @Override
+ public int read() throws IOException {
+ return bis.read();
+ }
+ };
+ Vector<String> headers = new Vector<String>();
+ headers.addElement("Accept");
+ headers.add("User-Agent");
+ Enumeration<String> headerNames = headers.elements();
+ try {
+ when(mockRequest.getRequestURI()).thenReturn(this.baseUri + uri);
+ when(mockRequest.getHeaderNames()).thenReturn(headerNames);
+ when(mockRequest.getHeader("Accept")).thenReturn("application/json");
+ when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
+ when(mockRequest.getInputStream()).thenReturn(inputStream);
+ when(mockResponse.getOutputStream()).thenReturn(printOut);
+ System.out.println("do a " + method + " request");
+ if (method == HTTPMETHOD_GET)
+ this.servlet.doGet(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_POST)
+ this.servlet.doPost(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_PUT)
+ this.servlet.doPut(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_DELETE)
+ this.servlet.doDelete(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_OPTIONS)
+ this.servlet.doOptions(mockRequest, mockResponse);
+ else
+ fail("http request method " + method + " test not implemented");
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+
+ verify(mockResponse).setStatus(200);
+ if (exact)
+ assertEquals(expectedResponse, out.toString());
+ else
+ assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse));
+ // currently unable to check extra headers
+ if (headersToCheck != null) {
+
+ }
+ }
+
+ @Before
+ private void init() throws IOException {
+
+
+ initEsTestWebserver(testPort);
+ }
+
+ @After
+ private void deinit() {
+ stopTestWebserver();
+ }
+
+ public static void initEsTestWebserver(int port) throws IOException {
+ initEsTestWebserver(port, "/mwtn/test");
+ }
+
+ public static void initEsTestWebserver(int port, String baseUri) throws IOException {
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ server.createContext(baseUri, new MyHandler());
+ //server.createContext("/", new MyRootHandler());
+ server.setExecutor(null); // creates a default executor
+ server.start();
+ System.out.println("http server started");
+ }
+
+ public static void stopTestWebserver() {
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ }
+
+
+
+ public static class MyHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println(String.format("req received: %s %s", method, t.getRequestURI()));
+ OutputStream os = null;
+ try {
+ if (method.equals(HTTPMETHOD_GET)) {
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_GET.length());
+ os = t.getResponseBody();
+ os.write(HelpEsServlet.RESPONSE_GET.getBytes());
+ } else if (method.equals(HTTPMETHOD_POST)) {
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_POST.length());
+ os = t.getResponseBody();
+ os.write(HelpEsServlet.RESPONSE_POST.getBytes());
+ } else if (method.equals(HTTPMETHOD_PUT)) {
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_PUT.length());
+ os = t.getResponseBody();
+ os.write(HelpEsServlet.RESPONSE_PUT.getBytes());
+ } else if (method.equals(HTTPMETHOD_DELETE)) {
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_DELETE.length());
+ os = t.getResponseBody();
+ os.write(HelpEsServlet.RESPONSE_DELETE.getBytes());
+ } else if (method.equals(HTTPMETHOD_OPTIONS)) {
+ t.sendResponseHeaders(200, HelpEsServlet.RESPONSE_OPTIONS.length());
+ //os = t.getResponseBody();
+ //os.write(RESPONSE_OPTIONS.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/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
index 77267e793..86a9467ec 100644
--- a/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
+++ b/sdnr/wt/apigateway/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/apigateway/test/helper/IPublicServlet.java
@@ -30,9 +30,13 @@ import javax.servlet.http.HttpServletResponse;
public interface IPublicServlet {
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ;
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ;
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
index 1ece24161..99a0aaa71 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/HtAssert.java
@@ -22,6 +22,7 @@
package org.onap.ccsdk.features.sdnr.wt.common;
import java.util.Arrays;
+
/**
*
* @author Michael Dürre
@@ -29,28 +30,28 @@ import java.util.Arrays;
*/
public class HtAssert {
-
- public static class HtNullable<T> {
- }
-
- public static void nonnull(Object... oList) {
- for (Object o : oList) {
- if (o == null) {
- throw new IllegalArgumentException(
- "One of the date parameters in ["+whoCalledMe()+"] is null (" + Arrays.toString(oList) + ")");
-
- }
- }
-
- };
-
- private static String whoCalledMe() {
- StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
- StackTraceElement caller = stackTraceElements[3];
- String classname = caller.getClassName();
- String methodName = caller.getMethodName();
- int lineNumber = caller.getLineNumber();
- return classname + "." + methodName + ":" + lineNumber;
- }
+
+ public static class HtNullable<T> {
+ }
+
+ public static void nonnull(Object... oList) {
+ for (Object o : oList) {
+ if (o == null) {
+ throw new IllegalArgumentException("One of the date parameters in [" + whoCalledMe() + "] is null ("
+ + Arrays.toString(oList) + ")");
+
+ }
+ }
+
+ };
+
+ private static String whoCalledMe() {
+ StackTraceElement[] stackTraceElements = Thread.currentThread().getStackTrace();
+ StackTraceElement caller = stackTraceElements[3];
+ String classname = caller.getClassName();
+ String methodName = caller.getMethodName();
+ int lineNumber = caller.getLineNumber();
+ return classname + "." + methodName + ":" + lineNumber;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/PropertyService.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/PropertyService.java
index 347971ec2..b391505e9 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/PropertyService.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/PropertyService.java
@@ -22,6 +22,6 @@
package org.onap.ccsdk.features.sdnr.wt.common;
public interface PropertyService {
-
- public String getProperty(String property);
+
+ public String getProperty(String property);
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
index 2aee0f8e6..bbd1859ed 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/Resources.java
@@ -35,72 +35,72 @@ import org.slf4j.LoggerFactory;
*
* @author Michael Dürre
*
- * class to get access to internal jar resources
+ * class to get access to internal jar resources
*/
public class Resources {
- // constants
- private static final Logger LOG = LoggerFactory.getLogger(Resources.class);
- // end of constants
+ // constants
+ private static final Logger LOG = LoggerFactory.getLogger(Resources.class);
+ // end of constants
- // static methods
- private static URL getFileURL(Class<?> cls, String resFile) {
- Bundle b = FrameworkUtil.getBundle(cls);
- URL u = null;
- LOG.debug("try to get file {}", resFile);
- if (b == null) {
- LOG.info("Load resource as file: {}", resFile);
- u = getUrlForRessource(cls, resFile);
- } else {
- LOG.info("Load resource from bundle: {}", resFile);
- u = b.getEntry(resFile);
- }
- return u;
- }
+ // static methods
+ private static URL getFileURL(Class<?> cls, String resFile) {
+ Bundle b = FrameworkUtil.getBundle(cls);
+ URL u = null;
+ LOG.debug("try to get file {}", resFile);
+ if (b == null) {
+ LOG.info("Load resource as file: {}", resFile);
+ u = getUrlForRessource(cls, resFile);
+ } else {
+ LOG.info("Load resource from bundle: {}", resFile);
+ u = b.getEntry(resFile);
+ }
+ return u;
+ }
- private static String readFile(final URL u) throws IOException {
- return readFile(u.openStream());
- }
+ private static String readFile(final URL u) throws IOException {
+ return readFile(u.openStream());
+ }
- private static String readFile(final InputStream s) throws IOException {
- // read file
- final String LR = "\n";
- BufferedReader in = new BufferedReader(new InputStreamReader(s));
- StringBuilder sb = new StringBuilder();
- String inputLine;
- while ((inputLine = in.readLine()) != null) {
- sb.append(inputLine + LR);
- }
- in.close();
- s.close();
- return sb.toString();
- }
+ private static String readFile(final InputStream s) throws IOException {
+ // read file
+ final String LR = "\n";
+ BufferedReader in = new BufferedReader(new InputStreamReader(s));
+ StringBuilder sb = new StringBuilder();
+ String inputLine;
+ while ((inputLine = in.readLine()) != null) {
+ sb.append(inputLine + LR);
+ }
+ in.close();
+ s.close();
+ return sb.toString();
+ }
- public static String getFileContent(Class<?> cls, String resFile) {
- LOG.debug("loading file {} from res", resFile);
- URL u = getFileURL(cls, resFile);
- String s = null;
- if (u == null) {
- LOG.warn("cannot find resfile: {}", resFile);
- return null;
- }
- try {
- s = readFile(u);
- } catch (Exception e) {
- LOG.warn("problem reading file: {}", e.getMessage());
- }
- return s;
+ public static String getFileContent(Class<?> cls, String resFile) {
+ LOG.debug("loading file {} from res", resFile);
+ URL u = getFileURL(cls, resFile);
+ String s = null;
+ if (u == null) {
+ LOG.warn("cannot find resfile: {}", resFile);
+ return null;
+ }
+ try {
+ s = readFile(u);
+ } catch (Exception e) {
+ LOG.warn("problem reading file: {}", e.getMessage());
+ }
+ return s;
- }
+ }
- public static URL getUrlForRessource(Class<?> cls, String fileOrDirectory) {
- //ClassLoader loader = Thread.currentThread().getContextClassLoader();
- ClassLoader loader = cls.getClassLoader();
- URL url = loader.getResource(fileOrDirectory);
- if (url == null && fileOrDirectory.startsWith("/")) {
- url = loader.getResource(fileOrDirectory.substring(1));
- }
- return url;
- }
- // end of static methods
+ public static URL getUrlForRessource(Class<?> cls, String fileOrDirectory) {
+ //ClassLoader loader = Thread.currentThread().getContextClassLoader();
+ ClassLoader loader = cls.getClassLoader();
+ URL url = loader.getResource(fileOrDirectory);
+ if (url == null && fileOrDirectory.startsWith("/")) {
+ url = loader.getResource(fileOrDirectory.substring(1));
+ }
+ return url;
+ }
+ // end of static methods
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/Configuration.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/Configuration.java
index f0c824c26..8187242cd 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/Configuration.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/Configuration.java
@@ -26,7 +26,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.configuration;
*/
public interface Configuration {
- String getSectionName();
+ String getSectionName();
void defaults();
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
index 18a69f004..fe43837e2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/ConfigurationFileRepresentation.java
@@ -43,206 +43,206 @@ import org.slf4j.LoggerFactory;
*/
public class ConfigurationFileRepresentation implements IConfigChangedListener {
- // constants
- private static final Logger LOG = LoggerFactory.getLogger(ConfigurationFileRepresentation.class);
-
- private static final long FILE_POLL_INTERVAL_MS = 1000;
- private static final String SECTIONNAME_ROOT = "";
- private static final String LR = "\n";
- private static final String EMPTY = "";
- // end of constants
-
- // variables
- /** Related configuration file **/
- private final File mFile;
- /** Monitor changes of file **/
- private final ConfigFileObserver fileObserver;
- /** List of sections **/
- private final HashMap<String, Section> sections;
- // end of variables
-
- // constructors
- public ConfigurationFileRepresentation(File f) {
-
- this.mFile = f;
- this.sections = new HashMap<String, Section>();
- try {
- if (!this.mFile.exists()) {
- if (!this.mFile.createNewFile()) {
- LOG.error("Can not create file {}", f.getAbsolutePath());
- }
- }
- reLoad();
-
- } catch (IOException e) {
- LOG.error("Problem loading config file {} : {}", f.getAbsolutePath(), e.getMessage());
- }
- this.fileObserver = new ConfigFileObserver(f.getAbsolutePath(), FILE_POLL_INTERVAL_MS);
- this.fileObserver.start();
- this.fileObserver.registerConfigChangedListener(this);
- }
-
- public ConfigurationFileRepresentation(String configurationfile) {
- this(new File(configurationfile));
- }
- // end of constructors
-
- // getters and setters
- public synchronized Optional<Section> getSection(String name) {
- return Optional.ofNullable(sections.get(name));
- }
- // end of getters and setters
-
- // private methods
- private synchronized void reLoad() {
- sections.clear();
- addSection(SECTIONNAME_ROOT);
- load();
- }
-
- private synchronized void load() {
- LOG.debug("loading file {}", getMFileName());
- String curSectionName = SECTIONNAME_ROOT;
- Optional<Section> sectionOptional = this.getSection(curSectionName);
- Section curSection = sectionOptional.isPresent() ? sectionOptional.get() : this.addSection(curSectionName);
- BufferedReader br = null;
- try {
- br = new BufferedReader(new FileReader(this.mFile));
- for (String line; (line = br.readLine()) != null;) {
- line = line.trim();
- if (line.isEmpty()) {
- continue;
- }
- if (line.startsWith("[") && line.endsWith("]")) {
- curSectionName = line.substring(1, line.length() - 1);
- curSection = this.addSection(curSectionName);
- } else {
- curSection.addLine(line);
- }
- }
-
- } catch (Exception e) {
- LOG.info("Problem loading configuration file. {} {}", getMFileName(), e);
- } finally {
- try {
- if (br != null) {
- br.close();
- }
- } catch (IOException e) {
- }
- }
- LOG.debug("finished loading file");
- LOG.debug("start parsing sections");
- for (Section section : this.sections.values()) {
- section.parseLines();
- }
- LOG.debug("finished parsing " + this.sections.size() + " sections");
- }
-
- private String getMFileName() {
- return mFile.getAbsolutePath();
- }
-
- // end of private methods
-
- // public methods
- public synchronized Section addSection(String name) {
- if (this.sections.containsKey(name)) {
- return this.sections.get(name);
- }
- Section s = new Section(name);
- this.sections.put(name, s);
- return s;
- }
-
- public synchronized void save() {
- LOG.debug("Write configuration to {}", getMFileName());
- try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.mFile, false))) {
- for (Section section : this.sections.values()) {
- if (section.hasValues()) {
- bw.write(String.join(LR, section.toLines()) + LR + LR);
- }
- }
- bw.close();
- } catch (Exception e) {
- LOG.warn("problem saving value: " + e.getMessage());
- }
- }
-
- public void registerConfigChangedListener(IConfigChangedListener l) {
- this.fileObserver.registerConfigChangedListener(l);
- }
-
- public void unregisterConfigChangedListener(IConfigChangedListener l) {
- this.fileObserver.unregisterConfigChangedListener(l);
- }
-
- @Override
- public void onConfigChanged() {
- LOG.debug("Reload on change {}", getMFileName());
- reLoad();
- }
-
- @Override
- public String toString() {
- return "ConfigurationFileRepresentation [mFile=" + mFile + ", sections=" + sections + "]";
- }
-
- @Override
- protected void finalize() throws Throwable {
- if (this.fileObserver != null) {
- this.fileObserver.interrupt();
- }
- super.finalize();
- }
-
- /*
- * Property access set/get
- */
- public synchronized void setProperty(String section, String key, Object value) {
- Optional<Section> os = this.getSection(section);
- if (os.isPresent()) {
- os.get().setProperty(key, value == null ? "null" : value.toString());
- save();
- } else {
- LOG.info("Unknown configuration section {}", section);
- }
- }
-
- public synchronized String getProperty(String section, String propertyKey) {
- Optional<Section> os = this.getSection(section);
- if (os.isPresent()) {
- return os.get().getProperty(propertyKey);
- } else {
- LOG.debug("Unknown configuration section {}", section);
- return EMPTY;
- }
- }
-
- public synchronized Optional<Long> getPropertyLong(String section, String propertyKey) {
- Optional<Section> os = this.getSection(section);
- if (os.isPresent()) {
- return os.get().getLong(propertyKey);
- } else {
- LOG.debug("Unknown configuration section {}", section);
- return Optional.empty();
- }
- }
-
- public synchronized boolean isPropertyAvailable(String section, String propertyKey) {
- Optional<Section> s = this.getSection(section);
- return s.isPresent() && s.get().hasKey(propertyKey);
- }
-
- public synchronized void setPropertyIfNotAvailable(String section, String propertyKey, Object propertyValue) {
- if (!isPropertyAvailable(section, propertyKey)) {
- setProperty(section, propertyKey, propertyValue.toString());
- }
- }
-
- public synchronized boolean getPropertyBoolean(String section, String propertyKey) {
- return getProperty(section, propertyKey).equalsIgnoreCase("true");
- }
- // end of public methods
+ // constants
+ private static final Logger LOG = LoggerFactory.getLogger(ConfigurationFileRepresentation.class);
+
+ private static final long FILE_POLL_INTERVAL_MS = 1000;
+ private static final String SECTIONNAME_ROOT = "";
+ private static final String LR = "\n";
+ private static final String EMPTY = "";
+ // end of constants
+
+ // variables
+ /** Related configuration file **/
+ private final File mFile;
+ /** Monitor changes of file **/
+ private final ConfigFileObserver fileObserver;
+ /** List of sections **/
+ private final HashMap<String, Section> sections;
+ // end of variables
+
+ // constructors
+ public ConfigurationFileRepresentation(File f) {
+
+ this.mFile = f;
+ this.sections = new HashMap<String, Section>();
+ try {
+ if (!this.mFile.exists()) {
+ if (!this.mFile.createNewFile()) {
+ LOG.error("Can not create file {}", f.getAbsolutePath());
+ }
+ }
+ reLoad();
+
+ } catch (IOException e) {
+ LOG.error("Problem loading config file {} : {}", f.getAbsolutePath(), e.getMessage());
+ }
+ this.fileObserver = new ConfigFileObserver(f.getAbsolutePath(), FILE_POLL_INTERVAL_MS);
+ this.fileObserver.start();
+ this.fileObserver.registerConfigChangedListener(this);
+ }
+
+ public ConfigurationFileRepresentation(String configurationfile) {
+ this(new File(configurationfile));
+ }
+ // end of constructors
+
+ // getters and setters
+ public synchronized Optional<Section> getSection(String name) {
+ return Optional.ofNullable(sections.get(name));
+ }
+ // end of getters and setters
+
+ // private methods
+ private synchronized void reLoad() {
+ sections.clear();
+ addSection(SECTIONNAME_ROOT);
+ load();
+ }
+
+ private synchronized void load() {
+ LOG.debug("loading file {}", getMFileName());
+ String curSectionName = SECTIONNAME_ROOT;
+ Optional<Section> sectionOptional = this.getSection(curSectionName);
+ Section curSection = sectionOptional.isPresent() ? sectionOptional.get() : this.addSection(curSectionName);
+ BufferedReader br = null;
+ try {
+ br = new BufferedReader(new FileReader(this.mFile));
+ for (String line; (line = br.readLine()) != null;) {
+ line = line.trim();
+ if (line.isEmpty()) {
+ continue;
+ }
+ if (line.startsWith("[") && line.endsWith("]")) {
+ curSectionName = line.substring(1, line.length() - 1);
+ curSection = this.addSection(curSectionName);
+ } else {
+ curSection.addLine(line);
+ }
+ }
+
+ } catch (Exception e) {
+ LOG.info("Problem loading configuration file. {} {}", getMFileName(), e);
+ } finally {
+ try {
+ if (br != null) {
+ br.close();
+ }
+ } catch (IOException e) {
+ }
+ }
+ LOG.debug("finished loading file");
+ LOG.debug("start parsing sections");
+ for (Section section : this.sections.values()) {
+ section.parseLines();
+ }
+ LOG.debug("finished parsing " + this.sections.size() + " sections");
+ }
+
+ private String getMFileName() {
+ return mFile.getAbsolutePath();
+ }
+
+ // end of private methods
+
+ // public methods
+ public synchronized Section addSection(String name) {
+ if (this.sections.containsKey(name)) {
+ return this.sections.get(name);
+ }
+ Section s = new Section(name);
+ this.sections.put(name, s);
+ return s;
+ }
+
+ public synchronized void save() {
+ LOG.debug("Write configuration to {}", getMFileName());
+ try (BufferedWriter bw = new BufferedWriter(new FileWriter(this.mFile, false))) {
+ for (Section section : this.sections.values()) {
+ if (section.hasValues()) {
+ bw.write(String.join(LR, section.toLines()) + LR + LR);
+ }
+ }
+ bw.close();
+ } catch (Exception e) {
+ LOG.warn("problem saving value: " + e.getMessage());
+ }
+ }
+
+ public void registerConfigChangedListener(IConfigChangedListener l) {
+ this.fileObserver.registerConfigChangedListener(l);
+ }
+
+ public void unregisterConfigChangedListener(IConfigChangedListener l) {
+ this.fileObserver.unregisterConfigChangedListener(l);
+ }
+
+ @Override
+ public void onConfigChanged() {
+ LOG.debug("Reload on change {}", getMFileName());
+ reLoad();
+ }
+
+ @Override
+ public String toString() {
+ return "ConfigurationFileRepresentation [mFile=" + mFile + ", sections=" + sections + "]";
+ }
+
+ @Override
+ protected void finalize() throws Throwable {
+ if (this.fileObserver != null) {
+ this.fileObserver.interrupt();
+ }
+ super.finalize();
+ }
+
+ /*
+ * Property access set/get
+ */
+ public synchronized void setProperty(String section, String key, Object value) {
+ Optional<Section> os = this.getSection(section);
+ if (os.isPresent()) {
+ os.get().setProperty(key, value == null ? "null" : value.toString());
+ save();
+ } else {
+ LOG.info("Unknown configuration section {}", section);
+ }
+ }
+
+ public synchronized String getProperty(String section, String propertyKey) {
+ Optional<Section> os = this.getSection(section);
+ if (os.isPresent()) {
+ return os.get().getProperty(propertyKey);
+ } else {
+ LOG.debug("Unknown configuration section {}", section);
+ return EMPTY;
+ }
+ }
+
+ public synchronized Optional<Long> getPropertyLong(String section, String propertyKey) {
+ Optional<Section> os = this.getSection(section);
+ if (os.isPresent()) {
+ return os.get().getLong(propertyKey);
+ } else {
+ LOG.debug("Unknown configuration section {}", section);
+ return Optional.empty();
+ }
+ }
+
+ public synchronized boolean isPropertyAvailable(String section, String propertyKey) {
+ Optional<Section> s = this.getSection(section);
+ return s.isPresent() && s.get().hasKey(propertyKey);
+ }
+
+ public synchronized void setPropertyIfNotAvailable(String section, String propertyKey, Object propertyValue) {
+ if (!isPropertyAvailable(section, propertyKey)) {
+ setProperty(section, propertyKey, propertyValue.toString());
+ }
+ }
+
+ public synchronized boolean getPropertyBoolean(String section, String propertyKey) {
+ return getProperty(section, propertyKey).equalsIgnoreCase("true");
+ }
+ // end of public methods
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/exception/ConfigurationException.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/exception/ConfigurationException.java
index cff2368a2..2c036fed1 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/exception/ConfigurationException.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/exception/ConfigurationException.java
@@ -28,4 +28,4 @@ public class ConfigurationException extends Exception {
public ConfigurationException(String m) {
super(m);
}
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
index 39c00da1d..54ebd03ac 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/Section.java
@@ -32,26 +32,27 @@ import java.util.regex.Pattern;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.exception.ConversionException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
+
/**
*
* @author Michael Dürre, Herbert Eiselt
*
- * subset of configuration identified by its name
+ * subset of configuration identified by its name
*/
public class Section {
- // constants
+ // constants
private static final Logger LOG = LoggerFactory.getLogger(Section.class);
private static final String DELIMITER = "=";
private static final String COMMENTCHARS[] = {"#", ";"};
// end of constants
-
+
// variables
private final String name;
private final List<String> rawLines;
private final LinkedHashMap<String, SectionValue> values;
// end of variables
-
+
// constructors
public Section(String name) {
LOG.debug("new section created: '{}'", name);
@@ -60,7 +61,7 @@ public class Section {
this.values = new LinkedHashMap<>();
}
//end of constructors
-
+
// getters and setters
public String getName() {
return name;
@@ -77,7 +78,7 @@ public class Section {
return false;
}
// end of private methods
-
+
// public methods
public void addLine(String line) {
LOG.trace("adding raw line:" + line);
@@ -88,38 +89,38 @@ public class Section {
return this.getProperty(key, "");
}
- public String getProperty(final String key, final String defValue) {
- String value=defValue;
- LOG.debug("try to get property for {} with def {}",key,defValue);
- if (values.containsKey(key)) {
- value = values.get(key).getValue();
- }
- //try to read env var
- if (value != null && value.contains("${")) {
-
- LOG.debug("try to find env var(s) for {}",value);
- final String regex = "(\\$\\{[A-Z0-9_-]+\\})";
- final Pattern pattern = Pattern.compile(regex);
- final Matcher matcher = pattern.matcher(value);
- String tmp=new String(value);
- while(matcher.find() && matcher.groupCount()>0) {
- final String mkey = matcher.group(1);
- if(mkey!=null) {
- try {
- LOG.debug("match found for v={} and env key={}",tmp,mkey);
- String env=System.getenv(mkey.substring(2,mkey.length()-1));
- tmp = tmp.replace(mkey, env==null?"":env );
- } catch (SecurityException e) {
- LOG.warn("unable to read env {}: {}", value, e);
- }
- }
- }
- value=tmp;
- }
- return value;
- }
-
-
+ public String getProperty(final String key, final String defValue) {
+ String value = defValue;
+ LOG.debug("try to get property for {} with def {}", key, defValue);
+ if (values.containsKey(key)) {
+ value = values.get(key).getValue();
+ }
+ //try to read env var
+ if (value != null && value.contains("${")) {
+
+ LOG.debug("try to find env var(s) for {}", value);
+ final String regex = "(\\$\\{[A-Z0-9_-]+\\})";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(value);
+ String tmp = new String(value);
+ while (matcher.find() && matcher.groupCount() > 0) {
+ final String mkey = matcher.group(1);
+ if (mkey != null) {
+ try {
+ LOG.debug("match found for v={} and env key={}", tmp, mkey);
+ String env = System.getenv(mkey.substring(2, mkey.length() - 1));
+ tmp = tmp.replace(mkey, env == null ? "" : env);
+ } catch (SecurityException e) {
+ LOG.warn("unable to read env {}: {}", value, e);
+ }
+ }
+ }
+ value = tmp;
+ }
+ return value;
+ }
+
+
public void setProperty(String key, String value) {
boolean isuncommented = this.isCommentLine(key);
@@ -129,7 +130,7 @@ public class Section {
if (this.values.containsKey(key)) {
this.values.get(key).setValue(value).setIsUncommented(isuncommented);
} else {
- this.values.put(key, new SectionValue(value,isuncommented));
+ this.values.put(key, new SectionValue(value, isuncommented));
}
}
@@ -155,8 +156,7 @@ public class Section {
if (hlp.length > 1) {
String key = hlp[0];
String value =
- line.length() > (key + DELIMITER).length() ? line.substring((key + DELIMITER).length())
- : "";
+ line.length() > (key + DELIMITER).length() ? line.substring((key + DELIMITER).length()) : "";
if (this.values.containsKey(key)) {
this.values.get(key).setValue(value);
} else {
@@ -170,7 +170,7 @@ public class Section {
}
}
-
+
public String[] toLines() {
List<String> lines = new ArrayList<>();
@@ -227,7 +227,7 @@ public class Section {
return Optional.of(Long.parseLong(v));
} catch (NumberFormatException e) {
}
- return Optional.empty();
+ return Optional.empty();
}
public boolean hasValues() {
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
index 3aacf9a40..a4758f1b5 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/configuration/subtypes/SectionValue.java
@@ -23,6 +23,7 @@ package org.onap.ccsdk.features.sdnr.wt.common.configuration.subtypes;
import java.util.ArrayList;
import java.util.List;
+
/**
*
* @author Michael Dürre, Herbert Eiselt
@@ -30,7 +31,7 @@ import java.util.List;
*/
class SectionValue {
- // variables
+ // variables
private String value;
private final List<String> comments;
private boolean isUncommented;
@@ -48,40 +49,40 @@ class SectionValue {
}
public SectionValue(String value, boolean isUncommented) {
- this(value, new ArrayList<String>(), isUncommented);
- }
+ this(value, new ArrayList<String>(), isUncommented);
+ }
// end of constructors
-
+
// getters and setters
- public String getValue() {
- return value;
- }
+ public String getValue() {
+ return value;
+ }
- public SectionValue setValue(String value) {
- this.value = value;
- return this;
- }
+ public SectionValue setValue(String value) {
+ this.value = value;
+ return this;
+ }
- public boolean isUncommented() {
- return isUncommented;
- }
+ public boolean isUncommented() {
+ return isUncommented;
+ }
- public SectionValue setIsUncommented(boolean isUncommented) {
- this.isUncommented = isUncommented;
- return this;
- }
+ public SectionValue setIsUncommented(boolean isUncommented) {
+ this.isUncommented = isUncommented;
+ return this;
+ }
- public List<String> getComments() {
- return comments;
- }
- // end of getters and setters
-
- // public methods
- @Override
- public String toString() {
- return "SectionValue [value=" + value + ", comments=" + comments + ", isUncommented=" + isUncommented + "]";
- }
- // end of public methods
+ public List<String> getComments() {
+ return comments;
+ }
+ // end of getters and setters
+
+ // public methods
+ @Override
+ public String toString() {
+ return "SectionValue [value=" + value + ", comments=" + comments + ", isUncommented=" + isUncommented + "]";
+ }
+ // end of public methods
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java
index 542a7cb08..3a9c10514 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseClient.java
@@ -36,14 +36,16 @@ public interface DatabaseClient {
/**
* Read JSON Object from database
+ *
* @param dataTypeName to read
* @param esId to provide id to read
* @return String with json structure
*/
- public @Nullable String doReadJsonData(String dataTypeName, @Nonnull IsEsObject esId );
+ public @Nullable String doReadJsonData(String dataTypeName, @Nonnull IsEsObject esId);
/**
* Read JSON Object from database
+ *
* @param dataTypeName to read
* @param esId of object to read
* @return String with json structure
@@ -52,6 +54,7 @@ public interface DatabaseClient {
/**
* Provide all Objects of the specified dataTypeName.
+ *
* @param dataTypeName to be used
* @return SearchResult with list of elements
*/
@@ -59,11 +62,13 @@ public interface DatabaseClient {
/**
* Provide all Objects that are covered by query.
+ *
* @param dataTypeName to be used
* @param queryBuilder with the query to be used.
* @return SearchResult with list of elements
*/
public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder queryBuilder);
+
/**
* Write one object into Database
*
@@ -72,37 +77,41 @@ public interface DatabaseClient {
* @param json String in JSON format.
* @return esId String of the database object or null in case of write problems.
*/
- public @Nullable String doWriteJsonString( String dataTypeName, @Nonnull IsEsObject esId, String json);
+ public @Nullable String doWriteJsonString(String dataTypeName, @Nonnull IsEsObject esId, String json);
/**
* Write one object into Database
+ *
* @param dataTypeName Name of datatype
* @param esId of object to be replaced or null for new entry.
* @param json String in JSON format.
* @return esId String of the database object or null in case of write problems.
*/
- public @Nullable String doWriteRaw( String dataTypeName, @Nullable String esId, String json);
+ public @Nullable String doWriteRaw(String dataTypeName, @Nullable String esId, String json);
/**
* Write one object into Database
+ *
* @param indexName Name of index
* @param dataTypeName Name of datatype
* @param esId of object to be replaced or null for new entry.
* @param json String in JSON format.
* @return esId String of the database object or null in case of write problems.
*/
- public @Nullable String doWriteRaw(String indexName,String dataTypeName, @Nullable String esId, String json);
-
+ public @Nullable String doWriteRaw(String indexName, String dataTypeName, @Nullable String esId, String json);
+
/**
* Remove Object from database
+ *
* @param dataTypeName of object
* @param esId of object to be deleted
* @return success
*/
- public boolean doRemove( String dataTypeName, IsEsObject esId );
+ public boolean doRemove(String dataTypeName, IsEsObject esId);
/**
* Remove Object from database
+ *
* @param dataTypeName of object
* @param esId as String of object to be deleted
* @return success
@@ -111,6 +120,7 @@ public interface DatabaseClient {
/**
* Verify if index already created
+ *
* @param dataTypeName to be verified.
* @return boolean accordingly
*/
@@ -118,6 +128,7 @@ public interface DatabaseClient {
/**
* Update one object in Database with id=esId or create if not exists.
+ *
* @param dataTypeName Name of datatype
* @param esId of object to be replaced or null for new entry.
* @param json String in JSON format.
@@ -127,6 +138,7 @@ public interface DatabaseClient {
/**
* Update one object in Database with id=esId or create if not exists.
+ *
* @param dataTypeName Name of datatype
* @param esId to use for DB object
* @param json object to write
@@ -137,6 +149,7 @@ public interface DatabaseClient {
/**
* remove items from database by query
+ *
* @param dataTypeName Name of datatype
* @param query query to select items to remove
* @return count of removed items
@@ -145,6 +158,7 @@ public interface DatabaseClient {
/**
* update object in database
+ *
* @param dataTypeName Name of datatype
* @param json dataobject
* @param query query to select item to update
@@ -156,7 +170,8 @@ public interface DatabaseClient {
*
* @param dataTypeName Name of datatype
* @param queryBuilder query to select items to read
- * @param ignoreException flag if serverside exception will be thrown if query is not valid (needed for user entered filters)
+ * @param ignoreException flag if serverside exception will be thrown if query is not valid (needed for user entered
+ * filters)
* @return results
*/
SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder queryBuilder,
@@ -165,21 +180,23 @@ public interface DatabaseClient {
/**
* read all data
+ *
* @param dataTypeName Name of datatype
- * @param ignoreException flag if serverside exception will be thrown if query is not valid (needed for user entered filters)
+ * @param ignoreException flag if serverside exception will be thrown if query is not valid (needed for user entered
+ * filters)
* @return results
*/
SearchResult<SearchHit> doReadAllJsonData(String dataTypeName, boolean ignoreException);
- /**
- * @param alias
- * @param dataTypeName
- * @param queryBuilder
- * @param ignoreException
- * @return
- */
- SearchResult<SearchHit> doReadByQueryJsonData(String alias, String dataTypeName, QueryBuilder queryBuilder,
- boolean ignoreException);
+ /**
+ * @param alias
+ * @param dataTypeName
+ * @param queryBuilder
+ * @param ignoreException
+ * @return
+ */
+ SearchResult<SearchHit> doReadByQueryJsonData(String alias, String dataTypeName, QueryBuilder queryBuilder,
+ boolean ignoreException);
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseConfig.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseConfig.java
index 969f0e85c..573c427a2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseConfig.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/DatabaseConfig.java
@@ -25,6 +25,6 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
public interface DatabaseConfig {
- HostInfo[] getHosts();
+ HostInfo[] getHosts();
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
index 70b81990e..9d5e9f648 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/ExtRestClient.java
@@ -108,17 +108,18 @@ public class ExtRestClient {
HttpAsyncClientBuilder httpAsyncClientBuilder = null;
try {
httpAsyncClientBuilder = httpClientBuilder.setSSLContext(BaseHTTPClient.setupSsl(this.trustAll));
- if(this.trustAll) {
- httpAsyncClientBuilder.setSSLHostnameVerifier(new HostnameVerifier() {
-
- @Override
- public boolean verify(String hostname, SSLSession session) {
- return true;
- }
- });
+ if (this.trustAll) {
+ httpAsyncClientBuilder.setSSLHostnameVerifier(new HostnameVerifier() {
+
+ @Override
+ public boolean verify(String hostname, SSLSession session) {
+ return true;
+ }
+ });
}
- } catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException | CertificateException | KeyStoreException | InvalidKeySpecException | IOException e) {
- LOG.warn("unable to init ssl context for db client: {}",e.getMessage());
+ } catch (NoSuchAlgorithmException | KeyManagementException | UnrecoverableKeyException
+ | CertificateException | KeyStoreException | InvalidKeySpecException | IOException e) {
+ LOG.warn("unable to init ssl context for db client: {}", e.getMessage());
}
if (basicAuthPassword == null || basicAuthUsername == null) {
return httpAsyncClientBuilder;
@@ -187,12 +188,12 @@ public class ExtRestClient {
private final RestClient client;
protected ExtRestClient(HostInfo[] hosts) {
- this(hosts, null, null,false);
+ this(hosts, null, null, false);
}
protected ExtRestClient(HostInfo[] hosts, String username, String password, boolean trustAll) {
this.client = RestClient.builder(get(hosts))
- .setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password,trustAll))
+ .setHttpClientConfigCallback(new BasicAuthHttpClientConfigCallback(username, password, trustAll))
.build();
}
@@ -215,6 +216,7 @@ public class ExtRestClient {
public ClusterSettingsResponse setupClusterSettings(ClusterSettingsRequest request) throws IOException {
return new ClusterSettingsResponse(this.client.performRequest(request.getInner()));
}
+
public CreateAliasResponse updateAliases(CreateAliasRequest request) throws IOException {
return new CreateAliasResponse(this.client.performRequest(request.getInner()));
}
@@ -265,6 +267,7 @@ public class ExtRestClient {
/**
* Search for database entries
+ *
* @param request inputRequest
* @param ignoreParseException especially for usercreated filters which may cause ES server response exceptions
* @return Response with related entries
@@ -357,12 +360,12 @@ public class ExtRestClient {
return new ExtRestClient(hosts);
}
- public static ExtRestClient createInstance(HostInfo[] hosts, String username, String password,boolean trustAll) {
+ public static ExtRestClient createInstance(HostInfo[] hosts, String username, String password, boolean trustAll) {
return new ExtRestClient(hosts, username, password, trustAll);
}
public static ExtRestClient createInstance(String hostname, int port, Protocol protocol) {
- return createInstance(new HostInfo[] { new HostInfo(hostname, port, protocol) });
+ return createInstance(new HostInfo[] {new HostInfo(hostname, port, protocol)});
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
index 9a369ea5b..e8d86a925 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/HtDatabaseClient.java
@@ -53,65 +53,70 @@ import org.slf4j.LoggerFactory;
/**
* @author Herbert, Micha
*
- * Hint: Elasticsearch index/alias and doctype will be the same value
- * server side restricted since ES 5.0
+ * Hint: Elasticsearch index/alias and doctype will be the same value server side restricted since ES 5.0
*
*/
public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, AutoCloseable {
- private static final boolean REFRESH_AFTER_REWRITE_DEFAULT = true;
- private static final boolean TRUSTALL_DEFAULT = false;
+ private static final boolean REFRESH_AFTER_REWRITE_DEFAULT = true;
+ private static final boolean TRUSTALL_DEFAULT = false;
- private final Logger LOG = LoggerFactory.getLogger(HtDatabaseClient.class);
+ private final Logger LOG = LoggerFactory.getLogger(HtDatabaseClient.class);
+
+ private boolean doRefreshAfterWrite;
- private boolean doRefreshAfterWrite;
public HtDatabaseClient(HostInfo[] hosts) {
- this(hosts,REFRESH_AFTER_REWRITE_DEFAULT);
- }
+ this(hosts, REFRESH_AFTER_REWRITE_DEFAULT);
+ }
+
public HtDatabaseClient(HostInfo[] hosts, boolean refreshAfterWrite) {
- this(hosts,refreshAfterWrite,null,null,TRUSTALL_DEFAULT);
- }
- public HtDatabaseClient(HostInfo[] hosts,String username,String password) {
- this(hosts,username,password,TRUSTALL_DEFAULT);
+ this(hosts, refreshAfterWrite, null, null, TRUSTALL_DEFAULT);
}
- public HtDatabaseClient(HostInfo[] hosts,String username,String password, boolean trustAll) {
- this(hosts,REFRESH_AFTER_REWRITE_DEFAULT,username,password,trustAll);
- }
- public HtDatabaseClient(HostInfo[] hosts, boolean refreshAfterWrite,String username,String password, boolean trustAll) {
- super(hosts,username,password,trustAll);
- this.doRefreshAfterWrite = refreshAfterWrite;
- }
-
+
+ public HtDatabaseClient(HostInfo[] hosts, String username, String password) {
+ this(hosts, username, password, TRUSTALL_DEFAULT);
+ }
+
+ public HtDatabaseClient(HostInfo[] hosts, String username, String password, boolean trustAll) {
+ this(hosts, REFRESH_AFTER_REWRITE_DEFAULT, username, password, trustAll);
+ }
+
+ public HtDatabaseClient(HostInfo[] hosts, boolean refreshAfterWrite, String username, String password,
+ boolean trustAll) {
+ super(hosts, username, password, trustAll);
+ this.doRefreshAfterWrite = refreshAfterWrite;
+ }
+
/*----------------------------------
* Functions
*/
- /**
- * Close function
- */
- @Override
- public void close() {
- try {
- super.close();
- } catch (IOException e) {
- LOG.warn("Problem closing db client: {}",e);
- }
- }
+ /**
+ * Close function
+ */
+ @Override
+ public void close() {
+ try {
+ super.close();
+ } catch (IOException e) {
+ LOG.warn("Problem closing db client: {}", e);
+ }
+ }
@Override
public boolean isExistsIndex(String esIndexAlias) {
- LOG.debug("Check status of ES index: {}", esIndexAlias);
+ LOG.debug("Check status of ES index: {}", esIndexAlias);
GetIndexRequest request = new GetIndexRequest(esIndexAlias);
- boolean indexStatus = false;
- try {
- indexStatus = this.indicesExists(request);
- } catch (IOException e) {
- LOG.warn("Problem checking index for {}: {}",esIndexAlias,e);
- }
+ boolean indexStatus = false;
+ try {
+ indexStatus = this.indicesExists(request);
+ } catch (IOException e) {
+ LOG.warn("Problem checking index for {}: {}", esIndexAlias, e);
+ }
return indexStatus;
@@ -124,16 +129,17 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
@Override
public @Nullable String doWriteRaw(String dataTypeName, @Nullable String esId, String json) {
- return this.doWriteRaw(dataTypeName, dataTypeName, esId, json);
+ return this.doWriteRaw(dataTypeName, dataTypeName, esId, json);
}
+
@Override
- public @Nullable String doWriteRaw(String indexName,String dataTypeName, @Nullable String esId, String json) {
-
+ public @Nullable String doWriteRaw(String indexName, String dataTypeName, @Nullable String esId, String json) {
+
IndexResponse response = null;
- IndexRequest indexRequest = new IndexRequest(indexName,dataTypeName,esId,this.doRefreshAfterWrite);
+ IndexRequest indexRequest = new IndexRequest(indexName, dataTypeName, esId, this.doRefreshAfterWrite);
indexRequest.source(json);
try {
- response = this.index(indexRequest );
+ response = this.index(indexRequest);
} catch (IOException e) {
LOG.warn("ES Exception {} Json: {}", e.getMessage(), json);
}
@@ -142,42 +148,43 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
LOG.warn("Response null during write: {} {}", esId, json);
return null;
}
-// if(this.doRefreshAfterWrite) {
-// this.doRefresh(dataTypeName);
-// }
- return response.getId();
+ // if(this.doRefreshAfterWrite) {
+ // this.doRefresh(dataTypeName);
+ // }
+ return response.getId();
}
private void doRefresh(String dataTypeName) {
- try {
- RefreshIndexResponse response = this.refreshIndex(new RefreshIndexRequest(dataTypeName));
- if(!response.succeeded()) {
- LOG.warn("seems that index {} was not refreshed",dataTypeName);
- }
- } catch (IOException e) {
- LOG.warn("problem with refreshing index: {}",e);
- }
-
- }
- @Override
+ try {
+ RefreshIndexResponse response = this.refreshIndex(new RefreshIndexRequest(dataTypeName));
+ if (!response.succeeded()) {
+ LOG.warn("seems that index {} was not refreshed", dataTypeName);
+ }
+ } catch (IOException e) {
+ LOG.warn("problem with refreshing index: {}", e);
+ }
+
+ }
+
+ @Override
public boolean doRemove(String dataTypeName, IsEsObject esId) {
- return doRemove(dataTypeName, esId.getEsId());
+ return doRemove(dataTypeName, esId.getEsId());
}
@Override
public boolean doRemove(String dataTypeName, String esId) {
- DeleteRequest deleteRequest = new DeleteRequest(dataTypeName,dataTypeName,esId,this.doRefreshAfterWrite);
- DeleteResponse response = null;
- try {
- response = this.delete(deleteRequest);
- } catch (IOException e) {
- LOG.warn("Problem deleting from db: {}",e.getMessage());
- }
-// if(this.doRefreshAfterWrite) {
-// this.doRefresh(dataTypeName);
-// }
- return response!=null?response.isDeleted():false;
+ DeleteRequest deleteRequest = new DeleteRequest(dataTypeName, dataTypeName, esId, this.doRefreshAfterWrite);
+ DeleteResponse response = null;
+ try {
+ response = this.delete(deleteRequest);
+ } catch (IOException e) {
+ LOG.warn("Problem deleting from db: {}", e.getMessage());
+ }
+ // if(this.doRefreshAfterWrite) {
+ // this.doRefresh(dataTypeName);
+ // }
+ return response != null ? response.isDeleted() : false;
}
@Override
@@ -193,118 +200,126 @@ public class HtDatabaseClient extends ExtRestClient implements DatabaseClient, A
@Override
public @Nullable String doReadJsonData(String dataTypeName, @Nonnull String esId) {
- LOG.debug("NetworkIndex read: {}", dataTypeName);
- GetRequest getRequest = new GetRequest(dataTypeName,dataTypeName,esId);
- GetResponse response = null;
- try {
- response = this.get(getRequest);
- } catch (IOException e) {
- LOG.warn("problem reading data {} with id {}: {}",dataTypeName,esId,e);
- }
- return response!=null && response.isExists() ? response.getSourceAsBytesRef() : null;
+ LOG.debug("NetworkIndex read: {}", dataTypeName);
+ GetRequest getRequest = new GetRequest(dataTypeName, dataTypeName, esId);
+ GetResponse response = null;
+ try {
+ response = this.get(getRequest);
+ } catch (IOException e) {
+ LOG.warn("problem reading data {} with id {}: {}", dataTypeName, esId, e);
+ }
+ return response != null && response.isExists() ? response.getSourceAsBytesRef() : null;
+ }
+
+ @Override
+ public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder queryBuilder) {
+
+ return this.doReadByQueryJsonData(dataTypeName, queryBuilder, false);
}
- @Override
- public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder queryBuilder) {
-
- return this.doReadByQueryJsonData(dataTypeName, queryBuilder, false);
- }
- @Override
- public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData( String dataTypeName,QueryBuilder queryBuilder, boolean ignoreException) {
- return this.doReadByQueryJsonData(dataTypeName, dataTypeName,queryBuilder,ignoreException);
- }
- @Override
- public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String alias, String dataTypeName,QueryBuilder queryBuilder, boolean ignoreException) {
-
- long total = 0;
- LOG.debug("NetworkIndex query and read: {}", dataTypeName);
-
- SearchRequest searchRequest = new SearchRequest(alias, dataTypeName);
- searchRequest.setQuery(queryBuilder);
- SearchResponse response = null;
- try {
- response = this.search(searchRequest,ignoreException);
- total = response.getTotal();
-
- } catch (IOException e) {
- LOG.warn("error do search {}: {}", queryBuilder, e);
- }
- return new SearchResult<SearchHit>(response != null ? response.getHits() : new SearchHit[] {}, total);
- }
- @Override
- public @Nonnull SearchResult<SearchHit> doReadAllJsonData(String dataTypeName) {
- return this.doReadAllJsonData( dataTypeName,false);
- }
@Override
- public @Nonnull SearchResult<SearchHit> doReadAllJsonData( String dataTypeName, boolean ignoreException) {
- return doReadByQueryJsonData( dataTypeName, QueryBuilders.matchAllQuery(),ignoreException);
- }
-
- public @Nonnull SearchResult<SearchHit> doReadAllJsonData(String alias, String dataType, boolean ignoreException) {
- return doReadByQueryJsonData( alias, dataType, QueryBuilders.matchAllQuery(),ignoreException);
- }
- @Override
- public String doUpdateOrCreate(String dataTypeName, String esId, String json) {
- return this.doUpdateOrCreate(dataTypeName, esId, json,null);
- }
-
-
-
- @Override
- public String doUpdateOrCreate(String dataTypeName, String esId, String json, List<String> onlyForInsert) {
- if(esId==null) {
- LOG.warn("try to update or insert {} with id null is not allowed.",dataTypeName);
- return null;
- }
- boolean success = false;
- UpdateRequest request = new UpdateRequest(dataTypeName, dataTypeName, esId,this.doRefreshAfterWrite);
- request.source(new JSONObject(json),onlyForInsert);
- try {
- UpdateResponse response = this.update(request);
- success = response.succeeded();
- } catch (IOException e) {
- LOG.warn("Problem updating {} with id {} and data {}: {}", dataTypeName, esId, json, e);
- }
-// if(this.doRefreshAfterWrite) {
-// this.doRefresh(dataTypeName);
-// }
- return success ? esId : null;
- }
- @Override
- public boolean doUpdate(String dataTypeName, String json, QueryBuilder query) {
- boolean success = false;
- UpdateByQueryRequest request = new UpdateByQueryRequest(dataTypeName, dataTypeName ,this.doRefreshAfterWrite);
- request.source(new JSONObject(json),query);
- try {
- UpdateByQueryResponse response = this.update(request);
- success = !response.hasFailures();
- } catch (IOException e) {
- LOG.warn("Problem updating items in {} with query {} and data {}: {}", dataTypeName, query, json, e);
- }
-// if(this.doRefreshAfterWrite) {
-// this.doRefresh(dataTypeName);
-// }
- return success;
- }
-
-
-
- @Override
- public int doRemove(String dataTypeName, QueryBuilder query) {
- int del=0;
- DeleteByQueryRequest request = new DeleteByQueryRequest(dataTypeName,this.doRefreshAfterWrite);
- request.source(query);
- try {
- DeleteByQueryResponse response = this.deleteByQuery(request);
- del = response.getDeleted();
- } catch (IOException e) {
- LOG.warn("Problem delete in {} with query {}:{} ", dataTypeName, query.toJSON(), e);
- }
-// if(this.doRefreshAfterWrite) {
-// this.doRefresh(dataTypeName);
-// }
- return del;
- }
-
-
+ public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder queryBuilder,
+ boolean ignoreException) {
+ return this.doReadByQueryJsonData(dataTypeName, dataTypeName, queryBuilder, ignoreException);
+ }
+
+ @Override
+ public @Nonnull SearchResult<SearchHit> doReadByQueryJsonData(String alias, String dataTypeName,
+ QueryBuilder queryBuilder, boolean ignoreException) {
+
+ long total = 0;
+ LOG.debug("NetworkIndex query and read: {}", dataTypeName);
+
+ SearchRequest searchRequest = new SearchRequest(alias, dataTypeName);
+ searchRequest.setQuery(queryBuilder);
+ SearchResponse response = null;
+ try {
+ response = this.search(searchRequest, ignoreException);
+ total = response.getTotal();
+
+ } catch (IOException e) {
+ LOG.warn("error do search {}: {}", queryBuilder, e);
+ }
+ return new SearchResult<SearchHit>(response != null ? response.getHits() : new SearchHit[] {}, total);
+ }
+
+ @Override
+ public @Nonnull SearchResult<SearchHit> doReadAllJsonData(String dataTypeName) {
+ return this.doReadAllJsonData(dataTypeName, false);
+ }
+
+ @Override
+ public @Nonnull SearchResult<SearchHit> doReadAllJsonData(String dataTypeName, boolean ignoreException) {
+ return doReadByQueryJsonData(dataTypeName, QueryBuilders.matchAllQuery(), ignoreException);
+ }
+
+ public @Nonnull SearchResult<SearchHit> doReadAllJsonData(String alias, String dataType, boolean ignoreException) {
+ return doReadByQueryJsonData(alias, dataType, QueryBuilders.matchAllQuery(), ignoreException);
+ }
+
+ @Override
+ public String doUpdateOrCreate(String dataTypeName, String esId, String json) {
+ return this.doUpdateOrCreate(dataTypeName, esId, json, null);
+ }
+
+
+
+ @Override
+ public String doUpdateOrCreate(String dataTypeName, String esId, String json, List<String> onlyForInsert) {
+ if (esId == null) {
+ LOG.warn("try to update or insert {} with id null is not allowed.", dataTypeName);
+ return null;
+ }
+ boolean success = false;
+ UpdateRequest request = new UpdateRequest(dataTypeName, dataTypeName, esId, this.doRefreshAfterWrite);
+ request.source(new JSONObject(json), onlyForInsert);
+ try {
+ UpdateResponse response = this.update(request);
+ success = response.succeeded();
+ } catch (IOException e) {
+ LOG.warn("Problem updating {} with id {} and data {}: {}", dataTypeName, esId, json, e);
+ }
+ // if(this.doRefreshAfterWrite) {
+ // this.doRefresh(dataTypeName);
+ // }
+ return success ? esId : null;
+ }
+
+ @Override
+ public boolean doUpdate(String dataTypeName, String json, QueryBuilder query) {
+ boolean success = false;
+ UpdateByQueryRequest request = new UpdateByQueryRequest(dataTypeName, dataTypeName, this.doRefreshAfterWrite);
+ request.source(new JSONObject(json), query);
+ try {
+ UpdateByQueryResponse response = this.update(request);
+ success = !response.hasFailures();
+ } catch (IOException e) {
+ LOG.warn("Problem updating items in {} with query {} and data {}: {}", dataTypeName, query, json, e);
+ }
+ // if(this.doRefreshAfterWrite) {
+ // this.doRefresh(dataTypeName);
+ // }
+ return success;
+ }
+
+
+
+ @Override
+ public int doRemove(String dataTypeName, QueryBuilder query) {
+ int del = 0;
+ DeleteByQueryRequest request = new DeleteByQueryRequest(dataTypeName, this.doRefreshAfterWrite);
+ request.source(query);
+ try {
+ DeleteByQueryResponse response = this.deleteByQuery(request);
+ del = response.getDeleted();
+ } catch (IOException e) {
+ LOG.warn("Problem delete in {} with query {}:{} ", dataTypeName, query.toJSON(), e);
+ }
+ // if(this.doRefreshAfterWrite) {
+ // this.doRefresh(dataTypeName);
+ // }
+ return del;
+ }
+
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/IsEsObject.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/IsEsObject.java
index 7dc6be372..e18eabcd3 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/IsEsObject.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/IsEsObject.java
@@ -28,12 +28,14 @@ public interface IsEsObject {
/**
* Set the ES Id
+ *
* @param id Set the ID, created by ES for this Object
*/
- void setEsId( String id );
+ void setEsId(String id);
/**
* Get Id content as string that is used in ES
+ *
* @return Related ID, that was specified by set command.
*/
String getEsId();
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java
index ed6c95fd2..250842e57 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/Portstatus.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.common.database;
@@ -58,11 +58,11 @@ public class Portstatus {
public static boolean isAvailable(HostInfo... hosts) {
for (HostInfo host : hosts) {
- if (!isAvailable(host.hostname, host.port)) {
- return false;
- }
- }
- return true;
+ if (!isAvailable(host.hostname, host.port)) {
+ return false;
+ }
+ }
+ return true;
}
public static boolean waitSecondsTillAvailable(long timeoutSeconds, HostInfo... hosts) {
@@ -72,7 +72,7 @@ public class Portstatus {
}
long waitSeconds = 0;
boolean res = false;
- while ( (timeoutSeconds == 0 || ++waitSeconds < timeoutSeconds) && !(res = isAvailable(hosts))) {
+ while ((timeoutSeconds == 0 || ++waitSeconds < timeoutSeconds) && !(res = isAvailable(hosts))) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
@@ -82,7 +82,7 @@ public class Portstatus {
return res;
}
- public static boolean waitSecondsTillAvailable(long timeoutSeconds, String dnsName, int port ) {
+ public static boolean waitSecondsTillAvailable(long timeoutSeconds, String dnsName, int port) {
return waitSecondsTillAvailable(timeoutSeconds, new HostInfo(dnsName, port));
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
index 749714b48..4c4c41437 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchHit.java
@@ -33,7 +33,7 @@ public class SearchHit {
public SearchHit(JSONObject o) {
this.raw = o;
- this.index=o.getString("_index");
+ this.index = o.getString("_index");
this.type = o.getString("_type");
this.id = o.getString("_id");
this.source = o.getJSONObject("_source");
@@ -42,9 +42,11 @@ public class SearchHit {
public String getIndex() {
return this.index;
}
+
public String getType() {
return this.type;
}
+
public String getId() {
return this.id;
}
@@ -52,9 +54,11 @@ public class SearchHit {
public JSONObject getSource() {
return this.source;
}
+
public String getSourceAsString() {
return this.source.toString();
}
+
public JSONObject getRaw() {
return this.raw;
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
index 5dc6115c8..5a011eec9 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/SearchResult.java
@@ -27,41 +27,46 @@ import java.util.List;
public class SearchResult<T> {
- /**
- * objects in results
- */
- private final List<T> hits;
- /**
- * size of all potential hits
- * not necessarily the number of hits
- */
- private long total;
+ /**
+ * objects in results
+ */
+ private final List<T> hits;
+ /**
+ * size of all potential hits not necessarily the number of hits
+ */
+ private long total;
- public SearchResult(T[] hits) {
- this(hits,hits==null?0:hits.length);
- }
- public SearchResult(T[] hits,long total) {
- this.hits = Arrays.asList(hits);
- this.total = total;
- }
-// public SearchResult(List<T> hits,long total) {
-// this.hits = hits;
-// this.total = total;
-// }
- public SearchResult() {
- this.hits=new ArrayList<>();
- this.total = 0;
- }
- public List<T> getHits() {
- return this.hits;
- }
- public long getTotal() {
- return this.total;
- }
- public void setTotal(long total) {
- this.total = total;
- }
- public void add(T object) {
- this.hits.add(object);
- }
+ public SearchResult(T[] hits) {
+ this(hits, hits == null ? 0 : hits.length);
+ }
+
+ public SearchResult(T[] hits, long total) {
+ this.hits = Arrays.asList(hits);
+ this.total = total;
+ }
+
+ // public SearchResult(List<T> hits,long total) {
+ // this.hits = hits;
+ // this.total = total;
+ // }
+ public SearchResult() {
+ this.hits = new ArrayList<>();
+ this.total = 0;
+ }
+
+ public List<T> getHits() {
+ return this.hits;
+ }
+
+ public long getTotal() {
+ return this.total;
+ }
+
+ public void setTotal(long total) {
+ this.total = total;
+ }
+
+ public void add(T object) {
+ this.hits.add(object);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
index 858807863..cb0454361 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/config/HostInfo.java
@@ -27,80 +27,83 @@ import java.util.regex.Pattern;
public class HostInfo {
- public enum Protocol{
- HTTP("http"),
- HTTPS("https");//,
-// FILETRANSFERPROTOCOL("ftp");
-
- private final String value;
-
- private Protocol(String s) {
- this.value = s;
- }
- @Override
- public String toString() {
- return this.value;
- }
- public String getValue() {
- return value;
- }
- public static Protocol getValueOf(String s) {
- s = s.toLowerCase();
- for(Protocol p:Protocol.values()) {
- if(p.value.equals(s)) {
- return p;
- }
- }
- return HTTP;
- }
- }
- private static final Protocol DEFAULT_PROTOCOL = Protocol.HTTP;
- public final String hostname;
- public final int port;
- public final Protocol protocol;
-
- public HostInfo(String hostname,int port, Protocol protocol) {
- this.hostname = hostname;
- this.port = port;
- this.protocol=protocol;
-
- }
-
- public HostInfo(String hostname, int port) {
- this(hostname,port,DEFAULT_PROTOCOL);
-
- }
-
- @Override
- public String toString() {
- return "HostInfo [hostname=" + hostname + ", port=" + port + ", protocol=" + protocol + "]";
- }
-
- public String toUrl() {
- return String.format("%s://%s:%d",this.protocol,this.hostname,this.port);
- }
-
- public static HostInfo getDefault() {
- return new HostInfo("localhost",9200,Protocol.HTTP);
- }
-
- /**
- * @param dbUrl
- * @return
- */
- public static HostInfo parse(String dbUrl) throws ParseException{
- final String regex = "^(https?):\\/\\/([^:]*):?([0-9]{0,5})$";
- final Pattern pattern = Pattern.compile(regex);
- final Matcher matcher = pattern.matcher(dbUrl);
- if(!matcher.find() || matcher.groupCount()<2) {
- throw new ParseException("url "+dbUrl+" not parseable", 0);
- }
- Protocol p = Protocol.getValueOf(matcher.group(1));
- String host = matcher.group(2);
- int port = p==Protocol.HTTP?80:443;
- if(matcher.groupCount()>2) {
- port=Integer.parseInt(matcher.group(3));
- }
- return new HostInfo(host,port,p);
- }
+ public enum Protocol {
+ HTTP("http"), HTTPS("https");//,
+ // FILETRANSFERPROTOCOL("ftp");
+
+ private final String value;
+
+ private Protocol(String s) {
+ this.value = s;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static Protocol getValueOf(String s) {
+ s = s.toLowerCase();
+ for (Protocol p : Protocol.values()) {
+ if (p.value.equals(s)) {
+ return p;
+ }
+ }
+ return HTTP;
+ }
+ }
+
+ private static final Protocol DEFAULT_PROTOCOL = Protocol.HTTP;
+ public final String hostname;
+ public final int port;
+ public final Protocol protocol;
+
+ public HostInfo(String hostname, int port, Protocol protocol) {
+ this.hostname = hostname;
+ this.port = port;
+ this.protocol = protocol;
+
+ }
+
+ public HostInfo(String hostname, int port) {
+ this(hostname, port, DEFAULT_PROTOCOL);
+
+ }
+
+ @Override
+ public String toString() {
+ return "HostInfo [hostname=" + hostname + ", port=" + port + ", protocol=" + protocol + "]";
+ }
+
+ public String toUrl() {
+ return String.format("%s://%s:%d", this.protocol, this.hostname, this.port);
+ }
+
+ public static HostInfo getDefault() {
+ return new HostInfo("localhost", 9200, Protocol.HTTP);
+ }
+
+ /**
+ * @param dbUrl
+ * @return
+ */
+ public static HostInfo parse(String dbUrl) throws ParseException {
+ final String regex = "^(https?):\\/\\/([^:]*):?([0-9]{0,5})$";
+ final Pattern pattern = Pattern.compile(regex);
+ final Matcher matcher = pattern.matcher(dbUrl);
+ if (!matcher.find() || matcher.groupCount() < 2) {
+ throw new ParseException("url " + dbUrl + " not parseable", 0);
+ }
+ Protocol p = Protocol.getValueOf(matcher.group(1));
+ String host = matcher.group(2);
+ int port = p == Protocol.HTTP ? 80 : 443;
+ if (matcher.groupCount() > 2) {
+ port = Integer.parseInt(matcher.group(3));
+ }
+ return new HostInfo(host, port, p);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java
index 1c1c4ecd3..d55e66d2e 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntry.java
@@ -30,24 +30,27 @@ import java.util.regex.Pattern;
*
*/
public class AliasesEntry {
- private static final String regex = "^([^\\ ]+)[\\ ]+([^\\ ]+)[\\ ]+.*$";
- private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+ private static final String regex = "^([^\\ ]+)[\\ ]+([^\\ ]+)[\\ ]+.*$";
+ private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
-
- public String getAlias() {
- return alias;
- }
- public String getIndex() {
- return index;
- }
- private final String alias;
- private final String index;
- public AliasesEntry(String line) throws ParseException {
- final Matcher matcher = pattern.matcher(line);
- if (!matcher.find() || matcher.groupCount() < 2) {
- throw new ParseException("unable to parse string:" + line, 0);
- }
- this.alias = matcher.group(1);
- this.index = matcher.group(2);
- }
+
+ public String getAlias() {
+ return alias;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+
+ private final String alias;
+ private final String index;
+
+ public AliasesEntry(String line) throws ParseException {
+ final Matcher matcher = pattern.matcher(line);
+ if (!matcher.find() || matcher.groupCount() < 2) {
+ throw new ParseException("unable to parse string:" + line, 0);
+ }
+ this.alias = matcher.group(1);
+ this.index = matcher.group(2);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java
index 3891ecfb7..e00ba5d4c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/AliasesEntryList.java
@@ -28,35 +28,35 @@ import java.util.List;
* @author Michael Dürre
*
*/
-public class AliasesEntryList extends ArrayList<AliasesEntry>{
+public class AliasesEntryList extends ArrayList<AliasesEntry> {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
- /**
- * @param alias
- * @return
- */
- public AliasesEntry findByAlias(String alias) {
- for(AliasesEntry e:this) {
- if(e.getAlias().equals(alias)) {
- return e;
- }
- }
- return null;
- }
+ /**
+ * @param alias
+ * @return
+ */
+ public AliasesEntry findByAlias(String alias) {
+ for (AliasesEntry e : this) {
+ if (e.getAlias().equals(alias)) {
+ return e;
+ }
+ }
+ return null;
+ }
- /**
- * @return
- */
- public List<String> getLinkedIndices() {
- List<String> list = new ArrayList<String>();
- for(AliasesEntry e:this) {
- list.add(e.getIndex());
- }
- return list;
- }
+ /**
+ * @return
+ */
+ public List<String> getLinkedIndices() {
+ List<String> list = new ArrayList<String>();
+ for (AliasesEntry e : this) {
+ list.add(e.getIndex());
+ }
+ return list;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
index 082a28817..2a8f04df3 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/DbFilter.java
@@ -25,42 +25,42 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.RangeQueryBuilder
public class DbFilter {
- public static String createDatabaseRegex(String restFilterValue) {
- return restFilterValue == null ? null : restFilterValue.replace("?", ".{1,1}").replace("*", ".*");
- }
+ public static String createDatabaseRegex(String restFilterValue) {
+ return restFilterValue == null ? null : restFilterValue.replace("?", ".{1,1}").replace("*", ".*");
+ }
- public static boolean hasSearchParams(String restFilterValue) {
- return restFilterValue == null ? false : restFilterValue.contains("*") || restFilterValue.contains("?");
- }
+ public static boolean hasSearchParams(String restFilterValue) {
+ return restFilterValue == null ? false : restFilterValue.contains("*") || restFilterValue.contains("?");
+ }
- public static boolean isComparisonValid(String restFilterValue) {
- return restFilterValue == null ? false : restFilterValue.contains(">") || restFilterValue.contains("<");
- }
+ public static boolean isComparisonValid(String restFilterValue) {
+ return restFilterValue == null ? false : restFilterValue.contains(">") || restFilterValue.contains("<");
+ }
- public static RangeQueryBuilder getRangeQuery(String key, String restFilterValue) {
- RangeQueryBuilder query = new RangeQueryBuilder(key);
- restFilterValue = restFilterValue.trim();
- if (restFilterValue.startsWith(">=")) {
- query.gte(getObjectFromString(restFilterValue.substring(2).trim()));
- } else if (restFilterValue.startsWith(">")) {
- query.gt(getObjectFromString(restFilterValue.substring(1).trim()));
- } else if (restFilterValue.startsWith("<=")) {
- query.lte(getObjectFromString(restFilterValue.substring(2).trim()));
- } else if (restFilterValue.startsWith("<")) {
- query.lt(getObjectFromString(restFilterValue.substring(1).trim()));
- } else {
- return null;
- }
+ public static RangeQueryBuilder getRangeQuery(String key, String restFilterValue) {
+ RangeQueryBuilder query = new RangeQueryBuilder(key);
+ restFilterValue = restFilterValue.trim();
+ if (restFilterValue.startsWith(">=")) {
+ query.gte(getObjectFromString(restFilterValue.substring(2).trim()));
+ } else if (restFilterValue.startsWith(">")) {
+ query.gt(getObjectFromString(restFilterValue.substring(1).trim()));
+ } else if (restFilterValue.startsWith("<=")) {
+ query.lte(getObjectFromString(restFilterValue.substring(2).trim()));
+ } else if (restFilterValue.startsWith("<")) {
+ query.lt(getObjectFromString(restFilterValue.substring(1).trim()));
+ } else {
+ return null;
+ }
- return query;
- }
+ return query;
+ }
- private static Object getObjectFromString(String str) {
- try {
- return Double.parseDouble(str);
- } catch (NumberFormatException | NullPointerException nfe) {
- return str;
- }
-
- }
+ private static Object getObjectFromString(String str) {
+ try {
+ return Double.parseDouble(str);
+ } catch (NumberFormatException | NullPointerException nfe) {
+ return str;
+ }
+
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java
index d99e0e701..7d106dfec 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/EsVersion.java
@@ -31,109 +31,108 @@ import org.eclipse.jdt.annotation.NonNull;
*
*/
public class EsVersion {
-
- private final String raw;
- private final int major;
- private final int minor;
- private final int revision;
-
- public EsVersion(@NonNull String version) throws ParseException {
- String[] hlp=version.split("\\.");
- if(hlp.length<3) {
- throw new ParseException("unable to parse version string: "+version, 0);
- }
- this.raw = version;
- this.major = Integer.parseInt(hlp[0]);
- this.minor = Integer.parseInt(hlp[1]);
- this.revision = Integer.parseInt(hlp[2]);
- }
- /**
- * @param major
- * @param minor
- * @param revision
- */
- public EsVersion(int major, int minor, int revision) {
- this.raw = String.format("%d.%d.%d", major,minor,revision);
- this.major = major;
- this.minor = minor;
- this.revision = revision;
- }
+ private final String raw;
+ private final int major;
+ private final int minor;
+ private final int revision;
- /**
- * @return the revision
- */
- public int getRevision() {
- return revision;
- }
+ public EsVersion(@NonNull String version) throws ParseException {
+ String[] hlp = version.split("\\.");
+ if (hlp.length < 3) {
+ throw new ParseException("unable to parse version string: " + version, 0);
+ }
+ this.raw = version;
+ this.major = Integer.parseInt(hlp[0]);
+ this.minor = Integer.parseInt(hlp[1]);
+ this.revision = Integer.parseInt(hlp[2]);
+ }
- /**
- * @return the minor
- */
- public int getMinor() {
- return minor;
- }
+ /**
+ * @param major
+ * @param minor
+ * @param revision
+ */
+ public EsVersion(int major, int minor, int revision) {
+ this.raw = String.format("%d.%d.%d", major, minor, revision);
+ this.major = major;
+ this.minor = minor;
+ this.revision = revision;
+ }
- /**
- * @return the major
- */
- public int getMajor() {
- return major;
- }
+ /**
+ * @return the revision
+ */
+ public int getRevision() {
+ return revision;
+ }
+
+ /**
+ * @return the minor
+ */
+ public int getMinor() {
+ return minor;
+ }
+
+ /**
+ * @return the major
+ */
+ public int getMajor() {
+ return major;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (!(obj instanceof EsVersion)) {
+ return false;
+ }
+ EsVersion esobj = (EsVersion) obj;
+ return this.major == esobj.major && this.minor == esobj.minor && this.revision == esobj.revision;
+ }
+
+ @Override
+ public int hashCode() {
+ return this.raw.hashCode();
+ }
+
+ public boolean isNewerOrEqualThan(EsVersion v) {
+ if (this.equals(v)) {
+ return true;
+ }
+ if (this.major > v.major) {
+ return true;
+ } else if (this.major < v.major) {
+ return false;
+ }
+ if (this.minor > v.minor) {
+ return true;
+ } else if (this.minor < v.minor) {
+ return false;
+ }
+ if (this.revision > v.revision) {
+ return true;
+ }
+ return false;
+ }
+
+ public boolean isOlderOrEqualThan(EsVersion v) {
+ if (this.equals(v)) {
+ return true;
+ }
+ if (this.major < v.major) {
+ return true;
+ } else if (this.major > v.major) {
+ return false;
+ }
+ if (this.minor < v.minor) {
+ return true;
+ } else if (this.minor > v.minor) {
+ return false;
+ }
+ if (this.revision < v.revision) {
+ return true;
+ }
+ return false;
+ }
- @Override
- public boolean equals(Object obj) {
- if(!(obj instanceof EsVersion)) {
- return false;
- }
- EsVersion esobj = (EsVersion)obj;
- return this.major==esobj.major && this.minor==esobj.minor && this.revision==esobj.revision;
- }
- @Override
- public int hashCode() {
- return this.raw.hashCode();
- }
- public boolean isNewerOrEqualThan(EsVersion v) {
- if(this.equals(v)) {
- return true;
- }
- if(this.major>v.major) {
- return true;
- }
- else if(this.major<v.major) {
- return false;
- }
- if(this.minor>v.minor) {
- return true;
- }
- else if(this.minor<v.minor) {
- return false;
- }
- if(this.revision>v.revision) {
- return true;
- }
- return false;
- }
- public boolean isOlderOrEqualThan(EsVersion v) {
- if(this.equals(v)) {
- return true;
- }
- if(this.major<v.major) {
- return true;
- }
- else if(this.major>v.major) {
- return false;
- }
- if(this.minor<v.minor) {
- return true;
- }
- else if(this.minor>v.minor) {
- return false;
- }
- if(this.revision<v.revision) {
- return true;
- }
- return false;
- }
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
index 26e088d3f..b31ff4389 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntry.java
@@ -28,97 +28,99 @@ import java.util.regex.Pattern;
/**
* @author Michael Dürre
*
- * Entry of list indices http request (/_cat/indices)
- *
- * yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb
+ * Entry of list indices http request (/_cat/indices)
+ *
+ * yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb
*/
public class IndicesEntry {
- private static final String regex = "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
- private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
- //for ES 2.2.0
- private static final String regexOld = "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
- private static final Pattern patternOld = Pattern.compile(regexOld, Pattern.MULTILINE);
+ private static final String regex =
+ "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
+ private static final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
+ //for ES 2.2.0
+ private static final String regexOld =
+ "^(yellow|red|green)[\\ ]+([^\\ ]*)[\\ ]+([^\\ ]*)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([0-9]+)[\\ ]+([^\\ ]+)[\\ ]+([^\\ ]+)$";
+ private static final Pattern patternOld = Pattern.compile(regexOld, Pattern.MULTILINE);
- private final String status;
- private final String status2;
- private final String name;
- private final String hash;
- private final int shards;
- private final int replicas;
- private final int c1;
- private final int c2;
- private final String size1;
- private final String size2;
+ private final String status;
+ private final String status2;
+ private final String name;
+ private final String hash;
+ private final int shards;
+ private final int replicas;
+ private final int c1;
+ private final int c2;
+ private final String size1;
+ private final String size2;
- public String getStatus() {
- return status;
- }
+ public String getStatus() {
+ return status;
+ }
- public String getStatus2() {
- return status2;
- }
+ public String getStatus2() {
+ return status2;
+ }
- public String getName() {
- return name;
- }
+ public String getName() {
+ return name;
+ }
- public String getHash() {
- return hash;
- }
+ public String getHash() {
+ return hash;
+ }
- public int getShards() {
- return shards;
- }
+ public int getShards() {
+ return shards;
+ }
- public int getReplicas() {
- return replicas;
- }
+ public int getReplicas() {
+ return replicas;
+ }
- public int getC1() {
- return c1;
- }
+ public int getC1() {
+ return c1;
+ }
- public int getC2() {
- return c2;
- }
+ public int getC2() {
+ return c2;
+ }
- public String getSize1() {
- return size1;
- }
+ public String getSize1() {
+ return size1;
+ }
- public String getSize2() {
- return size2;
- }
+ public String getSize2() {
+ return size2;
+ }
- public IndicesEntry(String line) throws ParseException {
- Matcher matcher = pattern.matcher(line.trim());
- if (!matcher.find() || matcher.groupCount() < 10) {
- matcher = patternOld.matcher(line.trim());
- if (!matcher.find() || matcher.groupCount() < 9) {
- throw new ParseException("unable to parse string:" + line, 0);
- }
- this.status = matcher.group(1);
- this.status2 = matcher.group(2);
- this.name = matcher.group(3);
- this.hash = "";
- this.shards = Integer.parseInt(matcher.group(4));
- this.replicas = Integer.parseInt(matcher.group(5));
- this.c1 = Integer.parseInt(matcher.group(6));
- this.c2 = Integer.parseInt(matcher.group(7));
- this.size1 = matcher.group(8);
- this.size2 = matcher.group(9);
- } else {
- this.status = matcher.group(1);
- this.status2 = matcher.group(2);
- this.name = matcher.group(3);
- this.hash = matcher.group(4);
- this.shards = Integer.parseInt(matcher.group(5));
- this.replicas = Integer.parseInt(matcher.group(6));
- this.c1 = Integer.parseInt(matcher.group(7));
- this.c2 = Integer.parseInt(matcher.group(8));
- this.size1 = matcher.group(9);
- this.size2 = matcher.group(10);
- }
- }
+ public IndicesEntry(String line) throws ParseException {
+ Matcher matcher = pattern.matcher(line.trim());
+ if (!matcher.find() || matcher.groupCount() < 10) {
+ matcher = patternOld.matcher(line.trim());
+ if (!matcher.find() || matcher.groupCount() < 9) {
+ throw new ParseException("unable to parse string:" + line, 0);
+ }
+ this.status = matcher.group(1);
+ this.status2 = matcher.group(2);
+ this.name = matcher.group(3);
+ this.hash = "";
+ this.shards = Integer.parseInt(matcher.group(4));
+ this.replicas = Integer.parseInt(matcher.group(5));
+ this.c1 = Integer.parseInt(matcher.group(6));
+ this.c2 = Integer.parseInt(matcher.group(7));
+ this.size1 = matcher.group(8);
+ this.size2 = matcher.group(9);
+ } else {
+ this.status = matcher.group(1);
+ this.status2 = matcher.group(2);
+ this.name = matcher.group(3);
+ this.hash = matcher.group(4);
+ this.shards = Integer.parseInt(matcher.group(5));
+ this.replicas = Integer.parseInt(matcher.group(6));
+ this.c1 = Integer.parseInt(matcher.group(7));
+ this.c2 = Integer.parseInt(matcher.group(8));
+ this.size1 = matcher.group(9);
+ this.size2 = matcher.group(10);
+ }
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java
index 5431db9e7..7b736835f 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/data/IndicesEntryList.java
@@ -28,38 +28,38 @@ import java.util.List;
* @author Michael Dürre
*
*/
-public class IndicesEntryList extends ArrayList<IndicesEntry>{
+public class IndicesEntryList extends ArrayList<IndicesEntry> {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
- /**
- * @param index
- * @return
- */
- public IndicesEntry findByIndex(String index) {
- for(IndicesEntry e:this) {
- if(e.getName().equals(index)) {
- return e;
- }
- }
- return null;
- }
+ /**
+ * @param index
+ * @return
+ */
+ public IndicesEntry findByIndex(String index) {
+ for (IndicesEntry e : this) {
+ if (e.getName().equals(index)) {
+ return e;
+ }
+ }
+ return null;
+ }
- /**
- * @param indices
- * @return
- */
- public IndicesEntryList subList(List<String> indices) {
- IndicesEntryList sublist = new IndicesEntryList();
- for(IndicesEntry e:this) {
- if(indices.contains(e.getName())) {
- sublist.add(e);
- }
- }
- return sublist;
- }
+ /**
+ * @param indices
+ * @return
+ */
+ public IndicesEntryList subList(List<String> indices) {
+ IndicesEntryList sublist = new IndicesEntryList();
+ for (IndicesEntry e : this) {
+ if (indices.contains(e.getName())) {
+ sublist.add(e);
+ }
+ }
+ return sublist;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
index b362c4684..359b9d04b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/BoolQueryBuilder.java
@@ -26,67 +26,67 @@ import org.json.JSONObject;
public class BoolQueryBuilder extends QueryBuilder {
- private JSONObject inner;
+ private JSONObject inner;
- public BoolQueryBuilder() {
- super();
- this.inner = new JSONObject();
- this.setQuery("bool", this.inner);
- }
+ public BoolQueryBuilder() {
+ super();
+ this.inner = new JSONObject();
+ this.setQuery("bool", this.inner);
+ }
- @Override
- public String toString() {
- return "BoolQueryBuilder [inner=" + inner + "]";
- }
+ @Override
+ public String toString() {
+ return "BoolQueryBuilder [inner=" + inner + "]";
+ }
- public static boolean isEmpty(JSONObject o) {
- return o.keySet().size() <= 0;
- }
+ public static boolean isEmpty(JSONObject o) {
+ return o.keySet().size() <= 0;
+ }
- public BoolQueryBuilder must(QueryBuilder query) {
+ public BoolQueryBuilder must(QueryBuilder query) {
- if (!isEmpty(this.inner)) {
- Object x = this.inner.has("must") ? this.inner.get("must") : this.inner;
- if (x instanceof JSONArray) {
- ((JSONArray) x).put(query.getInner());
- } else {
- this.inner = new JSONObject();
- this.inner.put("must", new JSONObject());
- JSONArray a = new JSONArray();
- a.put(x);
- a.put(query.getInner());
- this.inner.put("must", a);
- }
- } else {
- this.inner.put("must", query.getInner());
- }
- this.setQuery("bool", this.inner);
- return this;
- }
+ if (!isEmpty(this.inner)) {
+ Object x = this.inner.has("must") ? this.inner.get("must") : this.inner;
+ if (x instanceof JSONArray) {
+ ((JSONArray) x).put(query.getInner());
+ } else {
+ this.inner = new JSONObject();
+ this.inner.put("must", new JSONObject());
+ JSONArray a = new JSONArray();
+ a.put(x);
+ a.put(query.getInner());
+ this.inner.put("must", a);
+ }
+ } else {
+ this.inner.put("must", query.getInner());
+ }
+ this.setQuery("bool", this.inner);
+ return this;
+ }
- /**
- * @param query
- */
- public BoolQueryBuilder should(QueryBuilder query) {
- if (!isEmpty(this.inner)) {
- Object x = this.inner.has("should") ? this.inner.get("should") : this.inner;
- if (x instanceof JSONArray) {
- ((JSONArray) x).put(query.getInner());
- } else {
- this.inner = new JSONObject();
- // this.inner.put("should", new JSONObject());
- JSONArray a = new JSONArray();
- if (!x.toString().equals("{}")) {
- a.put(x);
- }
- a.put(query.getInner());
- this.inner.put("should", a);
- }
- } else {
- this.inner.put("should", query.getInner());
- }
- this.setQuery("bool", this.inner);
- return this;
- }
+ /**
+ * @param query
+ */
+ public BoolQueryBuilder should(QueryBuilder query) {
+ if (!isEmpty(this.inner)) {
+ Object x = this.inner.has("should") ? this.inner.get("should") : this.inner;
+ if (x instanceof JSONArray) {
+ ((JSONArray) x).put(query.getInner());
+ } else {
+ this.inner = new JSONObject();
+ // this.inner.put("should", new JSONObject());
+ JSONArray a = new JSONArray();
+ if (!x.toString().equals("{}")) {
+ a.put(x);
+ }
+ a.put(query.getInner());
+ this.inner.put("should", a);
+ }
+ } else {
+ this.inner.put("should", query.getInner());
+ }
+ this.setQuery("bool", this.inner);
+ return this;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilder.java
index ad6c199ea..519502efd 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilder.java
@@ -26,76 +26,78 @@ import org.json.JSONObject;
public class QueryBuilder {
- private JSONObject innerQuery;
- private final JSONObject outerQuery;
- private final JSONObject queryObj;
+ private JSONObject innerQuery;
+ private final JSONObject outerQuery;
+ private final JSONObject queryObj;
- public QueryBuilder() {
- this.outerQuery = new JSONObject();
- this.queryObj = new JSONObject();
- this.outerQuery.put("query", this.queryObj);
+ public QueryBuilder() {
+ this.outerQuery = new JSONObject();
+ this.queryObj = new JSONObject();
+ this.outerQuery.put("query", this.queryObj);
- }
+ }
- public QueryBuilder from(long from) {
- this.outerQuery.put("from", from);
- return this;
- }
+ public QueryBuilder from(long from) {
+ this.outerQuery.put("from", from);
+ return this;
+ }
- public QueryBuilder size(long size) {
- this.outerQuery.put("size", size);
- return this;
- }
+ public QueryBuilder size(long size) {
+ this.outerQuery.put("size", size);
+ return this;
+ }
- public QueryBuilder sort(String prop, SortOrder order) {
- JSONArray a;
- if (this.outerQuery.has("sort")) {
- a = this.outerQuery.getJSONArray("sort");
- } else {
- a = new JSONArray();
- }
- JSONObject sortObj = new JSONObject();
- JSONObject orderObj = new JSONObject();
- orderObj.put("order", order.getValue());
- sortObj.put(prop, orderObj);
- a.put(sortObj);
- this.outerQuery.put("sort", a);
- return this;
- }
+ public QueryBuilder sort(String prop, SortOrder order) {
+ JSONArray a;
+ if (this.outerQuery.has("sort")) {
+ a = this.outerQuery.getJSONArray("sort");
+ } else {
+ a = new JSONArray();
+ }
+ JSONObject sortObj = new JSONObject();
+ JSONObject orderObj = new JSONObject();
+ orderObj.put("order", order.getValue());
+ sortObj.put(prop, orderObj);
+ a.put(sortObj);
+ this.outerQuery.put("sort", a);
+ return this;
+ }
- public QueryBuilder aggregations(String key, SortOrder sortOrder) {
- JSONObject keyquery = new JSONObject();
- JSONObject terms = new JSONObject();
- JSONObject field = new JSONObject();
- field.put("field", key);
- terms.put("terms", field);
- if(sortOrder!=null) {
- JSONObject so = new JSONObject();
- so.put("_key",sortOrder.getValue());
- terms.put("order", so);
- }
- keyquery.put(key, terms);
- this.outerQuery.put("aggs", keyquery);
- return this;
- }
+ public QueryBuilder aggregations(String key, SortOrder sortOrder) {
+ JSONObject keyquery = new JSONObject();
+ JSONObject terms = new JSONObject();
+ JSONObject field = new JSONObject();
+ field.put("field", key);
+ terms.put("terms", field);
+ if (sortOrder != null) {
+ JSONObject so = new JSONObject();
+ so.put("_key", sortOrder.getValue());
+ terms.put("order", so);
+ }
+ keyquery.put(key, terms);
+ this.outerQuery.put("aggs", keyquery);
+ return this;
+ }
- protected QueryBuilder setQuery(String key, JSONObject query) {
- this.innerQuery = query;
- this.queryObj.put(key, this.innerQuery);
- return this;
- }
+ protected QueryBuilder setQuery(String key, JSONObject query) {
+ this.innerQuery = query;
+ this.queryObj.put(key, this.innerQuery);
+ return this;
+ }
- public JSONObject getInner() {
- return this.queryObj;
- }
- public boolean contains(String match) {
- return this.toJSON().contains(match);
- }
- public String toJSON() {
- return this.outerQuery.toString();
- }
+ public JSONObject getInner() {
+ return this.queryObj;
+ }
- public QueryBuilder aggregations(String key) {
- return this.aggregations(key, null);
- }
+ public boolean contains(String match) {
+ return this.toJSON().contains(match);
+ }
+
+ public String toJSON() {
+ return this.outerQuery.toString();
+ }
+
+ public QueryBuilder aggregations(String key) {
+ return this.aggregations(key, null);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
index 4d5b20037..7b22fd5e7 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/QueryBuilders.java
@@ -25,36 +25,42 @@ import org.json.JSONObject;
public class QueryBuilders {
- public static QueryBuilder matchAllQuery() {
- return new QueryBuilder().setQuery("match_all",new JSONObject());
- }
- public static QueryBuilder termQuery(String key, String value) {
- JSONObject o=new JSONObject();
- o.put(key, value);
- return new QueryBuilder().setQuery("term", o);
- }
- public static QueryBuilder matchQuery(String key, Object value) {
- JSONObject o=new JSONObject();
- o.put(key, value);
- return new QueryBuilder().setQuery("match", o);
- }
- public static BoolQueryBuilder boolQuery() {
- return new BoolQueryBuilder();
- }
- public static RangeQueryBuilder rangeQuery(String key) {
- return new RangeQueryBuilder(key);
- }
- public static RegexQueryBuilder regex(String propertyName, String re) {
- return new RegexQueryBuilder().add(propertyName, re);
- }
- /**
- * @param object
- * @return
- */
- public static QueryBuilder searchAllFieldsQuery(String filter) {
- JSONObject inner = new JSONObject();
- inner.put("default_field", "*");
- inner.put("query", filter==null?"":filter);
- return new QueryBuilder().setQuery("query_string", inner);
- }
+ public static QueryBuilder matchAllQuery() {
+ return new QueryBuilder().setQuery("match_all", new JSONObject());
+ }
+
+ public static QueryBuilder termQuery(String key, String value) {
+ JSONObject o = new JSONObject();
+ o.put(key, value);
+ return new QueryBuilder().setQuery("term", o);
+ }
+
+ public static QueryBuilder matchQuery(String key, Object value) {
+ JSONObject o = new JSONObject();
+ o.put(key, value);
+ return new QueryBuilder().setQuery("match", o);
+ }
+
+ public static BoolQueryBuilder boolQuery() {
+ return new BoolQueryBuilder();
+ }
+
+ public static RangeQueryBuilder rangeQuery(String key) {
+ return new RangeQueryBuilder(key);
+ }
+
+ public static RegexQueryBuilder regex(String propertyName, String re) {
+ return new RegexQueryBuilder().add(propertyName, re);
+ }
+
+ /**
+ * @param object
+ * @return
+ */
+ public static QueryBuilder searchAllFieldsQuery(String filter) {
+ JSONObject inner = new JSONObject();
+ inner.put("default_field", "*");
+ inner.put("query", filter == null ? "" : filter);
+ return new QueryBuilder().setQuery("query_string", inner);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RangeQueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RangeQueryBuilder.java
index 6977380ad..e8b3d3047 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RangeQueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RangeQueryBuilder.java
@@ -23,67 +23,69 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.queries;
import org.json.JSONObject;
-public class RangeQueryBuilder extends QueryBuilder{
+public class RangeQueryBuilder extends QueryBuilder {
- private Object gtValue=null;
- private Object gteValue=null;
- private Float boost=2.0f;
- private Object ltValue=null;
- private Object lteValue=null;
- private String key;
+ private Object gtValue = null;
+ private Object gteValue = null;
+ private Float boost = 2.0f;
+ private Object ltValue = null;
+ private Object lteValue = null;
+ private String key;
- public RangeQueryBuilder(String key) {
- super();
- this.key=key;
-
- }
+ public RangeQueryBuilder(String key) {
+ super();
+ this.key = key;
- private void setQuery() {
- JSONObject r=new JSONObject();
- JSONObject k=new JSONObject();
- if(this.gteValue!=null) {
- k.put("gte", this.gteValue);
- }else if(this.gtValue!=null) {
- k.put("gt", this.gtValue);
- }
- if(this.lteValue!=null) {
- k.put("lte", this.lteValue);
- } else if(this.ltValue!=null) {
- k.put("lt", this.ltValue);
- }
- if(this.boost!=null) {
- k.put("boost", this.boost);
- }
- r.put(this.key,k);
-
- this.setQuery("range",r);
- }
-
+ }
- public RangeQueryBuilder lte(Object compare) {
- this.lteValue=compare;
- this.ltValue=null;
- this.setQuery();
- return this;
- }
- public RangeQueryBuilder lt(Object compare) {
- this.lteValue=null;
- this.ltValue=compare;
- this.setQuery();
- return this;
- }
-
- public RangeQueryBuilder gte(Object compare) {
- this.gteValue=compare;
- this.gtValue=null;
- this.setQuery();
- return this;
- }
- public RangeQueryBuilder gt(Object compare) {
- this.gteValue=null;
- this.gtValue=compare;
- this.setQuery();
- return this;
- }
+ private void setQuery() {
+ JSONObject r = new JSONObject();
+ JSONObject k = new JSONObject();
+ if (this.gteValue != null) {
+ k.put("gte", this.gteValue);
+ } else if (this.gtValue != null) {
+ k.put("gt", this.gtValue);
+ }
+ if (this.lteValue != null) {
+ k.put("lte", this.lteValue);
+ } else if (this.ltValue != null) {
+ k.put("lt", this.ltValue);
+ }
+ if (this.boost != null) {
+ k.put("boost", this.boost);
+ }
+ r.put(this.key, k);
+
+ this.setQuery("range", r);
+ }
+
+
+ public RangeQueryBuilder lte(Object compare) {
+ this.lteValue = compare;
+ this.ltValue = null;
+ this.setQuery();
+ return this;
+ }
+
+ public RangeQueryBuilder lt(Object compare) {
+ this.lteValue = null;
+ this.ltValue = compare;
+ this.setQuery();
+ return this;
+ }
+
+ public RangeQueryBuilder gte(Object compare) {
+ this.gteValue = compare;
+ this.gtValue = null;
+ this.setQuery();
+ return this;
+ }
+
+ public RangeQueryBuilder gt(Object compare) {
+ this.gteValue = null;
+ this.gtValue = compare;
+ this.setQuery();
+ return this;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RegexQueryBuilder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RegexQueryBuilder.java
index 1df10ff56..d2002e506 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RegexQueryBuilder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/RegexQueryBuilder.java
@@ -25,23 +25,25 @@ import org.json.JSONObject;
public class RegexQueryBuilder extends QueryBuilder {
- private JSONObject inner;
+ private JSONObject inner;
- public RegexQueryBuilder() {
- super();
- this.inner = new JSONObject();
- this.setQuery("regexp", this.inner);
- }
- public RegexQueryBuilder add(String propertyName, String filter) {
- JSONObject regexFilter = new JSONObject();
- regexFilter.put("value", filter);
- regexFilter.put("flags", "ALL");
- regexFilter.put("max_determinized_states", 10000);
- this.inner.put(propertyName, regexFilter);
- return this;
- }
- @Override
- public String toString() {
- return "RegexQueryBuilder [inner=" + inner + "]";
- }
+ public RegexQueryBuilder() {
+ super();
+ this.inner = new JSONObject();
+ this.setQuery("regexp", this.inner);
+ }
+
+ public RegexQueryBuilder add(String propertyName, String filter) {
+ JSONObject regexFilter = new JSONObject();
+ regexFilter.put("value", filter);
+ regexFilter.put("flags", "ALL");
+ regexFilter.put("max_determinized_states", 10000);
+ this.inner.put(propertyName, regexFilter);
+ return this;
+ }
+
+ @Override
+ public String toString() {
+ return "RegexQueryBuilder [inner=" + inner + "]";
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/SortOrder.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/SortOrder.java
index 3c1bbf796..7647445ee 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/SortOrder.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/queries/SortOrder.java
@@ -23,15 +23,15 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.queries;
public enum SortOrder {
- ASCENDING("asc"),
- DESCENDING("desc");
-
- private final String value;
+ ASCENDING("asc"), DESCENDING("desc");
- SortOrder(String so){
- this.value=so;
- }
- public String getValue() {
- return this.value;
- }
+ private final String value;
+
+ SortOrder(String so) {
+ this.value = so;
+ }
+
+ public String getValue() {
+ return this.value;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
index e7261f3e5..028de75d2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/BaseRequest.java
@@ -33,76 +33,77 @@ import org.slf4j.LoggerFactory;
public abstract class BaseRequest {
- private static final Logger LOG = LoggerFactory.getLogger(BaseRequest.class);
-
- public static final int DEFAULT_RETRIES = 1;
-
- protected final Request request;
- private String query;
- private final boolean refresh;
-
- public BaseRequest(String method, String endpoint) {
- LOG.debug("create request {} {}" ,method, endpoint);
- this.refresh = false;
- this.request = new Request(method, endpoint);
- query = null;
- }
-
- public BaseRequest(String method, String endpoint, boolean refresh) {
- LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
- this.refresh = refresh;
- this.request = new Request(method, String.format("%s?refresh=%s", endpoint, String.valueOf(refresh)));
- query = null;
- }
-
- public BaseRequest(String method, String endpoint, boolean refresh, int retries) {
- LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
- this.refresh = refresh;
- this.request = new Request(method, String.format("%s?refresh=%s&retry_on_conflict=%d", endpoint, String.valueOf(refresh),retries));
- query = null;
- }
-
- public Request getInner() {
-
- return this.request;
- }
-
- public static String urlEncodeValue(String value) {
- if (value == null)
- return null;
- try {
- return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()).replace("+", "%20");
- } catch (UnsupportedEncodingException ex) {
- LOG.warn("encoding problem: {}", ex.getMessage());
- }
- return value;
- }
-
- @Override
- public String toString() {
- return this.request.getMethod() + " " + this.request.getEndpoint() + " : "
- + (this.query != null ? this.query : "no query");
- }
-
- protected void setQuery(QueryBuilder query) {
- this.setQuery(query.toJSON());
- }
-
- public void setQuery(JSONObject o) {
- this.setQuery(o.toString());
- }
-
- public void setQuery(String content) {
- this.query = content;
- LOG.trace("query={}", content);
- this.request.setJsonEntity(this.query);
- }
-
- protected String getQuery() {
- return this.query;
- }
-
- protected boolean doRefresh() {
- return this.refresh;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(BaseRequest.class);
+
+ public static final int DEFAULT_RETRIES = 1;
+
+ protected final Request request;
+ private String query;
+ private final boolean refresh;
+
+ public BaseRequest(String method, String endpoint) {
+ LOG.debug("create request {} {}", method, endpoint);
+ this.refresh = false;
+ this.request = new Request(method, endpoint);
+ query = null;
+ }
+
+ public BaseRequest(String method, String endpoint, boolean refresh) {
+ LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
+ this.refresh = refresh;
+ this.request = new Request(method, String.format("%s?refresh=%s", endpoint, String.valueOf(refresh)));
+ query = null;
+ }
+
+ public BaseRequest(String method, String endpoint, boolean refresh, int retries) {
+ LOG.debug("create request {} {} with refresh={}", method, endpoint, refresh);
+ this.refresh = refresh;
+ this.request = new Request(method,
+ String.format("%s?refresh=%s&retry_on_conflict=%d", endpoint, String.valueOf(refresh), retries));
+ query = null;
+ }
+
+ public Request getInner() {
+
+ return this.request;
+ }
+
+ public static String urlEncodeValue(String value) {
+ if (value == null)
+ return null;
+ try {
+ return URLEncoder.encode(value, StandardCharsets.UTF_8.toString()).replace("+", "%20");
+ } catch (UnsupportedEncodingException ex) {
+ LOG.warn("encoding problem: {}", ex.getMessage());
+ }
+ return value;
+ }
+
+ @Override
+ public String toString() {
+ return this.request.getMethod() + " " + this.request.getEndpoint() + " : "
+ + (this.query != null ? this.query : "no query");
+ }
+
+ protected void setQuery(QueryBuilder query) {
+ this.setQuery(query.toJSON());
+ }
+
+ public void setQuery(JSONObject o) {
+ this.setQuery(o.toString());
+ }
+
+ public void setQuery(String content) {
+ this.query = content;
+ LOG.trace("query={}", content);
+ this.request.setJsonEntity(this.query);
+ }
+
+ protected String getQuery() {
+ return this.query;
+ }
+
+ protected boolean doRefresh() {
+ return this.refresh;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterHealthRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterHealthRequest.java
index 4b837c823..e357c416b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterHealthRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterHealthRequest.java
@@ -21,15 +21,15 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class ClusterHealthRequest extends BaseRequest{
+public class ClusterHealthRequest extends BaseRequest {
-
- public ClusterHealthRequest() {
- super("GET","/_cluster/health");
- }
- public void timeout(long seconds) {
- this.request.addParameter("timeout", String.valueOf(seconds)+"s");
-
- }
+ public ClusterHealthRequest() {
+ super("GET", "/_cluster/health");
+ }
+
+ public void timeout(long seconds) {
+ this.request.addParameter("timeout", String.valueOf(seconds) + "s");
+
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterSettingsRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterSettingsRequest.java
index cc2d972b5..1379da5ad 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterSettingsRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ClusterSettingsRequest.java
@@ -25,26 +25,27 @@ import org.json.JSONObject;
//https://www.elastic.co/guide/en/elasticsearch/reference/6.8/docs-index_.html
//https://github.com/elastic/elasticsearch/blob/6.8/rest-api-spec/src/main/resources/rest-api-spec/api/cluster.put_settings.json
-public class ClusterSettingsRequest extends BaseRequest{
+public class ClusterSettingsRequest extends BaseRequest {
- private static final boolean DEFAULT_ALLOW_AUTOCREATEINDEX = true;
- private final JSONObject persistent;
- private final JSONObject data;
-
- public ClusterSettingsRequest() {
- this(DEFAULT_ALLOW_AUTOCREATEINDEX);
- }
- public ClusterSettingsRequest(boolean autoCreateIndex) {
- super("PUT","/_cluster/settings");
- this.data = new JSONObject();
- this.persistent = new JSONObject();
- this.data.put("persistent",this.persistent);
- this.allowAutoCreateIndex(autoCreateIndex);
- }
+ private static final boolean DEFAULT_ALLOW_AUTOCREATEINDEX = true;
+ private final JSONObject persistent;
+ private final JSONObject data;
- public ClusterSettingsRequest allowAutoCreateIndex(boolean allow) {
- this.persistent.put("action.auto_create_index", String.valueOf(allow));
- this.setQuery(this.data);
- return this;
- }
+ public ClusterSettingsRequest() {
+ this(DEFAULT_ALLOW_AUTOCREATEINDEX);
+ }
+
+ public ClusterSettingsRequest(boolean autoCreateIndex) {
+ super("PUT", "/_cluster/settings");
+ this.data = new JSONObject();
+ this.persistent = new JSONObject();
+ this.data.put("persistent", this.persistent);
+ this.allowAutoCreateIndex(autoCreateIndex);
+ }
+
+ public ClusterSettingsRequest allowAutoCreateIndex(boolean allow) {
+ this.persistent.put("action.auto_create_index", String.valueOf(allow));
+ this.setQuery(this.data);
+ return this;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CountRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CountRequest.java
index 65c38471d..053be8cbc 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CountRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CountRequest.java
@@ -21,12 +21,12 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class CountRequest extends BaseRequest{
+public class CountRequest extends BaseRequest {
+
+
+ public CountRequest(String alias, String dataType) {
+ super("GET", String.format("/%s/%s/_count", alias, dataType));
+ }
-
- public CountRequest(String alias,String dataType) {
- super("GET",String.format("/%s/%s/_count",alias,dataType));
- }
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java
index 1e46cc4de..f558fe45c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateAliasRequest.java
@@ -22,12 +22,12 @@
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_alias.json
-public class CreateAliasRequest extends BaseRequest{
+public class CreateAliasRequest extends BaseRequest {
- public CreateAliasRequest(String index,String alias) {
- super("PUT", String.format("/%s/_alias/%s",index,alias));
- }
+ public CreateAliasRequest(String index, String alias) {
+ super("PUT", String.format("/%s/_alias/%s", index, alias));
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
index 6f060196e..076032b29 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/CreateIndexRequest.java
@@ -25,30 +25,31 @@ import org.json.JSONObject;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.create.json
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.put_mapping.json
-public class CreateIndexRequest extends BaseRequest{
+public class CreateIndexRequest extends BaseRequest {
private JSONObject settings;
private JSONObject mappings;
public CreateIndexRequest(String index) {
- super("PUT","/"+index);
- this.mappings=new JSONObject();
+ super("PUT", "/" + index);
+ this.mappings = new JSONObject();
}
private void setRequest() {
- JSONObject o=new JSONObject();
- if(this.mappings!=null) {
+ JSONObject o = new JSONObject();
+ if (this.mappings != null) {
o.put("mappings", this.mappings);
}
- if(this.settings!=null) {
+ if (this.settings != null) {
o.put("settings", this.settings);
}
super.setQuery(o);
}
+
@SuppressWarnings("hiding")
public CreateIndexRequest mappings(JSONObject mappings) {
- this.mappings=mappings;
+ this.mappings = mappings;
this.setRequest();
return this;
}
@@ -59,11 +60,11 @@ public class CreateIndexRequest extends BaseRequest{
}
public boolean hasMappings() {
- return this.mappings!=null;
+ return this.mappings != null;
}
public boolean hasSettings() {
- return this.settings!=null;
+ return this.settings != null;
}
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java
index 92b481013..34da3a954 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteAliasRequest.java
@@ -22,10 +22,10 @@
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete_alias.json
-public class DeleteAliasRequest extends BaseRequest{
+public class DeleteAliasRequest extends BaseRequest {
- public DeleteAliasRequest(String index,String alias) {
- super("DELETE","/"+index+"/_alias/"+alias);
- }
+ public DeleteAliasRequest(String index, String alias) {
+ super("DELETE", "/" + index + "/_alias/" + alias);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
index 15c876e48..db884f643 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteByQueryRequest.java
@@ -23,22 +23,21 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
-public class DeleteByQueryRequest extends BaseRequest {
+public class DeleteByQueryRequest extends BaseRequest {
- public DeleteByQueryRequest(String alias) {
- this(alias, false);
- }
+ public DeleteByQueryRequest(String alias) {
+ this(alias, false);
+ }
- public DeleteByQueryRequest(String alias, boolean refresh) {
- super("POST",String.format("/%s/_delete_by_query",alias), refresh);
- }
+ public DeleteByQueryRequest(String alias, boolean refresh) {
+ super("POST", String.format("/%s/_delete_by_query", alias), refresh);
+ }
- public DeleteByQueryRequest source(QueryBuilder query) {
- this.setQuery(query);
- return this;
- }
+ public DeleteByQueryRequest source(QueryBuilder query) {
+ this.setQuery(query);
+ return this;
+ }
-
-
-} \ No newline at end of file
+
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteIndexRequest.java
index f94f238b5..fb3c82adc 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteIndexRequest.java
@@ -22,10 +22,10 @@
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.delete.json
-public class DeleteIndexRequest extends BaseRequest{
+public class DeleteIndexRequest extends BaseRequest {
- public DeleteIndexRequest(String index) {
- super("DELETE","/"+index);
- }
+ public DeleteIndexRequest(String index) {
+ super("DELETE", "/" + index);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
index 63202b169..a1a714765 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/DeleteRequest.java
@@ -23,22 +23,25 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
public class DeleteRequest extends BaseRequest {
- private final String alias;
- private final String esId;
- public DeleteRequest(String alias,String dataType,String esId) {
- this(alias, dataType, esId, false);
- }
- public DeleteRequest(String alias,String dataType,String esId, boolean refresh) {
- super("DELETE",String.format("/%s/%s/%s",alias,dataType,BaseRequest.urlEncodeValue(esId)), refresh);
- this.alias = alias;
- this.esId = esId;
- }
- protected String getAlias() {
- return this.alias;
- }
+ private final String alias;
+ private final String esId;
- protected String getEsId() {
- return this.esId;
- }
+ public DeleteRequest(String alias, String dataType, String esId) {
+ this(alias, dataType, esId, false);
+ }
+
+ public DeleteRequest(String alias, String dataType, String esId, boolean refresh) {
+ super("DELETE", String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId)), refresh);
+ this.alias = alias;
+ this.esId = esId;
+ }
+
+ protected String getAlias() {
+ return this.alias;
+ }
+
+ protected String getEsId() {
+ return this.esId;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetIndexRequest.java
index bdcc4a9bf..59a06a5d2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetIndexRequest.java
@@ -24,10 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists.json
public class GetIndexRequest extends BaseRequest {
- public GetIndexRequest(String index) {
- super("HEAD","/"+index);
- }
+ public GetIndexRequest(String index) {
+ super("HEAD", "/" + index);
+ }
+
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java
index 2fa7a1699..fa27d2b52 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetInfoRequest.java
@@ -24,10 +24,10 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
//https://github.com/elastic/elasticsearch/blob/6.4/rest-api-spec/src/main/resources/rest-api-spec/api/indices.exists.json
public class GetInfoRequest extends BaseRequest {
- public GetInfoRequest() {
- super("GET","/");
- }
+ public GetInfoRequest() {
+ super("GET", "/");
+ }
+
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetRequest.java
index a589b207b..6092d88b0 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/GetRequest.java
@@ -23,11 +23,11 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
import javax.annotation.Nonnull;
-public class GetRequest extends BaseRequest{
+public class GetRequest extends BaseRequest {
- public GetRequest(String alias,String dataType,@Nonnull String esId) {
- super("GET",String.format("/%s/%s/%s",alias,dataType,BaseRequest.urlEncodeValue(esId)));
- }
+ public GetRequest(String alias, String dataType, @Nonnull String esId) {
+ super("GET", String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId)));
+ }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
index a3ee578a9..81e218ec9 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/IndexRequest.java
@@ -25,37 +25,37 @@ import javax.annotation.Nullable;
public class IndexRequest extends BaseRequest {
- private final String alias;
- private final String esId;
-
- public IndexRequest(String alias, String dataType) {
- this(alias, dataType, null);
- }
-
- public IndexRequest(String alias, String dataType, @Nullable String esId) {
- super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
- : String.format("/%s/%s", alias, dataType));
- this.alias = alias;
- this.esId = esId;
- }
-
- public IndexRequest(String alias, String dataType, @Nullable String esId, boolean refresh) {
- super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
- : String.format("/%s/%s", alias, dataType),refresh);
- this.alias = alias;
- this.esId = esId;
- }
-
- public void source(String content) {
- super.setQuery(content);
- }
-
- protected String getAlias() {
- return this.alias;
- }
-
- protected String getEsId() {
- return this.esId;
- }
+ private final String alias;
+ private final String esId;
+
+ public IndexRequest(String alias, String dataType) {
+ this(alias, dataType, null);
+ }
+
+ public IndexRequest(String alias, String dataType, @Nullable String esId) {
+ super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
+ : String.format("/%s/%s", alias, dataType));
+ this.alias = alias;
+ this.esId = esId;
+ }
+
+ public IndexRequest(String alias, String dataType, @Nullable String esId, boolean refresh) {
+ super("POST", esId != null ? String.format("/%s/%s/%s", alias, dataType, BaseRequest.urlEncodeValue(esId))
+ : String.format("/%s/%s", alias, dataType), refresh);
+ this.alias = alias;
+ this.esId = esId;
+ }
+
+ public void source(String content) {
+ super.setQuery(content);
+ }
+
+ protected String getAlias() {
+ return this.alias;
+ }
+
+ protected String getEsId() {
+ return this.esId;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java
index 6ea945f78..d77910917 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListAliasesRequest.java
@@ -21,11 +21,11 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class ListAliasesRequest extends BaseRequest{
+public class ListAliasesRequest extends BaseRequest {
-
- public ListAliasesRequest() {
- super("GET","/_cat/aliases");
- }
+
+ public ListAliasesRequest() {
+ super("GET", "/_cat/aliases");
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java
index e65de56db..8a060fd43 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/ListIndicesRequest.java
@@ -21,11 +21,11 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class ListIndicesRequest extends BaseRequest{
+public class ListIndicesRequest extends BaseRequest {
-
- public ListIndicesRequest() {
- super("GET","/_cat/indices");
- }
+
+ public ListIndicesRequest() {
+ super("GET", "/_cat/indices");
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/NodeStatsRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/NodeStatsRequest.java
index dfb9b2cfc..022563a36 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/NodeStatsRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/NodeStatsRequest.java
@@ -21,10 +21,10 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class NodeStatsRequest extends BaseRequest{
+public class NodeStatsRequest extends BaseRequest {
-
- public NodeStatsRequest() {
- super("GET","/_nodes/stats");
- }
+
+ public NodeStatsRequest() {
+ super("GET", "/_nodes/stats");
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/RefreshIndexRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/RefreshIndexRequest.java
index 37760b697..327f81f50 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/RefreshIndexRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/RefreshIndexRequest.java
@@ -21,11 +21,11 @@
*/
package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
-public class RefreshIndexRequest extends BaseRequest{
+public class RefreshIndexRequest extends BaseRequest {
- public RefreshIndexRequest(String alias) {
- super("GET",String.format("/%s/_refresh",alias));
- }
+ public RefreshIndexRequest(String alias) {
+ super("GET", String.format("/%s/_refresh", alias));
+ }
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/SearchRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/SearchRequest.java
index bd6559371..113cb4e1e 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/SearchRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/SearchRequest.java
@@ -23,15 +23,15 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.requests;
import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilder;
-public class SearchRequest extends BaseRequest{
+public class SearchRequest extends BaseRequest {
- public SearchRequest(String alias,String dataType) {
- super("POST",String.format("/%s/%s/_search", alias,dataType));
- }
+ public SearchRequest(String alias, String dataType) {
+ super("POST", String.format("/%s/%s/_search", alias, dataType));
+ }
- @Override
- public void setQuery(QueryBuilder query){
- super.setQuery(query);
- }
+ @Override
+ public void setQuery(QueryBuilder query) {
+ super.setQuery(query);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
index 8bca04ff6..d351352af 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateByQueryRequest.java
@@ -28,89 +28,89 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.queries.QueryBuilders;
public class UpdateByQueryRequest extends BaseRequest {
- private JSONObject params;
- private final String alias;
-
- public UpdateByQueryRequest(String alias, String dataType) {
- this(alias, dataType, false);
- }
+ private JSONObject params;
+ private final String alias;
- public UpdateByQueryRequest(String alias, String dataType, boolean refresh) {
- super("POST", String.format("/%s/%s/_update_by_query", alias, dataType), refresh);
- this.alias = alias;
- this.params = null;
- }
+ public UpdateByQueryRequest(String alias, String dataType) {
+ this(alias, dataType, false);
+ }
- public void source(String esId, JSONObject map) {
- this.source(map, QueryBuilders.matchQuery("_id", esId));
- }
+ public UpdateByQueryRequest(String alias, String dataType, boolean refresh) {
+ super("POST", String.format("/%s/%s/_update_by_query", alias, dataType), refresh);
+ this.alias = alias;
+ this.params = null;
+ }
- public void source(JSONObject map, QueryBuilder query) {
- JSONObject outer = new JSONObject();
- outer.put("query", query.getInner());
- JSONObject script = new JSONObject();
- script.put("lang", "painless");
- script.put("inline", this.createInline(map));
- if(this.params!=null) {
- script.put("params",this.params);
- }
- outer.put("script", script);
- super.setQuery(outer.toString());
- }
+ public void source(String esId, JSONObject map) {
+ this.source(map, QueryBuilders.matchQuery("_id", esId));
+ }
- private String createInline(JSONObject map) {
- String s = "", k, pkey;
- int i = 1;
- Object value;
- for (Object key : map.keySet()) {
- k = String.valueOf(key);
- value = map.get(k);
- if (value instanceof JSONObject || value instanceof JSONArray) {
- pkey = String.format("p%d", i++);
- if (value instanceof JSONObject) {
- this.withParam(pkey, (JSONObject) value);
- } else {
- this.withParam(pkey, (JSONArray) value);
- }
+ public void source(JSONObject map, QueryBuilder query) {
+ JSONObject outer = new JSONObject();
+ outer.put("query", query.getInner());
+ JSONObject script = new JSONObject();
+ script.put("lang", "painless");
+ script.put("inline", this.createInline(map));
+ if (this.params != null) {
+ script.put("params", this.params);
+ }
+ outer.put("script", script);
+ super.setQuery(outer.toString());
+ }
- s += String.format("ctx._source['%s']=%s;", key, "params." + pkey);
- } else {
- s += String.format("ctx._source['%s']=%s;", key, escpaped(value));
- }
- }
- return s;
- }
+ private String createInline(JSONObject map) {
+ String s = "", k, pkey;
+ int i = 1;
+ Object value;
+ for (Object key : map.keySet()) {
+ k = String.valueOf(key);
+ value = map.get(k);
+ if (value instanceof JSONObject || value instanceof JSONArray) {
+ pkey = String.format("p%d", i++);
+ if (value instanceof JSONObject) {
+ this.withParam(pkey, (JSONObject) value);
+ } else {
+ this.withParam(pkey, (JSONArray) value);
+ }
- private UpdateByQueryRequest withParam(String key, JSONArray p) {
- if (this.params == null) {
- this.params = new JSONObject();
- }
- this.params.put(key, p);
- return this;
- }
+ s += String.format("ctx._source['%s']=%s;", key, "params." + pkey);
+ } else {
+ s += String.format("ctx._source['%s']=%s;", key, escpaped(value));
+ }
+ }
+ return s;
+ }
- private UpdateByQueryRequest withParam(String key, JSONObject p) {
- if (this.params == null) {
- this.params = new JSONObject();
- }
- this.params.put(key, p);
- return this;
- }
+ private UpdateByQueryRequest withParam(String key, JSONArray p) {
+ if (this.params == null) {
+ this.params = new JSONObject();
+ }
+ this.params.put(key, p);
+ return this;
+ }
- private String escpaped(Object value) {
- String s = "";
- if (value instanceof Boolean || value instanceof Integer || value instanceof Long || value instanceof Float
- || value instanceof Double) {
- s = String.valueOf(value);
- } else {
- s = "\"" + String.valueOf(value) + "\"";
- }
- return s;
+ private UpdateByQueryRequest withParam(String key, JSONObject p) {
+ if (this.params == null) {
+ this.params = new JSONObject();
+ }
+ this.params.put(key, p);
+ return this;
+ }
- }
+ private String escpaped(Object value) {
+ String s = "";
+ if (value instanceof Boolean || value instanceof Integer || value instanceof Long || value instanceof Float
+ || value instanceof Double) {
+ s = String.valueOf(value);
+ } else {
+ s = "\"" + String.valueOf(value) + "\"";
+ }
+ return s;
- protected String getAlias() {
- return this.alias;
- }
+ }
+
+ protected String getAlias() {
+ return this.alias;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
index 16923b238..eca3b4b1d 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/requests/UpdateRequest.java
@@ -31,123 +31,125 @@ import org.slf4j.LoggerFactory;
public class UpdateRequest extends BaseRequest {
- private static final Logger LOG = LoggerFactory.getLogger(UpdateRequest.class);
- private JSONObject params;
- private String alias;
- private String esId;
- private int retries;
-
- public UpdateRequest(String alias, String dataType, String esId) {
- this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES);
- }
- public UpdateRequest(String alias, String dataType, String esId, boolean refresh) {
- this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES, refresh);
- }
- public UpdateRequest(String alias, String dataType, String esId, int retries) {
- this(alias, dataType, esId, retries, false);
- }
-
- public UpdateRequest(String alias, String dataType, String esId, int retries, boolean refresh) {
- this(String.format("/%s/%s/%s/_update", alias, dataType, BaseRequest.urlEncodeValue(esId)), refresh);
- this.alias = alias;
- this.esId = esId;
- this.retries = retries;
- }
-
- public UpdateRequest(String uri, boolean refresh) {
- super("POST", uri, refresh, BaseRequest.DEFAULT_RETRIES);
- this.params = null;
- this.retries = 1;
-
- }
-
-
-
- private UpdateRequest withParam(String key, JSONObject p) {
- if (this.params == null) {
- this.params = new JSONObject();
- }
- this.params.put(key, p);
- return this;
- }
-
- private UpdateRequest withParam(String key, JSONArray p) {
- if (this.params == null) {
- this.params = new JSONObject();
- }
- this.params.put(key, p);
- return this;
- }
-
- public void source(JSONObject map) {
- this.source(map, null);
- }
-
- public void source(JSONObject map, List<String> onlyForInsert) {
- JSONObject outer = new JSONObject();
- JSONObject script = new JSONObject();
- script.put("lang", "painless");
- script.put("source", this.createInline(map, onlyForInsert));
- if (this.params != null) {
- script.put("params", this.params);
- }
- outer.put("script", script);
- outer.put("upsert", map);
- LOG.debug("update payload: " + outer.toString());
- super.setQuery(outer.toString());
- }
-
- private String createInline(JSONObject map, List<String> onlyForInsert) {
- if (onlyForInsert == null) {
- onlyForInsert = new ArrayList<String>();
- }
- String s = "", k = "";
- Object value;
- String pkey;
- int i = 0;
- for (Object key : map.keySet()) {
- k = String.valueOf(key);
- if (onlyForInsert.contains(k)) {
- continue;
- }
- value = map.get(k);
- if (value instanceof JSONObject || value instanceof JSONArray) {
- pkey = String.format("p%d", i++);
- if (value instanceof JSONObject) {
- this.withParam(pkey, (JSONObject) value);
- } else {
- this.withParam(pkey, (JSONArray) value);
- }
-
- s += String.format("ctx._source['%s']=%s;", key, "params." + pkey);
- } else {
- s += String.format("ctx._source['%s']=%s;", key, escpaped(value));
- }
- }
- return s;
- }
-
- private String escpaped(Object value) {
- String s = "";
- if (value instanceof Boolean || value instanceof Integer || value instanceof Long || value instanceof Float
- || value instanceof Double) {
- s = String.valueOf(value);
- } else {
- s = "\"" + String.valueOf(value) + "\"";
- }
- return s;
-
- }
-
- protected String getAlias() {
- return this.alias;
- }
-
- protected String getEsId() {
- return this.esId;
- }
-
- protected int getRetries() {
- return this.retries;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(UpdateRequest.class);
+ private JSONObject params;
+ private String alias;
+ private String esId;
+ private int retries;
+
+ public UpdateRequest(String alias, String dataType, String esId) {
+ this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES);
+ }
+
+ public UpdateRequest(String alias, String dataType, String esId, boolean refresh) {
+ this(alias, dataType, esId, BaseRequest.DEFAULT_RETRIES, refresh);
+ }
+
+ public UpdateRequest(String alias, String dataType, String esId, int retries) {
+ this(alias, dataType, esId, retries, false);
+ }
+
+ public UpdateRequest(String alias, String dataType, String esId, int retries, boolean refresh) {
+ this(String.format("/%s/%s/%s/_update", alias, dataType, BaseRequest.urlEncodeValue(esId)), refresh);
+ this.alias = alias;
+ this.esId = esId;
+ this.retries = retries;
+ }
+
+ public UpdateRequest(String uri, boolean refresh) {
+ super("POST", uri, refresh, BaseRequest.DEFAULT_RETRIES);
+ this.params = null;
+ this.retries = 1;
+
+ }
+
+
+
+ private UpdateRequest withParam(String key, JSONObject p) {
+ if (this.params == null) {
+ this.params = new JSONObject();
+ }
+ this.params.put(key, p);
+ return this;
+ }
+
+ private UpdateRequest withParam(String key, JSONArray p) {
+ if (this.params == null) {
+ this.params = new JSONObject();
+ }
+ this.params.put(key, p);
+ return this;
+ }
+
+ public void source(JSONObject map) {
+ this.source(map, null);
+ }
+
+ public void source(JSONObject map, List<String> onlyForInsert) {
+ JSONObject outer = new JSONObject();
+ JSONObject script = new JSONObject();
+ script.put("lang", "painless");
+ script.put("source", this.createInline(map, onlyForInsert));
+ if (this.params != null) {
+ script.put("params", this.params);
+ }
+ outer.put("script", script);
+ outer.put("upsert", map);
+ LOG.debug("update payload: " + outer.toString());
+ super.setQuery(outer.toString());
+ }
+
+ private String createInline(JSONObject map, List<String> onlyForInsert) {
+ if (onlyForInsert == null) {
+ onlyForInsert = new ArrayList<String>();
+ }
+ String s = "", k = "";
+ Object value;
+ String pkey;
+ int i = 0;
+ for (Object key : map.keySet()) {
+ k = String.valueOf(key);
+ if (onlyForInsert.contains(k)) {
+ continue;
+ }
+ value = map.get(k);
+ if (value instanceof JSONObject || value instanceof JSONArray) {
+ pkey = String.format("p%d", i++);
+ if (value instanceof JSONObject) {
+ this.withParam(pkey, (JSONObject) value);
+ } else {
+ this.withParam(pkey, (JSONArray) value);
+ }
+
+ s += String.format("ctx._source['%s']=%s;", key, "params." + pkey);
+ } else {
+ s += String.format("ctx._source['%s']=%s;", key, escpaped(value));
+ }
+ }
+ return s;
+ }
+
+ private String escpaped(Object value) {
+ String s = "";
+ if (value instanceof Boolean || value instanceof Integer || value instanceof Long || value instanceof Float
+ || value instanceof Double) {
+ s = String.valueOf(value);
+ } else {
+ s = "\"" + String.valueOf(value) + "\"";
+ }
+ return s;
+
+ }
+
+ protected String getAlias() {
+ return this.alias;
+ }
+
+ protected String getEsId() {
+ return this.esId;
+ }
+
+ protected int getRetries() {
+ return this.retries;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AcknowledgedResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AcknowledgedResponse.java
index c022c4e6f..1d178a103 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AcknowledgedResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AcknowledgedResponse.java
@@ -24,19 +24,19 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
import org.elasticsearch.client.Response;
import org.json.JSONObject;
-public class AcknowledgedResponse extends BaseResponse{
+public class AcknowledgedResponse extends BaseResponse {
- private boolean isAcknowledged;
+ private boolean isAcknowledged;
- public AcknowledgedResponse(Response response) {
- super(response);
- JSONObject o = this.getJson(response);
- if(o!=null) {
- this.isAcknowledged=o.getBoolean("acknowledged");
- }
- }
+ public AcknowledgedResponse(Response response) {
+ super(response);
+ JSONObject o = this.getJson(response);
+ if (o != null) {
+ this.isAcknowledged = o.getBoolean("acknowledged");
+ }
+ }
- public boolean isAcknowledged() {
- return this.isAcknowledged;
- }
+ public boolean isAcknowledged() {
+ return this.isAcknowledged;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AggregationEntries.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AggregationEntries.java
index 4a0564cd9..752c15e37 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AggregationEntries.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/AggregationEntries.java
@@ -25,24 +25,25 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
-public class AggregationEntries extends LinkedHashMap<String,Long>{
+public class AggregationEntries extends LinkedHashMap<String, Long> {
- private static final long serialVersionUID = 1L;
+ private static final long serialVersionUID = 1L;
- /**
- * Return page with keys
- * @param size elements
- * @param offset start position in list.
- * @return List<String> with selected values
- */
- public String[] getKeysAsPagedStringList(long size, long offset) {
- List<String> ltps = new ArrayList<String>();
- String[] keys = keySet().toArray(new String[0]);
- for (long i = offset; i < keys.length && i < offset + size; i++) {
- ltps.add(keys[(int) i]);
- }
- return ltps.toArray(new String[0]);
- }
+ /**
+ * Return page with keys
+ *
+ * @param size elements
+ * @param offset start position in list.
+ * @return List<String> with selected values
+ */
+ public String[] getKeysAsPagedStringList(long size, long offset) {
+ List<String> ltps = new ArrayList<String>();
+ String[] keys = keySet().toArray(new String[0]);
+ for (long i = offset; i < keys.length && i < offset + size; i++) {
+ ltps.add(keys[(int) i]);
+ }
+ return ltps.toArray(new String[0]);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
index a3a1b16e1..2746be4a4 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/BaseResponse.java
@@ -32,66 +32,67 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class BaseResponse {
- private static final Logger LOG = LoggerFactory.getLogger(BaseResponse.class);
+ private static final Logger LOG = LoggerFactory.getLogger(BaseResponse.class);
- private final int responseCode;
+ private final int responseCode;
- BaseResponse(Response response) {
- this.responseCode = response != null ? response.getStatusLine().getStatusCode() : 0;
- }
+ BaseResponse(Response response) {
+ this.responseCode = response != null ? response.getStatusLine().getStatusCode() : 0;
+ }
- int getResponseCode() {
- return this.responseCode;
- }
+ int getResponseCode() {
+ return this.responseCode;
+ }
- public boolean isResponseSucceeded() {
- return this.responseCode < 300;
- }
+ public boolean isResponseSucceeded() {
+ return this.responseCode < 300;
+ }
- JSONObject getJson(Response response) {
- if(response==null) {
- LOG.warn("unable to parse response. response is null.");
- return null;
- }
- try {
- String sresponse = EntityUtils.toString(response.getEntity());
- LOG.debug("parsing response={}", sresponse);
- return new JSONObject(sresponse);
- } catch (UnsupportedOperationException | IOException e) {
- LOG.warn("error parsing es response: {}", e.getMessage());
- return null;
- }
+ JSONObject getJson(Response response) {
+ if (response == null) {
+ LOG.warn("unable to parse response. response is null.");
+ return null;
+ }
+ try {
+ String sresponse = EntityUtils.toString(response.getEntity());
+ LOG.debug("parsing response={}", sresponse);
+ return new JSONObject(sresponse);
+ } catch (UnsupportedOperationException | IOException e) {
+ LOG.warn("error parsing es response: {}", e.getMessage());
+ return null;
+ }
- }
+ }
- JSONObject getJson(String json) {
- return new JSONObject(json);
- }
+ JSONObject getJson(String json) {
+ return new JSONObject(json);
+ }
- /**
- * @param response
- * @return
- */
- List<String> getLines(Response response){
- return this.getLines(response,true);
- }
- List<String> getLines(Response response,boolean ignoreEmpty) {
- try {
- String sresponse = EntityUtils.toString(response.getEntity());
- LOG.debug("parsing response={}", sresponse);
- String[] hlp = sresponse.split("\n");
- List<String> lines=new ArrayList<String>();
- for(String h:hlp) {
- if(ignoreEmpty && h.trim().length()==0) {
- continue;
- }
- lines.add(h);
- }
- return lines;
- } catch (UnsupportedOperationException | IOException e) {
- LOG.warn("error parsing es response: {}", e.getMessage());
- return null;
- }
+ /**
+ * @param response
+ * @return
+ */
+ List<String> getLines(Response response) {
+ return this.getLines(response, true);
+ }
- }
+ List<String> getLines(Response response, boolean ignoreEmpty) {
+ try {
+ String sresponse = EntityUtils.toString(response.getEntity());
+ LOG.debug("parsing response={}", sresponse);
+ String[] hlp = sresponse.split("\n");
+ List<String> lines = new ArrayList<String>();
+ for (String h : hlp) {
+ if (ignoreEmpty && h.trim().length() == 0) {
+ continue;
+ }
+ lines.add(h);
+ }
+ return lines;
+ } catch (UnsupportedOperationException | IOException e) {
+ LOG.warn("error parsing es response: {}", e.getMessage());
+ return null;
+ }
+
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
index cb365d2b3..27abbea8a 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterHealthResponse.java
@@ -56,6 +56,7 @@ public class ClusterHealthResponse extends BaseResponse {
public boolean isTimedOut() {
return this.timedOut;
}
+
@SuppressWarnings("hiding")
public boolean isStatusMinimal(String status) {
if (status == null) {
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterSettingsResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterSettingsResponse.java
index 49d9f864a..ee38bbf00 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterSettingsResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ClusterSettingsResponse.java
@@ -25,7 +25,7 @@ import org.elasticsearch.client.Response;
public class ClusterSettingsResponse extends AcknowledgedResponse {
- public ClusterSettingsResponse(Response response) {
+ public ClusterSettingsResponse(Response response) {
super(response);
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java
index 1e792063e..2194e84b8 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateAliasResponse.java
@@ -25,8 +25,8 @@ import org.elasticsearch.client.Response;
public class CreateAliasResponse extends AcknowledgedResponse {
- public CreateAliasResponse(Response response) {
- super(response);
- }
+ public CreateAliasResponse(Response response) {
+ super(response);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateIndexResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateIndexResponse.java
index 13ac8d5bf..af77d5526 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateIndexResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/CreateIndexResponse.java
@@ -25,8 +25,8 @@ import org.elasticsearch.client.Response;
public class CreateIndexResponse extends AcknowledgedResponse {
- public CreateIndexResponse(Response response) {
- super(response);
- }
+ public CreateIndexResponse(Response response) {
+ super(response);
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java
index 53756af02..584cb9d9b 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteAliasResponse.java
@@ -25,8 +25,8 @@ import org.elasticsearch.client.Response;
public class DeleteAliasResponse extends AcknowledgedResponse {
- public DeleteAliasResponse(Response response) {
- super(response);
- }
+ public DeleteAliasResponse(Response response) {
+ super(response);
+ }
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteByQueryResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteByQueryResponse.java
index 7c0b1352a..94c86dd58 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteByQueryResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteByQueryResponse.java
@@ -26,29 +26,29 @@ import org.json.JSONObject;
/**
* {"took":1,"batches":0,"retries":{"search":0,"bulk":0},"throttled_millis":0,"total":0,"deleted":0,"noops":0,"requests_per_second":-1,"failures":[],"version_conflicts":0,"throttled_until_millis":0,"timed_out":false}
+ *
* @author jack
*
*/
public class DeleteByQueryResponse extends BaseResponse {
- private int deleted;
+ private int deleted;
- public DeleteByQueryResponse(Response response) {
- super(response);
- try {
- JSONObject o = this.getJson(response);
- if (o != null) {
- this.deleted = o.getInt("deleted");
- }
- }
- catch(Exception e) {
- this.deleted=0;
- }
+ public DeleteByQueryResponse(Response response) {
+ super(response);
+ try {
+ JSONObject o = this.getJson(response);
+ if (o != null) {
+ this.deleted = o.getInt("deleted");
+ }
+ } catch (Exception e) {
+ this.deleted = 0;
+ }
- }
+ }
- public int getDeleted() {
- return this.deleted;
- }
+ public int getDeleted() {
+ return this.deleted;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteIndexResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteIndexResponse.java
index a0e589033..94fcbc5fa 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteIndexResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteIndexResponse.java
@@ -25,8 +25,8 @@ import org.elasticsearch.client.Response;
public class DeleteIndexResponse extends AcknowledgedResponse {
- public DeleteIndexResponse(Response response) {
- super(response);
- }
+ public DeleteIndexResponse(Response response) {
+ super(response);
+ }
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
index d4dee0441..f6202d009 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/DeleteResponse.java
@@ -26,28 +26,26 @@ import org.json.JSONObject;
public class DeleteResponse extends BaseResponse {
- private boolean isDeleted;
-
- public DeleteResponse(Response response) {
- super(response);
- if (this.isResponseSucceeded()) {
-
- JSONObject o = this.getJson(response);
- if (o != null) {
- this.isDeleted = "deleted".equals(o.getString("result"));
- }
- else {
- this.isDeleted=false;
- }
- }
- else {
- this.isDeleted=false;
- }
-
- }
-
- public boolean isDeleted() {
- return this.isDeleted;
- }
+ private boolean isDeleted;
+
+ public DeleteResponse(Response response) {
+ super(response);
+ if (this.isResponseSucceeded()) {
+
+ JSONObject o = this.getJson(response);
+ if (o != null) {
+ this.isDeleted = "deleted".equals(o.getString("result"));
+ } else {
+ this.isDeleted = false;
+ }
+ } else {
+ this.isDeleted = false;
+ }
+
+ }
+
+ public boolean isDeleted() {
+ return this.isDeleted;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java
index 1bc43a6d0..946a8fb4a 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetInfoResponse.java
@@ -28,49 +28,40 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
public class GetInfoResponse extends BaseResponse {
/**
- * {
- * "name" : "kpOdXt-",
- * "cluster_name" : "docker-cluster",
- * "cluster_uuid" : "qags6CGGTrS75iBhrAdsgg",
- * "version" : {
- * "number" : "6.4.3",
- * "build_flavor" : "default",
- * "build_type" : "tar",
- * "build_hash" : "fe40335",
- * "build_date" : "2018-10-30T23:17:19.084789Z",
- * "build_snapshot" : false,
- * "lucene_version" : "7.4.0",
- * "minimum_wire_compatibility_version" : "5.6.0",
- * "minimum_index_compatibility_version" : "5.0.0"
- * },
- * "tagline" : "You Know, for Search"
- *}
+ * { "name" : "kpOdXt-", "cluster_name" : "docker-cluster", "cluster_uuid" : "qags6CGGTrS75iBhrAdsgg", "version" : {
+ * "number" : "6.4.3", "build_flavor" : "default", "build_type" : "tar", "build_hash" : "fe40335", "build_date" :
+ * "2018-10-30T23:17:19.084789Z", "build_snapshot" : false, "lucene_version" : "7.4.0",
+ * "minimum_wire_compatibility_version" : "5.6.0", "minimum_index_compatibility_version" : "5.0.0" }, "tagline" :
+ * "You Know, for Search" }
*/
- private final String clusterName;
- private final String name;
-
- private final EsVersion version;
- public GetInfoResponse(Response response) throws Exception {
+ private final String clusterName;
+ private final String name;
+
+ private final EsVersion version;
+
+ public GetInfoResponse(Response response) throws Exception {
super(response);
JSONObject o = this.getJson(response);
- if(o==null) {
- throw new Exception("unable to read response");
+ if (o == null) {
+ throw new Exception("unable to read response");
}
this.name = o.getString("name");
this.clusterName = o.getString("cluster_name");
this.version = new EsVersion(o.getJSONObject("version").getString("number"));
}
- public String getClusterName() {
- return clusterName;
- }
- public String getName() {
- return name;
- }
- public EsVersion getVersion() {
- return version;
- }
-
-
-
+ public String getClusterName() {
+ return clusterName;
+ }
+
+ public String getName() {
+ return name;
+ }
+
+ public EsVersion getVersion() {
+ return version;
+ }
+
+
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetResponse.java
index 0c9b511e4..47ab7e859 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/GetResponse.java
@@ -27,28 +27,28 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
public class GetResponse extends BaseResponse {
- private boolean found;
- private SearchHit result;
-
- public GetResponse(Response response) {
- super(response);
- if (this.isResponseSucceeded()) {
- JSONObject o = this.getJson(response);
- this.found = o.getBoolean("found");
- this.result = new SearchHit(o);
- } else {
- this.found = false;
- this.result = null;
- }
-
- }
-
- public boolean isExists() {
- return this.found;
- }
-
- public String getSourceAsBytesRef() {
- return this.result.getSourceAsString();
- }
+ private boolean found;
+ private SearchHit result;
+
+ public GetResponse(Response response) {
+ super(response);
+ if (this.isResponseSucceeded()) {
+ JSONObject o = this.getJson(response);
+ this.found = o.getBoolean("found");
+ this.result = new SearchHit(o);
+ } else {
+ this.found = false;
+ this.result = null;
+ }
+
+ }
+
+ public boolean isExists() {
+ return this.found;
+ }
+
+ public String getSourceAsBytesRef() {
+ return this.result.getSourceAsString();
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/IndexResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/IndexResponse.java
index fc2faf99d..9978cfde3 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/IndexResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/IndexResponse.java
@@ -24,30 +24,31 @@ package org.onap.ccsdk.features.sdnr.wt.common.database.responses;
import org.elasticsearch.client.Response;
import org.json.JSONObject;
-public class IndexResponse extends BaseResponse{
-
- private boolean isCreated;
- private String id;
- private boolean isUpdated;
-
- public IndexResponse(Response response) {
- super(response);
- JSONObject o = this.getJson(response);
- this.id=o.getString("_id");
- this.isCreated="created".equals(o.getString("result"));
- this.isUpdated="updated".equals(o.getString("result"));
- //{"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
- }
-
- public String getId() {
- return this.id;
- }
-
- public boolean isCreated() {
- return this.isCreated;
- }
- public boolean isUpdated() {
- return this.isUpdated;
- }
+public class IndexResponse extends BaseResponse {
+
+ private boolean isCreated;
+ private String id;
+ private boolean isUpdated;
+
+ public IndexResponse(Response response) {
+ super(response);
+ JSONObject o = this.getJson(response);
+ this.id = o.getString("_id");
+ this.isCreated = "created".equals(o.getString("result"));
+ this.isUpdated = "updated".equals(o.getString("result"));
+ //{"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
+ }
+
+ public String getId() {
+ return this.id;
+ }
+
+ public boolean isCreated() {
+ return this.isCreated;
+ }
+
+ public boolean isUpdated() {
+ return this.isUpdated;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java
index b5b073f3b..7956b2bfc 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListAliasesResponse.java
@@ -43,25 +43,27 @@ public class ListAliasesResponse extends BaseResponse {
* faultcurrent faultcurrent-v1 - - -
* connectionlog connectionlog-v1 - - -
*/
- private final AliasesEntryList entries;
+ private final AliasesEntryList entries;
+
public ListAliasesResponse(Response response) throws ParseException {
super(response);
- List<String> lines=this.getLines(response);
+ List<String> lines = this.getLines(response);
this.entries = new AliasesEntryList();
- if(lines!=null) {
- for(String line:lines) {
- this.entries.add(new AliasesEntry(line));
- }
+ if (lines != null) {
+ for (String line : lines) {
+ this.entries.add(new AliasesEntry(line));
+ }
}
}
+
/**
*
* @return null if parsing failed otherwise valid (=>no entries may also be valid)
*/
- public AliasesEntryList getEntries(){
- return this.entries;
+ public AliasesEntryList getEntries() {
+ return this.entries;
}
-
-
+
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java
index 461ae7a33..f6e854abd 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/ListIndicesResponse.java
@@ -42,26 +42,27 @@ public class ListIndicesResponse extends BaseResponse {
* yellow open networkelement-connection-v1 YT3lj0AKRoOmtN30Zbdfqw 5 1 0 0 1.2kb 1.2kb
* yellow open connectionlog-v1 7yrVaaM1QjyO5eMsCUHNHQ 5 1 0 0 1.2kb 1.2kb
*/
- private final IndicesEntryList entries;
- public ListIndicesResponse(Response response) throws ParseException {
+ private final IndicesEntryList entries;
+
+ public ListIndicesResponse(Response response) throws ParseException {
super(response);
- List<String> lines=this.getLines(response);
+ List<String> lines = this.getLines(response);
this.entries = new IndicesEntryList();
- if(lines!=null) {
- for(String line:lines) {
- this.entries.add(new IndicesEntry(line));
- }
+ if (lines != null) {
+ for (String line : lines) {
+ this.entries.add(new IndicesEntry(line));
+ }
}
-
+
}
- /**
- * @return
- */
- public IndicesEntryList getEntries() {
- return this.entries;
- }
-
-
-
+ /**
+ * @return
+ */
+ public IndicesEntryList getEntries() {
+ return this.entries;
+ }
+
+
+
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/NodeStatsResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/NodeStatsResponse.java
index 1d308d127..ba5a83784 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/NodeStatsResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/NodeStatsResponse.java
@@ -31,83 +31,86 @@ import org.json.JSONObject;
public class NodeStatsResponse extends BaseResponse {
- private NodesInfo nodesInfo;
- private Map<String,NodeStats> nodeStats;
-
- public NodesInfo getNodesInfo() {
- return this.nodesInfo;
- }
- public Map<String,NodeStats> getNodeStatistics(){
- return this.nodeStats;
- }
- public NodeStatsResponse(Response response) throws UnsupportedOperationException, IOException, JSONException {
- super(response);
-
- JSONObject o = this.getJson(response);
- String k;
- if (o != null) {
- this.nodesInfo = new NodesInfo(o.getJSONObject("_nodes"));
- this.nodeStats = new HashMap<>();
- if(this.nodesInfo.successful>0) {
- JSONObject stats = o.getJSONObject("nodes");
- for (Object key : stats.keySet()) {
- k=String.valueOf(key);
- this.nodeStats.put(k, new NodeStats(k,stats.getJSONObject(k)));
- }
- }
- }
- }
-
-
-
- public static class NodesInfo{
- @Override
- public String toString() {
- return "NodesInfo [total=" + total + ", successful=" + successful + ", failed=" + failed + "]";
- }
-
- public final int total;
- public final int successful;
- public final int failed;
-
- public NodesInfo(JSONObject o) {
- this.total =o.getInt("total");
- this.successful = o.getInt("successful");
- this.failed = o.getInt("failed");
- }
- }
- public static class NodeStats{
- public final String name;
- public final NodeTotalDiskStats total;
-
- @Override
- public String toString() {
- return "NodeStats [name=" + name + ", total=" + total + "]";
- }
-
- public NodeStats(String name,JSONObject o) {
- this.name = name;
- this.total = new NodeTotalDiskStats(o.getJSONObject("fs").getJSONObject("total"));
- }
- }
- public static class NodeTotalDiskStats{
- public final long total;
- public final long available;
- public final long free;
-
- @Override
- public String toString() {
- return "NodeTotalDiskStats [total=" + total + ", available=" + available + ", free=" + free
- + ", getUseDiskPercentage()=" + getUseDiskPercentage() + "]";
- }
-
- public float getUseDiskPercentage() {
- return (total-available)*100.0f/(float)total;
- }
- public NodeTotalDiskStats(JSONObject o) {
- this.total = o.getLong("total_in_bytes");
- this.available = o.getLong("available_in_bytes");
- this.free = o.getLong("free_in_bytes");
- }
- }
+ private NodesInfo nodesInfo;
+ private Map<String, NodeStats> nodeStats;
+
+ public NodesInfo getNodesInfo() {
+ return this.nodesInfo;
+ }
+
+ public Map<String, NodeStats> getNodeStatistics() {
+ return this.nodeStats;
+ }
+
+ public NodeStatsResponse(Response response) throws UnsupportedOperationException, IOException, JSONException {
+ super(response);
+
+ JSONObject o = this.getJson(response);
+ String k;
+ if (o != null) {
+ this.nodesInfo = new NodesInfo(o.getJSONObject("_nodes"));
+ this.nodeStats = new HashMap<>();
+ if (this.nodesInfo.successful > 0) {
+ JSONObject stats = o.getJSONObject("nodes");
+ for (Object key : stats.keySet()) {
+ k = String.valueOf(key);
+ this.nodeStats.put(k, new NodeStats(k, stats.getJSONObject(k)));
+ }
+ }
+ }
+ }
+
+
+
+ public static class NodesInfo {
+ @Override
+ public String toString() {
+ return "NodesInfo [total=" + total + ", successful=" + successful + ", failed=" + failed + "]";
+ }
+
+ public final int total;
+ public final int successful;
+ public final int failed;
+
+ public NodesInfo(JSONObject o) {
+ this.total = o.getInt("total");
+ this.successful = o.getInt("successful");
+ this.failed = o.getInt("failed");
+ }
+ }
+ public static class NodeStats {
+ public final String name;
+ public final NodeTotalDiskStats total;
+
+ @Override
+ public String toString() {
+ return "NodeStats [name=" + name + ", total=" + total + "]";
+ }
+
+ public NodeStats(String name, JSONObject o) {
+ this.name = name;
+ this.total = new NodeTotalDiskStats(o.getJSONObject("fs").getJSONObject("total"));
+ }
+ }
+ public static class NodeTotalDiskStats {
+ public final long total;
+ public final long available;
+ public final long free;
+
+ @Override
+ public String toString() {
+ return "NodeTotalDiskStats [total=" + total + ", available=" + available + ", free=" + free
+ + ", getUseDiskPercentage()=" + getUseDiskPercentage() + "]";
+ }
+
+ public float getUseDiskPercentage() {
+ return (total - available) * 100.0f / (float) total;
+ }
+
+ public NodeTotalDiskStats(JSONObject o) {
+ this.total = o.getLong("total_in_bytes");
+ this.available = o.getLong("available_in_bytes");
+ this.free = o.getLong("free_in_bytes");
+ }
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/RefreshIndexResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/RefreshIndexResponse.java
index eb56c7171..f55ff1a66 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/RefreshIndexResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/RefreshIndexResponse.java
@@ -32,17 +32,17 @@ import org.json.JSONObject;
*/
public class RefreshIndexResponse extends BaseResponse {
- private boolean succeeded;
+ private boolean succeeded;
- public RefreshIndexResponse(Response response) {
- super(response);
- JSONObject o = this.getJson(response);
- this.succeeded = o.getJSONObject("_shards").getInt("failed") == 0;
- // {"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
- }
+ public RefreshIndexResponse(Response response) {
+ super(response);
+ JSONObject o = this.getJson(response);
+ this.succeeded = o.getJSONObject("_shards").getInt("failed") == 0;
+ // {"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
+ }
- public boolean succeeded() {
- return this.succeeded;
- }
+ public boolean succeeded() {
+ return this.succeeded;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/SearchResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/SearchResponse.java
index a5d2f1a36..6a7ed0d06 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/SearchResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/SearchResponse.java
@@ -28,58 +28,60 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
public class SearchResponse extends BaseResponse {
- private long total;
- private SearchHit[] searchHits;
- private JSONObject aggregations;
+ private long total;
+ private SearchHit[] searchHits;
+ private JSONObject aggregations;
- public SearchResponse(Response response) {
- super(response);
- this.handleResult(this.getJson(response));
- }
+ public SearchResponse(Response response) {
+ super(response);
+ this.handleResult(this.getJson(response));
+ }
- public SearchResponse(String json) {
- super(null);
- this.handleResult(this.getJson(json));
- }
+ public SearchResponse(String json) {
+ super(null);
+ this.handleResult(this.getJson(json));
+ }
- private void handleResult(JSONObject result) {
- if(result!=null && this.isResponseSucceeded()) {
- JSONObject hitsouter=result.getJSONObject("hits");
- this.total = hitsouter.getLong("total");
- JSONArray a=hitsouter.getJSONArray("hits");
- SearchHit[] hits=new SearchHit[a.length()];
- for(int i=0;i<a.length();i++) {
- hits[i]=new SearchHit(a.getJSONObject(i));
- }
- this.searchHits=hits;
- if(result.has("aggregations")) {
- this.aggregations = result.getJSONObject("aggregations");
- }
- else {
- this.aggregations=null;
- }
- }
- else {
- this.searchHits=new SearchHit[0];
- }
- }
- public SearchHit[] getHits() {
- return this.searchHits;
- }
- public long getTotal() {
- return this.total;
- }
- public boolean hasAggregations() {
- return this.aggregations!=null;
- }
- public AggregationEntries getAggregations(String property) {
- AggregationEntries entries=new AggregationEntries();
- if(this.aggregations!=null && this.aggregations.has(property)) {
- JSONArray a=this.aggregations.getJSONObject(property).getJSONArray("buckets");
- for(int i=0;i<a.length();i++) {
- entries.put(a.getJSONObject(i).getString("key"),a.getJSONObject(i).getLong("doc_count") );
- }
- }
- return entries;
- }
+ private void handleResult(JSONObject result) {
+ if (result != null && this.isResponseSucceeded()) {
+ JSONObject hitsouter = result.getJSONObject("hits");
+ this.total = hitsouter.getLong("total");
+ JSONArray a = hitsouter.getJSONArray("hits");
+ SearchHit[] hits = new SearchHit[a.length()];
+ for (int i = 0; i < a.length(); i++) {
+ hits[i] = new SearchHit(a.getJSONObject(i));
+ }
+ this.searchHits = hits;
+ if (result.has("aggregations")) {
+ this.aggregations = result.getJSONObject("aggregations");
+ } else {
+ this.aggregations = null;
+ }
+ } else {
+ this.searchHits = new SearchHit[0];
+ }
+ }
+
+ public SearchHit[] getHits() {
+ return this.searchHits;
+ }
+
+ public long getTotal() {
+ return this.total;
+ }
+
+ public boolean hasAggregations() {
+ return this.aggregations != null;
+ }
+
+ public AggregationEntries getAggregations(String property) {
+ AggregationEntries entries = new AggregationEntries();
+ if (this.aggregations != null && this.aggregations.has(property)) {
+ JSONArray a = this.aggregations.getJSONObject(property).getJSONArray("buckets");
+ for (int i = 0; i < a.length(); i++) {
+ entries.put(a.getJSONObject(i).getString("key"), a.getJSONObject(i).getLong("doc_count"));
+ }
+ }
+ return entries;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateByQueryResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateByQueryResponse.java
index 7d70f52fa..761b3c7c2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateByQueryResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateByQueryResponse.java
@@ -25,50 +25,39 @@ import org.elasticsearch.client.Response;
import org.json.JSONObject;
/**
- * {
- * "took":47,
- * "timed_out":false,
- * "total":1,
- * "updated":1,
- * "deleted":0,
- * "batches":1,
- * "version_conflicts":0,
- * "noops":0,
- * "retries":{
- * "bulk":0,
- * "search":0
- * },
- * "throttled_millis":0,
- * "requests_per_second":-1.0,
- * "throttled_until_millis":0,
- * "failures":[]}
+ * { "took":47, "timed_out":false, "total":1, "updated":1, "deleted":0, "batches":1, "version_conflicts":0, "noops":0,
+ * "retries":{ "bulk":0, "search":0 }, "throttled_millis":0, "requests_per_second":-1.0, "throttled_until_millis":0,
+ * "failures":[]}
+ *
* @author jack
*
*/
-public class UpdateByQueryResponse extends BaseResponse{
+public class UpdateByQueryResponse extends BaseResponse {
-
- private int isUpdated;
- private int failures;
- public UpdateByQueryResponse(Response response) {
- super(response);
- JSONObject o = this.getJson(response);
-
- this.isUpdated=o.getInt("updated");
- this.failures = o.getJSONArray("failures").length();
- //{"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
- }
+ private int isUpdated;
+ private int failures;
-
- public boolean isUpdated() {
- return this.isUpdated>0;
- }
- public boolean hasFailures() {
- return this.failures>0;
- }
- @Override
- public String toString() {
- return "UpdateByQueryResponse [isUpdated=" + isUpdated + ", failures=" + failures + "]";
- }
+ public UpdateByQueryResponse(Response response) {
+ super(response);
+ JSONObject o = this.getJson(response);
+
+ this.isUpdated = o.getInt("updated");
+ this.failures = o.getJSONArray("failures").length();
+ //{"_index":"historicalperformance24h","_type":"historicalperformance24h","_id":"CbZxvWwB4xjGPydc9ida","_version":1,"result":"created","_shards":{"total":4,"successful":1,"failed":0},"_seq_no":1,"_primary_term":1}
+ }
+
+
+ public boolean isUpdated() {
+ return this.isUpdated > 0;
+ }
+
+ public boolean hasFailures() {
+ return this.failures > 0;
+ }
+
+ @Override
+ public String toString() {
+ return "UpdateByQueryResponse [isUpdated=" + isUpdated + ", failures=" + failures + "]";
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateResponse.java
index 55f2652fa..80cb24872 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/database/responses/UpdateResponse.java
@@ -25,45 +25,34 @@ import org.elasticsearch.client.Response;
import org.json.JSONObject;
/**
- {
-"_index": "networkelement-connection-v1",
-"_type": "networkelement-connection",
-"_id": "sim2",
-"_version": 2,
-"result": "updated",
-"_shards": {
-"total": 2,
-"successful": 1,
-"failed": 0
-},
-"_seq_no": 5,
-"_primary_term": 1
-}
+ * { "_index": "networkelement-connection-v1", "_type": "networkelement-connection", "_id": "sim2", "_version": 2,
+ * "result": "updated", "_shards": { "total": 2, "successful": 1, "failed": 0 }, "_seq_no": 5, "_primary_term": 1 }
+ *
* @author jack
*
*/
-public class UpdateResponse extends BaseResponse{
-
- private String result;
+public class UpdateResponse extends BaseResponse {
+
+ private String result;
+
+ public UpdateResponse(Response response) {
+ super(response);
+ JSONObject o = this.getJson(response);
+
+ this.result = o.getString("result");
+ }
+
+ public boolean succeeded() {
+ if (this.result == null) {
+ return false;
+ }
+ String s = this.result.toLowerCase();
+ return s.equals("updated") || s.equals("created");
+ }
- public UpdateResponse(Response response) {
- super(response);
- JSONObject o = this.getJson(response);
-
- this.result=o.getString("result");
- }
-
- public boolean succeeded() {
- if(this.result==null) {
- return false;
- }
- String s=this.result.toLowerCase();
- return s.equals("updated") || s.equals("created");
- }
+ @Override
+ public String toString() {
+ return "UpdateResponse [result=" + result + "]";
+ }
- @Override
- public String toString() {
- return "UpdateResponse [result=" + result + "]";
- }
-
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
index bbdc505cd..809a44382 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/FileWatchdog.java
@@ -26,8 +26,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Check every now and then that a certain file has not changed. If it has, then call the
- * {@link #doOnChange} method.
+ * Check every now and then that a certain file has not changed. If it has, then call the {@link #doOnChange} method.
*
* @author JunHo Yoon
* @since 3.1.1
@@ -78,7 +77,7 @@ public abstract class FileWatchdog extends Thread {
try {
fileExists = file.exists();
} catch (SecurityException e) {
- LOGGER.warn("Was not allowed to read check file existence, file:[{}].",filename);
+ LOGGER.warn("Was not allowed to read check file existence, file:[{}].", filename);
this.interrupt(); // there is no point in continuing
return;
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
index 092e65e60..2e0701257 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomFile.java
@@ -37,61 +37,64 @@ import org.xml.sax.SAXException;
public class PomFile {
- private Document xmlDoc;
+ private Document xmlDoc;
- public PomFile(InputStream is) throws ParserConfigurationException, SAXException, IOException {
- DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory
- .newInstance();
-// documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
-// documentBuilderFactory.setFeature(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
-// documentBuilderFactory.setFeature(XMLInputFactory.SUPPORT_DTD, false);
+ public PomFile(InputStream is) throws ParserConfigurationException, SAXException, IOException {
+ DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
+ // documentBuilderFactory.setFeature(XMLConstants.FEATURE_SECURE_PROCESSING, true);
+ // documentBuilderFactory.setFeature(XMLInputFactory.IS_SUPPORTING_EXTERNAL_ENTITIES, false);
+ // documentBuilderFactory.setFeature(XMLInputFactory.SUPPORT_DTD, false);
- DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
- this.xmlDoc = documentBuilder.parse(is);
- }
-
- public String getProperty(String key) {
- Node props = findChild("properties",this.xmlDoc.getDocumentElement());
- if(props!=null) {
- Node prop = findChild(key, props);
- if(prop!=null) {
- return getTextValue(prop);
- }
- }
- return null;
- }
- public String getParentVersion() {
- Node parent = findChild("parent",this.xmlDoc.getDocumentElement());
- if(parent!=null) {
- Node version = findChild("version", parent);
- if(version!=null) {
- return getTextValue(version);
- }
- }
- return null;
- }
- private static String getTextValue(Node node) {
- StringBuffer textValue = new StringBuffer();
- for (int i = 0,length = node.getChildNodes().getLength(); i < length; i ++) {
- Node c = node.getChildNodes().item(i);
- if (c.getNodeType() == Node.TEXT_NODE) {
- textValue.append(c.getNodeValue());
- }
- }
- return textValue.toString().trim();
- }
+ DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
+ this.xmlDoc = documentBuilder.parse(is);
+ }
+
+ public String getProperty(String key) {
+ Node props = findChild("properties", this.xmlDoc.getDocumentElement());
+ if (props != null) {
+ Node prop = findChild(key, props);
+ if (prop != null) {
+ return getTextValue(prop);
+ }
+ }
+ return null;
+ }
+
+ public String getParentVersion() {
+ Node parent = findChild("parent", this.xmlDoc.getDocumentElement());
+ if (parent != null) {
+ Node version = findChild("version", parent);
+ if (version != null) {
+ return getTextValue(version);
+ }
+ }
+ return null;
+ }
+
+ private static String getTextValue(Node node) {
+ StringBuffer textValue = new StringBuffer();
+ for (int i = 0, length = node.getChildNodes().getLength(); i < length; i++) {
+ Node c = node.getChildNodes().item(i);
+ if (c.getNodeType() == Node.TEXT_NODE) {
+ textValue.append(c.getNodeValue());
+ }
+ }
+ return textValue.toString().trim();
+ }
+
+ private Node findChild(String name, Node root) {
+ List<Element> childs = getChildElementNodes(root);
+ for (Element n : childs) {
+ if (name.equals(n.getNodeName())) {
+ return n;
+ }
+ }
+ return null;
+ }
- private Node findChild(String name,Node root) {
- List<Element> childs = getChildElementNodes(root);
- for(Element n : childs) {
- if(name.equals(n.getNodeName())) {
- return n;
- }
- }
- return null;
- }
- /**
+ /**
* get all child nodes with type ELEMENT_NODE back in a list
+ *
* @param node parent node
* @return List with child nodes
*/
@@ -100,11 +103,11 @@ public class PomFile {
NodeList childs = node.getChildNodes();
Node item;
//System.out.println("Query node "+node.getNodeName());
- for (int n=0; n < childs.getLength(); n++) {
+ for (int n = 0; n < childs.getLength(); n++) {
item = childs.item(n);
//System.out.println(node.getNodeName()+"-"+item.getNodeName()+" "+item.getNodeType());
if (item.getNodeType() == Node.ELEMENT_NODE) {
- res.add((Element)childs.item(n));
+ res.add((Element) childs.item(n));
}
}
return res;
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomPropertiesFile.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomPropertiesFile.java
index 20aa97199..3057dfe0a 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomPropertiesFile.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/file/PomPropertiesFile.java
@@ -31,66 +31,66 @@ import java.util.Date;
import java.util.Locale;
/**
- * Example Content:
- * #Generated by org.apache.felix.bundleplugin
- * #Tue Nov 19 10:17:57 CET 2019
- * version=0.7.0-SNAPSHOT
- * groupId=org.onap.ccsdk.features.sdnr.wt
-* artifactId=sdnr-wt-data-provider-provider
+ * Example Content: #Generated by org.apache.felix.bundleplugin #Tue Nov 19 10:17:57 CET 2019 version=0.7.0-SNAPSHOT
+ * groupId=org.onap.ccsdk.features.sdnr.wt artifactId=sdnr-wt-data-provider-provider
+ *
* @author jack
*
*/
public class PomPropertiesFile {
- private Date buildDate;
- private String version;
- private String groupId;
- private String artifactId;
-
- public Date getBuildDate() {
- return this.buildDate;
- }
- public String getVersion() {
- return this.version;
- }
- public String getGroupId() {
- return this.groupId;
- }
- public String getArtifactId() {
- return this.artifactId;
- }
- private final DateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
- public PomPropertiesFile(InputStream is) throws IOException {
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- int intRead;
- while ((intRead = is.read()) != -1) {
- bos.write(intRead);
- }
- this.parse(new String(bos.toByteArray()));
- }
+ private Date buildDate;
+ private String version;
+ private String groupId;
+ private String artifactId;
- private void parse(String s) {
- String[] lines = s.split("\n");
- for(String line:lines) {
-
- if(line.startsWith("#Generated")) {
-
- } else if( line.startsWith("groupId")) {
- this.groupId = line.substring("groupId=".length());
- }
- else if(line.startsWith("artifactId")) {
- this.artifactId = line.substring("artifactId=".length());
- }
- else if(line.startsWith("#")){
- try {
- this.buildDate = sdf.parse(line.substring(1));
- } catch (ParseException e) {
-
- }
- }
- if(version!=null && this.buildDate!=null && this.groupId!=null && this.artifactId!=null) {
- break;
- }
- }
- }
+ public Date getBuildDate() {
+ return this.buildDate;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public String getGroupId() {
+ return this.groupId;
+ }
+
+ public String getArtifactId() {
+ return this.artifactId;
+ }
+
+ private final DateFormat sdf = new SimpleDateFormat("EEE MMM dd HH:mm:ss zzz yyyy", Locale.US);
+
+ public PomPropertiesFile(InputStream is) throws IOException {
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ int intRead;
+ while ((intRead = is.read()) != -1) {
+ bos.write(intRead);
+ }
+ this.parse(new String(bos.toByteArray()));
+ }
+
+ private void parse(String s) {
+ String[] lines = s.split("\n");
+ for (String line : lines) {
+
+ if (line.startsWith("#Generated")) {
+
+ } else if (line.startsWith("groupId")) {
+ this.groupId = line.substring("groupId=".length());
+ } else if (line.startsWith("artifactId")) {
+ this.artifactId = line.substring("artifactId=".length());
+ } else if (line.startsWith("#")) {
+ try {
+ this.buildDate = sdf.parse(line.substring(1));
+ } catch (ParseException e) {
+
+ }
+ }
+ if (version != null && this.buildDate != null && this.groupId != null && this.artifactId != null) {
+ break;
+ }
+ }
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
index 169546a7e..fdba374c7 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPClient.java
@@ -86,10 +86,10 @@ public class BaseHTTPClient {
}
public BaseHTTPClient(String base, boolean trustAllCerts, String certFilename, String passphrase, int sslCertType) {
- if(!base.endsWith("/")) {
- base+="/";
+ if (!base.endsWith("/")) {
+ base += "/";
}
- this.baseUrl = base;
+ this.baseUrl = base;
this.trustAll = trustAllCerts;
try {
sc = setupSsl(trustAll, certFilename, passphrase, sslCertType);
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
index 1b844395b..91a2cc27c 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseHTTPResponse.java
@@ -23,24 +23,23 @@ package org.onap.ccsdk.features.sdnr.wt.common.http;
public class BaseHTTPResponse {
- public static final int CODE404 = 404;
- public static final int CODE200 = 200;
- public static final BaseHTTPResponse UNKNOWN = new BaseHTTPResponse(-1, "");
- public final int code;
- public final String body;
+ public static final int CODE404 = 404;
+ public static final int CODE200 = 200;
+ public static final BaseHTTPResponse UNKNOWN = new BaseHTTPResponse(-1, "");
+ public final int code;
+ public final String body;
- public BaseHTTPResponse(int code,String body)
- {
- this.code=code;
- this.body=body;
- }
+ public BaseHTTPResponse(int code, String body) {
+ this.code = code;
+ this.body = body;
+ }
- @Override
- public String toString() {
- return "BaseHTTPResponse [code=" + code + ", body=" + body + "]";
- }
+ @Override
+ public String toString() {
+ return "BaseHTTPResponse [code=" + code + ", body=" + body + "]";
+ }
- public boolean isSuccess() {
- return this.code==CODE200;
- }
+ public boolean isSuccess() {
+ return this.code == CODE200;
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
index b65984a58..59e4e7705 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/http/BaseServlet.java
@@ -61,7 +61,9 @@ public abstract class BaseServlet extends HttpServlet {
protected abstract boolean isOff();
protected abstract boolean doTrustAll();
+
protected abstract void trustAll(boolean trust);
+
protected abstract String getRemoteUrl(String uri);
/**
@@ -74,7 +76,7 @@ public abstract class BaseServlet extends HttpServlet {
sc = SSLContext.getInstance("TLSv1.2");
if (trustall) {
if (trustCerts == null) {
- trustCerts = new TrustManager[] { new javax.net.ssl.X509TrustManager() {
+ trustCerts = new TrustManager[] {new javax.net.ssl.X509TrustManager() {
@Override
public java.security.cert.X509Certificate[] getAcceptedIssuers() {
return new java.security.cert.X509Certificate[] {};
@@ -89,7 +91,7 @@ public abstract class BaseServlet extends HttpServlet {
public void checkServerTrusted(java.security.cert.X509Certificate[] certs, String authType) {
// do not check anything when trust all
}
- } };
+ }};
}
} else {
if (trustCerts != null) {
@@ -101,7 +103,9 @@ public abstract class BaseServlet extends HttpServlet {
}
protected abstract boolean trustInsecure();
- protected abstract boolean isCorsEnabled();
+
+ protected abstract boolean isCorsEnabled();
+
public BaseServlet() {
this.trysslSetup(true);
}
@@ -117,7 +121,7 @@ public abstract class BaseServlet extends HttpServlet {
*/
private void trysslSetup(boolean force) {
// if trustall config has changed
- if (force || this.doTrustAll() != this.trustInsecure()) {
+ if (force || this.doTrustAll() != this.trustInsecure()) {
this.trustAll(this.trustInsecure());
// resetup ssl config
try {
@@ -158,8 +162,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -184,8 +187,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -210,8 +212,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -236,8 +237,7 @@ public abstract class BaseServlet extends HttpServlet {
LOG.warn(e.getMessage());
}
http.disconnect();
- }
- else {
+ } else {
this.set404Response(resp);
}
}
@@ -249,24 +249,24 @@ public abstract class BaseServlet extends HttpServlet {
private URLConnection getConnection(HttpServletRequest req, final String method) throws IOException {
- LOG.debug("{} Request to {}", method,req.getRequestURL());
+ LOG.debug("{} Request to {}", method, req.getRequestURL());
String surl = this.getRemoteUrl(req.getRequestURI());
- if("GET".equals(method)) {
+ if ("GET".equals(method)) {
Enumeration<?> params = req.getParameterNames();
- if(params!=null) {
+ if (params != null) {
String param;
- if(params.hasMoreElements()) {
- param=(String)params.nextElement();
- surl+="?"+param+"="+req.getParameter(param);
+ if (params.hasMoreElements()) {
+ param = (String) params.nextElement();
+ surl += "?" + param + "=" + req.getParameter(param);
}
- while(params.hasMoreElements()) {
- param=(String)params.nextElement();
- surl+="&"+param+"="+req.getParameter(param);
+ while (params.hasMoreElements()) {
+ param = (String) params.nextElement();
+ surl += "&" + param + "=" + req.getParameter(param);
}
}
}
LOG.debug("RemoteURL: {}", surl);
- if(surl==null) {
+ if (surl == null) {
return null;
}
URL url = new URL(surl);
@@ -284,7 +284,7 @@ public abstract class BaseServlet extends HttpServlet {
String s = "";
Enumeration<?> headers = req.getHeaderNames();
while (headers.hasMoreElements()) {
- String h = (String)headers.nextElement();
+ String h = (String) headers.nextElement();
String v = req.getHeader(h);
if (h != null && h.equals("Host")) {
v = url.getAuthority();
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
index c845729a1..f95dfe0b2 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/test/JSONAssert.java
@@ -29,172 +29,173 @@ import org.json.JSONObject;
public class JSONAssert {
- /**
- * nonstrict comparison means that json array items can be in different orders
- */
- private static Comparator<JSONObject> nonStrictComarator = new Comparator<JSONObject>() {
-
- @Override
- public int compare(JSONObject o1, JSONObject o2) {
- if (o1.equals(o2)) {
- return 0;
- }
- Iterator<?> keys = o1.keys();
- while (keys.hasNext()) {
- String key = String.valueOf(keys.next());
- int x = this.test(o1.get(key), o2.get(key));
- if (x != 0) {
- return x;
- }
- }
- return 0;
- }
-
- private int test(Object o1, Object o2) {
- int x;
- if ((o1 instanceof Double) && (o2 instanceof Double)) {
-
- return (((Double) o1).doubleValue() - ((Double) o2).doubleValue()) < 0 ? -1 : 1;
- } else if ((o1 instanceof Boolean) && (o2 instanceof Boolean)) {
- return ((Boolean) o1).booleanValue() == ((Boolean) o2).booleanValue() ? 0 : -1;
-
- } else if ((o1 instanceof String) && (o2 instanceof String)) {
-
- return ((String) o1).equals(((String) o2)) ? 0 : -1;
- } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) {
- if (((JSONObject) o1).length() != ((JSONObject) o2).length()) {
- return ((JSONObject) o1).length() - ((JSONObject) o2).length() < 0 ? -1 : 1;
- }
- Iterator<?> keys = ((JSONObject) o1).keys();
- while (keys.hasNext()) {
- String key = String.valueOf(keys.next());
- if (!((JSONObject) o2).has(key)) {
- return -1;
- }
- x = this.test(((JSONObject) o1).get(key), ((JSONObject) o2).get(key));
- if (x != 0) {
- return x;
- }
- }
- } else if ((o1 instanceof JSONArray) && (o2 instanceof JSONArray)) {
- if (((JSONArray) o1).length() != ((JSONArray) o2).length()) {
- return ((JSONArray) o1).length() - ((JSONArray) o2).length() < 0 ? -1 : 1;
- }
- for (int i = 0; i < ((JSONArray) o1).length(); i++) {
- x = this.findInArray(((JSONArray) o1).get(i), (JSONArray) o2);
- if (x != 0) {
- return x;
- }
- }
- for (int i = 0; i < ((JSONArray) o2).length(); i++) {
- x = this.findInArray(((JSONArray) o2).get(i), (JSONArray) o1);
- if (x != 0) {
- return x;
- }
- }
- }
- return 0;
-
- }
-
- private int findInArray(Object node, JSONArray o) {
- for (int i = 0; i < o.length(); i++) {
- if (this.test(o.get(i), node) == 0) {
- return 0;
- }
- }
- return -1;
- }
- };
- /**
- * strict comparison means that json array items have to be in the same order
- */
- private static Comparator<JSONObject> strictComarator = new Comparator<JSONObject>() {
-
- @Override
- public int compare(JSONObject o1, JSONObject o2) {
- if (o1.equals(o2)) {
- return 0;
- }
- Iterator<?> keys = o1.keys();
- while (keys.hasNext()) {
- String key = String.valueOf(keys.next());
- int x = this.test(o1.get(key), o2.get(key));
- if (x != 0) {
- return x;
- }
- }
- return 0;
- }
-
- private int test(Object o1, Object o2) {
- int x;
- if ((o1 instanceof Double) && (o2 instanceof Double)) {
-
- return (((Double) o1).doubleValue() - ((Double) o2).doubleValue()) < 0 ? -1 : 1;
- } else if ((o1 instanceof Boolean) && (o2 instanceof Boolean)) {
- return ((Boolean) o1).booleanValue() == ((Boolean) o2).booleanValue() ? 0 : -1;
-
- } else if ((o1 instanceof String) && (o2 instanceof String)) {
-
- return ((String) o1).equals(((String) o2)) ? 0 : -1;
- } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) {
- if (((JSONObject) o1).length() == 0 && ((JSONObject) o2).length() == 0) {
- return 0;
- }
- Iterator<?> keys = ((JSONObject) o1).keys();
- while (keys.hasNext()) {
- String key = String.valueOf(keys.next());
- if (!((JSONObject) o2).has(key)) {
- return -1;
- }
- x = this.test(((JSONObject) o1).get(key), ((JSONObject) o2).get(key));
- if (x != 0) {
- return x;
- }
- }
- } else if ((o1 instanceof JSONArray) && (o2 instanceof JSONArray)) {
- if (((JSONArray) o1).length() != ((JSONArray) o2).length()) {
- return ((JSONArray) o1).length() - ((JSONArray) o2).length() < 0 ? -1 : 1;
- }
- for (int i = 0; i < ((JSONArray) o1).length(); i++) {
- x = this.test(((JSONArray) o1).get(i), ((JSONArray) o2).get(i));
- if (x != 0) {
- return x;
- }
- }
- }
- return 0;
-
- }
- };
- public static void assertEquals(String def, String toTest, boolean strict) throws JSONException {
- assertEquals(null, def, toTest, strict);
- }
-
- public static void assertEquals(String message, String def, String toTest, boolean strict) throws JSONException {
- if (strict) {
- assertEqualsStrict(message, def, toTest);
- } else {
- assertEqualsNonStrict(message, def, toTest);
- }
- }
-
- private static void assertEqualsNonStrict(String message, String def, String toTest) throws JSONException {
-
- JSONObject d1 = new JSONObject(def);
- JSONObject d2 = new JSONObject(toTest);
- if (nonStrictComarator.compare(d1, d2) != 0) {
- throw new AssertionError(message);
- }
- }
-
- private static void assertEqualsStrict(String message, String def, String toTest) throws JSONException {
- JSONObject d1 = new JSONObject(def);
- JSONObject d2 = new JSONObject(toTest);
- if (strictComarator.compare(d1, d2) != 0) {
- throw new AssertionError(message);
- }
- }
+ /**
+ * nonstrict comparison means that json array items can be in different orders
+ */
+ private static Comparator<JSONObject> nonStrictComarator = new Comparator<JSONObject>() {
+
+ @Override
+ public int compare(JSONObject o1, JSONObject o2) {
+ if (o1.equals(o2)) {
+ return 0;
+ }
+ Iterator<?> keys = o1.keys();
+ while (keys.hasNext()) {
+ String key = String.valueOf(keys.next());
+ int x = this.test(o1.get(key), o2.get(key));
+ if (x != 0) {
+ return x;
+ }
+ }
+ return 0;
+ }
+
+ private int test(Object o1, Object o2) {
+ int x;
+ if ((o1 instanceof Double) && (o2 instanceof Double)) {
+
+ return (((Double) o1).doubleValue() - ((Double) o2).doubleValue()) < 0 ? -1 : 1;
+ } else if ((o1 instanceof Boolean) && (o2 instanceof Boolean)) {
+ return ((Boolean) o1).booleanValue() == ((Boolean) o2).booleanValue() ? 0 : -1;
+
+ } else if ((o1 instanceof String) && (o2 instanceof String)) {
+
+ return ((String) o1).equals(((String) o2)) ? 0 : -1;
+ } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) {
+ if (((JSONObject) o1).length() != ((JSONObject) o2).length()) {
+ return ((JSONObject) o1).length() - ((JSONObject) o2).length() < 0 ? -1 : 1;
+ }
+ Iterator<?> keys = ((JSONObject) o1).keys();
+ while (keys.hasNext()) {
+ String key = String.valueOf(keys.next());
+ if (!((JSONObject) o2).has(key)) {
+ return -1;
+ }
+ x = this.test(((JSONObject) o1).get(key), ((JSONObject) o2).get(key));
+ if (x != 0) {
+ return x;
+ }
+ }
+ } else if ((o1 instanceof JSONArray) && (o2 instanceof JSONArray)) {
+ if (((JSONArray) o1).length() != ((JSONArray) o2).length()) {
+ return ((JSONArray) o1).length() - ((JSONArray) o2).length() < 0 ? -1 : 1;
+ }
+ for (int i = 0; i < ((JSONArray) o1).length(); i++) {
+ x = this.findInArray(((JSONArray) o1).get(i), (JSONArray) o2);
+ if (x != 0) {
+ return x;
+ }
+ }
+ for (int i = 0; i < ((JSONArray) o2).length(); i++) {
+ x = this.findInArray(((JSONArray) o2).get(i), (JSONArray) o1);
+ if (x != 0) {
+ return x;
+ }
+ }
+ }
+ return 0;
+
+ }
+
+ private int findInArray(Object node, JSONArray o) {
+ for (int i = 0; i < o.length(); i++) {
+ if (this.test(o.get(i), node) == 0) {
+ return 0;
+ }
+ }
+ return -1;
+ }
+ };
+ /**
+ * strict comparison means that json array items have to be in the same order
+ */
+ private static Comparator<JSONObject> strictComarator = new Comparator<JSONObject>() {
+
+ @Override
+ public int compare(JSONObject o1, JSONObject o2) {
+ if (o1.equals(o2)) {
+ return 0;
+ }
+ Iterator<?> keys = o1.keys();
+ while (keys.hasNext()) {
+ String key = String.valueOf(keys.next());
+ int x = this.test(o1.get(key), o2.get(key));
+ if (x != 0) {
+ return x;
+ }
+ }
+ return 0;
+ }
+
+ private int test(Object o1, Object o2) {
+ int x;
+ if ((o1 instanceof Double) && (o2 instanceof Double)) {
+
+ return (((Double) o1).doubleValue() - ((Double) o2).doubleValue()) < 0 ? -1 : 1;
+ } else if ((o1 instanceof Boolean) && (o2 instanceof Boolean)) {
+ return ((Boolean) o1).booleanValue() == ((Boolean) o2).booleanValue() ? 0 : -1;
+
+ } else if ((o1 instanceof String) && (o2 instanceof String)) {
+
+ return ((String) o1).equals(((String) o2)) ? 0 : -1;
+ } else if ((o1 instanceof JSONObject) && (o2 instanceof JSONObject)) {
+ if (((JSONObject) o1).length() == 0 && ((JSONObject) o2).length() == 0) {
+ return 0;
+ }
+ Iterator<?> keys = ((JSONObject) o1).keys();
+ while (keys.hasNext()) {
+ String key = String.valueOf(keys.next());
+ if (!((JSONObject) o2).has(key)) {
+ return -1;
+ }
+ x = this.test(((JSONObject) o1).get(key), ((JSONObject) o2).get(key));
+ if (x != 0) {
+ return x;
+ }
+ }
+ } else if ((o1 instanceof JSONArray) && (o2 instanceof JSONArray)) {
+ if (((JSONArray) o1).length() != ((JSONArray) o2).length()) {
+ return ((JSONArray) o1).length() - ((JSONArray) o2).length() < 0 ? -1 : 1;
+ }
+ for (int i = 0; i < ((JSONArray) o1).length(); i++) {
+ x = this.test(((JSONArray) o1).get(i), ((JSONArray) o2).get(i));
+ if (x != 0) {
+ return x;
+ }
+ }
+ }
+ return 0;
+
+ }
+ };
+
+ public static void assertEquals(String def, String toTest, boolean strict) throws JSONException {
+ assertEquals(null, def, toTest, strict);
+ }
+
+ public static void assertEquals(String message, String def, String toTest, boolean strict) throws JSONException {
+ if (strict) {
+ assertEqualsStrict(message, def, toTest);
+ } else {
+ assertEqualsNonStrict(message, def, toTest);
+ }
+ }
+
+ private static void assertEqualsNonStrict(String message, String def, String toTest) throws JSONException {
+
+ JSONObject d1 = new JSONObject(def);
+ JSONObject d2 = new JSONObject(toTest);
+ if (nonStrictComarator.compare(d1, d2) != 0) {
+ throw new AssertionError(message);
+ }
+ }
+
+ private static void assertEqualsStrict(String message, String def, String toTest) throws JSONException {
+ JSONObject d1 = new JSONObject(def);
+ JSONObject d2 = new JSONObject(toTest);
+ if (strictComarator.compare(d1, d2) != 0) {
+ throw new AssertionError(message);
+ }
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/Environment.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/Environment.java
index a2ef92910..050152f50 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/Environment.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/Environment.java
@@ -27,24 +27,22 @@ import java.util.Map;
public class Environment {
- public static String getVar(String v)
- {
- if(v.equals("$HOSTNAME"))
- {
- String s=null;
- try {
- s = Inet4Address.getLocalHost().getHostName();
- } catch (UnknownHostException e) {
+ public static String getVar(String v) {
+ if (v.equals("$HOSTNAME")) {
+ String s = null;
+ try {
+ s = Inet4Address.getLocalHost().getHostName();
+ } catch (UnknownHostException e) {
- }
- if(s!=null && s.length()>0)
- return s;
- }
- Map<String, String> env = System.getenv();
+ }
+ if (s != null && s.length() > 0)
+ return s;
+ }
+ Map<String, String> env = System.getenv();
for (String envName : env.keySet()) {
- if(envName!=null && envName.equals(v))
- return env.get(envName);
+ if (envName != null && envName.equals(v))
+ return env.get(envName);
}
return null;
- }
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/ResourceFileLoader.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/ResourceFileLoader.java
index 739ffb35f..208957a53 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/ResourceFileLoader.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/ResourceFileLoader.java
@@ -25,9 +25,9 @@ import java.io.File;
public class ResourceFileLoader {
- public static File getFile(Object o, String fileName) {
- ClassLoader classLoader = o.getClass().getClassLoader();
- return new File(classLoader.getResource(fileName).getFile());
- }
+ public static File getFile(Object o, String fileName) {
+ ClassLoader classLoader = o.getClass().getClassLoader();
+ return new File(classLoader.getResource(fileName).getFile());
+ }
}
diff --git a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/StackTrace.java b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/StackTrace.java
index ee17c55f7..5826285db 100644
--- a/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/StackTrace.java
+++ b/sdnr/wt/common/src/main/java/org/onap/ccsdk/features/sdnr/wt/common/util/StackTrace.java
@@ -32,6 +32,7 @@ public class StackTrace {
/**
* Return stacktrace as String
+ *
* @param e with stacktrace information to be converte
* @return String with call stack
*/
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java
index 57ae0e3bc..3584d7f28 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseHttpClient.java
@@ -47,141 +47,139 @@ import com.sun.net.httpserver.HttpServer;
@SuppressWarnings("restriction")
public class TestBaseHttpClient {
- public static final String HTTPMETHOD_GET = "GET";
- public static final String HTTPMETHOD_POST = "POST";
- public static final String HTTPMETHOD_PUT = "PUT";
- public static final String HTTPMETHOD_DELETE = "DELETE";
- public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
- private static final String TESTURI = "/mwtn/test";
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
- private static final int testPort = 54440;
-
- @Test
- public void test() {
- MyHttpClient httpClient = new MyHttpClient("http://localhost:"+testPort, true);
- Map<String, String> headers = new HashMap<String,String>();
- headers.put("Authorization", BaseHTTPClient.getAuthorizationHeaderValue("admin", "admin"));
- headers.put("Content-Type","application/json");
- BaseHTTPResponse response=null;
- try {
- response= httpClient.sendRequest(TESTURI, HTTPMETHOD_GET, null, headers );
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertEquals(RESPONSE_GET, response.body);
- try {
- response= httpClient.sendRequest(TESTURI, HTTPMETHOD_POST, "{}", headers );
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertTrue(response.isSuccess());
- System.out.println(response.toString());
- assertEquals(RESPONSE_POST, response.body);
- try {
- response= httpClient.sendRequest(TESTURI, HTTPMETHOD_PUT, "{}", headers );
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertEquals(RESPONSE_PUT, response.body);
- try {
- response= httpClient.sendRequest(TESTURI, HTTPMETHOD_DELETE, "{}", headers );
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertEquals(RESPONSE_DELETE, response.body);
-
- }
-
-
-
-
- @BeforeClass
- public static void initTestWebserver() throws IOException {
- server = HttpServer.create(new InetSocketAddress("127.0.0.1", testPort), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- server.createContext(TESTURI, 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() {
- System.out.println("try to stop server");
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped" );
- }
- }
-
- private class MyHttpClient extends BaseHTTPClient{
-
- public MyHttpClient(String base, boolean trustAllCerts) {
- super(base, trustAllCerts);
- }
-
- @Override
- public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
- throws IOException {
- return super.sendRequest(uri, method, body, headers);
- }
- }
-
- public static class MyHandler implements HttpHandler {
-
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println(String.format("req received: %s %s" ,method,t.getRequestURI()));
- OutputStream os = null;
- try {
- if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, RESPONSE_GET.length());
- os = t.getResponseBody();
- os.write(RESPONSE_GET.getBytes());
- } else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, RESPONSE_POST.length());
- os = t.getResponseBody();
- os.write(RESPONSE_POST.getBytes());
- } else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, RESPONSE_PUT.length());
- os = t.getResponseBody();
- os.write(RESPONSE_PUT.getBytes());
- } else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, RESPONSE_DELETE.length());
- os = t.getResponseBody();
- os.write(RESPONSE_DELETE.getBytes());
- } else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, RESPONSE_OPTIONS.length());
- //os = t.getResponseBody();
- //os.write(RESPONSE_OPTIONS.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.flush();
- os.close();
- }
- }
- }
- }
+ public static final String HTTPMETHOD_GET = "GET";
+ public static final String HTTPMETHOD_POST = "POST";
+ public static final String HTTPMETHOD_PUT = "PUT";
+ public static final String HTTPMETHOD_DELETE = "DELETE";
+ public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
+ public static final String RESPONSE_GET = "This is the response get";
+ public static final String RESPONSE_POST = "This is the response post";
+ public static final String RESPONSE_PUT = "This is the response put";
+ public static final String RESPONSE_DELETE = "This is the response delete";
+ public static final String RESPONSE_OPTIONS = "This is the response options";
+ private static final String TESTURI = "/mwtn/test";
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+ private static final int testPort = 54440;
+
+ @Test
+ public void test() {
+ MyHttpClient httpClient = new MyHttpClient("http://localhost:" + testPort, true);
+ Map<String, String> headers = new HashMap<String, String>();
+ headers.put("Authorization", BaseHTTPClient.getAuthorizationHeaderValue("admin", "admin"));
+ headers.put("Content-Type", "application/json");
+ BaseHTTPResponse response = null;
+ try {
+ response = httpClient.sendRequest(TESTURI, HTTPMETHOD_GET, null, headers);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertEquals(RESPONSE_GET, response.body);
+ try {
+ response = httpClient.sendRequest(TESTURI, HTTPMETHOD_POST, "{}", headers);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertTrue(response.isSuccess());
+ System.out.println(response.toString());
+ assertEquals(RESPONSE_POST, response.body);
+ try {
+ response = httpClient.sendRequest(TESTURI, HTTPMETHOD_PUT, "{}", headers);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertEquals(RESPONSE_PUT, response.body);
+ try {
+ response = httpClient.sendRequest(TESTURI, HTTPMETHOD_DELETE, "{}", headers);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertEquals(RESPONSE_DELETE, response.body);
+
+ }
+
+
+
+ @BeforeClass
+ public static void initTestWebserver() throws IOException {
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", testPort), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ server.createContext(TESTURI, 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() {
+ System.out.println("try to stop server");
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ }
+
+ private class MyHttpClient extends BaseHTTPClient {
+
+ public MyHttpClient(String base, boolean trustAllCerts) {
+ super(base, trustAllCerts);
+ }
+
+ @Override
+ public BaseHTTPResponse sendRequest(String uri, String method, String body, Map<String, String> headers)
+ throws IOException {
+ return super.sendRequest(uri, method, body, headers);
+ }
+ }
+
+ public static class MyHandler implements HttpHandler {
+
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println(String.format("req received: %s %s", method, t.getRequestURI()));
+ OutputStream os = null;
+ try {
+ if (method.equals(HTTPMETHOD_GET)) {
+ t.sendResponseHeaders(200, RESPONSE_GET.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_GET.getBytes());
+ } else if (method.equals(HTTPMETHOD_POST)) {
+ t.sendResponseHeaders(200, RESPONSE_POST.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_POST.getBytes());
+ } else if (method.equals(HTTPMETHOD_PUT)) {
+ t.sendResponseHeaders(200, RESPONSE_PUT.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_PUT.getBytes());
+ } else if (method.equals(HTTPMETHOD_DELETE)) {
+ t.sendResponseHeaders(200, RESPONSE_DELETE.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_DELETE.getBytes());
+ } else if (method.equals(HTTPMETHOD_OPTIONS)) {
+ t.sendResponseHeaders(200, RESPONSE_OPTIONS.length());
+ //os = t.getResponseBody();
+ //os.write(RESPONSE_OPTIONS.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.flush();
+ os.close();
+ }
+ }
+ }
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java
index 02a82a70d..0c1ae50ee 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestBaseServlet.java
@@ -35,40 +35,43 @@ import org.onap.ccsdk.features.sdnr.wt.common.test.helper.HelpServletBase;
* @author Michael Dürre
*
*/
-public class TestBaseServlet extends HelpServletBase{
+public class TestBaseServlet extends HelpServletBase {
- private static final int PORT = 40003;
- public TestBaseServlet() {
- super("/base",PORT);
- }
-
- @Test
- public void test() throws ServletException, IOException {
-
- String query = "{\"query\":{\"match_all\":{}}}";
- HelpServlet servlet = new HelpServlet(PORT);
- this.setServlet(servlet);
- // test disabled message
- String expectedResponse = "offline";
- testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
- testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
- testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
- testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
- servlet.setOffline(false);
- // initEsTestWebserver(port);
- testrequest(HTTPMETHOD_GET, query, HelpServletBase.RESPONSE_GET, true);
- testrequest(HTTPMETHOD_POST, query, HelpServletBase.RESPONSE_POST, true);
- testrequest(HTTPMETHOD_PUT, query, HelpServletBase.RESPONSE_PUT, true);
- testrequest(HTTPMETHOD_DELETE, query, HelpServletBase.RESPONSE_DELETE, true);
- testrequest(HTTPMETHOD_OPTIONS, query, "", false);
- // stopTestWebserver();
- }
- @Before
- public void init() throws IOException{
- HelpServletBase.initEsTestWebserver(PORT);
- }
- @After
- public void deinit() {
- HelpServletBase.stopTestWebserver();
- }
+ private static final int PORT = 40003;
+
+ public TestBaseServlet() {
+ super("/base", PORT);
+ }
+
+ @Test
+ public void test() throws ServletException, IOException {
+
+ String query = "{\"query\":{\"match_all\":{}}}";
+ HelpServlet servlet = new HelpServlet(PORT);
+ this.setServlet(servlet);
+ // test disabled message
+ String expectedResponse = "offline";
+ testrequest(HTTPMETHOD_GET, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_POST, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_PUT, query, expectedResponse, false);
+ testrequest(HTTPMETHOD_DELETE, query, expectedResponse, false);
+ servlet.setOffline(false);
+ // initEsTestWebserver(port);
+ testrequest(HTTPMETHOD_GET, query, HelpServletBase.RESPONSE_GET, true);
+ testrequest(HTTPMETHOD_POST, query, HelpServletBase.RESPONSE_POST, true);
+ testrequest(HTTPMETHOD_PUT, query, HelpServletBase.RESPONSE_PUT, true);
+ testrequest(HTTPMETHOD_DELETE, query, HelpServletBase.RESPONSE_DELETE, true);
+ testrequest(HTTPMETHOD_OPTIONS, query, "", false);
+ // stopTestWebserver();
+ }
+
+ @Before
+ public void init() throws IOException {
+ HelpServletBase.initEsTestWebserver(PORT);
+ }
+
+ @After
+ public void deinit() {
+ HelpServletBase.stopTestWebserver();
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java
index 3b19f5c4b..415620415 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestConfig.java
@@ -44,218 +44,222 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
public class TestConfig {
- private static final String TESTFILENAME = "test.properties";
- private static final String TESTKEY1 = "abc";
- private static final String TESTKEY2 = "def";
- private static final String TESTKEY3 = "hhh";
- private static final String TESTKEY4 = "hhv";
-
- private static final int TESTVALUE1=123;
- private static final int TESTVALUE1_2=1234;
- private static final boolean TESTVALUE2 = true;
- private static final String TESTVALUE3 = "http://localhost:2223";
- private static final String TESTVALUE4 = "httasdasdas";
- private static final String TESTCONTENT1 = " [test]\n" +
- TESTKEY1+"="+TESTVALUE1+"\n" +
- "#her a comment\n"+
- TESTKEY2+"="+TESTVALUE2+"\n" +
- TESTKEY3+"="+TESTVALUE3;
-
-
-
-
- @After
- @Before
- public void init() {
- File f=new File(TESTFILENAME);
- if(f.exists()) {
- f.delete();
- }
- }
-
- public void write(String filename,String lines) {
-
- try {
- Files.write(new File(filename).toPath(), lines.getBytes());
- } catch (IOException e) {
- fail("problem writing file "+filename);
- }
- }
- @Test
- public void testRead() {
- this.write(TESTFILENAME, TESTCONTENT1);
- ConfigurationFileRepresentation confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- Section section = confiuration.getSection("test").get();
- assertNotNull(section);
- try {
- assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
- assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
- assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
- } catch (ConversionException e) {
- fail(e.getMessage());
- }
- this.init();
- }
- @Test
- public void testWrite() {
- final String SECTIONNAME = "test";
- //write values
- ConfigurationFileRepresentation confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- Section section=confiuration.addSection(SECTIONNAME);
-
- section.setProperty(TESTKEY1, String.valueOf(TESTVALUE1));
- section.setProperty(TESTKEY2, String.valueOf(TESTVALUE2));
- section.setProperty(TESTKEY3, String.valueOf(TESTVALUE3));
- confiuration.save();
-
- //verify written
- ConfigurationFileRepresentation confiuration2=new ConfigurationFileRepresentation(TESTFILENAME);
-
- section = confiuration2.getSection(SECTIONNAME).get();
- assertNotNull(section);
- try {
- assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
- assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
- assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
- } catch (ConversionException e) {
- fail(e.getMessage());
- }
- this.init();
-
- //write directly into base
- confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- section=confiuration.addSection(SECTIONNAME);
- confiuration.setProperty(SECTIONNAME,TESTKEY1 , TESTVALUE1);
- confiuration.setProperty(SECTIONNAME,TESTKEY2 , TESTVALUE2);
- confiuration.setProperty(SECTIONNAME,TESTKEY3 , TESTVALUE3);
- confiuration.save();
-
- //verify
- confiuration2=new ConfigurationFileRepresentation(TESTFILENAME);
- section = confiuration2.getSection(SECTIONNAME).get();
- assertNotNull(section);
- assertEquals(TESTVALUE1, confiuration.getPropertyLong(SECTIONNAME,TESTKEY1).get().intValue());
- assertEquals(TESTVALUE2, confiuration.getPropertyBoolean(SECTIONNAME,TESTKEY2));
- assertEquals(TESTVALUE3, confiuration.getProperty(SECTIONNAME,TESTKEY3));
- this.init();
-
-
- }
- @Test
- public void testOverwrite() {
- final String SECTIONNAME = "test";
- //write values
- ConfigurationFileRepresentation confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- Section section=confiuration.addSection(SECTIONNAME);
-
- section.setProperty(TESTKEY1, String.valueOf(TESTVALUE1));
- section.setProperty(TESTKEY2, String.valueOf(TESTVALUE2));
- section.setProperty(TESTKEY3, String.valueOf(TESTVALUE3));
- confiuration.save();
-
- //verify written
- ConfigurationFileRepresentation confiuration2=new ConfigurationFileRepresentation(TESTFILENAME);
-
- section = confiuration2.getSection(SECTIONNAME).get();
-
- assertNotNull(section);
- try {
- assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
- assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
- assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
- } catch (ConversionException e) {
- fail(e.getMessage());
- }
-
- //write directly into base
- confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- section=confiuration.addSection(SECTIONNAME);
- confiuration.setPropertyIfNotAvailable(SECTIONNAME,TESTKEY1 , TESTVALUE1_2);
- confiuration.setPropertyIfNotAvailable(SECTIONNAME,TESTKEY4 , TESTVALUE4);
-
- confiuration.save();
-
- //verify
- confiuration2=new ConfigurationFileRepresentation(TESTFILENAME);
- section = confiuration2.getSection(SECTIONNAME).get();
- assertNotNull(section);
- assertEquals(TESTVALUE1, confiuration.getPropertyLong(SECTIONNAME,TESTKEY1).get().intValue());
- assertEquals(TESTVALUE2, confiuration.getPropertyBoolean(SECTIONNAME,TESTKEY2));
- assertEquals(TESTVALUE3, confiuration.getProperty(SECTIONNAME,TESTKEY3));
- assertEquals(TESTVALUE4, confiuration.getProperty(SECTIONNAME,TESTKEY4));
- this.init();
-
-
- }
- static boolean changeFlag=false;
- @Test
- public void testChangeListener() {
-
- changeFlag=false;
- this.init();
- ConfigurationFileRepresentation confiuration=new ConfigurationFileRepresentation(TESTFILENAME);
- IConfigChangedListener listener = new IConfigChangedListener() {
-
- @Override
- public void onConfigChanged() {
- changeFlag=true;
- }
- };
- confiuration.registerConfigChangedListener(listener );
- try {
- Thread.sleep(2000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- this.write(TESTFILENAME, TESTCONTENT1);
- int i=10;
- while(i-->0) {
- try {
- Thread.sleep(1000);
- } catch (InterruptedException e) {
- Thread.currentThread().interrupt();
- }
- if(changeFlag) {
- break;
- }
- }
- confiuration.unregisterConfigChangedListener(listener);
- assertTrue("changelistener not called",changeFlag);
- }
- @Test
- public void testHostInfo() {
- HostInfo hi=HostInfo.getDefault();
- try {
- new URL(hi.toUrl());
- } catch (MalformedURLException e) {
- fail("url conversion failed: "+e.getMessage());
- }
- hi = new HostInfo("localhost", 44444, Protocol.getValueOf("https"));
- try {
- new URL(hi.toUrl());
- } catch (MalformedURLException e) {
- fail("url conversion failed: "+e.getMessage());
- }
-
- }
- @Test
- public void testEnvPropert() {
- final String KEY = "basada";
- Section section = new Section("test");
- section.addLine(KEY+"=${USER} in ${HOME}");
- section.parseLines();
- assertTrue(section.getProperty(KEY).length()>" in ".length());
- }
- public static void setEnv(String key, String value) {
- try {
- Map<String, String> env = System.getenv();
- Class<?> cl = env.getClass();
- Field field = cl.getDeclaredField("m");
- field.setAccessible(true);
- Map<String, String> writableEnv = (Map<String, String>) field.get(env);
- writableEnv.put(key, value);
- } catch (Exception e) {
- throw new IllegalStateException("Failed to set environment variable", e);
- }
- }
+ private static final String TESTFILENAME = "test.properties";
+ private static final String TESTKEY1 = "abc";
+ private static final String TESTKEY2 = "def";
+ private static final String TESTKEY3 = "hhh";
+ private static final String TESTKEY4 = "hhv";
+
+ private static final int TESTVALUE1 = 123;
+ private static final int TESTVALUE1_2 = 1234;
+ private static final boolean TESTVALUE2 = true;
+ private static final String TESTVALUE3 = "http://localhost:2223";
+ private static final String TESTVALUE4 = "httasdasdas";
+ private static final String TESTCONTENT1 = " [test]\n" + TESTKEY1 + "=" + TESTVALUE1 + "\n" + "#her a comment\n"
+ + TESTKEY2 + "=" + TESTVALUE2 + "\n" + TESTKEY3 + "=" + TESTVALUE3;
+
+
+
+ @After
+ @Before
+ public void init() {
+ File f = new File(TESTFILENAME);
+ if (f.exists()) {
+ f.delete();
+ }
+ }
+
+ public void write(String filename, String lines) {
+
+ try {
+ Files.write(new File(filename).toPath(), lines.getBytes());
+ } catch (IOException e) {
+ fail("problem writing file " + filename);
+ }
+ }
+
+ @Test
+ public void testRead() {
+ this.write(TESTFILENAME, TESTCONTENT1);
+ ConfigurationFileRepresentation confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ Section section = confiuration.getSection("test").get();
+ assertNotNull(section);
+ try {
+ assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
+ assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
+ assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
+ } catch (ConversionException e) {
+ fail(e.getMessage());
+ }
+ this.init();
+ }
+
+ @Test
+ public void testWrite() {
+ final String SECTIONNAME = "test";
+ //write values
+ ConfigurationFileRepresentation confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ Section section = confiuration.addSection(SECTIONNAME);
+
+ section.setProperty(TESTKEY1, String.valueOf(TESTVALUE1));
+ section.setProperty(TESTKEY2, String.valueOf(TESTVALUE2));
+ section.setProperty(TESTKEY3, String.valueOf(TESTVALUE3));
+ confiuration.save();
+
+ //verify written
+ ConfigurationFileRepresentation confiuration2 = new ConfigurationFileRepresentation(TESTFILENAME);
+
+ section = confiuration2.getSection(SECTIONNAME).get();
+ assertNotNull(section);
+ try {
+ assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
+ assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
+ assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
+ } catch (ConversionException e) {
+ fail(e.getMessage());
+ }
+ this.init();
+
+ //write directly into base
+ confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ section = confiuration.addSection(SECTIONNAME);
+ confiuration.setProperty(SECTIONNAME, TESTKEY1, TESTVALUE1);
+ confiuration.setProperty(SECTIONNAME, TESTKEY2, TESTVALUE2);
+ confiuration.setProperty(SECTIONNAME, TESTKEY3, TESTVALUE3);
+ confiuration.save();
+
+ //verify
+ confiuration2 = new ConfigurationFileRepresentation(TESTFILENAME);
+ section = confiuration2.getSection(SECTIONNAME).get();
+ assertNotNull(section);
+ assertEquals(TESTVALUE1, confiuration.getPropertyLong(SECTIONNAME, TESTKEY1).get().intValue());
+ assertEquals(TESTVALUE2, confiuration.getPropertyBoolean(SECTIONNAME, TESTKEY2));
+ assertEquals(TESTVALUE3, confiuration.getProperty(SECTIONNAME, TESTKEY3));
+ this.init();
+
+
+ }
+
+ @Test
+ public void testOverwrite() {
+ final String SECTIONNAME = "test";
+ //write values
+ ConfigurationFileRepresentation confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ Section section = confiuration.addSection(SECTIONNAME);
+
+ section.setProperty(TESTKEY1, String.valueOf(TESTVALUE1));
+ section.setProperty(TESTKEY2, String.valueOf(TESTVALUE2));
+ section.setProperty(TESTKEY3, String.valueOf(TESTVALUE3));
+ confiuration.save();
+
+ //verify written
+ ConfigurationFileRepresentation confiuration2 = new ConfigurationFileRepresentation(TESTFILENAME);
+
+ section = confiuration2.getSection(SECTIONNAME).get();
+
+ assertNotNull(section);
+ try {
+ assertEquals(TESTVALUE1, section.getInt(TESTKEY1, 0));
+ assertEquals(TESTVALUE2, section.getBoolean(TESTKEY2, !TESTVALUE2));
+ assertEquals(TESTVALUE3, section.getString(TESTKEY3, ""));
+ } catch (ConversionException e) {
+ fail(e.getMessage());
+ }
+
+ //write directly into base
+ confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ section = confiuration.addSection(SECTIONNAME);
+ confiuration.setPropertyIfNotAvailable(SECTIONNAME, TESTKEY1, TESTVALUE1_2);
+ confiuration.setPropertyIfNotAvailable(SECTIONNAME, TESTKEY4, TESTVALUE4);
+
+ confiuration.save();
+
+ //verify
+ confiuration2 = new ConfigurationFileRepresentation(TESTFILENAME);
+ section = confiuration2.getSection(SECTIONNAME).get();
+ assertNotNull(section);
+ assertEquals(TESTVALUE1, confiuration.getPropertyLong(SECTIONNAME, TESTKEY1).get().intValue());
+ assertEquals(TESTVALUE2, confiuration.getPropertyBoolean(SECTIONNAME, TESTKEY2));
+ assertEquals(TESTVALUE3, confiuration.getProperty(SECTIONNAME, TESTKEY3));
+ assertEquals(TESTVALUE4, confiuration.getProperty(SECTIONNAME, TESTKEY4));
+ this.init();
+
+
+ }
+
+ static boolean changeFlag = false;
+
+ @Test
+ public void testChangeListener() {
+
+ changeFlag = false;
+ this.init();
+ ConfigurationFileRepresentation confiuration = new ConfigurationFileRepresentation(TESTFILENAME);
+ IConfigChangedListener listener = new IConfigChangedListener() {
+
+ @Override
+ public void onConfigChanged() {
+ changeFlag = true;
+ }
+ };
+ confiuration.registerConfigChangedListener(listener);
+ try {
+ Thread.sleep(2000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ this.write(TESTFILENAME, TESTCONTENT1);
+ int i = 10;
+ while (i-- > 0) {
+ try {
+ Thread.sleep(1000);
+ } catch (InterruptedException e) {
+ Thread.currentThread().interrupt();
+ }
+ if (changeFlag) {
+ break;
+ }
+ }
+ confiuration.unregisterConfigChangedListener(listener);
+ assertTrue("changelistener not called", changeFlag);
+ }
+
+ @Test
+ public void testHostInfo() {
+ HostInfo hi = HostInfo.getDefault();
+ try {
+ new URL(hi.toUrl());
+ } catch (MalformedURLException e) {
+ fail("url conversion failed: " + e.getMessage());
+ }
+ hi = new HostInfo("localhost", 44444, Protocol.getValueOf("https"));
+ try {
+ new URL(hi.toUrl());
+ } catch (MalformedURLException e) {
+ fail("url conversion failed: " + e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testEnvPropert() {
+ final String KEY = "basada";
+ Section section = new Section("test");
+ section.addLine(KEY + "=${USER} in ${HOME}");
+ section.parseLines();
+ assertTrue(section.getProperty(KEY).length() > " in ".length());
+ }
+
+ public static void setEnv(String key, String value) {
+ try {
+ Map<String, String> env = System.getenv();
+ Class<?> cl = env.getClass();
+ Field field = cl.getDeclaredField("m");
+ field.setAccessible(true);
+ Map<String, String> writableEnv = (Map<String, String>) field.get(env);
+ writableEnv.put(key, value);
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to set environment variable", e);
+ }
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java
index fc244f6b6..4d7cbdce9 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDatabaseFilterConversion.java
@@ -32,54 +32,60 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.DbFilter;
public class TestDatabaseFilterConversion {
- @Test
- public void testStartsWith() {
- String re=DbFilter.createDatabaseRegex("abc*");
- assertEquals("abc.*", re);
- }
- @Test
- public void testEndsWith() {
- String re=DbFilter.createDatabaseRegex("*abc");
- assertEquals(".*abc", re);
- }
- @Test
- public void testMultiple() {
- String re=DbFilter.createDatabaseRegex("abc*ff*fa");
- assertEquals("abc.*ff.*fa", re);
- }
-
- @Test
- public void testPlaceholder() {
- String re=DbFilter.createDatabaseRegex("abc?ef");
- assertEquals("abc.{1,1}ef", re);
- }
- @Test
- public void testCombined() {
- String re=DbFilter.createDatabaseRegex("abc?ff*fa");
- assertEquals("abc.{1,1}ff.*fa", re);
- }
- @Test
- public void testFilterCheck() {
- assertTrue(DbFilter.hasSearchParams("abc?"));
- assertTrue(DbFilter.hasSearchParams("bac*"));
- assertFalse(DbFilter.hasSearchParams("abc+"));
- }
- @Test
- public void testRangeConversion() {
- try {
- JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"gte\":2230,\"boost\":2}}}}",
- DbFilter.getRangeQuery("port", ">=2230").toJSON(),true);
- JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"gt\":2230,\"boost\":2}}}}",
- DbFilter.getRangeQuery("port", ">2230").toJSON(),true);
- JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"lte\":2230,\"boost\":2}}}}",
- DbFilter.getRangeQuery("port", "<=2230").toJSON(),true);
- JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"lt\":2230,\"boost\":2}}}}",
- DbFilter.getRangeQuery("port", "<2230").toJSON(),true);
- JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"timestamp\":{\"lt\":\"2018-01-01T23:59:59.0Z\",\"boost\":2}}}}",
- DbFilter.getRangeQuery("timestamp", "<2018-01-01T23:59:59.0Z").toJSON(),true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- }
-
+ @Test
+ public void testStartsWith() {
+ String re = DbFilter.createDatabaseRegex("abc*");
+ assertEquals("abc.*", re);
+ }
+
+ @Test
+ public void testEndsWith() {
+ String re = DbFilter.createDatabaseRegex("*abc");
+ assertEquals(".*abc", re);
+ }
+
+ @Test
+ public void testMultiple() {
+ String re = DbFilter.createDatabaseRegex("abc*ff*fa");
+ assertEquals("abc.*ff.*fa", re);
+ }
+
+ @Test
+ public void testPlaceholder() {
+ String re = DbFilter.createDatabaseRegex("abc?ef");
+ assertEquals("abc.{1,1}ef", re);
+ }
+
+ @Test
+ public void testCombined() {
+ String re = DbFilter.createDatabaseRegex("abc?ff*fa");
+ assertEquals("abc.{1,1}ff.*fa", re);
+ }
+
+ @Test
+ public void testFilterCheck() {
+ assertTrue(DbFilter.hasSearchParams("abc?"));
+ assertTrue(DbFilter.hasSearchParams("bac*"));
+ assertFalse(DbFilter.hasSearchParams("abc+"));
+ }
+
+ @Test
+ public void testRangeConversion() {
+ try {
+ JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"gte\":2230,\"boost\":2}}}}",
+ DbFilter.getRangeQuery("port", ">=2230").toJSON(), true);
+ JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"gt\":2230,\"boost\":2}}}}",
+ DbFilter.getRangeQuery("port", ">2230").toJSON(), true);
+ JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"lte\":2230,\"boost\":2}}}}",
+ DbFilter.getRangeQuery("port", "<=2230").toJSON(), true);
+ JSONAssert.assertEquals("", "{\"query\":{\"range\":{\"port\":{\"lt\":2230,\"boost\":2}}}}",
+ DbFilter.getRangeQuery("port", "<2230").toJSON(), true);
+ JSONAssert.assertEquals("",
+ "{\"query\":{\"range\":{\"timestamp\":{\"lt\":\"2018-01-01T23:59:59.0Z\",\"boost\":2}}}}",
+ DbFilter.getRangeQuery("timestamp", "<2018-01-01T23:59:59.0Z").toJSON(), true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ }
+
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
index 04259b9f6..cf9d93052 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbClient.java
@@ -40,154 +40,154 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
public class TestDbClient {
- private static HtDatabaseClient dbClient;
- private static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
- .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
-
- @BeforeClass
- public static void init() throws Exception {
-
- dbClient = new HtDatabaseClient(hosts);
- dbClient.waitForYellowStatus(20000);
-
- }
-
- @Test
- public void testCRUD() {
- final String IDX = "test23-knmoinsd";
- final String ID = "abcddd";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
-
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- clearIndexData(IDX);
- //Create
- String esId = dbClient.doWriteRaw(IDX, ID, JSON);
- assertEquals("inserted id is wrong", ID, esId);
- //Read
- SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 1, result.getTotal());
- assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
- //Update
- esId = dbClient.doUpdateOrCreate(IDX, ID, JSON2);
- assertEquals("update response not successfull", ID, esId);
- //check that update with null fails
- assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
- //Verify update
- result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 1, result.getTotal());
- assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
- //test second read
- String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
-
- @Override
- public void setEsId(String id) {
-
- }
-
- @Override
- public String getEsId() {
- return ID;
- }
- });
- //test all read
- result = dbClient.doReadAllJsonData(IDX);
- assertNotNull("all read not working", result);
-
- assertEquals("read works not as expected", JSON2, resStr);
- //Delete
- boolean del = dbClient.doRemove(IDX, new IsEsObject() {
-
- @Override
- public void setEsId(String id) {
-
- }
-
- @Override
- public String getEsId() {
- return ID;
- }
- });
- assertTrue("item not deleted", del);
- //Verify
- result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 0, result.getTotal());
-
- }
-
- /**
- * @param iDX
- */
- private void clearIndexData(String idx) {
- try {
- dbClient.deleteByQuery(new DeleteByQueryRequest(idx, true).source(QueryBuilders.matchAllQuery()));
- } catch (IOException e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }
-
- }
-
- @Test
- public void testCRUD2() {
- final String IDX = "test23-knmoins3d";
- final String ID = "abcddd";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- //Create
- String esId = dbClient.doWriteRaw(IDX, ID, JSON);
- assertEquals("inserted id is wrong", ID, esId);
- //Read
- SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 1, result.getTotal());
- assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
- QueryBuilder matchQuery = QueryBuilders.matchQuery("_id", ID);
- //Update
- assertTrue("update response not successfull", dbClient.doUpdate(IDX, JSON2, matchQuery));
- //check that update with null fails
- assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
- //Verify update
- result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 1, result.getTotal());
- assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
- //test second read
- String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
-
- @Override
- public void setEsId(String id) {
-
- }
-
- @Override
- public String getEsId() {
- return ID;
- }
- });
- //test all read
- result = dbClient.doReadAllJsonData(IDX);
- assertNotNull("all read not working", result);
-
- assertEquals("read works not as expected", JSON2, resStr);
- //Delete
- int del = dbClient.doRemove(IDX, matchQuery);
- assertTrue("item not deleted", del > 0);
- //Verify
- result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
- assertEquals("amount of results is wrong", 0, result.getTotal());
-
- }
+ private static HtDatabaseClient dbClient;
+ private static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))};
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ dbClient = new HtDatabaseClient(hosts);
+ dbClient.waitForYellowStatus(20000);
+
+ }
+
+ @Test
+ public void testCRUD() {
+ final String IDX = "test23-knmoinsd";
+ final String ID = "abcddd";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
+
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ clearIndexData(IDX);
+ //Create
+ String esId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertEquals("inserted id is wrong", ID, esId);
+ //Read
+ SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
+ //Update
+ esId = dbClient.doUpdateOrCreate(IDX, ID, JSON2);
+ assertEquals("update response not successfull", ID, esId);
+ //check that update with null fails
+ assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
+ //Verify update
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
+ //test second read
+ String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
+
+ @Override
+ public void setEsId(String id) {
+
+ }
+
+ @Override
+ public String getEsId() {
+ return ID;
+ }
+ });
+ //test all read
+ result = dbClient.doReadAllJsonData(IDX);
+ assertNotNull("all read not working", result);
+
+ assertEquals("read works not as expected", JSON2, resStr);
+ //Delete
+ boolean del = dbClient.doRemove(IDX, new IsEsObject() {
+
+ @Override
+ public void setEsId(String id) {
+
+ }
+
+ @Override
+ public String getEsId() {
+ return ID;
+ }
+ });
+ assertTrue("item not deleted", del);
+ //Verify
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 0, result.getTotal());
+
+ }
+
+ /**
+ * @param iDX
+ */
+ private void clearIndexData(String idx) {
+ try {
+ dbClient.deleteByQuery(new DeleteByQueryRequest(idx, true).source(QueryBuilders.matchAllQuery()));
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }
+
+ }
+
+ @Test
+ public void testCRUD2() {
+ final String IDX = "test23-knmoins3d";
+ final String ID = "abcddd";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ //Create
+ String esId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertEquals("inserted id is wrong", ID, esId);
+ //Read
+ SearchResult<SearchHit> result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON, result.getHits().get(0).getSourceAsString());
+ QueryBuilder matchQuery = QueryBuilders.matchQuery("_id", ID);
+ //Update
+ assertTrue("update response not successfull", dbClient.doUpdate(IDX, JSON2, matchQuery));
+ //check that update with null fails
+ assertNull("update with id null should not be possible", dbClient.doUpdateOrCreate(IDX, null, JSON2));
+ //Verify update
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 1, result.getTotal());
+ assertEquals("data not valid", JSON2, result.getHits().get(0).getSourceAsString());
+ //test second read
+ String resStr = dbClient.doReadJsonData(IDX, new IsEsObject() {
+
+ @Override
+ public void setEsId(String id) {
+
+ }
+
+ @Override
+ public String getEsId() {
+ return ID;
+ }
+ });
+ //test all read
+ result = dbClient.doReadAllJsonData(IDX);
+ assertNotNull("all read not working", result);
+
+ assertEquals("read works not as expected", JSON2, resStr);
+ //Delete
+ int del = dbClient.doRemove(IDX, matchQuery);
+ assertTrue("item not deleted", del > 0);
+ //Verify
+ result = dbClient.doReadByQueryJsonData(IDX, QueryBuilders.matchQuery("_id", ID));
+ assertEquals("amount of results is wrong", 0, result.getTotal());
+
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
index 93d4b1af6..127908c08 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbQueries.java
@@ -35,252 +35,167 @@ import org.onap.ccsdk.features.sdnr.wt.common.test.JSONAssert;
public class TestDbQueries {
- private static final String MATCH_ALL_QUERY = "{\n" +
- " \"query\": {\n" +
- " \"match_all\" : {\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String MATCH_QUERY_KEY = "is-required";
- private static final Object MATCH_QUERY_VALUE = true;
- private static final String MATCH_QUERY = "{\n" +
- " \"query\": {\n" +
- " \"match\" : {\n" +
- " \""+MATCH_QUERY_KEY+"\" : "+MATCH_QUERY_VALUE+"\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String MATCH_QUERY_KEY2 = "node-id";
- private static final Object MATCH_QUERY_VALUE2 = "sim2";
- private static final String BOOL_QUERY_MUST = "{\n" +
- " \"query\": {\n" +
- " \"bool\": {\n" +
- " \"must\": [\n" +
- " {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY2+"\":"+MATCH_QUERY_VALUE2+" \n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String BOOL_QUERY_MUST_SINGLE = "{\n" +
- " \"query\": {\n" +
- " \"bool\": {\n" +
- " \"must\": {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String BOOL_QUERY_SHOULD = "{\n" +
- " \"query\": {\n" +
- " \"bool\": {\n" +
- " \"should\": [\n" +
- " {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY2+"\":"+MATCH_QUERY_VALUE2+" \n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String BOOL_QUERY_SHOULD_SINGLE = "{\n" +
- " \"query\": {\n" +
- " \"bool\": {\n" +
- " \"should\": {\n" +
- " \"match\": {\n" +
- " \""+MATCH_QUERY_KEY+"\": "+MATCH_QUERY_VALUE+"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String RANGE_QUERY_KEY = "timestamp";
- private static final String RANGE_QUERY_LTEND = "2017-08-10T20:00:00.0Z";
- private static final String RANGE_QUERY = "{\n" +
- " \"query\": {\n" +
- " \"range\" : {\n" +
- " \""+RANGE_QUERY_KEY+"\" : {\n" +
- " \"lte\" : \""+RANGE_QUERY_LTEND+"\",\n" +
- " \"boost\": 2.0\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String RANGEBOOL_QUERY="{\n" +
- " \"query\": {\n" +
- " \"bool\": {\n" +
- " \"must\": [\n" +
- " {\n" +
- " \"match\": {\n" +
- " \"is-required\": true\n" +
- " }\n" +
- " },\n" +
- " {\n" +
- " \"regexp\": {\n" +
- " \"node-id\": {\n" +
- " \"max_determinized_states\": 10000,\n" +
- " \"flags\": \"ALL\",\n" +
- " \"value\": \"sim.*\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String AGG_FIELD = "severity";
- private static final String AGG_QUERY = "{\n" +
- " \"query\": {\n" +
- " \"match_all\": {}\n" +
- " },\n" +
- " \"aggs\": {\n" +
- " \"severity\": {\n" +
- " \"terms\": {\n" +
- " \"field\": \""+AGG_FIELD+"\"\n" +
- " }\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final long FROMANDSIZE_QUERY_SIZE = 20;
- private static final long FROMANDSIZE_QUERY_FROM = 120;
- private static final String FROMANDSIZE_QUERY = "{\n" +
- " \"size\": "+FROMANDSIZE_QUERY_SIZE+",\n" +
- " \"query\": {\n" +
- " \"match_all\": {}\n" +
- " },\n" +
- " \"from\":"+FROMANDSIZE_QUERY_FROM+"\n" +
- "}";
- private static final String TERMQUERY_KEY = "node-id";
- private static final String TERMQUERY_VALUE = "abc";
- private static final String TERM_QUERY = "{\n" +
- " \"query\": {\n" +
- " \"term\": {\n" +
- " \""+TERMQUERY_KEY+"\": \""+TERMQUERY_VALUE+"\"\n" +
- " }\n" +
- " }\n" +
- "}";
- private static final String SORTING_PROPERTY = "node-id";
- private static final String SORTING_QUERY_ASC = "{\n" +
- " \"query\": {\n" +
- " \"match_all\": {}\n" +
- " },\n" +
- " \"sort\": [\n" +
- " {\n" +
- " \""+SORTING_PROPERTY+"\": {\n" +
- " \"order\": \"asc\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- "}";
- private static final String SORTING_QUERY_DESC = "{\n" +
- " \"query\": {\n" +
- " \"match_all\": {}\n" +
- " },\n" +
- " \"sort\": [\n" +
- " {\n" +
- " \""+SORTING_PROPERTY+"\": {\n" +
- " \"order\": \"desc\"\n" +
- " }\n" +
- " }\n" +
- " ]\n" +
- "}";
-
- private void testEquals(String message,String json, QueryBuilder query) {
- this.testEquals(message, json, query,true);
- }
- private void testEquals(String message,String json, QueryBuilder query,boolean strict) {
-
- try {
- System.out.println("===test if "+message+"===================");
- System.out.println("orig : "+trim(json));
- System.out.println("totest: "+query.toJSON().trim());
- JSONAssert.assertEquals(json,query.toJSON(),strict);
- } catch (JSONException e) {
- fail(message);
- }
- }
-
- private String trim(String json) {
- return json.trim().replaceAll("\n","").replaceAll(" ", "");
- }
+ private static final String MATCH_ALL_QUERY =
+ "{\n" + " \"query\": {\n" + " \"match_all\" : {\n" + " }\n" + " }\n" + "}";
+ private static final String MATCH_QUERY_KEY = "is-required";
+ private static final Object MATCH_QUERY_VALUE = true;
+ private static final String MATCH_QUERY = "{\n" + " \"query\": {\n" + " \"match\" : {\n"
+ + " \"" + MATCH_QUERY_KEY + "\" : " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n" + "}";
+ private static final String MATCH_QUERY_KEY2 = "node-id";
+ private static final Object MATCH_QUERY_VALUE2 = "sim2";
+ private static final String BOOL_QUERY_MUST =
+ "{\n" + " \"query\": {\n" + " \"bool\": {\n" + " \"must\": [\n" + " {\n"
+ + " \"match\": {\n" + " \"" + MATCH_QUERY_KEY + "\": "
+ + MATCH_QUERY_VALUE + "\n" + " }\n" + " },\n"
+ + " {\n" + " \"match\": {\n" + " \""
+ + MATCH_QUERY_KEY2 + "\":" + MATCH_QUERY_VALUE2 + " \n" + " }\n"
+ + " }\n" + " ]\n" + " }\n" + " }\n" + "}";
+ private static final String BOOL_QUERY_MUST_SINGLE = "{\n" + " \"query\": {\n" + " \"bool\": {\n"
+ + " \"must\": {\n" + " \"match\": {\n" + " \""
+ + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n"
+ + " }\n" + " }\n" + "}";
+ private static final String BOOL_QUERY_SHOULD = "{\n" + " \"query\": {\n" + " \"bool\": {\n"
+ + " \"should\": [\n" + " {\n" + " \"match\": {\n"
+ + " \"" + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n"
+ + " }\n" + " },\n" + " {\n"
+ + " \"match\": {\n" + " \"" + MATCH_QUERY_KEY2 + "\":"
+ + MATCH_QUERY_VALUE2 + " \n" + " }\n" + " }\n" + " ]\n"
+ + " }\n" + " }\n" + "}";
+ private static final String BOOL_QUERY_SHOULD_SINGLE = "{\n" + " \"query\": {\n" + " \"bool\": {\n"
+ + " \"should\": {\n" + " \"match\": {\n" + " \""
+ + MATCH_QUERY_KEY + "\": " + MATCH_QUERY_VALUE + "\n" + " }\n" + " }\n"
+ + " }\n" + " }\n" + "}";
+ private static final String RANGE_QUERY_KEY = "timestamp";
+ private static final String RANGE_QUERY_LTEND = "2017-08-10T20:00:00.0Z";
+ private static final String RANGE_QUERY = "{\n" + " \"query\": {\n" + " \"range\" : {\n"
+ + " \"" + RANGE_QUERY_KEY + "\" : {\n" + " \"lte\" : \"" + RANGE_QUERY_LTEND
+ + "\",\n" + " \"boost\": 2.0\n" + " }\n" + " }\n" + " }\n" + "}";
+ private static final String RANGEBOOL_QUERY = "{\n" + " \"query\": {\n" + " \"bool\": {\n"
+ + " \"must\": [\n" + " {\n" + " \"match\": {\n"
+ + " \"is-required\": true\n" + " }\n" + " },\n"
+ + " {\n" + " \"regexp\": {\n" + " \"node-id\": {\n"
+ + " \"max_determinized_states\": 10000,\n"
+ + " \"flags\": \"ALL\",\n" + " \"value\": \"sim.*\"\n"
+ + " }\n" + " }\n" + " }\n" + " ]\n"
+ + " }\n" + " }\n" + "}";
+ private static final String AGG_FIELD = "severity";
+ private static final String AGG_QUERY =
+ "{\n" + " \"query\": {\n" + " \"match_all\": {}\n" + " },\n" + " \"aggs\": {\n"
+ + " \"severity\": {\n" + " \"terms\": {\n" + " \"field\": \""
+ + AGG_FIELD + "\"\n" + " }\n" + " }\n" + " }\n" + "}";
+ private static final long FROMANDSIZE_QUERY_SIZE = 20;
+ private static final long FROMANDSIZE_QUERY_FROM = 120;
+ private static final String FROMANDSIZE_QUERY = "{\n" + " \"size\": " + FROMANDSIZE_QUERY_SIZE + ",\n"
+ + " \"query\": {\n" + " \"match_all\": {}\n" + " },\n" + " \"from\":"
+ + FROMANDSIZE_QUERY_FROM + "\n" + "}";
+ private static final String TERMQUERY_KEY = "node-id";
+ private static final String TERMQUERY_VALUE = "abc";
+ private static final String TERM_QUERY = "{\n" + " \"query\": {\n" + " \"term\": {\n" + " \""
+ + TERMQUERY_KEY + "\": \"" + TERMQUERY_VALUE + "\"\n" + " }\n" + " }\n" + "}";
+ private static final String SORTING_PROPERTY = "node-id";
+ private static final String SORTING_QUERY_ASC = "{\n" + " \"query\": {\n" + " \"match_all\": {}\n"
+ + " },\n" + " \"sort\": [\n" + " {\n" + " \"" + SORTING_PROPERTY + "\": {\n"
+ + " \"order\": \"asc\"\n" + " }\n" + " }\n" + " ]\n" + "}";
+ private static final String SORTING_QUERY_DESC = "{\n" + " \"query\": {\n" + " \"match_all\": {}\n"
+ + " },\n" + " \"sort\": [\n" + " {\n" + " \"" + SORTING_PROPERTY + "\": {\n"
+ + " \"order\": \"desc\"\n" + " }\n" + " }\n" + " ]\n" + "}";
- @Test
- public void testMatchAll() {
- testEquals("match all query is wrong", MATCH_ALL_QUERY, QueryBuilders.matchAllQuery());
- }
- @Test
- public void testMatch() {
- testEquals("match query is wrong", MATCH_QUERY, QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE));
- }
- @Test
- public void testBoolMust() {
- testEquals("bool query is wrong", BOOL_QUERY_MUST,
- QueryBuilders.boolQuery().
- must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)).
- must(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
- }
- @Test
- public void testBoolMustSingle() {
- testEquals("bool single query is wrong", BOOL_QUERY_MUST_SINGLE,
- QueryBuilders.boolQuery().
- must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
- }
- @Test
- public void testBoolShould() {
- testEquals("bool query is wrong", BOOL_QUERY_SHOULD,
- QueryBuilders.boolQuery().
- should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)).
- should(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
- }
- @Test
- public void testBoolShouldSingle() {
- testEquals("bool single query is wrong", BOOL_QUERY_SHOULD_SINGLE,
- QueryBuilders.boolQuery().
- should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
- }
- @Test
- public void testRange() {
- testEquals("range query is wrong", RANGE_QUERY, QueryBuilders.rangeQuery(RANGE_QUERY_KEY).lte(RANGE_QUERY_LTEND));
-
- }
- @Test
- public void testAggregation() {
- testEquals("aggregation query is wrong",AGG_QUERY, QueryBuilders.matchAllQuery().aggregations(AGG_FIELD));
- }
- @Test
- public void testSizeAndFrom() {
- testEquals("aggregation query is wrong",FROMANDSIZE_QUERY, QueryBuilders.matchAllQuery().size(FROMANDSIZE_QUERY_SIZE).from(FROMANDSIZE_QUERY_FROM));
- }
- @Test
- public void testRegex() {
- testEquals("range and bool query is wrong1",RANGEBOOL_QUERY,QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("is-required", true)).must(QueryBuilders.regex("node-id", DbFilter.createDatabaseRegex("sim*"))),false);
- BoolQueryBuilder q = QueryBuilders.boolQuery().must(QueryBuilders.regex("node-id", DbFilter.createDatabaseRegex("sim*")));
- q.must(QueryBuilders.matchQuery("is-required", true));
- testEquals("range and bool query is wrong2",RANGEBOOL_QUERY,q,false);
- }
- @Test
- public void testTerm() {
- testEquals("term query is wrong", TERM_QUERY, QueryBuilders.termQuery(TERMQUERY_KEY, TERMQUERY_VALUE));
- }
- @Test
- public void testSorting() {
- testEquals("sortorder is wrong",SORTING_QUERY_ASC, QueryBuilders.matchAllQuery().sort(SORTING_PROPERTY, SortOrder.ASCENDING));
- testEquals("sortorder is wrong",SORTING_QUERY_DESC, QueryBuilders.matchAllQuery().sort(SORTING_PROPERTY, SortOrder.DESCENDING));
- }
+ private void testEquals(String message, String json, QueryBuilder query) {
+ this.testEquals(message, json, query, true);
+ }
+
+ private void testEquals(String message, String json, QueryBuilder query, boolean strict) {
+
+ try {
+ System.out.println("===test if " + message + "===================");
+ System.out.println("orig : " + trim(json));
+ System.out.println("totest: " + query.toJSON().trim());
+ JSONAssert.assertEquals(json, query.toJSON(), strict);
+ } catch (JSONException e) {
+ fail(message);
+ }
+ }
+
+ private String trim(String json) {
+ return json.trim().replaceAll("\n", "").replaceAll(" ", "");
+ }
+
+ @Test
+ public void testMatchAll() {
+ testEquals("match all query is wrong", MATCH_ALL_QUERY, QueryBuilders.matchAllQuery());
+ }
+
+ @Test
+ public void testMatch() {
+ testEquals("match query is wrong", MATCH_QUERY, QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE));
+ }
+
+ @Test
+ public void testBoolMust() {
+ testEquals("bool query is wrong", BOOL_QUERY_MUST,
+ QueryBuilders.boolQuery().must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE))
+ .must(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
+ }
+
+ @Test
+ public void testBoolMustSingle() {
+ testEquals("bool single query is wrong", BOOL_QUERY_MUST_SINGLE,
+ QueryBuilders.boolQuery().must(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
+ }
+
+ @Test
+ public void testBoolShould() {
+ testEquals("bool query is wrong", BOOL_QUERY_SHOULD,
+ QueryBuilders.boolQuery().should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE))
+ .should(QueryBuilders.matchQuery(MATCH_QUERY_KEY2, MATCH_QUERY_VALUE2)));
+ }
+
+ @Test
+ public void testBoolShouldSingle() {
+ testEquals("bool single query is wrong", BOOL_QUERY_SHOULD_SINGLE,
+ QueryBuilders.boolQuery().should(QueryBuilders.matchQuery(MATCH_QUERY_KEY, MATCH_QUERY_VALUE)));
+ }
+
+ @Test
+ public void testRange() {
+ testEquals("range query is wrong", RANGE_QUERY,
+ QueryBuilders.rangeQuery(RANGE_QUERY_KEY).lte(RANGE_QUERY_LTEND));
+
+ }
+
+ @Test
+ public void testAggregation() {
+ testEquals("aggregation query is wrong", AGG_QUERY, QueryBuilders.matchAllQuery().aggregations(AGG_FIELD));
+ }
+
+ @Test
+ public void testSizeAndFrom() {
+ testEquals("aggregation query is wrong", FROMANDSIZE_QUERY,
+ QueryBuilders.matchAllQuery().size(FROMANDSIZE_QUERY_SIZE).from(FROMANDSIZE_QUERY_FROM));
+ }
+
+ @Test
+ public void testRegex() {
+ testEquals("range and bool query is wrong1", RANGEBOOL_QUERY,
+ QueryBuilders.boolQuery().must(QueryBuilders.matchQuery("is-required", true))
+ .must(QueryBuilders.regex("node-id", DbFilter.createDatabaseRegex("sim*"))),
+ false);
+ BoolQueryBuilder q =
+ QueryBuilders.boolQuery().must(QueryBuilders.regex("node-id", DbFilter.createDatabaseRegex("sim*")));
+ q.must(QueryBuilders.matchQuery("is-required", true));
+ testEquals("range and bool query is wrong2", RANGEBOOL_QUERY, q, false);
+ }
+
+ @Test
+ public void testTerm() {
+ testEquals("term query is wrong", TERM_QUERY, QueryBuilders.termQuery(TERMQUERY_KEY, TERMQUERY_VALUE));
+ }
+
+ @Test
+ public void testSorting() {
+ testEquals("sortorder is wrong", SORTING_QUERY_ASC,
+ QueryBuilders.matchAllQuery().sort(SORTING_PROPERTY, SortOrder.ASCENDING));
+ testEquals("sortorder is wrong", SORTING_QUERY_DESC,
+ QueryBuilders.matchAllQuery().sort(SORTING_PROPERTY, SortOrder.DESCENDING));
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
index 2226c5e7e..756d70c85 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestDbRequests.java
@@ -73,491 +73,491 @@ import org.json.JSONObject;
public class TestDbRequests {
- private static HtDatabaseClient dbClient;
- private static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
- .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
-
- @BeforeClass
- public static void init() throws Exception {
-
- dbClient = new HtDatabaseClient(hosts);
-
- }
-
- @AfterClass
- public static void deinit() {
- if (dbClient != null) {
- dbClient.close();
- }
- }
-
- @Test
- public void testHealth() {
-
- ClusterHealthResponse response = null;
- ClusterHealthRequest request = new ClusterHealthRequest();
- request.timeout(10);
- try {
- response = dbClient.health(request);
- } catch (UnsupportedOperationException | IOException | JSONException e) {
- fail(e.getMessage());
- }
- assertNotNull("response is null", response);
- assertTrue(response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW));
- }
-
- @Test
- public void testCount() {
-
- }
-
- @Test
- public void testIndexAndAliasList() {
- final String ALIAS = "asdoi32kmsasd";
- final String IDX = ALIAS + "-v1";
- CreateIndexRequest request = new CreateIndexRequest(IDX);
- CreateIndexResponse response = null;
- try {
- response = dbClient.createIndex(request);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
-
- CreateAliasRequest request3 = new CreateAliasRequest(IDX, ALIAS);
- CreateAliasResponse response3 = null;
- try {
- response3 = dbClient.createAlias(request3);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response3);
- assertTrue(response3.isResponseSucceeded());
-
- assertTrue("index not existing", dbClient.isExistsIndex(IDX));
- ListIndicesResponse response2 = null;
- try {
- response2 = dbClient.getIndices();
- } catch (ParseException | IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response2);
- assertNotNull(response2.getEntries());
- assertTrue(response2.getEntries().size() > 0);
-
- DeleteIndexRequest request11 = new DeleteIndexRequest(IDX);
-
- DeleteIndexResponse response11 = null;
- try {
- response11 = dbClient.deleteIndex(request11);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response11);
- assertFalse("index still existing", dbClient.isExistsIndex(IDX));
- this.deleteAlias(IDX, ALIAS);
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testCreateAndDeleteIndex() {
- final String IDX = "testcidx1";
- CreateIndexRequest request = new CreateIndexRequest(IDX);
- CreateIndexResponse response = null;
- try {
- response = dbClient.createIndex(request);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
-
- assertTrue("index not existing", dbClient.isExistsIndex(IDX));
-
- DeleteIndexRequest request2 = new DeleteIndexRequest(IDX);
-
- DeleteIndexResponse response2 = null;
- try {
- response2 = dbClient.deleteIndex(request2);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response2);
- assertFalse("index still existing", dbClient.isExistsIndex(IDX));
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testInsertAndDelete() {
- final String IDX = "tesnt23-knmoinsd";
- final String ID = "abcddd";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX).mappings(defaultMappings(IDX, false)));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- this.insert(IDX, ID, JSON);
- // delete data
- DeleteRequest request2 = new DeleteRequest(IDX, IDX, ID);
- DeleteResponse response2 = null;
- try {
- response2 = dbClient.delete(request2);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response2);
- assertTrue(response2.isDeleted());
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- // verify data deleted
- GetRequest request4 = new GetRequest(IDX, IDX, ID);
- GetResponse response4 = null;
- try {
- response4 = dbClient.get(request4);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- assertNotNull(response4);
- assertFalse("data still existing", response4.isExists());
- this.deleteIndex(IDX);
- }
-
- /**
- * @param b
- * @return
- */
- private JSONObject defaultMappings(String idx, boolean useStrict) {
- String mapping = "{}";
- return new JSONObject(String.format("{\"%s\":{%s\"properties\":%s}}", idx,
- useStrict ? "\"dynamic\": false," : "\"dynamic\": true,", mapping));
- }
-
- @Test
- public void testInsertAndDeleteByQuery() {
- final String IDX = "test534-knmoinsd";
- final String ID = "abcdddseae";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- this.insert(IDX, ID, JSON);
-
- // delete data
- DeleteByQueryRequest request2 = new DeleteByQueryRequest(IDX);
- request2.source(QueryBuilders.matchQuery("_id", ID));
- DeleteByQueryResponse response2 = null;
- try {
- response2 = dbClient.deleteByQuery(request2);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response2);
- assertTrue(response2.isResponseSucceeded());
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- // verify data deleted
- GetRequest request4 = new GetRequest(IDX, IDX, ID);
- GetResponse response4 = null;
- try {
- response4 = dbClient.get(request4);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- assertNotNull(response4);
- assertFalse("data still existing", response4.isExists());
- this.deleteIndex(IDX);
- }
-
- private void insert(String IDX, String ID, String JSON) {
-
- // create data
- IndexRequest request = new IndexRequest(IDX, IDX, ID);
- request.source(JSON);
- String responseId = null;
- responseId = dbClient.doWriteRaw(IDX, ID, JSON);
- assertNotNull(responseId);
- if (ID != null) {
- assertEquals("id not correct", ID, responseId);
- } else {
- ID = responseId;
- }
- // do db refresh
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- // verify data exists
- String response3 = null;
- response3 = dbClient.doReadJsonData(IDX, ID);
- assertNotNull(response3);
- JSONAssert.assertEquals("could not verify update", JSON, response3, true);
- }
-
- @Test
- public void testSearch() {
- final String IDX = "testb44-moinsd";
- final String ID = "abe";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- final String ID2 = "abe2";
- final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
- final String ID3 = "abe3";
- final String JSON3 = "{\"data\":{\"inner\":\"more3\"}}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- this.insert(IDX, ID, JSON);
- this.insert(IDX, ID2, JSON2);
- this.insert(IDX, ID3, JSON3);
- SearchRequest request = new SearchRequest(IDX, IDX);
- request.setQuery(QueryBuilders.matchAllQuery());
- SearchResponse response = null;
- try {
- response = dbClient.search(request);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertEquals("not all items found", 3, response.getHits().length);
- assertEquals("incorrect index", IDX, response.getHits()[0].getIndex());
- assertEquals("incorrect type", IDX, response.getHits()[0].getType());
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testUpdate() {
- final String IDX = "test45134-moinsd";
- final String ID = "assbe";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- this.insert(IDX, ID, JSON);
- UpdateRequest request = new UpdateRequest(IDX, IDX, ID);
- UpdateResponse response = null;
- try {
- request.source(new JSONObject(JSON2));
- response = dbClient.update(request);
- } catch (JSONException | IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertTrue(response.succeeded());
- // refresh index
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- // verify update
- GetRequest request3 = new GetRequest(IDX, IDX, ID);
- GetResponse response3 = null;
- try {
- response3 = dbClient.get(request3);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- assertNotNull(response3);
- JSONAssert.assertEquals("could not verify update", JSON2, response3.getSourceAsBytesRef(), true);
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testUpdateByQuery() {
- final String IDX = "test224534k-moinsd";
- final String ID = "asssabe";
- final String JSON = "{\"data\":{\"inner\":\"more\"}}";
- final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
- try {
- if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
- dbClient.createIndex(new CreateIndexRequest(IDX));
- }
- } catch (IOException e) {
- fail("unable to create index");
- }
- this.insert(IDX, ID, JSON);
- UpdateByQueryRequest request = new UpdateByQueryRequest(IDX, IDX);
- UpdateByQueryResponse response = null;
- try {
- request.source(ID, new JSONObject(JSON2));
- response = dbClient.update(request);
- } catch (JSONException | IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertTrue(response.isUpdated());
- // refresh index
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- // verify update
- GetRequest request3 = new GetRequest(IDX, IDX, ID);
- GetResponse response3 = null;
- try {
- response3 = dbClient.get(request3);
- } catch (IOException e1) {
- fail(e1.getMessage());
- }
- assertNotNull(response3);
- JSONAssert.assertEquals("could not verify update", JSON2, response3.getSourceAsBytesRef(), true);
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testAggregations() {
- final String IDX = "test3227533677-moisnsd";
- final String JSON = "{ \"node-id\":\"sim1\",\"severity\":\"critical\"}";
- final String JSON2 = "{ \"node-id\":\"sim2\",\"severity\":\"critical\"}";
- final String JSON3 = "{ \"node-id\":\"sim3\",\"severity\":\"minor\"}";
- final String JSON4 = "{ \"node-id\":\"sim4\",\"severity\":\"warning\"}";
- final String JSON5 = "{ \"node-id\":\"sim5\",\"severity\":\"major\"}";
- final String MAPPINGS = String.format("{\"" + IDX + "\":{\"properties\":%s}}",
- "{\"node-id\":{\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"}}");
- // create index with mapping keyword
- CreateIndexResponse iresponse = null;
- try {
- if (!dbClient.isExistsIndex(IDX)) {
- iresponse = dbClient.createIndex(new CreateIndexRequest(IDX).mappings(new JSONObject(MAPPINGS)));
- assertNotNull(iresponse);
- assertTrue(iresponse.isAcknowledged());
- }
- } catch (IOException e1) {
- this.deleteIndex(IDX);
- fail("unable to create index: " + e1.getMessage());
- }
-
- // fill index
- this.insert(IDX, null, JSON);
- this.insert(IDX, null, JSON2);
- this.insert(IDX, null, JSON3);
- this.insert(IDX, null, JSON4);
- this.insert(IDX, null, JSON5);
- // refresh index
- try {
- dbClient.refreshIndex(new RefreshIndexRequest(IDX));
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
- SearchRequest request = new SearchRequest(IDX, IDX);
- request.setQuery(QueryBuilders.matchAllQuery().aggregations("severity").size(0));
- SearchResponse response = null;
- try {
- response = dbClient.search(request);
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(response);
- assertTrue(response.hasAggregations());
- assertEquals("aggregation size not correct", 4, response.getAggregations("severity").size());
-
- List<String> items1 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 0));
- List<String> items2 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 2));
- assertEquals("pagination does not work", 2, items1.size());
- assertEquals("pagination does not work", 2, items2.size());
- for (String s : items1) {
- assertFalse("pagination overlap is not allowed", items2.contains(s));
- }
- for (String s : items2) {
- assertFalse("pagination overlap is not allowed", items1.contains(s));
- }
-
- this.deleteIndex(IDX);
- }
-
- @Test
- public void testStatistics() {
- NodeStatsResponse stats = null;
- try {
- stats = dbClient.stats(new NodeStatsRequest());
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(stats);
- System.out.println(stats.getNodesInfo());
- System.out.println(stats.getNodeStatistics());
- }
-
- // @Test
- public void testPreventAutoCreateIndex() {
- final String IDX1 = "acidx1";
- final String ID1 = "acid1";
- final String IDX2 = "acidx2";
- final String ID2 = "acid2";
- final String OBJ = "{\"test\":5}";
-
- ClusterSettingsResponse settingsResponse = null;
- String esId = null;
- // set setting to allow autocreate
- try {
- settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(settingsResponse);
- assertTrue(settingsResponse.isAcknowledged());
- // test if something new can be created
- esId = dbClient.doWriteRaw(IDX1, IDX1, ID1, OBJ);
- assertEquals(ID1, esId);
- // set setting to deny autocreate
- try {
- settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(settingsResponse);
- assertTrue(settingsResponse.isAcknowledged());
- // test if something new cannot be created
- esId = dbClient.doWriteRaw(IDX2, IDX2, ID2, OBJ);
- assertNull(esId);
- // set setting to allow autocreate
- try {
- settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
- } catch (IOException e) {
- fail(e.getMessage());
- }
- assertNotNull(settingsResponse);
- assertTrue(settingsResponse.isAcknowledged());
-
- }
-
- private void deleteAlias(String idx, String alias) {
- try {
- dbClient.deleteAlias(new DeleteAliasRequest(idx, alias));
- } catch (IOException e) {
-
- }
- }
-
- private void deleteIndex(String idx) {
- try {
- dbClient.deleteIndex(new DeleteIndexRequest(idx));
- } catch (IOException e) {
-
- }
- }
+ private static HtDatabaseClient dbClient;
+ private static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))};
+
+ @BeforeClass
+ public static void init() throws Exception {
+
+ dbClient = new HtDatabaseClient(hosts);
+
+ }
+
+ @AfterClass
+ public static void deinit() {
+ if (dbClient != null) {
+ dbClient.close();
+ }
+ }
+
+ @Test
+ public void testHealth() {
+
+ ClusterHealthResponse response = null;
+ ClusterHealthRequest request = new ClusterHealthRequest();
+ request.timeout(10);
+ try {
+ response = dbClient.health(request);
+ } catch (UnsupportedOperationException | IOException | JSONException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull("response is null", response);
+ assertTrue(response.isStatusMinimal(ClusterHealthResponse.HEALTHSTATUS_YELLOW));
+ }
+
+ @Test
+ public void testCount() {
+
+ }
+
+ @Test
+ public void testIndexAndAliasList() {
+ final String ALIAS = "asdoi32kmsasd";
+ final String IDX = ALIAS + "-v1";
+ CreateIndexRequest request = new CreateIndexRequest(IDX);
+ CreateIndexResponse response = null;
+ try {
+ response = dbClient.createIndex(request);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+
+ CreateAliasRequest request3 = new CreateAliasRequest(IDX, ALIAS);
+ CreateAliasResponse response3 = null;
+ try {
+ response3 = dbClient.createAlias(request3);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response3);
+ assertTrue(response3.isResponseSucceeded());
+
+ assertTrue("index not existing", dbClient.isExistsIndex(IDX));
+ ListIndicesResponse response2 = null;
+ try {
+ response2 = dbClient.getIndices();
+ } catch (ParseException | IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response2);
+ assertNotNull(response2.getEntries());
+ assertTrue(response2.getEntries().size() > 0);
+
+ DeleteIndexRequest request11 = new DeleteIndexRequest(IDX);
+
+ DeleteIndexResponse response11 = null;
+ try {
+ response11 = dbClient.deleteIndex(request11);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response11);
+ assertFalse("index still existing", dbClient.isExistsIndex(IDX));
+ this.deleteAlias(IDX, ALIAS);
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testCreateAndDeleteIndex() {
+ final String IDX = "testcidx1";
+ CreateIndexRequest request = new CreateIndexRequest(IDX);
+ CreateIndexResponse response = null;
+ try {
+ response = dbClient.createIndex(request);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+
+ assertTrue("index not existing", dbClient.isExistsIndex(IDX));
+
+ DeleteIndexRequest request2 = new DeleteIndexRequest(IDX);
+
+ DeleteIndexResponse response2 = null;
+ try {
+ response2 = dbClient.deleteIndex(request2);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response2);
+ assertFalse("index still existing", dbClient.isExistsIndex(IDX));
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testInsertAndDelete() {
+ final String IDX = "tesnt23-knmoinsd";
+ final String ID = "abcddd";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX).mappings(defaultMappings(IDX, false)));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ this.insert(IDX, ID, JSON);
+ // delete data
+ DeleteRequest request2 = new DeleteRequest(IDX, IDX, ID);
+ DeleteResponse response2 = null;
+ try {
+ response2 = dbClient.delete(request2);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response2);
+ assertTrue(response2.isDeleted());
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // verify data deleted
+ GetRequest request4 = new GetRequest(IDX, IDX, ID);
+ GetResponse response4 = null;
+ try {
+ response4 = dbClient.get(request4);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(response4);
+ assertFalse("data still existing", response4.isExists());
+ this.deleteIndex(IDX);
+ }
+
+ /**
+ * @param b
+ * @return
+ */
+ private JSONObject defaultMappings(String idx, boolean useStrict) {
+ String mapping = "{}";
+ return new JSONObject(String.format("{\"%s\":{%s\"properties\":%s}}", idx,
+ useStrict ? "\"dynamic\": false," : "\"dynamic\": true,", mapping));
+ }
+
+ @Test
+ public void testInsertAndDeleteByQuery() {
+ final String IDX = "test534-knmoinsd";
+ final String ID = "abcdddseae";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ this.insert(IDX, ID, JSON);
+
+ // delete data
+ DeleteByQueryRequest request2 = new DeleteByQueryRequest(IDX);
+ request2.source(QueryBuilders.matchQuery("_id", ID));
+ DeleteByQueryResponse response2 = null;
+ try {
+ response2 = dbClient.deleteByQuery(request2);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response2);
+ assertTrue(response2.isResponseSucceeded());
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // verify data deleted
+ GetRequest request4 = new GetRequest(IDX, IDX, ID);
+ GetResponse response4 = null;
+ try {
+ response4 = dbClient.get(request4);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(response4);
+ assertFalse("data still existing", response4.isExists());
+ this.deleteIndex(IDX);
+ }
+
+ private void insert(String IDX, String ID, String JSON) {
+
+ // create data
+ IndexRequest request = new IndexRequest(IDX, IDX, ID);
+ request.source(JSON);
+ String responseId = null;
+ responseId = dbClient.doWriteRaw(IDX, ID, JSON);
+ assertNotNull(responseId);
+ if (ID != null) {
+ assertEquals("id not correct", ID, responseId);
+ } else {
+ ID = responseId;
+ }
+ // do db refresh
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // verify data exists
+ String response3 = null;
+ response3 = dbClient.doReadJsonData(IDX, ID);
+ assertNotNull(response3);
+ JSONAssert.assertEquals("could not verify update", JSON, response3, true);
+ }
+
+ @Test
+ public void testSearch() {
+ final String IDX = "testb44-moinsd";
+ final String ID = "abe";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ final String ID2 = "abe2";
+ final String JSON2 = "{\"data\":{\"inner\":\"more2\"}}";
+ final String ID3 = "abe3";
+ final String JSON3 = "{\"data\":{\"inner\":\"more3\"}}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ this.insert(IDX, ID, JSON);
+ this.insert(IDX, ID2, JSON2);
+ this.insert(IDX, ID3, JSON3);
+ SearchRequest request = new SearchRequest(IDX, IDX);
+ request.setQuery(QueryBuilders.matchAllQuery());
+ SearchResponse response = null;
+ try {
+ response = dbClient.search(request);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertEquals("not all items found", 3, response.getHits().length);
+ assertEquals("incorrect index", IDX, response.getHits()[0].getIndex());
+ assertEquals("incorrect type", IDX, response.getHits()[0].getType());
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testUpdate() {
+ final String IDX = "test45134-moinsd";
+ final String ID = "assbe";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ this.insert(IDX, ID, JSON);
+ UpdateRequest request = new UpdateRequest(IDX, IDX, ID);
+ UpdateResponse response = null;
+ try {
+ request.source(new JSONObject(JSON2));
+ response = dbClient.update(request);
+ } catch (JSONException | IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertTrue(response.succeeded());
+ // refresh index
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // verify update
+ GetRequest request3 = new GetRequest(IDX, IDX, ID);
+ GetResponse response3 = null;
+ try {
+ response3 = dbClient.get(request3);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(response3);
+ JSONAssert.assertEquals("could not verify update", JSON2, response3.getSourceAsBytesRef(), true);
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testUpdateByQuery() {
+ final String IDX = "test224534k-moinsd";
+ final String ID = "asssabe";
+ final String JSON = "{\"data\":{\"inner\":\"more\"}}";
+ final String JSON2 = "{\"data\":{\"inner\":\"more2\"},\"data2\":\"value2\",\"data3\":true}";
+ try {
+ if (!dbClient.indicesExists(new GetIndexRequest(IDX))) {
+ dbClient.createIndex(new CreateIndexRequest(IDX));
+ }
+ } catch (IOException e) {
+ fail("unable to create index");
+ }
+ this.insert(IDX, ID, JSON);
+ UpdateByQueryRequest request = new UpdateByQueryRequest(IDX, IDX);
+ UpdateByQueryResponse response = null;
+ try {
+ request.source(ID, new JSONObject(JSON2));
+ response = dbClient.update(request);
+ } catch (JSONException | IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertTrue(response.isUpdated());
+ // refresh index
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ // verify update
+ GetRequest request3 = new GetRequest(IDX, IDX, ID);
+ GetResponse response3 = null;
+ try {
+ response3 = dbClient.get(request3);
+ } catch (IOException e1) {
+ fail(e1.getMessage());
+ }
+ assertNotNull(response3);
+ JSONAssert.assertEquals("could not verify update", JSON2, response3.getSourceAsBytesRef(), true);
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testAggregations() {
+ final String IDX = "test3227533677-moisnsd";
+ final String JSON = "{ \"node-id\":\"sim1\",\"severity\":\"critical\"}";
+ final String JSON2 = "{ \"node-id\":\"sim2\",\"severity\":\"critical\"}";
+ final String JSON3 = "{ \"node-id\":\"sim3\",\"severity\":\"minor\"}";
+ final String JSON4 = "{ \"node-id\":\"sim4\",\"severity\":\"warning\"}";
+ final String JSON5 = "{ \"node-id\":\"sim5\",\"severity\":\"major\"}";
+ final String MAPPINGS = String.format("{\"" + IDX + "\":{\"properties\":%s}}",
+ "{\"node-id\":{\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"}}");
+ // create index with mapping keyword
+ CreateIndexResponse iresponse = null;
+ try {
+ if (!dbClient.isExistsIndex(IDX)) {
+ iresponse = dbClient.createIndex(new CreateIndexRequest(IDX).mappings(new JSONObject(MAPPINGS)));
+ assertNotNull(iresponse);
+ assertTrue(iresponse.isAcknowledged());
+ }
+ } catch (IOException e1) {
+ this.deleteIndex(IDX);
+ fail("unable to create index: " + e1.getMessage());
+ }
+
+ // fill index
+ this.insert(IDX, null, JSON);
+ this.insert(IDX, null, JSON2);
+ this.insert(IDX, null, JSON3);
+ this.insert(IDX, null, JSON4);
+ this.insert(IDX, null, JSON5);
+ // refresh index
+ try {
+ dbClient.refreshIndex(new RefreshIndexRequest(IDX));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+
+ SearchRequest request = new SearchRequest(IDX, IDX);
+ request.setQuery(QueryBuilders.matchAllQuery().aggregations("severity").size(0));
+ SearchResponse response = null;
+ try {
+ response = dbClient.search(request);
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(response);
+ assertTrue(response.hasAggregations());
+ assertEquals("aggregation size not correct", 4, response.getAggregations("severity").size());
+
+ List<String> items1 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 0));
+ List<String> items2 = Arrays.asList(response.getAggregations("severity").getKeysAsPagedStringList(2, 2));
+ assertEquals("pagination does not work", 2, items1.size());
+ assertEquals("pagination does not work", 2, items2.size());
+ for (String s : items1) {
+ assertFalse("pagination overlap is not allowed", items2.contains(s));
+ }
+ for (String s : items2) {
+ assertFalse("pagination overlap is not allowed", items1.contains(s));
+ }
+
+ this.deleteIndex(IDX);
+ }
+
+ @Test
+ public void testStatistics() {
+ NodeStatsResponse stats = null;
+ try {
+ stats = dbClient.stats(new NodeStatsRequest());
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(stats);
+ System.out.println(stats.getNodesInfo());
+ System.out.println(stats.getNodeStatistics());
+ }
+
+ // @Test
+ public void testPreventAutoCreateIndex() {
+ final String IDX1 = "acidx1";
+ final String ID1 = "acid1";
+ final String IDX2 = "acidx2";
+ final String ID2 = "acid2";
+ final String OBJ = "{\"test\":5}";
+
+ ClusterSettingsResponse settingsResponse = null;
+ String esId = null;
+ // set setting to allow autocreate
+ try {
+ settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(settingsResponse);
+ assertTrue(settingsResponse.isAcknowledged());
+ // test if something new can be created
+ esId = dbClient.doWriteRaw(IDX1, IDX1, ID1, OBJ);
+ assertEquals(ID1, esId);
+ // set setting to deny autocreate
+ try {
+ settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(settingsResponse);
+ assertTrue(settingsResponse.isAcknowledged());
+ // test if something new cannot be created
+ esId = dbClient.doWriteRaw(IDX2, IDX2, ID2, OBJ);
+ assertNull(esId);
+ // set setting to allow autocreate
+ try {
+ settingsResponse = dbClient.setupClusterSettings(new ClusterSettingsRequest(true));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(settingsResponse);
+ assertTrue(settingsResponse.isAcknowledged());
+
+ }
+
+ private void deleteAlias(String idx, String alias) {
+ try {
+ dbClient.deleteAlias(new DeleteAliasRequest(idx, alias));
+ } catch (IOException e) {
+
+ }
+ }
+
+ private void deleteIndex(String idx) {
+ try {
+ dbClient.deleteIndex(new DeleteIndexRequest(idx));
+ } catch (IOException e) {
+
+ }
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
index 32177d8df..883d48ac1 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestEsData.java
@@ -42,74 +42,78 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.IndicesEntryList;
*/
public class TestEsData {
-
- @Test
- public void testVersion() {
- EsVersion version=null;
- try {
- version = new EsVersion("2.3.4");
- } catch (ParseException e) {
- fail(e.getMessage());
- }
- assertNotNull(version);
- assertEquals(2, version.getMajor());
- assertEquals(3, version.getMinor());
- assertEquals(4, version.getRevision());
-
- EsVersion versionNewer = new EsVersion(5,0,0);
- EsVersion versionOlder = new EsVersion(2,2,0);
-
- assertTrue(version.isOlderOrEqualThan(versionNewer));
- assertTrue(version.isNewerOrEqualThan(versionOlder));
-
- }
- @Test
- public void testIndices() {
- IndicesEntryList list = new IndicesEntryList();
- IndicesEntry entry=null;
- try {
- entry=new IndicesEntry("yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 2 3 1.2kb 2.4kb");
- list.add(entry);
- list.add(new IndicesEntry("yellow open networkelement-connection-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
- list.add(new IndicesEntry("yellow open faultlog-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
- list.add(new IndicesEntry("yellow open eventlog-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
- } catch (ParseException e) {
- fail(e.getMessage());
- }
- assertEquals(4, list.size());
- assertNotNull(list.findByIndex("eventlog-v1"));
- assertNull(list.findByIndex("faultcurrent"));
- assertNotNull(entry);
- assertEquals("yellow",entry.getStatus());
- assertEquals("open", entry.getStatus2());
- assertEquals("inventoryequipment-v1", entry.getName());
- assertEquals("5nNPRbJ3T9arMxqxBbJKyQ", entry.getHash());
- assertEquals(5, entry.getShards());
- assertEquals(1, entry.getReplicas());
- assertEquals(2, entry.getC1());
- assertEquals(3, entry.getC2());
- assertEquals("1.2kb", entry.getSize1());
- assertEquals("2.4kb", entry.getSize2());
-
- }
- @Test
- public void testAliases() {
- AliasesEntryList list = new AliasesEntryList();
- AliasesEntry entry=null;
- try {
- entry=new AliasesEntry("networkelement-connection networkelement-connection-v1 - - -");
- list.add(entry);
- list.add(new AliasesEntry("faultcurrent faultcurrent-v1 - - -"));
- list.add(new AliasesEntry("faultlog faultlog-v1 - - -"));
- list.add(new AliasesEntry("maintenancemode maintenancemode-v1 - - -"));
- } catch (ParseException e) {
- fail(e.getMessage());
- }
- assertEquals(4, list.size());
- assertNotNull(list.findByAlias("faultcurrent"));
- assertNull(list.findByAlias("eventlog"));
- assertNotNull(entry);
- assertEquals("networkelement-connection",entry.getAlias());
- assertEquals("networkelement-connection-v1", entry.getIndex());
- }
+
+ @Test
+ public void testVersion() {
+ EsVersion version = null;
+ try {
+ version = new EsVersion("2.3.4");
+ } catch (ParseException e) {
+ fail(e.getMessage());
+ }
+ assertNotNull(version);
+ assertEquals(2, version.getMajor());
+ assertEquals(3, version.getMinor());
+ assertEquals(4, version.getRevision());
+
+ EsVersion versionNewer = new EsVersion(5, 0, 0);
+ EsVersion versionOlder = new EsVersion(2, 2, 0);
+
+ assertTrue(version.isOlderOrEqualThan(versionNewer));
+ assertTrue(version.isNewerOrEqualThan(versionOlder));
+
+ }
+
+ @Test
+ public void testIndices() {
+ IndicesEntryList list = new IndicesEntryList();
+ IndicesEntry entry = null;
+ try {
+ entry = new IndicesEntry(
+ "yellow open inventoryequipment-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 2 3 1.2kb 2.4kb");
+ list.add(entry);
+ list.add(new IndicesEntry(
+ "yellow open networkelement-connection-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
+ list.add(new IndicesEntry("yellow open faultlog-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
+ list.add(new IndicesEntry("yellow open eventlog-v1 5nNPRbJ3T9arMxqxBbJKyQ 5 1 0 0 1.2kb 1.2kb"));
+ } catch (ParseException e) {
+ fail(e.getMessage());
+ }
+ assertEquals(4, list.size());
+ assertNotNull(list.findByIndex("eventlog-v1"));
+ assertNull(list.findByIndex("faultcurrent"));
+ assertNotNull(entry);
+ assertEquals("yellow", entry.getStatus());
+ assertEquals("open", entry.getStatus2());
+ assertEquals("inventoryequipment-v1", entry.getName());
+ assertEquals("5nNPRbJ3T9arMxqxBbJKyQ", entry.getHash());
+ assertEquals(5, entry.getShards());
+ assertEquals(1, entry.getReplicas());
+ assertEquals(2, entry.getC1());
+ assertEquals(3, entry.getC2());
+ assertEquals("1.2kb", entry.getSize1());
+ assertEquals("2.4kb", entry.getSize2());
+
+ }
+
+ @Test
+ public void testAliases() {
+ AliasesEntryList list = new AliasesEntryList();
+ AliasesEntry entry = null;
+ try {
+ entry = new AliasesEntry("networkelement-connection networkelement-connection-v1 - - -");
+ list.add(entry);
+ list.add(new AliasesEntry("faultcurrent faultcurrent-v1 - - -"));
+ list.add(new AliasesEntry("faultlog faultlog-v1 - - -"));
+ list.add(new AliasesEntry("maintenancemode maintenancemode-v1 - - -"));
+ } catch (ParseException e) {
+ fail(e.getMessage());
+ }
+ assertEquals(4, list.size());
+ assertNotNull(list.findByAlias("faultcurrent"));
+ assertNull(list.findByAlias("eventlog"));
+ assertNotNull(entry);
+ assertEquals("networkelement-connection", entry.getAlias());
+ assertEquals("networkelement-connection-v1", entry.getIndex());
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java
index d927ed750..72eba38e8 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestJsonAssert.java
@@ -31,142 +31,143 @@ import org.onap.ccsdk.features.sdnr.wt.common.test.JSONAssert;
public class TestJsonAssert {
- @Test
- public void testGenericTypes() {
- try {
- JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":true}", true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- try {
- JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":2}", true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- try {
- JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abc\"}", true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
-
- }
-
- @Test
- public void testGenericTypesFails() {
- try {
- JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":false}", true);
- fail("test boolean not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- try {
- JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":3}", true);
- fail("test int not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- try {
- JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abcd\"}", true);
- fail("test string not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
-
- }
-
- @Test
- public void testObject() {
- try {
- JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}",
- "{ \"test\":{\"more\":{\"x\":1,\"z\":{},\"y\":\"2\"}}}", true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testObjectFails() {
- try {
- JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}",
- "{ \"test\":{\"more\":{\"x\":1,\"z\":{}}}}", true);
- fail("test object not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- }
-
- @Test
- public void testArrayStrict() {
- try {
- JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
- "{ \"test\":[\"a\",\"b\",\"c\"]}", true);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testArrayStrictFails() {
- try {
- JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
- "{ \"test\":[\"a\",\"c\",\"b\"]}", true);
- fail("test object not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- }
-
- @Test
- public void testArrayNonStrict() {
- try {
- JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
- "{ \"test\":[\"a\",\"c\",\"b\"]}", false);
- } catch (JSONException e) {
- fail(e.getMessage());
- }
- }
-
- @Test
- public void testArrayNonStrictFails() {
- try {
- JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
- "{ \"test\":[\"a\",\"c\",\"b\",\"d\"]}", false);
- fail("test object not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- try {
- JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
- "{ \"test\":[\"a\",\"b\",\"d\"]}", false);
- fail("test object not failed, but has to");
- } catch (JSONException e) {
- fail("problem with json");
- } catch (AssertionError e) {
-
- }
- }
-
- @Test
- public void testNullParamCheck() {
-
- try {
-
- HtAssert.nonnull("test", new JSONArray(), null);
- fail("exception not thrown");
- } catch (Exception e) {
- assertTrue(e.getMessage().contains("org.onap.ccsdk.features.sdnr.wt.common.test.TestJsonAssert") && e.getMessage().contains("testNullParamCheck"));
- }
- }
+ @Test
+ public void testGenericTypes() {
+ try {
+ JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":true}", true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ try {
+ JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":2}", true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ try {
+ JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abc\"}", true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+
+ }
+
+ @Test
+ public void testGenericTypesFails() {
+ try {
+ JSONAssert.assertEquals("test boolean", "{ \"test\":true}", "{ \"test\":false}", true);
+ fail("test boolean not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ try {
+ JSONAssert.assertEquals("test int", "{ \"test\":2}", "{ \"test\":3}", true);
+ fail("test int not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ try {
+ JSONAssert.assertEquals("test string", "{ \"test\":\"abc\"}", "{ \"test\":\"abcd\"}", true);
+ fail("test string not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+
+ }
+
+ @Test
+ public void testObject() {
+ try {
+ JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}",
+ "{ \"test\":{\"more\":{\"x\":1,\"z\":{},\"y\":\"2\"}}}", true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testObjectFails() {
+ try {
+ JSONAssert.assertEquals("test object", "{ \"test\":{\"more\":{\"x\":1,\"y\":\"2\",\"z\":{}}}}",
+ "{ \"test\":{\"more\":{\"x\":1,\"z\":{}}}}", true);
+ fail("test object not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ }
+
+ @Test
+ public void testArrayStrict() {
+ try {
+ JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
+ "{ \"test\":[\"a\",\"b\",\"c\"]}", true);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testArrayStrictFails() {
+ try {
+ JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
+ "{ \"test\":[\"a\",\"c\",\"b\"]}", true);
+ fail("test object not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ }
+
+ @Test
+ public void testArrayNonStrict() {
+ try {
+ JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
+ "{ \"test\":[\"a\",\"c\",\"b\"]}", false);
+ } catch (JSONException e) {
+ fail(e.getMessage());
+ }
+ }
+
+ @Test
+ public void testArrayNonStrictFails() {
+ try {
+ JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
+ "{ \"test\":[\"a\",\"c\",\"b\",\"d\"]}", false);
+ fail("test object not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ try {
+ JSONAssert.assertEquals("test array strict", "{ \"test\":[\"a\",\"b\",\"c\"]}",
+ "{ \"test\":[\"a\",\"b\",\"d\"]}", false);
+ fail("test object not failed, but has to");
+ } catch (JSONException e) {
+ fail("problem with json");
+ } catch (AssertionError e) {
+
+ }
+ }
+
+ @Test
+ public void testNullParamCheck() {
+
+ try {
+
+ HtAssert.nonnull("test", new JSONArray(), null);
+ fail("exception not thrown");
+ } catch (Exception e) {
+ assertTrue(e.getMessage().contains("org.onap.ccsdk.features.sdnr.wt.common.test.TestJsonAssert")
+ && e.getMessage().contains("testNullParamCheck"));
+ }
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java
index 292856940..67c6c97f7 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPageHashMap.java
@@ -26,37 +26,37 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.responses.AggregationEntr
public class TestPageHashMap {
- @Test
- public void testGenericTypes() {
- AggregationEntries agg = new AggregationEntries();
+ @Test
+ public void testGenericTypes() {
+ AggregationEntries agg = new AggregationEntries();
- for (int t=0; t < 100; t++) {
- agg.put("Key"+t, Long.valueOf(t));
- }
+ for (int t = 0; t < 100; t++) {
+ agg.put("Key" + t, Long.valueOf(t));
+ }
- int x =0;
- for (String k : agg.keySet()) {
- if (x++ >= 10)
- break;
- System.out.println("Keys: "+k);
- }
+ int x = 0;
+ for (String k : agg.keySet()) {
+ if (x++ >= 10)
+ break;
+ System.out.println("Keys: " + k);
+ }
- String[] res;
+ String[] res;
- res = agg.getKeysAsPagedStringList(5, 10);
- System.out.println("Entries: "+res.length);
- for (int t=0; t < res.length; t++) {
- System.out.println("Entry "+t+": "+res[t]);
- }
+ res = agg.getKeysAsPagedStringList(5, 10);
+ System.out.println("Entries: " + res.length);
+ for (int t = 0; t < res.length; t++) {
+ System.out.println("Entry " + t + ": " + res[t]);
+ }
- res = agg.getKeysAsPagedStringList(5, 10);
- System.out.println("Entries: "+res.length);
- for (int t=0; t < res.length; t++) {
- System.out.println("Entry "+t+": "+res[t]);
- }
+ res = agg.getKeysAsPagedStringList(5, 10);
+ System.out.println("Entries: " + res.length);
+ for (int t = 0; t < res.length; t++) {
+ System.out.println("Entry " + t + ": " + res[t]);
+ }
- }
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java
index a6f1b51b3..9de285d1b 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPomfile.java
@@ -37,19 +37,17 @@ import org.xml.sax.SAXException;
public class TestPomfile {
- private static final String TESTPROPERTY_KEY="elasticsearch-rest-client.version";
+ private static final String TESTPROPERTY_KEY = "elasticsearch-rest-client.version";
private static final String TESTPROPERTY_VALUE = "6.4.3";
private static final String POMFILENAME = "pom.xml";
- private static final String POM_PROPERTY = "#Generated by org.apache.felix.bundleplugin\n" +
- "#Tue Nov 19 11:20:33 CET 2019\n" +
- "version=0.7.0-SNAPSHOT\n" +
- "groupId=org.onap.ccsdk.features.sdnr.wt\n" +
- "artifactId=sdnr-wt-data-provider-provider\n";
+ private static final String POM_PROPERTY = "#Generated by org.apache.felix.bundleplugin\n"
+ + "#Tue Nov 19 11:20:33 CET 2019\n" + "version=0.7.0-SNAPSHOT\n"
+ + "groupId=org.onap.ccsdk.features.sdnr.wt\n" + "artifactId=sdnr-wt-data-provider-provider\n";
//private static final Date DATE_EXPECTED = new Date(119, 10, 19, 11, 20, 33);
@Test
public void test() {
- PomFile pom=null;
+ PomFile pom = null;
try {
pom = new PomFile(new FileInputStream(POMFILENAME));
} catch (ParserConfigurationException | SAXException | IOException e) {
@@ -59,6 +57,7 @@ public class TestPomfile {
assertEquals(TESTPROPERTY_VALUE, pom.getProperty(TESTPROPERTY_KEY));
}
+
@Test
public void testProp() {
PomPropertiesFile file = null;
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java
index 379142db2..d073043c2 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/TestPortstatus.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.common.test;
import static org.junit.Assert.assertFalse;
@@ -29,47 +29,49 @@ import org.mockito.Mockito;
import org.onap.ccsdk.features.sdnr.wt.common.database.Portstatus;
import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo;
-public class TestPortstatus extends Mockito{
+public class TestPortstatus extends Mockito {
@Test
public void testIsAvailable() throws IOException {
- assertFalse("Port status should be false", Portstatus.isAvailable("localhost", 4567) );
+ assertFalse("Port status should be false", Portstatus.isAvailable("localhost", 4567));
ServerSocket serverSocket = new ServerSocket(4567);
- assertTrue("Port status should be true", Portstatus.isAvailable("localhost", 4567) );
+ assertTrue("Port status should be true", Portstatus.isAvailable("localhost", 4567));
serverSocket.close();
}
@Test
public void testWaitIsAvailable() throws IOException {
ServerSocket serverSocket = new ServerSocket(4567);
- assertTrue("Port status should be true", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567) );
+ assertTrue("Port status should be true", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567));
serverSocket.close();
}
@Test
public void testWaitIsAvailableHostInfo() throws IOException {
ServerSocket serverSocket = new ServerSocket(4567);
- assertTrue("Port status should be true", Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)) );
+ assertTrue("Port status should be true",
+ Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)));
serverSocket.close();
}
@Test
public void testWaitTillAvailable() throws IOException {
Instant start = Instant.now();
- assertFalse("Port status should be false", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567) );
+ assertFalse("Port status should be false", Portstatus.waitSecondsTillAvailable(5, "localhost", 4567));
Instant end = Instant.now();
long seconds = Duration.between(start, end).getSeconds();
- assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7 );
+ assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7);
}
@Test
public void testWaitTillAvailableHostinfo() throws IOException {
Instant start = Instant.now();
- assertFalse("Port status should be false", Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)));
+ assertFalse("Port status should be false",
+ Portstatus.waitSecondsTillAvailable(5, new HostInfo("localhost", 4567)));
Instant end = Instant.now();
long seconds = Duration.between(start, end).getSeconds();
- assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7 );
+ assertTrue("Port status timeout 5 expected and not between 3 .. 7 seconds", 3 < seconds && seconds < 7);
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java
index 6ec47c230..a6f77c72d 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServlet.java
@@ -29,99 +29,112 @@ import javax.servlet.http.HttpServletResponse;
import org.onap.ccsdk.features.sdnr.wt.common.http.BaseServlet;
-public class HelpServlet extends BaseServlet implements IPublicServlet{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
- private static final String HOST = "localhost";
- private int port;
- private boolean isoff;
-
- /**
- * @param port
- */
- public HelpServlet(int port) {
- this.port = port;
- this.isoff=true;
- }
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPost(req, resp);
- }
- @Override
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doPut(req, resp);
- }
- @Override
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
- @Override
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doDelete(req, resp);
- }
- @Override
- protected String getOfflineResponse() {
- return "offline";
- }
- @Override
- protected boolean isOff() {
- return this.isoff;
- }
- @Override
- protected boolean doTrustAll() {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- protected void trustAll(boolean trust) {
- // TODO Auto-generated method stub
-
- }
- @Override
- protected String getRemoteUrl(String uri) {
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- if (uri.startsWith("base")) {
- uri = uri.substring("base".length());
- }
- if (uri.startsWith("/")) {
- uri = uri.substring(1);
- }
- String base = "http://" + HOST + ":" + this.port;
- if (!base.endsWith("/")) {
- base += "/";
- }
-
- return base + uri;
- }
- @Override
- protected boolean trustInsecure() {
- // TODO Auto-generated method stub
- return false;
- }
- @Override
- protected boolean isCorsEnabled() {
- // TODO Auto-generated method stub
- return false;
- }
- /**
- * @param b
- */
- public void setOffline(boolean b) {
- this.isoff = b;
-
- }
+public class HelpServlet extends BaseServlet implements IPublicServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ public static final String RESPONSE_GET = "This is the response get";
+ public static final String RESPONSE_POST = "This is the response post";
+ public static final String RESPONSE_PUT = "This is the response put";
+ public static final String RESPONSE_DELETE = "This is the response delete";
+ public static final String RESPONSE_OPTIONS = "This is the response options";
+ private static final String HOST = "localhost";
+ private int port;
+ private boolean isoff;
+
+ /**
+ * @param port
+ */
+ public HelpServlet(int port) {
+ this.port = port;
+ this.isoff = true;
+ }
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPost(req, resp);
+ }
+
+ @Override
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doPut(req, resp);
+ }
+
+ @Override
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
+
+ @Override
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doDelete(req, resp);
+ }
+
+ @Override
+ protected String getOfflineResponse() {
+ return "offline";
+ }
+
+ @Override
+ protected boolean isOff() {
+ return this.isoff;
+ }
+
+ @Override
+ protected boolean doTrustAll() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ // TODO Auto-generated method stub
+
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ if (uri.startsWith("base")) {
+ uri = uri.substring("base".length());
+ }
+ if (uri.startsWith("/")) {
+ uri = uri.substring(1);
+ }
+ String base = "http://" + HOST + ":" + this.port;
+ if (!base.endsWith("/")) {
+ base += "/";
+ }
+
+ return base + uri;
+ }
+
+ @Override
+ protected boolean trustInsecure() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ @Override
+ protected boolean isCorsEnabled() {
+ // TODO Auto-generated method stub
+ return false;
+ }
+
+ /**
+ * @param b
+ */
+ public void setOffline(boolean b) {
+ this.isoff = b;
+
+ }
}
diff --git a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java
index 8144e6eb7..c163c746f 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/HelpServletBase.java
@@ -52,178 +52,179 @@ import com.sun.net.httpserver.HttpServer;
public class HelpServletBase {
- public static final String RESPONSE_GET = "This is the response get";
- public static final String RESPONSE_POST = "This is the response post";
- public static final String RESPONSE_PUT = "This is the response put";
- public static final String RESPONSE_DELETE = "This is the response delete";
- public static final String RESPONSE_OPTIONS = "This is the response options";
-
- public static final String HTTPMETHOD_GET = "GET";
- public static final String HTTPMETHOD_POST = "POST";
- public static final String HTTPMETHOD_PUT = "PUT";
- public static final String HTTPMETHOD_DELETE = "DELETE";
- public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
- private IPublicServlet servlet;
- private static HttpServer server;
- private static ExecutorService httpThreadPool;
-
- public final String HOST = "localhost";
- protected static int testPort;
- private final String baseUri;
- protected static final String LR = "\n";
-
- public HelpServletBase(String baseuri, int port) {
- this.baseUri=baseuri;
- testPort = port;
- }
-
- public void setServlet(IPublicServlet s)
- {
- this.servlet=s;
- }
-
- protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
- this.testrequest("/mwtn/test",method, data, expectedResponse, exact, null);
- }
- protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact) {
- this.testrequest(uri,method, data, expectedResponse, exact, null);
- }
-
- protected void testrequest(String uri,String method, String data, String expectedResponse, boolean exact,
- Map<String, String> headersToCheck) {
-
- HttpServletRequest mockRequest = mock(HttpServletRequest.class);
- HttpServletResponse mockResponse = mock(HttpServletResponse.class);
-
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes());
- ServletInputStream inputStream= new ServletInputStream() {
- @Override
- public int read() throws IOException {
- return bis.read();
- }
- };
- Vector<String> headers=new Vector<String>();
- headers.addElement("Accept");
- headers.add("User-Agent");
- Enumeration<String> headerNames = headers.elements();
- try {
- when(mockRequest.getRequestURI()).thenReturn(this.baseUri+uri);
- when(mockRequest.getHeaderNames()).thenReturn(headerNames);
- when(mockRequest.getHeader("Accept")).thenReturn("application/json");
- when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
- when(mockRequest.getInputStream()).thenReturn(inputStream);
- when(mockResponse.getOutputStream()).thenReturn(printOut);
- System.out.println("do a " + method + " request");
- if (method == HTTPMETHOD_GET)
- this.servlet.doGet(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_POST)
- this.servlet.doPost(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_PUT)
- this.servlet.doPut(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_DELETE)
- this.servlet.doDelete(mockRequest, mockResponse);
- else if (method == HTTPMETHOD_OPTIONS)
- this.servlet.doOptions(mockRequest, mockResponse);
- else
- fail("http request method " + method + " test not implemented");
- } catch (Exception e) {
- System.err.println(e.getMessage());
- }
-
- verify(mockResponse).setStatus(200);
- if (exact)
- assertEquals(expectedResponse, out.toString());
- else
- assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse));
- // currently unable to check extra headers
- if (headersToCheck != null) {
-
- }
- }
- @Before
- private void init() throws IOException{
-
-
- initEsTestWebserver(testPort);
- }
- @After
- private void deinit() {
- stopTestWebserver();
- }
-
- public static void initEsTestWebserver(int port) throws IOException {
- initEsTestWebserver(port, "/mwtn/test");
- }
- public static void initEsTestWebserver(int port,String baseUri) throws IOException {
- server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
- httpThreadPool = Executors.newFixedThreadPool(5);
- server.setExecutor(httpThreadPool);
- server.createContext(baseUri, new MyHandler());
- //server.createContext("/", new MyRootHandler());
- server.setExecutor(null); // creates a default executor
- server.start();
- System.out.println("http server started");
- }
-
- public static void stopTestWebserver() {
- if (server != null) {
- server.stop(0);
- httpThreadPool.shutdownNow();
- System.out.println("http server stopped" );
- }
- }
-
-
-
- public static class MyHandler implements HttpHandler {
- @Override
- public void handle(HttpExchange t) throws IOException {
- String method = t.getRequestMethod();
- System.out.println(String.format("req received: %s %s" ,method,t.getRequestURI()));
- OutputStream os = null;
- try {
- if (method.equals(HTTPMETHOD_GET)) {
- t.sendResponseHeaders(200, RESPONSE_GET.length());
- os = t.getResponseBody();
- os.write(RESPONSE_GET.getBytes());
- } else if (method.equals(HTTPMETHOD_POST)) {
- t.sendResponseHeaders(200, RESPONSE_POST.length());
- os = t.getResponseBody();
- os.write(RESPONSE_POST.getBytes());
- } else if (method.equals(HTTPMETHOD_PUT)) {
- t.sendResponseHeaders(200, RESPONSE_PUT.length());
- os = t.getResponseBody();
- os.write(RESPONSE_PUT.getBytes());
- } else if (method.equals(HTTPMETHOD_DELETE)) {
- t.sendResponseHeaders(200, RESPONSE_DELETE.length());
- os = t.getResponseBody();
- os.write(RESPONSE_DELETE.getBytes());
- } else if (method.equals(HTTPMETHOD_OPTIONS)) {
- t.sendResponseHeaders(200, RESPONSE_OPTIONS.length());
- //os = t.getResponseBody();
- //os.write(RESPONSE_OPTIONS.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();
- }
- }
- }
- }
+ public static final String RESPONSE_GET = "This is the response get";
+ public static final String RESPONSE_POST = "This is the response post";
+ public static final String RESPONSE_PUT = "This is the response put";
+ public static final String RESPONSE_DELETE = "This is the response delete";
+ public static final String RESPONSE_OPTIONS = "This is the response options";
+
+ public static final String HTTPMETHOD_GET = "GET";
+ public static final String HTTPMETHOD_POST = "POST";
+ public static final String HTTPMETHOD_PUT = "PUT";
+ public static final String HTTPMETHOD_DELETE = "DELETE";
+ public static final String HTTPMETHOD_OPTIONS = "OPTIONS";
+ private IPublicServlet servlet;
+ private static HttpServer server;
+ private static ExecutorService httpThreadPool;
+
+ public final String HOST = "localhost";
+ protected static int testPort;
+ private final String baseUri;
+ protected static final String LR = "\n";
+
+ public HelpServletBase(String baseuri, int port) {
+ this.baseUri = baseuri;
+ testPort = port;
+ }
+
+ public void setServlet(IPublicServlet s) {
+ this.servlet = s;
+ }
+
+ protected void testrequest(String method, String data, String expectedResponse, boolean exact) {
+ this.testrequest("/mwtn/test", method, data, expectedResponse, exact, null);
+ }
+
+ protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact) {
+ this.testrequest(uri, method, data, expectedResponse, exact, null);
+ }
+
+ protected void testrequest(String uri, String method, String data, String expectedResponse, boolean exact,
+ Map<String, String> headersToCheck) {
+
+ HttpServletRequest mockRequest = mock(HttpServletRequest.class);
+ HttpServletResponse mockResponse = mock(HttpServletResponse.class);
+
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ ByteArrayInputStream bis = new ByteArrayInputStream(data.getBytes());
+ ServletInputStream inputStream = new ServletInputStream() {
+ @Override
+ public int read() throws IOException {
+ return bis.read();
+ }
+ };
+ Vector<String> headers = new Vector<String>();
+ headers.addElement("Accept");
+ headers.add("User-Agent");
+ Enumeration<String> headerNames = headers.elements();
+ try {
+ when(mockRequest.getRequestURI()).thenReturn(this.baseUri + uri);
+ when(mockRequest.getHeaderNames()).thenReturn(headerNames);
+ when(mockRequest.getHeader("Accept")).thenReturn("application/json");
+ when(mockRequest.getHeader("User-Agent")).thenReturn("Gecko abc");
+ when(mockRequest.getInputStream()).thenReturn(inputStream);
+ when(mockResponse.getOutputStream()).thenReturn(printOut);
+ System.out.println("do a " + method + " request");
+ if (method == HTTPMETHOD_GET)
+ this.servlet.doGet(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_POST)
+ this.servlet.doPost(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_PUT)
+ this.servlet.doPut(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_DELETE)
+ this.servlet.doDelete(mockRequest, mockResponse);
+ else if (method == HTTPMETHOD_OPTIONS)
+ this.servlet.doOptions(mockRequest, mockResponse);
+ else
+ fail("http request method " + method + " test not implemented");
+ } catch (Exception e) {
+ System.err.println(e.getMessage());
+ }
+
+ verify(mockResponse).setStatus(200);
+ if (exact)
+ assertEquals(expectedResponse, out.toString());
+ else
+ assertTrue("response not for method " + method + "correct", out.toString().contains(expectedResponse));
+ // currently unable to check extra headers
+ if (headersToCheck != null) {
+
+ }
+ }
+
+ @Before
+ private void init() throws IOException {
+
+
+ initEsTestWebserver(testPort);
+ }
+
+ @After
+ private void deinit() {
+ stopTestWebserver();
+ }
+
+ public static void initEsTestWebserver(int port) throws IOException {
+ initEsTestWebserver(port, "/mwtn/test");
+ }
+
+ public static void initEsTestWebserver(int port, String baseUri) throws IOException {
+ server = HttpServer.create(new InetSocketAddress("127.0.0.1", port), 0);
+ httpThreadPool = Executors.newFixedThreadPool(5);
+ server.setExecutor(httpThreadPool);
+ server.createContext(baseUri, new MyHandler());
+ //server.createContext("/", new MyRootHandler());
+ server.setExecutor(null); // creates a default executor
+ server.start();
+ System.out.println("http server started");
+ }
+
+ public static void stopTestWebserver() {
+ if (server != null) {
+ server.stop(0);
+ httpThreadPool.shutdownNow();
+ System.out.println("http server stopped");
+ }
+ }
+
+
+
+ public static class MyHandler implements HttpHandler {
+ @Override
+ public void handle(HttpExchange t) throws IOException {
+ String method = t.getRequestMethod();
+ System.out.println(String.format("req received: %s %s", method, t.getRequestURI()));
+ OutputStream os = null;
+ try {
+ if (method.equals(HTTPMETHOD_GET)) {
+ t.sendResponseHeaders(200, RESPONSE_GET.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_GET.getBytes());
+ } else if (method.equals(HTTPMETHOD_POST)) {
+ t.sendResponseHeaders(200, RESPONSE_POST.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_POST.getBytes());
+ } else if (method.equals(HTTPMETHOD_PUT)) {
+ t.sendResponseHeaders(200, RESPONSE_PUT.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_PUT.getBytes());
+ } else if (method.equals(HTTPMETHOD_DELETE)) {
+ t.sendResponseHeaders(200, RESPONSE_DELETE.length());
+ os = t.getResponseBody();
+ os.write(RESPONSE_DELETE.getBytes());
+ } else if (method.equals(HTTPMETHOD_OPTIONS)) {
+ t.sendResponseHeaders(200, RESPONSE_OPTIONS.length());
+ //os = t.getResponseBody();
+ //os.write(RESPONSE_OPTIONS.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/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java
index e6634d6a1..1d97b615a 100644
--- a/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java
+++ b/sdnr/wt/common/src/test/java/org/onap/ccsdk/features/sdnr/wt/common/test/helper/IPublicServlet.java
@@ -28,9 +28,13 @@ import javax.servlet.http.HttpServletResponse;
public interface IPublicServlet {
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
- public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ;
- public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException ;
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doPut(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
+
+ public void doDelete(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException;
}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java
index 559ed3148..2af7324e5 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/ArchiveCleanProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import java.util.Date;
@@ -23,6 +23,7 @@ public interface ArchiveCleanProvider {
/**
* Remove all index data older, than specified from faultlog and eventlog
+ *
* @param olderAreOutdated time to specify older elements
* @return number of removed elements
*/
@@ -30,6 +31,7 @@ public interface ArchiveCleanProvider {
/**
* Get number of elements older then
+ *
* @param olderAreOutdated date to compare with and specify older elements
* @return number of elements
*/
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
index 15cc89212..a9e334668 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/DataProvider.java
@@ -67,6 +67,7 @@ public interface DataProvider extends ArchiveCleanProvider {
/**
* write internal equipment to database
+ *
* @param internalEquipment with mandatory fields.
*/
void writeInventory(Inventory internalEquipment);
@@ -81,6 +82,7 @@ public interface DataProvider extends ArchiveCleanProvider {
/**
* Update after new mountpoint registration
+ *
* @param networkElementConnectionEntitiy data
* @param nodeId of device (mountpoint name)
*/
@@ -101,9 +103,9 @@ public interface DataProvider extends ArchiveCleanProvider {
*/
void doWritePerformanceData(List<PmdataEntity> list);
- /**
- * @return
- */
- HtDatabaseClient getRawClient();
+ /**
+ * @return
+ */
+ HtDatabaseClient getRawClient();
}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java
index 11681c05f..51fe25d89 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/HtDatabaseMaintenance.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import java.util.List;
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java
index 95ea0752b..9ba10cd0b 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEntityDataProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.StatusChangedHandler.StatusKey;
@@ -31,7 +31,7 @@ public interface IEntityDataProvider {
public void setReadyStatus(boolean status);
/** Set some static status information after startup */
- public void setStatus(StatusKey key,String value);
+ public void setStatus(StatusKey key, String value);
/** Database configuration information **/
public IEsConfig getEsConfig();
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java
index f41095db9..0f8f5e37d 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/IEsConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import org.onap.ccsdk.features.sdnr.wt.common.configuration.filechange.IConfigChangedListener;
@@ -44,5 +44,5 @@ public interface IEsConfig {
void registerConfigChangedListener(IConfigChangedListener archiveCleanService);
-
+
}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java
index 5bed9f7a3..26962c2e6 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/NetconfTimeStamp.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
import java.time.LocalDateTime;
@@ -27,61 +27,63 @@ import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.
*/
public interface NetconfTimeStamp {
- /**
- * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
- *
- * @return String with Date in NETCONF/YANG Format Version 1.0.
- */
- String getTimeStampAsNetconfString();
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+ *
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ String getTimeStampAsNetconfString();
- /**
- * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
-
- * @return String with Date in NETCONF/YANG Format Version 1.0.
- */
- String getTimeStampAsNetconfString(Date date);
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
+ *
+ * @return String with Date in NETCONF/YANG Format Version 1.0.
+ */
+ String getTimeStampAsNetconfString(Date date);
- /**
- * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
- *
- * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
- */
- DateAndTime getTimeStamp();
+ /**
+ * Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format in GMT
+ *
+ * @return DateAndTime Type 1.0. Date in NETCONF/YANG Format Version 1.0.
+ */
+ DateAndTime getTimeStamp();
- /**
- * 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.
- */
- DateAndTime getTimeStamp(Date date);
+ /**
+ * 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.
+ */
+ DateAndTime getTimeStamp(Date date);
- /**
- * 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.
- */
- DateAndTime getTimeStamp(String date);
+ /**
+ * 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.
+ */
+ DateAndTime getTimeStamp(String date);
- /**
- * Return the String with a NETCONF time converted to long
- *
- * @param netconfTime as String according the formats given above
- * @return Epoch milliseconds
- * @throws IllegalArgumentException In case of no compliant time format definition for the string
- */
- long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException;
+ /**
+ * Return the String with a NETCONF time converted to long
+ *
+ * @param netconfTime as String according the formats given above
+ * @return Epoch milliseconds
+ * @throws IllegalArgumentException In case of no compliant time format definition for the string
+ */
+ long getTimeStampFromNetconfAsMilliseconds(String netconfTime) throws IllegalArgumentException;
- /**
- * 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 "Maleformed date" is delivered back.
- */
- String getTimeStampFromNetconf(String netconfTime);
+ /**
+ * 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 "Maleformed date" is delivered back.
+ */
+ String getTimeStampFromNetconf(String netconfTime);
- Date getDateFromNetconf(String netconfTime);
+ Date getDateFromNetconf(String netconfTime);
- String getTimeStampAsNetconfString(LocalDateTime dt);
+ String getTimeStampAsNetconfString(LocalDateTime dt);
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java
index fa64d4d3e..d97ee8463 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/StatusChangedHandler.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,16 +14,17 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model;
public interface StatusChangedHandler {
- public enum StatusKey {
- CLUSTER_SIZE,
-
- }
- public void onStatusChanged(StatusKey key,String newValue);
-
+ public enum StatusKey {
+ CLUSTER_SIZE,
+
+ }
+
+ public void onStatusChanged(StatusKey key, String newValue);
+
}
diff --git a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java
index f5dd65269..c7f921708 100644
--- a/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java
+++ b/sdnr/wt/data-provider/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/model/types/NetconfTimeStampImpl.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types;
import java.time.LocalDateTime;
@@ -41,32 +41,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 NetconfTimeStampImpl implements NetconfTimeStamp {
@@ -77,22 +70,20 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
/**
* Specify the input format expected from netconf, and from specific devices.
*/
- private static DateTimeFormatter formatterInput = DateTimeFormatter.ofPattern(""
- + "[yyyy-MM-dd'T'HH:mm[:ss][.SSS][.SS][.S][xxx][xx][X][Z]]"
- + "[yyyyMMddHHmmss[.SSS][.SS][.S][xxx][xx][X][Z]]"
- ).withZone(ZoneOffset.UTC);
+ private static DateTimeFormatter formatterInput =
+ DateTimeFormatter.ofPattern("" + "[yyyy-MM-dd'T'HH:mm[:ss][.SSS][.SS][.S][xxx][xx][X][Z]]"
+ + "[yyyyMMddHHmmss[.SSS][.SS][.S][xxx][xx][X][Z]]").withZone(ZoneOffset.UTC);
/**
* Specify output format that is used internally
*/
- private static DateTimeFormatter formatterOutput = DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.S'Z'")
- .withZone(ZoneOffset.UTC);
+ private static DateTimeFormatter formatterOutput =
+ DateTimeFormatter.ofPattern("yyyy-MM-dd'T'HH:mm:ss.S'Z'").withZone(ZoneOffset.UTC);
/**
* Use static access
*/
- private NetconfTimeStampImpl() {
- }
+ private NetconfTimeStampImpl() {}
/*
* ------------------------------------ Public function
@@ -100,6 +91,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
/**
* Use this function to get the converter
+ *
* @return global converter
*/
public static NetconfTimeStamp getConverter() {
@@ -118,12 +110,12 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
/**
* Get actual timestamp as NETCONF specific type NETCONF/YANG 1.0 Format
-
+ *
* @return String with Date in NETCONF/YANG Format Version 1.0.
*/
@Override
public String getTimeStampAsNetconfString(Date date) {
- return ZonedDateTime.ofInstant(date.toInstant(),ZoneOffset.UTC).format(formatterOutput);
+ return ZonedDateTime.ofInstant(date.toInstant(), ZoneOffset.UTC).format(formatterOutput);
}
@@ -140,6 +132,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
/**
* 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.
*/
@@ -147,8 +140,10 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
public DateAndTime getTimeStamp(Date date) {
return DateAndTime.getDefaultInstance(getTimeStampAsNetconfString(date));
}
+
/**
* 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.
*/
@@ -173,14 +168,14 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
throw new IllegalArgumentException(
"No pattern for NETCONF data string: " + netconfTime + " Msg:" + e.getMessage());
}
- }
+ }
/**
* 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 "Maleformed 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 "Maleformed date" is delivered back.
*/
@Override
public String getTimeStampFromNetconf(String netconfTime) {
@@ -189,7 +184,7 @@ public class NetconfTimeStampImpl implements NetconfTimeStamp {
return inputUTC;
} catch (Exception e) {
LOG.info(e.getMessage());
- }
+ }
LOG.debug("No pattern for NETCONF data string: {}", netconfTime);
return "Malformed date: " + netconfTime; // Error handling
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
index b7abe5950..3fe2a62af 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessor.java
@@ -33,28 +33,29 @@ import org.slf4j.LoggerFactory;
public class DataObjectAcessor<T extends DataObject> extends EsDataObjectReaderWriter<T> {
- private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessor.class);
- public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
- this(dbClient, entity, clazz, true);
- LOG.info("Create {}", this.getClass().getName());
- }
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz) throws ClassNotFoundException {
+ this(dbClient, entity, clazz, true);
+ LOG.info("Create {}", this.getClass().getName());
+ }
- public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean idSupported) throws ClassNotFoundException {
- super(dbClient, entity, clazz);
- if (idSupported) {
- setEsIdAttributeName("_id");
- }
- }
+ public DataObjectAcessor(HtDatabaseClient dbClient, Entity entity, Class<T> clazz, boolean idSupported)
+ throws ClassNotFoundException {
+ super(dbClient, entity, clazz);
+ if (idSupported) {
+ setEsIdAttributeName("_id");
+ }
+ }
- QueryResult<T> getData(EntityInput input) {
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
+ QueryResult<T> getData(EntityInput input) {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
LOG.info("Request: {}", this.getDataTypeName());
- QueryBuilder query = QueryByFilter.fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
- QueryByFilter.setSortOrder(query, input.getSortorder());
- SearchResult<T> result = doReadAll(query,query.contains("range"));
- return new QueryResult<>(page, pageSize, result);
- }
+ QueryBuilder query = QueryByFilter.fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
+ QueryByFilter.setSortOrder(query, input.getSortorder());
+ SearchResult<T> result = doReadAll(query, query.contains("range"));
+ return new QueryResult<>(page, pageSize, result);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
index ec1a20880..8eb51b6aa 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorPm.java
@@ -42,124 +42,128 @@ import org.slf4j.LoggerFactory;
public class DataObjectAcessorPm<T extends DataObject> extends DataObjectAcessor<T> {
- private final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
-
- private static final String UUID_KEY = "uuid-interface";
- private static final String NODE_KEY = "node-name";
- private static final String KEY = "node-name";
-
-
- enum Intervall {
- PMDATA15M("historicalperformance15min", "historicalperformance15min"),
- PMDATA24H("historicalperformance24h", "historicalperformance24h");
-
- String index;
- String type;
-
- Intervall(String index, String type) {
- this.index = index;
- this.type = type;
- }
-
- public String getIndex() {
- return index;
- }
-
- public String getType() {
- return type;
- }
- }
-
- private ExtRestClient dbClient;
- private Intervall mode;
-
- public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz) throws ClassNotFoundException {
- super(dbClient, entity, clazz, false);
- this.dbClient = dbClient;
- this.mode = mode;
- }
-
- /**
- * get aggregated list of ltps for filter NODE_KEY
- * @param input
- * @return
- * @throws IOException
- */
- QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
- Filter nodeFilter = QueryByFilter.getFilter(input.getFilter(), NODE_KEY);
- if (nodeFilter != null) {
- SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
- request.setQuery(QueryBuilders.matchQuery(NODE_KEY, nodeFilter.getFiltervalue()).aggregations(UUID_KEY).size(0));
- try {
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(UUID_KEY);
- String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
- long totalSize = aggs.size();
- return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
- } catch (IOException e) {
- throw new IOException("problem reading ltps for req="+request, e);
- }
- } else {
- String msg = "no nodename in filter found ";
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- }
- }
-
-// QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
-//
-// long page = QueryByFilter.getPage(input);
-// long pageSize = QueryByFilter.getPageSize(input);
-//
-// SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
-// request.setQuery(QueryBuilders.matchAllQuery().aggregations(KEY).size(0));
-//// try {
-// SearchResponse response = this.dbClient.search(request);
-// AggregationEntries aggs = response.getAggregations(KEY);
-// String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
-// long totalSize = aggs.size();
-// return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
-//// } catch (IOException e) {
-//// throw new IOException("problem reading nodes for req="+request, e);
-//// }
-// }
- /**
- * get aggregated devices list
- * @param input filter should be empty/no filter handled, only sortorder for KEY ('node-name')
- * @return
- * @throws IOException
- */
- QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
-
- long page = QueryByFilter.getPage(input);
- long pageSize = QueryByFilter.getPageSize(input);
-
- Sortorder soNode = QueryByFilter.getSortOrder(input.getSortorder(), KEY);
- SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
- QueryBuilder query = null;
- if (soNode != null) {
- query = QueryBuilders.matchAllQuery()
- .aggregations(KEY,
- soNode.getSortorder() == SortOrder.Ascending
- ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
- : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING)
- .size(0);
- } else {
- query = QueryBuilders.matchAllQuery().aggregations(KEY).size(0);
- }
- request.setQuery(query);
- try {
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(KEY);
- String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
- long totalSize = aggs.size();
- return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
- } catch (IOException e) {
- throw new IOException("problem reading nodes for req=" + request, e);
- }
-
- }
+ private final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+
+ private static final String UUID_KEY = "uuid-interface";
+ private static final String NODE_KEY = "node-name";
+ private static final String KEY = "node-name";
+
+
+ enum Intervall {
+ PMDATA15M("historicalperformance15min", "historicalperformance15min"), PMDATA24H("historicalperformance24h",
+ "historicalperformance24h");
+
+ String index;
+ String type;
+
+ Intervall(String index, String type) {
+ this.index = index;
+ this.type = type;
+ }
+
+ public String getIndex() {
+ return index;
+ }
+
+ public String getType() {
+ return type;
+ }
+ }
+
+ private ExtRestClient dbClient;
+ private Intervall mode;
+
+ public DataObjectAcessorPm(HtDatabaseClient dbClient, Intervall mode, Entity entity, Class<T> clazz)
+ throws ClassNotFoundException {
+ super(dbClient, entity, clazz, false);
+ this.dbClient = dbClient;
+ this.mode = mode;
+ }
+
+ /**
+ * get aggregated list of ltps for filter NODE_KEY
+ *
+ * @param input
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataLtpList(EntityInput input) throws IOException {
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+ Filter nodeFilter = QueryByFilter.getFilter(input.getFilter(), NODE_KEY);
+ if (nodeFilter != null) {
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ request.setQuery(
+ QueryBuilders.matchQuery(NODE_KEY, nodeFilter.getFiltervalue()).aggregations(UUID_KEY).size(0));
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(UUID_KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading ltps for req=" + request, e);
+ }
+ } else {
+ String msg = "no nodename in filter found ";
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ }
+
+ // QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+ //
+ // long page = QueryByFilter.getPage(input);
+ // long pageSize = QueryByFilter.getPageSize(input);
+ //
+ // SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ // request.setQuery(QueryBuilders.matchAllQuery().aggregations(KEY).size(0));
+ //// try {
+ // SearchResponse response = this.dbClient.search(request);
+ // AggregationEntries aggs = response.getAggregations(KEY);
+ // String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ // long totalSize = aggs.size();
+ // return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ //// } catch (IOException e) {
+ //// throw new IOException("problem reading nodes for req="+request, e);
+ //// }
+ // }
+ /**
+ * get aggregated devices list
+ *
+ * @param input filter should be empty/no filter handled, only sortorder for KEY ('node-name')
+ * @return
+ * @throws IOException
+ */
+ QueryResult<String> getDataDeviceList(EntityInput input) throws IOException {
+
+ long page = QueryByFilter.getPage(input);
+ long pageSize = QueryByFilter.getPageSize(input);
+
+ Sortorder soNode = QueryByFilter.getSortOrder(input.getSortorder(), KEY);
+ SearchRequest request = new SearchRequest(mode.getIndex(), mode.getType());
+ QueryBuilder query = null;
+ if (soNode != null) {
+ query = QueryBuilders.matchAllQuery()
+ .aggregations(KEY,
+ soNode.getSortorder() == SortOrder.Ascending
+ ? org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.ASCENDING
+ : org.onap.ccsdk.features.sdnr.wt.common.database.queries.SortOrder.DESCENDING)
+ .size(0);
+ } else {
+ query = QueryBuilders.matchAllQuery().aggregations(KEY).size(0);
+ }
+ request.setQuery(query);
+ try {
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(KEY);
+ String[] uuids = aggs.getKeysAsPagedStringList(pageSize, pageSize * (page - 1));
+ long totalSize = aggs.size();
+ return new QueryResult<String>(page, pageSize, new SearchResult<String>(uuids, totalSize));
+ } catch (IOException e) {
+ throw new IOException("problem reading nodes for req=" + request, e);
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
index c1a6b2936..4dd52f43a 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataObjectAcessorStatus.java
@@ -37,39 +37,34 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class DataObjectAcessorStatus extends DataObjectAcessor<Data> {
- final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
+ final String ESDATATYPE_FAULTCURRENT_SEVERITY_KEY = "severity";
- private final ExtRestClient dbClient;
- private final Entity entity;
+ private final ExtRestClient dbClient;
+ private final Entity entity;
- public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity)
- throws ClassNotFoundException {
- super(dbClient, entity, Data.class, false);
- this.dbClient = dbClient;
- this.entity = entity;
- }
+ public DataObjectAcessorStatus(HtDatabaseClient dbClient, Entity entity) throws ClassNotFoundException {
+ super(dbClient, entity, Data.class, false);
+ this.dbClient = dbClient;
+ this.entity = entity;
+ }
- QueryResult<Data> getDataStatus() throws IOException {
- SearchRequest request = getNewInstanceOfSearchRequest(entity);
- request.setQuery(
- QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
- SearchResponse response = this.dbClient.search(request);
- AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
+ QueryResult<Data> getDataStatus() throws IOException {
+ SearchRequest request = getNewInstanceOfSearchRequest(entity);
+ request.setQuery(QueryBuilders.matchAllQuery().aggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY).size(0));
+ SearchResponse response = this.dbClient.search(request);
+ AggregationEntries aggs = response.getAggregations(ESDATATYPE_FAULTCURRENT_SEVERITY_KEY);
- Data[] data = { new DataBuilder().setFaults(new FaultsBuilder().
- setCriticals(aggs.getOrDefault("Critical",0L)).
- setMajors(aggs.getOrDefault("Major", 0L)).
- setMinors(aggs.getOrDefault("Minor", 0L)).
- setWarnings(aggs.getOrDefault("Warning", 0L)).
- build()).build() };
- long toalsize = data.length;
- return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
+ Data[] data = {new DataBuilder().setFaults(new FaultsBuilder().setCriticals(aggs.getOrDefault("Critical", 0L))
+ .setMajors(aggs.getOrDefault("Major", 0L)).setMinors(aggs.getOrDefault("Minor", 0L))
+ .setWarnings(aggs.getOrDefault("Warning", 0L)).build()).build()};
+ long toalsize = data.length;
+ return new QueryResult<Data>(1L, 1L, new SearchResult<Data>(data, toalsize));
- }
+ }
private static SearchRequest getNewInstanceOfSearchRequest(Entity entity) {
- return new SearchRequest(entity.getName(), entity.getName());
+ return new SearchRequest(entity.getName(), entity.getName());
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
index f75989acd..a92265a84 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeChildObject.java
@@ -29,17 +29,18 @@ import java.util.Map;
*/
public class DataTreeChildObject {
- private final String label;
- private final String ownSeverity;
- private final String childrenSeveritySummary;
- private final boolean isMatch;
- private final Map<String,DataTreeChildObject> children;
-
- public DataTreeChildObject(String label,boolean isMatch,Map<String,DataTreeChildObject>children,String ownSeverity,String childrenSeveritySummary) {
- this.label = label;
- this.isMatch = isMatch;
- this.children = children;
- this.ownSeverity = ownSeverity;
- this.childrenSeveritySummary = childrenSeveritySummary;
- }
+ private final String label;
+ private final String ownSeverity;
+ private final String childrenSeveritySummary;
+ private final boolean isMatch;
+ private final Map<String, DataTreeChildObject> children;
+
+ public DataTreeChildObject(String label, boolean isMatch, Map<String, DataTreeChildObject> children,
+ String ownSeverity, String childrenSeveritySummary) {
+ this.label = label;
+ this.isMatch = isMatch;
+ this.children = children;
+ this.ownSeverity = ownSeverity;
+ this.childrenSeveritySummary = childrenSeveritySummary;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
index cc3f6cc55..4333dccb4 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/DataTreeObject.java
@@ -27,6 +27,6 @@ import java.util.HashMap;
* @author Michael Dürre
*
*/
-public class DataTreeObject extends HashMap<String,DataTreeChildObject> {
-
+public class DataTreeObject extends HashMap<String, DataTreeChildObject> {
+
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
index 4fa0a57cc..08db03475 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ElasticSearchDataProvider.java
@@ -75,11 +75,11 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
private static final Logger LOG = LoggerFactory.getLogger(ElasticSearchDataProvider.class);
- private static final String EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE = "unable to write data to database";
- private static final String EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE = "unable to update data in database";
- private static final String EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE = "unable to remove data from database";
+ private static final String EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE = "unable to write data to database";
+ private static final String EXCEPTION_UNABLE_TO_UPDATE_IN_DATABASE = "unable to update data in database";
+ private static final String EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE = "unable to remove data from database";
- private static final boolean DEFAULT_TRUSTALLCERTS = false;
+ private static final boolean DEFAULT_TRUSTALLCERTS = false;
private final HtDatabaseClient dbClient;
private final DataObjectAcessor<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> eventRWFaultCurrent;
@@ -96,54 +96,58 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
private final DataObjectAcessorStatus readStatus;
private final HtDatabaseEventsService databaseService;
private final HtDatabaseMaintenanceService databaseMaintenanceService;
+
public HtDatabaseClient getRawClient() {
- return this.dbClient;
+ return this.dbClient;
}
+
public ElasticSearchDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts,null,null,DEFAULT_TRUSTALLCERTS);
+ this(hosts, null, null, DEFAULT_TRUSTALLCERTS);
}
- public ElasticSearchDataProvider(HostInfo[] hosts,String authUsername,String authPassword, boolean trustAllCerts) throws Exception {
- super();
- LOG.info("Start {}", this.getClass().getName());
- this.dbClient = new HtDatabaseClient(hosts,authUsername,authPassword,trustAllCerts);
- this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer,
+ public ElasticSearchDataProvider(HostInfo[] hosts, String authUsername, String authPassword, boolean trustAllCerts)
+ throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+
+ this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword, trustAllCerts);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class);
- this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
+ this.mediatorserverRW.setWriteInterface(MediatorServerEntity.class);
- this.maintenanceRW = new DataObjectAcessor<>(dbClient, Entity.Maintenancemode,
+ this.maintenanceRW = new DataObjectAcessor<>(dbClient, Entity.Maintenancemode,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data.class);
- this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
+ this.maintenanceRW.setWriteInterface(MaintenanceEntity.class);
- this.equipmentRW = new DataObjectAcessor<>(dbClient, Entity.Inventoryequipment,
+ this.equipmentRW = new DataObjectAcessor<>(dbClient, Entity.Inventoryequipment,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
- this.eventRWFaultCurrent = new DataObjectAcessor<>(dbClient, Entity.Faultcurrent,
+ this.eventRWFaultCurrent = new DataObjectAcessor<>(dbClient, Entity.Faultcurrent,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data.class);
- this.eventRWFaultLog = new DataObjectAcessor<>(dbClient, Entity.Faultlog,
+ this.eventRWFaultLog = new DataObjectAcessor<>(dbClient, Entity.Faultlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data.class);
- this.connnectionlogRW = new DataObjectAcessor<>(dbClient, Entity.Connectionlog,
+ this.connnectionlogRW = new DataObjectAcessor<>(dbClient, Entity.Connectionlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data.class);
- this.eventlogRW = new DataObjectAcessor<>(dbClient, Entity.Eventlog,
+ this.eventlogRW = new DataObjectAcessor<>(dbClient, Entity.Eventlog,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data.class);
- this.networkelementConnectionRW = new DataObjectAcessor<>(dbClient, Entity.NetworkelementConnection,
+ this.networkelementConnectionRW = new DataObjectAcessor<>(dbClient, Entity.NetworkelementConnection,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data.class);
- this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
+ this.networkelementConnectionRW.setWriteInterface(NetworkElementConnectionEntity.class);
- this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
+ this.pm15mRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA15M, Entity.Historicalperformance15min,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
- this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
+ this.pm24hRW = new DataObjectAcessorPm<>(dbClient, Intervall.PMDATA24H, Entity.Historicalperformance24h,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data.class);
- this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent );
+ this.readStatus = new DataObjectAcessorStatus(dbClient, Entity.Faultcurrent);
- this.databaseService = new HtDatabaseEventsService(dbClient, this);
- this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
+ this.databaseService = new HtDatabaseEventsService(dbClient, this);
+ this.databaseMaintenanceService = new HtDatabaseMaintenanceService(dbClient);
}
/*-------------------------
@@ -157,8 +161,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
ReadFaultcurrentListOutputBuilder outputBuilder = new ReadFaultcurrentListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> result = this.eventRWFaultCurrent
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> result =
+ this.eventRWFaultCurrent.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.PaginationBuilder(
@@ -171,8 +175,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//eventRWFaultLog
public ReadFaultlogListOutputBuilder readFaultLogList(EntityInput input) {
ReadFaultlogListOutputBuilder outputBuilder = new ReadFaultlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> result = this.eventRWFaultLog
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> result =
+ this.eventRWFaultLog.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.PaginationBuilder(
@@ -185,8 +189,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//maintenanceRW
public ReadMaintenanceListOutputBuilder readMaintenanceList(EntityInput input) {
ReadMaintenanceListOutputBuilder outputBuilder = new ReadMaintenanceListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> result = this.maintenanceRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> result =
+ this.maintenanceRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.PaginationBuilder(
@@ -200,8 +204,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
public ReadMediatorServerListOutputBuilder readMediatorServerList(EntityInput input) {
ReadMediatorServerListOutputBuilder outputBuilder = new ReadMediatorServerListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> result = this.mediatorserverRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> result =
+ this.mediatorserverRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.PaginationBuilder(
@@ -212,11 +216,11 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder
//networkelementConnectionRW
- public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(
- EntityInput input) {
- ReadNetworkElementConnectionListOutputBuilder outputBuilder = new ReadNetworkElementConnectionListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> result = this.networkelementConnectionRW
- .getData(input);
+ public ReadNetworkElementConnectionListOutputBuilder readNetworkElementConnectionList(EntityInput input) {
+ ReadNetworkElementConnectionListOutputBuilder outputBuilder =
+ new ReadNetworkElementConnectionListOutputBuilder();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> result =
+ this.networkelementConnectionRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.PaginationBuilder(
@@ -229,8 +233,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//equipmentRW
public ReadInventoryListOutputBuilder readInventoryList(EntityInput input) {
ReadInventoryListOutputBuilder outputBuilder = new ReadInventoryListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> result = this.equipmentRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> result =
+ this.equipmentRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.PaginationBuilder(
@@ -243,8 +247,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//connnectionlogRW
public ReadConnectionlogListOutputBuilder readConnectionlogList(EntityInput input) {
ReadConnectionlogListOutputBuilder outputBuilder = new ReadConnectionlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> result = this.connnectionlogRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> result =
+ this.connnectionlogRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.PaginationBuilder(
@@ -257,8 +261,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//eventlogRW
public ReadEventlogListOutputBuilder readEventlogList(ReadEventlogListInput input) throws IOException {
ReadEventlogListOutputBuilder outputBuilder = new ReadEventlogListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> result = this.eventlogRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> result =
+ this.eventlogRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.PaginationBuilder(
@@ -270,8 +274,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder
public ReadPmdata15mListOutputBuilder readPmdata15mList(EntityInput input) {
ReadPmdata15mListOutputBuilder outputBuilder = new ReadPmdata15mListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result = this.pm15mRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result =
+ this.pm15mRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder(
@@ -283,8 +287,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
//org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Pagination
public ReadPmdata24hListOutputBuilder readPmdata24hList(EntityInput input) {
ReadPmdata24hListOutputBuilder outputBuilder = new ReadPmdata24hListOutputBuilder();
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> result = this.pm24hRW
- .getData(input);
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> result =
+ this.pm24hRW.getData(input);
outputBuilder.setData(result.getResult().getHits());
outputBuilder.setPagination(
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.PaginationBuilder(
@@ -318,14 +322,14 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
ReadPmdata24hLtpListOutputBuilder outputBuilder = new ReadPmdata24hLtpListOutputBuilder();
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder();
- outputBuilder.setPagination(new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder(
- result.getPagination()).build());
+ outputBuilder.setPagination(
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.ltp.list.output.PaginationBuilder(
+ result.getPagination()).build());
outputBuilder.setData(result.getResult().getHits());
return outputBuilder;
}
- public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input)
- throws IOException {
+ public ReadPmdata24hDeviceListOutputBuilder readPmdata24hDeviceList(EntityInput input) throws IOException {
QueryResult<String> result = pm24hRW.getDataDeviceList(input);
@@ -338,7 +342,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
}
public ReadStatusOutputBuilder readStatus() throws IOException {
- QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> result = readStatus.getDataStatus();
+ QueryResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> result =
+ readStatus.getDataStatus();
ReadStatusOutputBuilder outputBuilder = new ReadStatusOutputBuilder();
outputBuilder.setData(result.getResult().getHits());
@@ -349,7 +354,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return this.dbClient.waitForYellowStatus(unit.toMillis(timeout));
}
- public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
+ public CreateNetworkElementConnectionOutputBuilder createNetworkElementConnection(
NetworkElementConnectionEntity input) throws IOException {
String id = this.networkelementConnectionRW.update(input, input.getNodeId());
if (id == null) {
@@ -375,7 +380,8 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return builder;
}
- public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(DeleteNetworkElementConnectionInput input) throws IOException {
+ public DeleteNetworkElementConnectionOutputBuilder deleteNetworkElementConnection(
+ DeleteNetworkElementConnectionInput input) throws IOException {
boolean removed = this.networkelementConnectionRW.remove(input.getId());
if (!removed) {
throw new IOException(EXCEPTION_UNABLE_TO_REMOVE_FROM_DATABASE);
@@ -425,7 +431,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
}
public CreateMaintenanceOutputBuilder createMaintenance(CreateMaintenanceInput input) throws IOException {
- String id = this.maintenanceRW.write(input, input.getNodeId());
+ String id = this.maintenanceRW.write(input, input.getNodeId());
if (id == null) {
throw new IOException(EXCEPTION_UNABLE_TO_WRITE_IN_DATABASE);
}
@@ -433,7 +439,7 @@ public class ElasticSearchDataProvider /*extends BaseStatusProvider /* implement
return builder;
}
- public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
+ public CreateMediatorServerOutputBuilder createMediatorServer(CreateMediatorServerInput input) throws IOException {
String id = this.mediatorserverRW.write(input, null);
if (id == null) {
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
index 16b13ba96..7efdab110 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/FaultEntityManager.java
@@ -33,18 +33,18 @@ public class FaultEntityManager {
private static final Pattern pattern = Pattern.compile(".*\\[layerProtocol=(.*)\\]");
/**
- * The leading indication for notification or events that are not in the
- * currentProblem data of the ONF Coremodel
+ * The leading indication for notification or events that are not in the currentProblem data of the ONF Coremodel
*/
private static final String NOCURRENTPROBLEMINDICATION = "#";
/**
* Specific problems are not moving into current problem list
+ *
* @param problemName to be verified
* @return true if problem is current
*/
public static boolean isManagedAsCurrentProblem(String problemName) {
- return ! problemName.startsWith(NOCURRENTPROBLEMINDICATION);
+ return !problemName.startsWith(NOCURRENTPROBLEMINDICATION);
}
public static boolean isManagedAsCurrentProblem(Fault problem) {
@@ -53,6 +53,7 @@ public class FaultEntityManager {
/**
* Specific problems are not moving into current problem list
+ *
* @param fault to be verified
* @return true if cleared indication
*/
@@ -62,9 +63,10 @@ public class FaultEntityManager {
/**
* Create a specific ES id for the current log.
+ *
* @return a string with the generated ES Id
*/
- public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
+ public static String genSpecificEsId(String nodeName, String objectId, String problemName) {
String uuId;
@@ -86,6 +88,7 @@ public class FaultEntityManager {
/**
* Create Es id
+ *
* @param fault used to create uuid for faultcurrent
* @return String with Id
*/
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
index 4a4b332d6..d255cadcd 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseEventsService.java
@@ -63,8 +63,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Event service, writing all events into the database into the appropriate
- * index.
+ * Event service, writing all events into the database into the appropriate index.
*
* @author herbert
*/
@@ -88,7 +87,8 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
// --- Construct and initialize
- public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider) throws Exception {
+ public HtDatabaseEventsService(HtDatabaseClient client, ElasticSearchDataProvider elasticSearchDataProvider)
+ throws Exception {
LOG.info("Create {} start", HtDatabaseEventsService.class);
this.dataProvider = elasticSearchDataProvider;
@@ -100,27 +100,27 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWEventLogDevicemanager = new EsDataObjectReaderWriter2<>(client, Entity.Eventlog,
EventlogEntity.class, EventlogBuilder.class);
- eventRWEquipment = new EsDataObjectReaderWriter2<>(client, Entity.Inventoryequipment,
- InventoryEntity.class, InventoryBuilder.class);
+ eventRWEquipment = new EsDataObjectReaderWriter2<>(client, Entity.Inventoryequipment, InventoryEntity.class,
+ InventoryBuilder.class);
eventRWFaultCurrentDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultcurrent,
FaultcurrentEntity.class, FaultcurrentBuilder.class);
- eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog,
- FaultlogEntity.class, FaultlogBuilder.class);
+ eventRWFaultLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Faultlog, FaultlogEntity.class,
+ FaultlogBuilder.class);
eventRWConnectionLogDB = new EsDataObjectReaderWriter2<>(client, Entity.Connectionlog,
ConnectionlogEntity.class, ConnectionlogBuilder.class);
networkelementConnectionDB = new EsDataObjectReaderWriter2<>(client, Entity.NetworkelementConnection,
NetworkElementConnectionEntity.class, NetworkElementConnectionBuilder.class)
- .setEsIdAttributeName("_id");
+ .setEsIdAttributeName("_id");
- pmData15mDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min,
- PmdataEntity.class, PmdataEntityBuilder.class);
+ pmData15mDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance15min, PmdataEntity.class,
+ PmdataEntityBuilder.class);
- pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h,
- PmdataEntity.class, PmdataEntityBuilder.class);
+ pmData24hDB = new EsDataObjectReaderWriter2<>(client, Entity.Historicalperformance24h, PmdataEntity.class,
+ PmdataEntityBuilder.class);
} catch (Exception e) {
LOG.error("Can not start database client. Exception: {}", e);
@@ -142,6 +142,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
eventRWConnectionLogDB.write(event, null);
}
+
// -- Event log
@Override
public void writeEventLog(EventlogEntity event) {
@@ -163,7 +164,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
}
LOG.debug("Write fault to faultlog: {}", fault.toString());
- eventRWFaultLogDB.write(fault,null);
+ eventRWFaultLogDB.write(fault, null);
}
// -- Fault current
@@ -248,6 +249,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* write internal equipment to database
+ *
* @param internalEquipment with mandatory fields.
*/
@Override
@@ -256,14 +258,14 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
if (assertIfClientNullForNodeName(internalEquipment.getNodeId())) {
return;
}
- if(internalEquipment.getManufacturerIdentifier()==null) {
- internalEquipment = new InventoryBuilder(internalEquipment).setManufacturerIdentifier("").build();
+ if (internalEquipment.getManufacturerIdentifier() == null) {
+ internalEquipment = new InventoryBuilder(internalEquipment).setManufacturerIdentifier("").build();
}
- if(internalEquipment.getDate()==null) {
- internalEquipment = new InventoryBuilder(internalEquipment).setDate("").build();
+ if (internalEquipment.getDate() == null) {
+ internalEquipment = new InventoryBuilder(internalEquipment).setDate("").build();
}
-
- eventRWEquipment.write(internalEquipment, internalEquipment.getNodeId()+"/"+internalEquipment.getUuid());
+
+ eventRWEquipment.write(internalEquipment, internalEquipment.getNodeId() + "/" + internalEquipment.getUuid());
}
@@ -275,18 +277,22 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
* @param nodeId Id for this DB element
*/
@Override
- public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
+ public void updateNetworkConnectionDeviceType(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId) {
this.networkelementConnectionDB.update(networkElementConnectionEntitiy, nodeId);
}
/**
* Update after new mountpoint registration
+ *
* @param networkElementConnectionEntitiy data
* @param nodeId of device (mountpoint name)
*/
@Override
- public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy, String nodeId) {
- this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId, Arrays.asList("is-required", "username", "password"));
+ public void updateNetworkConnection22(NetworkElementConnectionEntity networkElementConnectionEntitiy,
+ String nodeId) {
+ this.networkelementConnectionDB.updateOrCreate(networkElementConnectionEntitiy, nodeId,
+ Arrays.asList("is-required", "username", "password"));
}
/* please do not remove */
@@ -302,15 +308,16 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
NetworkElementConnectionEntity e = this.networkelementConnectionDB.read(nodeId);
if (e != null && (isRequired = e.isIsRequired()) != null) {
if (isRequired) {
- LOG.debug("updating connection status for {} of required ne to disconnected",nodeId);
- this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder().setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
+ LOG.debug("updating connection status for {} of required ne to disconnected", nodeId);
+ this.networkelementConnectionDB.update(new UpdateNetworkElementConnectionInputBuilder()
+ .setStatus(ConnectionLogStatus.Disconnected).build(), nodeId);
} else {
- LOG.debug("remove networkelement-connection for {} entry because of non-required",nodeId);
+ LOG.debug("remove networkelement-connection for {} entry because of non-required", nodeId);
this.networkelementConnectionDB.remove(nodeId);
}
- }
- else {
- LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",nodeId);
+ } else {
+ LOG.warn("Unable to update connection-status. dbentry for {} not found in networkelement-connection",
+ nodeId);
}
}
@@ -349,6 +356,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
/**
* Verify status of client
+ *
* @param event that is printed with message
* @return true if client is null
*/
@@ -359,8 +367,10 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private boolean assertIfClientNullForNodeName(Object object) {
return assertIfClientNull("No DB, can not handle node: {}", object);
}
+
/**
* Verify status of client
+ *
* @param message to print including {} for object printout.
* @return true if client is null
*/
@@ -378,6 +388,7 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsEventBase {
/**
* Query to get older Elements
+ *
* @param netconfTimeStamp to identify older Elements
* @return QueryBuilder for older elements related to timestamp
*/
@@ -388,29 +399,31 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
private static class EsFaultLogDevicemanager {
/**
* Get older Elements
+ *
* @param netconfTimeStamp to identify query elements older than this timestamp.
* @return QueryBuilder for related elements
*/
public static QueryBuilder getQueryForTimeStamp(String netconfTimeStamp) {
return new RangeQueryBuilder("timestamp").lte(netconfTimeStamp);
}
- }
- public static class EsFaultCurrent {
+ }
+ public static class EsFaultCurrent {
/**
* @param nodeName name of the node
* @return query builder
*/
- public static QueryBuilder getQueryForOneNode( String nodeName) {
+ public static QueryBuilder getQueryForOneNode(String nodeName) {
return QueryBuilders.matchQuery("node-id", nodeName);
}
- public static QueryBuilder getQueryForOneNodeAndObjectId( String nodeName, String objectId) {
+ public static QueryBuilder getQueryForOneNodeAndObjectId(String nodeName, String objectId) {
BoolQueryBuilder bq = QueryBuilders.boolQuery();
bq.must(QueryBuilders.matchQuery("node-id", nodeName));
bq.must(QueryBuilders.matchQuery("object-id", objectId));
return bq;
}
}
+
@Override
public List<NetworkElementConnectionEntity> getNetworkElementConnections() {
return this.networkelementConnectionDB.doReadAll().getHits();
@@ -431,28 +444,29 @@ public class HtDatabaseEventsService implements ArchiveCleanProvider, DataProvid
id.append(date != null ? date.getValue() : "null");
switch (granularityPeriod) {
- case Period15Min:
- pmData15mDB.write(elem, id.toString());
- break;
- case Period24Hours:
- pmData24hDB.write(elem, id.toString());
- break;
- case Unknown:
- default:
- LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
- break;
+ case Period15Min:
+ pmData15mDB.write(elem, id.toString());
+ break;
+ case Period24Hours:
+ pmData24hDB.write(elem, id.toString());
+ break;
+ case Unknown:
+ default:
+ LOG.debug("Unknown granularity {} id {}", granularityPeriod, id);
+ break;
}
- } );
+ });
}
- @NonNull GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
+ @NonNull
+ GranularityPeriodType nnGetGranularityPeriodType(@Nullable GranularityPeriodType granularityPeriod) {
return granularityPeriod != null ? granularityPeriod : GranularityPeriodType.Unknown;
}
- @Override
- public HtDatabaseClient getRawClient() {
- return this.client;
- }
+ @Override
+ public HtDatabaseClient getRawClient() {
+ return this.client;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
index 245b89003..a675f6876 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/HtDatabaseMaintenanceService.java
@@ -61,6 +61,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
/**
* Get existing object for mountpoint to manage maintenance mode
+ *
* @return Object with configuration
*/
@Override
@@ -74,26 +75,23 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
}
@Override
- public
- MaintenanceEntity setMaintenance(MaintenanceEntity m) {
+ public MaintenanceEntity setMaintenance(MaintenanceEntity m) {
if (maintenanceRW != null) {
- if (maintenanceRW.write(m, m.getNodeId() ) == null) {
- throw new IllegalArgumentException("Problem writing to database: "+m.getId());
+ if (maintenanceRW.write(m, m.getNodeId()) == null) {
+ throw new IllegalArgumentException("Problem writing to database: " + m.getId());
}
- LOG.info("Wrote maintenance object {}", m.toString());
+ LOG.info("Wrote maintenance object {}", m.toString());
}
return m;
}
@Override
- public
- List<MaintenanceEntity> getAll() {
+ public List<MaintenanceEntity> getAll() {
return maintenanceRW != null ? maintenanceRW.doReadAll().getHits() : new ArrayList<>();
}
@Override
- public
- MaintenanceEntity createIfNotExists(String mountpointId) {
+ public MaintenanceEntity createIfNotExists(String mountpointId) {
MaintenanceEntity deviceMaintenanceMode = null;
if (maintenanceRW != null) {
deviceMaintenanceMode = maintenanceRW.read(mountpointId);
@@ -111,8 +109,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
}
@Override
- public
- void deleteIfNotRequired(String mountPointNodeName) {
+ public void deleteIfNotRequired(String mountPointNodeName) {
if (!this.isRequireNe(mountPointNodeName)) {
if (maintenanceRW != null) {
@@ -128,6 +125,7 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
/**
* Provide default maintenanceinformation for a device
+ *
* @param mountpointId nodeId of device
* @return default data
*/
@@ -143,14 +141,14 @@ public class HtDatabaseMaintenanceService implements HtDatabaseMaintenance {
deviceMaintenanceModeBuilder.setStart(now);
deviceMaintenanceModeBuilder.setEnd(now);
deviceMaintenanceModeBuilder.setActive(false);
-
+
// Reference to all
//consistent to UI input to null/not empty string
//deviceMaintenanceModeBuilder.setObjectIdRef("");
//deviceMaintenanceModeBuilder.setProblem("");
-
+
return deviceMaintenanceModeBuilder.build();
- }
+ }
// -- Private
/**
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
index 0d2e39bcb..38e5b13e2 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/MediatorServerDataProvider.java
@@ -38,66 +38,66 @@ import org.slf4j.LoggerFactory;
public class MediatorServerDataProvider implements AutoCloseable {
- private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
+ private static final Logger LOG = LoggerFactory.getLogger(MediatorServerDataProvider.class);
- private final HtDatabaseClient dbClient;
- private final DataObjectAcessor<Data> mediatorserverRW;
- private final int REFRESH_INTERVAL = 60;
- private final Map<String, Data> entries;
- private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
- private boolean isRunning;
+ private final HtDatabaseClient dbClient;
+ private final DataObjectAcessor<Data> mediatorserverRW;
+ private final int REFRESH_INTERVAL = 60;
+ private final Map<String, Data> entries;
+ private final ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
+ private boolean isRunning;
- public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
- this(hosts, null, null);
- }
+ public MediatorServerDataProvider(HostInfo[] hosts) throws Exception {
+ this(hosts, null, null);
+ }
- public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception {
- super();
- LOG.info("Start {}", this.getClass().getName());
- this.entries = new HashMap<>();
- this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword);
- this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer, Data.class);
- this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
- }
+ public MediatorServerDataProvider(HostInfo[] hosts, String authUsername, String authPassword) throws Exception {
+ super();
+ LOG.info("Start {}", this.getClass().getName());
+ this.entries = new HashMap<>();
+ this.dbClient = new HtDatabaseClient(hosts, authUsername, authPassword);
+ this.mediatorserverRW = new DataObjectAcessor<>(dbClient, Entity.MediatorServer, Data.class);
+ this.scheduler.scheduleAtFixedRate(onTick, this.REFRESH_INTERVAL, this.REFRESH_INTERVAL, TimeUnit.SECONDS);
+ }
- private final Runnable onTick = new Runnable() {
+ private final Runnable onTick = new Runnable() {
- @Override
- public void run() {
- isRunning = true;
- runIt();
- isRunning = false;
- }
+ @Override
+ public void run() {
+ isRunning = true;
+ runIt();
+ isRunning = false;
+ }
- };
+ };
- private void runIt() {
- SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
- List<Data> data = result.getHits();
- for (Data item : data) {
- MediatorServerDataProvider.this.entries.put(item.getId(), item);
- }
- }
+ private void runIt() {
+ SearchResult<Data> result = MediatorServerDataProvider.this.mediatorserverRW.doReadAll();
+ List<Data> data = result.getHits();
+ for (Data item : data) {
+ MediatorServerDataProvider.this.entries.put(item.getId(), item);
+ }
+ }
- /**
- *
- * @param dbServerId
- * @return url or null if not exists
- */
- public String getHostUrl(String dbServerId) {
- Data info = this.entries.getOrDefault(dbServerId, null);
- return info == null ? null : info.getUrl();
- }
+ /**
+ *
+ * @param dbServerId
+ * @return url or null if not exists
+ */
+ public String getHostUrl(String dbServerId) {
+ Data info = this.entries.getOrDefault(dbServerId, null);
+ return info == null ? null : info.getUrl();
+ }
- public boolean triggerReloadSync() {
- if (!isRunning) {
- runIt();
- }
- return true;
- }
+ public boolean triggerReloadSync() {
+ if (!isRunning) {
+ runIt();
+ }
+ return true;
+ }
- @Override
- public void close() throws Exception {
- this.scheduler.shutdown();
- }
+ @Override
+ public void close() throws Exception {
+ this.scheduler.shutdown();
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
index 330b0baf5..8027fb2c5 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/ODLVersionLUT.java
@@ -23,41 +23,42 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.data;
public class ODLVersionLUT {
- public static String getONAPReleaseName(String onapCCSDKVersion,String def) {
- if(onapCCSDKVersion==null) {
- return def;
- }
- if(onapCCSDKVersion.startsWith("1.6.")) {
- return "ONAP Guillin";
- }
- if(onapCCSDKVersion.startsWith("1.5.")) {
- return "ONAP Frankfurt";
- }
- if(onapCCSDKVersion.startsWith("1.4.")) {
- return "ONAP El Alto";
- }
- if(onapCCSDKVersion.startsWith("1.3.")) {
- return "ONAP El Alto";
- }
- return def;
- }
- public static String getOdlVersion(String onapCCSDKVersion,String def) {
-
- if(onapCCSDKVersion==null) {
- return def;
- }
- if(onapCCSDKVersion.startsWith("1.6.")) {
- return "sodium-SRX (0.11.X)";
- }
- if(onapCCSDKVersion.startsWith("1.5.")) {
- return "neon-SR1 (0.10.1)";
- }
- if(onapCCSDKVersion.startsWith("1.4.")) {
- return "neon-SR1 (0.10.1)";
- }
- if(onapCCSDKVersion.startsWith("1.3.")) {
- return "fluorine-SR2 (0.9.2)";
- }
- return def;
- }
+ public static String getONAPReleaseName(String onapCCSDKVersion, String def) {
+ if (onapCCSDKVersion == null) {
+ return def;
+ }
+ if (onapCCSDKVersion.startsWith("1.6.")) {
+ return "ONAP Guillin";
+ }
+ if (onapCCSDKVersion.startsWith("1.5.")) {
+ return "ONAP Frankfurt";
+ }
+ if (onapCCSDKVersion.startsWith("1.4.")) {
+ return "ONAP El Alto";
+ }
+ if (onapCCSDKVersion.startsWith("1.3.")) {
+ return "ONAP El Alto";
+ }
+ return def;
+ }
+
+ public static String getOdlVersion(String onapCCSDKVersion, String def) {
+
+ if (onapCCSDKVersion == null) {
+ return def;
+ }
+ if (onapCCSDKVersion.startsWith("1.6.")) {
+ return "sodium-SRX (0.11.X)";
+ }
+ if (onapCCSDKVersion.startsWith("1.5.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if (onapCCSDKVersion.startsWith("1.4.")) {
+ return "neon-SR1 (0.10.1)";
+ }
+ if (onapCCSDKVersion.startsWith("1.3.")) {
+ return "fluorine-SR2 (0.9.2)";
+ }
+ return def;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
index a83dfd975..b6a502071 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryByFilter.java
@@ -44,12 +44,12 @@ import org.slf4j.LoggerFactory;
public class QueryByFilter {
- private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
- private static final List<String> timestampValueNames = Arrays.asList("timestamp","start","end");
+ private static final Logger LOG = LoggerFactory.getLogger(DataObjectAcessorPm.class);
+ private static final List<String> timestampValueNames = Arrays.asList("timestamp", "start", "end");
- private QueryByFilter() {
- //Hide
- }
+ private QueryByFilter() {
+ //Hide
+ }
static long getPage(EntityInput input) {
return getPage(input, 1);
@@ -88,7 +88,7 @@ public class QueryByFilter {
}
- public static Sortorder getSortOrder(@Nullable List<Sortorder> list, String prop) {
+ public static Sortorder getSortOrder(@Nullable List<Sortorder> list, String prop) {
if (list == null) {
return null;
}
@@ -100,7 +100,7 @@ public class QueryByFilter {
return null;
}
- public static Filter getFilter(@Nullable List<Filter> list, String prop) {
+ public static Filter getFilter(@Nullable List<Filter> list, String prop) {
if (list == null) {
return null;
}
@@ -112,161 +112,157 @@ public class QueryByFilter {
return null;
}
- public static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
+ public static QueryBuilder fromFilter(@Nullable List<Filter> filters) {
return fromFilter(filters, "");
}
- private static String fillTimeStamp(String value) {
- int idx=value.lastIndexOf("*");
- final String REPLACE="0000-00-00T00:00:00.0Z";
- String s = value.substring(0,idx)+REPLACE.substring(idx);
- if(Integer.parseInt(s.substring(5,7))==0) {
- s=s.substring(0,5)+"01-"+s.substring(8);
+ private static String fillTimeStamp(String value) {
+ int idx = value.lastIndexOf("*");
+ final String REPLACE = "0000-00-00T00:00:00.0Z";
+ String s = value.substring(0, idx) + REPLACE.substring(idx);
+ if (Integer.parseInt(s.substring(5, 7)) == 0) {
+ s = s.substring(0, 5) + "01-" + s.substring(8);
}
- if(Integer.parseInt(s.substring(8,10))==0) {
- s=s.substring(0,8)+"01"+s.substring(10);
+ if (Integer.parseInt(s.substring(8, 10)) == 0) {
+ s = s.substring(0, 8) + "01" + s.substring(10);
}
return s;
- }
- /**
- * convert timestamp with ending placeholder in filter to elasticsearch filter
- * e.g. 2017* => gte: 2017-01-01T00:00:00Z, lt:2018-01-01T00:00:00Z
- *
- * 201* => 2010-01... 2020 ..
- * 2018-* => 2018-01... <=> 2019-01
- *
- */
- private static @Nullable QueryBuilder fromTimestampSearchFilter(String property,String value) {
- if(!value.endsWith("*")) {
+ }
+
+ /**
+ * convert timestamp with ending placeholder in filter to elasticsearch filter e.g. 2017* => gte:
+ * 2017-01-01T00:00:00Z, lt:2018-01-01T00:00:00Z
+ *
+ * 201* => 2010-01... 2020 .. 2018-* => 2018-01... <=> 2019-01
+ *
+ */
+ private static @Nullable QueryBuilder fromTimestampSearchFilter(String property, String value) {
+ if (!value.endsWith("*")) {
return null;
}
- int idx=value.lastIndexOf("*");
+ int idx = value.lastIndexOf("*");
String lowerEnd = fillTimeStamp(value);
- String upperEnd =null;
+ String upperEnd = null;
NetconfTimeStamp converter = NetconfTimeStampImpl.getConverter();
Date dt = null;
- try{
- dt=converter.getDateFromNetconf(lowerEnd);
- }
- catch(Exception e) {
+ try {
+ dt = converter.getDateFromNetconf(lowerEnd);
+ } catch (Exception e) {
}
- if(dt==null) {
+ if (dt == null) {
return null;
}
-// property.substring(0,idx)+REPLACE.substring(idx+1);
- Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
+ // property.substring(0,idx)+REPLACE.substring(idx+1);
+ Calendar c = Calendar.getInstance(TimeZone.getTimeZone("UTC"));
c.setTime(dt);
int tmpvalue;
- switch(idx) {
- case 1: // (2*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1000);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 2: // (20*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+100);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 3: // (200*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 4: // (2000*)
- case 5: // (2000-*)
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 6: //switch 10 months (2000-0* or 2000-1*)
- tmpvalue = c.get(Calendar.MONTH);
- if(tmpvalue<9) {
- c.set(Calendar.MONTH,9);
- }
- else {
- c.set(Calendar.YEAR,c.get(Calendar.YEAR)+1);
- c.set(Calendar.MONTH,0);
+ switch (idx) {
+ case 1: // (2*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1000);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 2: // (20*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 100);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 3: // (200*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 4: // (2000*)
+ case 5: // (2000-*)
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 6: //switch 10 months (2000-0* or 2000-1*)
+ tmpvalue = c.get(Calendar.MONTH);
+ if (tmpvalue < 9) {
+ c.set(Calendar.MONTH, 9);
+ } else {
+ c.set(Calendar.YEAR, c.get(Calendar.YEAR) + 1);
+ c.set(Calendar.MONTH, 0);
}
upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 7: //switch one month (2018-01* or 2018-01-*)
- case 8:
- c.add(Calendar.MONTH, 1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 9: // (2018-01-0*)
- tmpvalue = c.get(Calendar.DAY_OF_MONTH);
- if(tmpvalue==1) {
- c.set(Calendar.DAY_OF_MONTH, 10);
- }else if(tmpvalue==10) {
- c.set(Calendar.DAY_OF_MONTH, 20);
- }else if(tmpvalue==20) {
- if(c.getActualMaximum(Calendar.DAY_OF_MONTH)<30) {
- c.set(Calendar.DAY_OF_MONTH,1);
- c.add(Calendar.MONTH,1);
+ break;
+ case 7: //switch one month (2018-01* or 2018-01-*)
+ case 8:
+ c.add(Calendar.MONTH, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 9: // (2018-01-0*)
+ tmpvalue = c.get(Calendar.DAY_OF_MONTH);
+ if (tmpvalue == 1) {
+ c.set(Calendar.DAY_OF_MONTH, 10);
+ } else if (tmpvalue == 10) {
+ c.set(Calendar.DAY_OF_MONTH, 20);
+ } else if (tmpvalue == 20) {
+ if (c.getActualMaximum(Calendar.DAY_OF_MONTH) < 30) {
+ c.set(Calendar.DAY_OF_MONTH, 1);
+ c.add(Calendar.MONTH, 1);
+ } else {
+ c.set(Calendar.DAY_OF_MONTH, 30);
+ }
+ } else if (tmpvalue == 30) {
+ c.set(Calendar.DAY_OF_MONTH, 1);
+ c.add(Calendar.MONTH, 1);
+ } else {
+ break;
}
- else {
- c.set(Calendar.DAY_OF_MONTH,30);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 10: // (2018-01-01*)
+ case 11: // (2018-01-01T*)
+ c.add(Calendar.DAY_OF_MONTH, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 12: // (2018-01-01T1*)
+ tmpvalue = c.get(Calendar.HOUR_OF_DAY);
+ if (tmpvalue == 20) {
+ c.set(Calendar.HOUR_OF_DAY, 0);
+ c.add(Calendar.DAY_OF_MONTH, 1);
+ } else {
+ c.add(Calendar.HOUR_OF_DAY, 10);
}
- }else if(tmpvalue==30) {
- c.set(Calendar.DAY_OF_MONTH,1);
- c.add(Calendar.MONTH,1);
- }
- else {
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 13: // (2018-01-01T11*)
+ case 14: // (2018-01-01T11-*)
+ c.add(Calendar.HOUR_OF_DAY, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 15: // (2018-01-01T11-3*)
+ c.add(Calendar.MINUTE, 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 16: // (2018-01-01T11-32*)
+ case 17: // (2018-01-01T11-32-*)
+ c.add(Calendar.MINUTE, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 18: // (2018-01-01T11-32-1*)
+ c.add(Calendar.SECOND, 10);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
+ break;
+ case 19: // (2018-01-01T11-32-11*)
+ case 20: // (2018-01-01T11-32-11.*)
+ c.add(Calendar.SECOND, 1);
+ upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
break;
- }
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 10: // (2018-01-01*)
- case 11: // (2018-01-01T*)
- c.add(Calendar.DAY_OF_MONTH,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 12: // (2018-01-01T1*)
- tmpvalue = c.get(Calendar.HOUR_OF_DAY);
- if(tmpvalue==20) {
- c.set(Calendar.HOUR_OF_DAY,0);
- c.add(Calendar.DAY_OF_MONTH,1);
- }
- else {
- c.add(Calendar.HOUR_OF_DAY,10);
- }
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 13: // (2018-01-01T11*)
- case 14: // (2018-01-01T11-*)
- c.add(Calendar.HOUR_OF_DAY,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 15: // (2018-01-01T11-3*)
- c.add(Calendar.MINUTE,10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 16: // (2018-01-01T11-32*)
- case 17: // (2018-01-01T11-32-*)
- c.add(Calendar.MINUTE,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 18: // (2018-01-01T11-32-1*)
- c.add(Calendar.SECOND,10);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
- case 19: // (2018-01-01T11-32-11*)
- case 20: // (2018-01-01T11-32-11.*)
- c.add(Calendar.SECOND,1);
- upperEnd = converter.getTimeStampAsNetconfString(c.getTime());
- break;
default:
break;
}
- if(upperEnd==null) {
+ if (upperEnd == null) {
return null;
}
return QueryBuilders.rangeQuery(property).gte(lowerEnd).lt(upperEnd);
}
+
private static QueryBuilder fromFilter(@Nullable List<Filter> filters, String prefix) {
if (filters == null || filters.size() == 0) {
return QueryBuilders.matchAllQuery();
@@ -274,17 +270,16 @@ public class QueryByFilter {
} else if (filters.size() == 1) {
QueryBuilder query;
String p = filters.get(0).getProperty();
- String v= filters.get(0).getFiltervalue();
+ String v = filters.get(0).getFiltervalue();
if ("id".equals(p)) {
p = "_id";
- }
- else {
- // v=v.toLowerCase();
+ } else {
+ // v=v.toLowerCase();
}
if (DbFilter.hasSearchParams(v)) {
- if(p!=null && timestampValueNames.contains(p.toLowerCase())) {
- query = fromTimestampSearchFilter(p,v);
- if(query!=null) {
+ if (p != null && timestampValueNames.contains(p.toLowerCase())) {
+ query = fromTimestampSearchFilter(p, v);
+ if (query != null) {
return query;
}
}
@@ -295,50 +290,45 @@ public class QueryByFilter {
RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p, v);
if (q != null) {
return q;
- }
- else {
+ } else {
return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
}
- }
- else {
+ } else {
return QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v);
}
- }
- else {
+ } else {
BoolQueryBuilder query = new BoolQueryBuilder();
QueryBuilder tmpQuery;
for (Filter fi : filters) {
String p = fi.getProperty();
- String v=fi.getFiltervalue();
+ String v = fi.getFiltervalue();
if ("id".equals(p)) {
p = "_id";
+ } else {
+ // v=v.toLowerCase();
}
- else {
- // v=v.toLowerCase();
- }
- if(DbFilter.hasSearchParams(v)) {
- if(p!=null && timestampValueNames.contains(p.toLowerCase())) {
- tmpQuery=fromTimestampSearchFilter(p,v);
- if(tmpQuery!=null) {
+ if (DbFilter.hasSearchParams(v)) {
+ if (p != null && timestampValueNames.contains(p.toLowerCase())) {
+ tmpQuery = fromTimestampSearchFilter(p, v);
+ if (tmpQuery != null) {
query.must(tmpQuery);
- }else {
- query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ } else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,
+ DbFilter.createDatabaseRegex(v)));
}
- }else {
- query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,DbFilter.createDatabaseRegex(v)));
+ } else {
+ query.must(QueryBuilders.regex((prefix != null ? prefix : "") + p,
+ DbFilter.createDatabaseRegex(v)));
}
- }
- else if (DbFilter.isComparisonValid(v)) {
- RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p,v);
- if(q!=null) {
+ } else if (DbFilter.isComparisonValid(v)) {
+ RangeQueryBuilder q = DbFilter.getRangeQuery((prefix != null ? prefix : "") + p, v);
+ if (q != null) {
query.must(q);
+ } else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v));
}
- else {
- query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
- }
- }
- else {
- query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p,v));
+ } else {
+ query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + p, v));
}
}
LOG.trace("Query result. {}", query.toJSON());
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
index 87e1a7cdb..61e524192 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/QueryResult.java
@@ -29,27 +29,26 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class QueryResult<T> {
- private SearchResult<T> result;
- private PaginationOutputG pagination;
-
- public QueryResult(long page, long pageSize, SearchResult<T> result) {
- this.result = result;
-
- PaginationBuilder x = new PaginationBuilder();
- x.setPage(BigInteger.valueOf(page));
- x.setSize(pageSize);
- x.setTotal(BigInteger.valueOf(result.getTotal()));
- pagination = x.build();
- }
-
- public SearchResult<T> getResult() {
- return result;
- }
-
- PaginationOutputG getPagination() {
- return pagination;
- }
-
+ private SearchResult<T> result;
+ private PaginationOutputG pagination;
+
+ public QueryResult(long page, long pageSize, SearchResult<T> result) {
+ this.result = result;
+
+ PaginationBuilder x = new PaginationBuilder();
+ x.setPage(BigInteger.valueOf(page));
+ x.setSize(pageSize);
+ x.setTotal(BigInteger.valueOf(result.getTotal()));
+ pagination = x.build();
+ }
+
+ public SearchResult<T> getResult() {
+ return result;
+ }
+
+ PaginationOutputG getPagination() {
+ return pagination;
+ }
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
index dce309c33..9b8806ab8 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/SystemInfo.java
@@ -48,284 +48,290 @@ import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
public class SystemInfo {
- private static NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
- private static NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH));
- private static NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
- private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
- protected static boolean showMemoryPools = false;
+ private static NumberFormat fmtI = new DecimalFormat("###,###", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtDec = new DecimalFormat("###,###.##", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static NumberFormat fmtD = new DecimalFormat("###,##0.000", new DecimalFormatSymbols(Locale.ENGLISH));
+ private static OperatingSystemMXBean os = ManagementFactory.getOperatingSystemMXBean();
+ protected static boolean showMemoryPools = false;
- public static String getMdSalVersion(String def) {
- return getMdSalVersion("", def);
- }
- public static String getYangToolsVersion(String def) {
- return getYangToolsVersion("", def);
- }
-
- public static String getMdSalVersion(String baseOdlDirectory,String def) {
- return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/mdsal/mdsal-binding-api/",def);
- }
- public static String getYangToolsVersion(String baseOdlDirectory,String def) {
- return getFeatureVersionByFolder(baseOdlDirectory,"system/org/opendaylight/yangtools/odl-yangtools-common/",def);
- }
- private static String getFeatureVersionByFolder(String baseOdlDirectory,String dir,String def) {
- final String regex = "^[0-9]+\\.[0-9]+\\.[0-9]+(-SNAPSHOT)?$";
- Stream<Path> entries=null;
- try {
- if(baseOdlDirectory!=null && baseOdlDirectory.length()>0 && !baseOdlDirectory.endsWith("/")) {
- baseOdlDirectory+="/";
- }
- entries = Files.list(new File(baseOdlDirectory+dir).toPath());
- } catch (IOException e) {
-
- }
- if(entries==null) {
- return def;
- }
- final Pattern pattern = Pattern.compile(regex);
-
- Iterator<Path> it = entries.iterator();
- Path p;File f;
- while(it.hasNext()) {
- p = it.next();
- f=p.toFile();
- if(f.isDirectory()) {
- final Matcher matcher = pattern.matcher(f.getName().toString());
- if(matcher.find()) {
- def= matcher.group(0);
- break;
- }
- }
- }
- entries.close();
- return def;
- }
- public static String get() throws Exception {
- StringBuilder sb = new StringBuilder();
- int maxNameLen;
+ public static String getMdSalVersion(String def) {
+ return getMdSalVersion("", def);
+ }
- RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
- ThreadMXBean threads = ManagementFactory.getThreadMXBean();
- MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
- ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
+ public static String getYangToolsVersion(String def) {
+ return getYangToolsVersion("", def);
+ }
- //
- // print Karaf informations
- //
- maxNameLen = 25;
- sb.append("Karaf\n");
- printValue(sb, "Karaf version", maxNameLen, System.getProperty("karaf.version"));
- printValue(sb, "Karaf home", maxNameLen, System.getProperty("karaf.home"));
- printValue(sb, "Karaf base", maxNameLen, System.getProperty("karaf.base"));
- String osgi = getOsgiFramework();
- if (osgi != null) {
- printValue(sb, "OSGi Framework", maxNameLen, osgi);
- }
+ public static String getMdSalVersion(String baseOdlDirectory, String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory, "system/org/opendaylight/mdsal/mdsal-binding-api/", def);
+ }
- sb.append("JVM\n");
- printValue(sb, "Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
- printValue(sb, "Version", maxNameLen, System.getProperty("java.version"));
- printValue(sb, "Vendor", maxNameLen, runtime.getVmVendor());
- printValue(sb, "Pid", maxNameLen, getPid());
- printValue(sb, "Uptime", maxNameLen, printDuration(runtime.getUptime()));
- try {
- Class<?> sunOS = Class.forName("com.sun.management.OperatingSystemMXBean");
- printValue(sb, "Process CPU time", maxNameLen,
- printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 1000000.0));
- printValue(sb, "Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad")));
- printValue(sb, "System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad")));
- } catch (Throwable t) {
- }
- try {
- Class<?> unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
- printValue(sb, "Open file descriptors", maxNameLen,
- printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount")));
- printValue(sb, "Max file descriptors", maxNameLen,
- printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount")));
- } catch (Throwable t) {
- }
- printValue(sb, "Total compile time", maxNameLen,
- printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
+ public static String getYangToolsVersion(String baseOdlDirectory, String def) {
+ return getFeatureVersionByFolder(baseOdlDirectory, "system/org/opendaylight/yangtools/odl-yangtools-common/",
+ def);
+ }
- sb.append("Threads\n");
- printValue(sb, "Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
- printValue(sb, "Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
- printValue(sb, "Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
- printValue(sb, "Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
+ private static String getFeatureVersionByFolder(String baseOdlDirectory, String dir, String def) {
+ final String regex = "^[0-9]+\\.[0-9]+\\.[0-9]+(-SNAPSHOT)?$";
+ Stream<Path> entries = null;
+ try {
+ if (baseOdlDirectory != null && baseOdlDirectory.length() > 0 && !baseOdlDirectory.endsWith("/")) {
+ baseOdlDirectory += "/";
+ }
+ entries = Files.list(new File(baseOdlDirectory + dir).toPath());
+ } catch (IOException e) {
- sb.append("Memory\n");
- printValue(sb, "Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
- printValue(sb, "Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
- printValue(sb, "Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
- printValue(sb, "Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
- for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
- String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = "
- + printDuration(gc.getCollectionTime());
- printValue(sb, "Garbage collector", maxNameLen, val);
- }
+ }
+ if (entries == null) {
+ return def;
+ }
+ final Pattern pattern = Pattern.compile(regex);
-// if (showMemoryPools) {
-// List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
-// sb.append("Memory Pools\n");
-// printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size()));
-// String spaces4 = " ";
-// for (MemoryPoolMXBean pool : memoryPools) {
-// String name = pool.getName();
-// MemoryType type = pool.getType();
-// printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name);
-//
-// // PeakUsage/CurrentUsage
-// MemoryUsage peakUsage = pool.getPeakUsage();
-// MemoryUsage usage = pool.getUsage();
-//
-// if (usage != null && peakUsage != null) {
-// long init = peakUsage.getInit();
-// long used = peakUsage.getUsed();
-// long committed = peakUsage.getCommitted();
-// long max = peakUsage.getMax();
-// sb.append(spaces4 + spaces4 + "Peak Usage\n");
-// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
-//
-// init = usage.getInit();
-// used = usage.getUsed();
-// committed = usage.getCommitted();
-// max = usage.getMax();
-// sb.append(spaces4 + spaces4 + "Current Usage\n");
-// printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
-// printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
-// }
-// }
-// }
+ Iterator<Path> it = entries.iterator();
+ Path p;
+ File f;
+ while (it.hasNext()) {
+ p = it.next();
+ f = p.toFile();
+ if (f.isDirectory()) {
+ final Matcher matcher = pattern.matcher(f.getName().toString());
+ if (matcher.find()) {
+ def = matcher.group(0);
+ break;
+ }
+ }
+ }
+ entries.close();
+ return def;
+ }
- sb.append("Classes\n");
- printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
- printValue(sb, "Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
- printValue(sb, "Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
+ public static String get() throws Exception {
+ StringBuilder sb = new StringBuilder();
+ int maxNameLen;
- sb.append("Operating system\n");
- printValue(sb, "Name", maxNameLen, os.getName() + " version " + os.getVersion());
- printValue(sb, "Architecture", maxNameLen, os.getArch());
- printValue(sb, "Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
- try {
- printValue(sb, "Total physical memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
- printValue(sb, "Free physical memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
- printValue(sb, "Committed virtual memory", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
- printValue(sb, "Total swap space", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
- printValue(sb, "Free swap space", maxNameLen,
- printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
- } catch (Throwable t) {
- }
- return sb.toString();
- }
+ RuntimeMXBean runtime = ManagementFactory.getRuntimeMXBean();
+ ThreadMXBean threads = ManagementFactory.getThreadMXBean();
+ MemoryMXBean mem = ManagementFactory.getMemoryMXBean();
+ ClassLoadingMXBean cl = ManagementFactory.getClassLoadingMXBean();
- private static String getPid() {
- // In Java 9 the new process API can be used:
- // long pid = ProcessHandle.current().getPid();
- String name = ManagementFactory.getRuntimeMXBean().getName();
- String[] parts = name.split("@");
- return parts[0];
- }
+ //
+ // print Karaf informations
+ //
+ maxNameLen = 25;
+ sb.append("Karaf\n");
+ printValue(sb, "Karaf version", maxNameLen, System.getProperty("karaf.version"));
+ printValue(sb, "Karaf home", maxNameLen, System.getProperty("karaf.home"));
+ printValue(sb, "Karaf base", maxNameLen, System.getProperty("karaf.base"));
+ String osgi = getOsgiFramework();
+ if (osgi != null) {
+ printValue(sb, "OSGi Framework", maxNameLen, osgi);
+ }
- private static long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
- Method mth = os.getClass().getMethod(name);
- return (Long) mth.invoke(os);
- }
+ sb.append("JVM\n");
+ printValue(sb, "Java Virtual Machine", maxNameLen, runtime.getVmName() + " version " + runtime.getVmVersion());
+ printValue(sb, "Version", maxNameLen, System.getProperty("java.version"));
+ printValue(sb, "Vendor", maxNameLen, runtime.getVmVendor());
+ printValue(sb, "Pid", maxNameLen, getPid());
+ printValue(sb, "Uptime", maxNameLen, printDuration(runtime.getUptime()));
+ try {
+ Class<?> sunOS = Class.forName("com.sun.management.OperatingSystemMXBean");
+ printValue(sb, "Process CPU time", maxNameLen,
+ printDuration(getValueAsLong(sunOS, "getProcessCpuTime") / 1000000.0));
+ printValue(sb, "Process CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getProcessCpuLoad")));
+ printValue(sb, "System CPU load", maxNameLen, fmtDec.format(getValueAsDouble(sunOS, "getSystemCpuLoad")));
+ } catch (Throwable t) {
+ }
+ try {
+ Class<?> unixOS = Class.forName("com.sun.management.UnixOperatingSystemMXBean");
+ printValue(sb, "Open file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getOpenFileDescriptorCount")));
+ printValue(sb, "Max file descriptors", maxNameLen,
+ printLong(getValueAsLong(unixOS, "getMaxFileDescriptorCount")));
+ } catch (Throwable t) {
+ }
+ printValue(sb, "Total compile time", maxNameLen,
+ printDuration(ManagementFactory.getCompilationMXBean().getTotalCompilationTime()));
- private static long getValueAsLong(Class<?> osImpl, String name) throws Exception {
- if (osImpl.isInstance(os)) {
- Method mth = osImpl.getMethod(name);
- return (Long) mth.invoke(os);
- }
- return -1;
- }
+ sb.append("Threads\n");
+ printValue(sb, "Live threads", maxNameLen, Integer.toString(threads.getThreadCount()));
+ printValue(sb, "Daemon threads", maxNameLen, Integer.toString(threads.getDaemonThreadCount()));
+ printValue(sb, "Peak", maxNameLen, Integer.toString(threads.getPeakThreadCount()));
+ printValue(sb, "Total started", maxNameLen, Long.toString(threads.getTotalStartedThreadCount()));
- private static double getValueAsDouble(Class<?> osImpl, String name) throws Exception {
- if (osImpl.isInstance(os)) {
- Method mth = osImpl.getMethod(name);
- return (Double) mth.invoke(os);
- }
- return -1;
- }
+ sb.append("Memory\n");
+ printValue(sb, "Current heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getUsed()));
+ printValue(sb, "Maximum heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getMax()));
+ printValue(sb, "Committed heap size", maxNameLen, printSizeInKb(mem.getHeapMemoryUsage().getCommitted()));
+ printValue(sb, "Pending objects", maxNameLen, Integer.toString(mem.getObjectPendingFinalizationCount()));
+ for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
+ String val = "Name = '" + gc.getName() + "', Collections = " + gc.getCollectionCount() + ", Time = "
+ + printDuration(gc.getCollectionTime());
+ printValue(sb, "Garbage collector", maxNameLen, val);
+ }
- private static String printLong(long i) {
- return fmtI.format(i);
- }
+ // if (showMemoryPools) {
+ // List<MemoryPoolMXBean> memoryPools = ManagementFactory.getMemoryPoolMXBeans();
+ // sb.append("Memory Pools\n");
+ // printValue(sb, "Total Memory Pools", maxNameLen, printLong(memoryPools.size()));
+ // String spaces4 = " ";
+ // for (MemoryPoolMXBean pool : memoryPools) {
+ // String name = pool.getName();
+ // MemoryType type = pool.getType();
+ // printValue(sb, spaces4 + "Pool (" + type + ")", maxNameLen, name);
+ //
+ // // PeakUsage/CurrentUsage
+ // MemoryUsage peakUsage = pool.getPeakUsage();
+ // MemoryUsage usage = pool.getUsage();
+ //
+ // if (usage != null && peakUsage != null) {
+ // long init = peakUsage.getInit();
+ // long used = peakUsage.getUsed();
+ // long committed = peakUsage.getCommitted();
+ // long max = peakUsage.getMax();
+ // sb.append(spaces4 + spaces4 + "Peak Usage\n");
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+ //
+ // init = usage.getInit();
+ // used = usage.getUsed();
+ // committed = usage.getCommitted();
+ // max = usage.getMax();
+ // sb.append(spaces4 + spaces4 + "Current Usage\n");
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "init", maxNameLen, printLong(init));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "used", maxNameLen, printLong(used));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "committed", maxNameLen, printLong(committed));
+ // printValue(sb, spaces4 + spaces4 + spaces4 + "max", maxNameLen, printLong(max));
+ // }
+ // }
+ // }
- private static String printSizeInKb(double size) {
- return fmtI.format((long) (size / 1024)) + " kbytes";
- }
+ sb.append("Classes\n");
+ printValue(sb, "Current classes loaded", maxNameLen, printLong(cl.getLoadedClassCount()));
+ printValue(sb, "Total classes loaded", maxNameLen, printLong(cl.getTotalLoadedClassCount()));
+ printValue(sb, "Total classes unloaded", maxNameLen, printLong(cl.getUnloadedClassCount()));
- protected static String printDuration(double uptime) {
- uptime /= 1000;
- if (uptime < 60) {
- return fmtD.format(uptime) + " seconds";
- }
- uptime /= 60;
- if (uptime < 60) {
- long minutes = (long) uptime;
- String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- return s;
- }
- uptime /= 60;
- if (uptime < 24) {
- long hours = (long) uptime;
- long minutes = (long) ((uptime - hours) * 60);
- String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- if (minutes != 0) {
- s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
- }
- return s;
- }
- uptime /= 24;
- long days = (long) uptime;
- long hours = (long) ((uptime - days) * 24);
- String s = fmtI.format(days) + (days > 1 ? " days" : " day");
- if (hours != 0) {
- s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
- }
- return s;
- }
+ sb.append("Operating system\n");
+ printValue(sb, "Name", maxNameLen, os.getName() + " version " + os.getVersion());
+ printValue(sb, "Architecture", maxNameLen, os.getArch());
+ printValue(sb, "Processors", maxNameLen, Integer.toString(os.getAvailableProcessors()));
+ try {
+ printValue(sb, "Total physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalPhysicalMemorySize")));
+ printValue(sb, "Free physical memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreePhysicalMemorySize")));
+ printValue(sb, "Committed virtual memory", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getCommittedVirtualMemorySize")));
+ printValue(sb, "Total swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getTotalSwapSpaceSize")));
+ printValue(sb, "Free swap space", maxNameLen,
+ printSizeInKb(getSunOsValueAsLong(os, "getFreeSwapSpaceSize")));
+ } catch (Throwable t) {
+ }
+ return sb.toString();
+ }
- static void printSysValue(StringBuilder sb, String prop, int pad) {
- printValue(sb, prop, pad, System.getProperty(prop));
- }
+ private static String getPid() {
+ // In Java 9 the new process API can be used:
+ // long pid = ProcessHandle.current().getPid();
+ String name = ManagementFactory.getRuntimeMXBean().getName();
+ String[] parts = name.split("@");
+ return parts[0];
+ }
- static void printValue(StringBuilder sb, String name, int pad, String value) {
- sb.append(" " + // SimpleAnsi.INTENSITY_BOLD +
- name + // SimpleAnsi.INTENSITY_NORMAL +
- spaces(pad - name.length()) + " " + value + "\n");
- }
+ private static long getSunOsValueAsLong(OperatingSystemMXBean os, String name) throws Exception {
+ Method mth = os.getClass().getMethod(name);
+ return (Long) mth.invoke(os);
+ }
- static String spaces(int nb) {
- StringBuilder sb = new StringBuilder();
- for (int i = 0; i < nb; i++) {
- sb.append(' ');
- }
- return sb.toString();
- }
+ private static long getValueAsLong(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Long) mth.invoke(os);
+ }
+ return -1;
+ }
- static String getOsgiFramework() {
- try {
- Callable<String> call = new Callable<String>() {
- @Override
- public String call() throws Exception {
- BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
- Bundle sysBundle = context.getBundle(0);
- return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
- }
- };
- return call.call();
- } catch (Throwable t) {
- // We're not in OSGi, just safely return null
- return null;
- }
- }
+ private static double getValueAsDouble(Class<?> osImpl, String name) throws Exception {
+ if (osImpl.isInstance(os)) {
+ Method mth = osImpl.getMethod(name);
+ return (Double) mth.invoke(os);
+ }
+ return -1;
+ }
+
+ private static String printLong(long i) {
+ return fmtI.format(i);
+ }
+
+ private static String printSizeInKb(double size) {
+ return fmtI.format((long) (size / 1024)) + " kbytes";
+ }
+
+ protected static String printDuration(double uptime) {
+ uptime /= 1000;
+ if (uptime < 60) {
+ return fmtD.format(uptime) + " seconds";
+ }
+ uptime /= 60;
+ if (uptime < 60) {
+ long minutes = (long) uptime;
+ String s = fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ return s;
+ }
+ uptime /= 60;
+ if (uptime < 24) {
+ long hours = (long) uptime;
+ long minutes = (long) ((uptime - hours) * 60);
+ String s = fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ if (minutes != 0) {
+ s += " " + fmtI.format(minutes) + (minutes > 1 ? " minutes" : " minute");
+ }
+ return s;
+ }
+ uptime /= 24;
+ long days = (long) uptime;
+ long hours = (long) ((uptime - days) * 24);
+ String s = fmtI.format(days) + (days > 1 ? " days" : " day");
+ if (hours != 0) {
+ s += " " + fmtI.format(hours) + (hours > 1 ? " hours" : " hour");
+ }
+ return s;
+ }
+
+ static void printSysValue(StringBuilder sb, String prop, int pad) {
+ printValue(sb, prop, pad, System.getProperty(prop));
+ }
+
+ static void printValue(StringBuilder sb, String name, int pad, String value) {
+ sb.append(" " + // SimpleAnsi.INTENSITY_BOLD +
+ name + // SimpleAnsi.INTENSITY_NORMAL +
+ spaces(pad - name.length()) + " " + value + "\n");
+ }
+
+ static String spaces(int nb) {
+ StringBuilder sb = new StringBuilder();
+ for (int i = 0; i < nb; i++) {
+ sb.append(' ');
+ }
+ return sb.toString();
+ }
+
+ static String getOsgiFramework() {
+ try {
+ Callable<String> call = new Callable<String>() {
+ @Override
+ public String call() throws Exception {
+ BundleContext context = FrameworkUtil.getBundle(getClass()).getBundleContext();
+ Bundle sysBundle = context.getBundle(0);
+ return sysBundle.getSymbolicName() + "-" + sysBundle.getVersion();
+ }
+ };
+ return call.call();
+ } catch (Throwable t) {
+ // We're not in OSGi, just safely return null
+ return null;
+ }
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
index d54afd642..4f259aa4b 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFileProvider.java
@@ -42,169 +42,167 @@ import org.slf4j.LoggerFactory;
public class YangFileProvider {
- private static final Logger LOG = LoggerFactory.getLogger(YangFileProvider.class);
-
- private static final FilenameFilter yangFilenameFilter = new FilenameFilter() {
-
- @Override
- public boolean accept(File dir, String name) {
- return name.toLowerCase().endsWith(".yang");
- }
- };
-
- private static final int BUFFER_SIZE = 1024;
-
- private final Path mainSourcePath;
- private final List<Path> additionalSources;
-
- public YangFileProvider(String path) {
- this.mainSourcePath = new File(path).toPath();
- this.additionalSources = new ArrayList<>();
- }
-
- public boolean hasFileForModule(String module, String version) {
- return this.mainSourcePath.resolve(YangFilename.createFilename(module, version)).toFile().exists();
- }
-
- public boolean hasFileForModule(String module) {
- return this.findYangFiles(module).size() > 0;
- }
-
- private List<YangFilename> findYangFiles(String module) {
- List<YangFilename> list = new ArrayList<>();
- String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
- YangFilename yangfile;
- for (String file : files) {
- files = this.mainSourcePath.toFile().list(yangFilenameFilter);
- for (String fn : files) {
- try {
- yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
- if (yangfile.getModule().equals(module)) {
- list.add(yangfile);
- }
- } catch (ParseException e) {
- LOG.warn("unable to handle yangfile {}: {}", file, e);
- }
- }
- }
- for (Path addPath : this.additionalSources) {
- files = addPath.toFile().list(yangFilenameFilter);
- for (String file : files) {
- try {
- yangfile = new YangFilename(addPath.resolve(file).toString());
- if (yangfile.getModule().equals(module)) {
- list.add(yangfile);
- }
- } catch (ParseException e) {
- LOG.warn("unable to handle yangfile {}: {}", file, e);
- }
- }
- }
- return list;
- }
-
- /**
- * get yang file from source with specified version or least newer one if
- * version is null then the latest one
- *
- * @param module
- * @param version
- * @return
- * @throws ParseException
- */
- private @Nullable YangFilename getYangFile(@Nonnull String module, @Nullable String version) throws ParseException {
- YangFilename f = null;
- List<YangFilename> list = this.findYangFiles(module);
-
- list.sort(SortByDateAscComparator.getInstance());
-
- // find specific version or nearest oldest
- if (version != null) {
- Date rev = YangFilename.parseRevision(version);
- for (YangFilename item : list) {
- if (rev.equals(item.getRevision())) {
- f = item;
- break;
- }
- if (item.getRevision().after(rev)) {
- f = item;
- break;
- }
- }
- }
- // get latest
- else {
- f = list.get(list.size() - 1);
- }
- return f;
- }
-
- /**
- * write filestream directly to output stream easier for http handling
- *
- * @param module
- * @param version
- * @param outputStream
- * @return
- * @throws IOException
- * @throws ParseException
- */
- public int writeOutput(@Nonnull String module, @Nullable String version, @Nonnull OutputStream outputStream)
- throws IOException, ParseException {
- YangFilename fn = this.getYangFile(module, version);
- if(fn==null) {
- return 0;
- }
- byte[] buffer = new byte[BUFFER_SIZE];
- int bytesRead = -1;
- int sumlen = 0;
- InputStream inputStream = null ;
- try {
- inputStream= new FileInputStream(fn.getFilename());
-
- while ((bytesRead = inputStream.read(buffer)) != -1) {
- outputStream.write(buffer, 0, bytesRead);
- sumlen += bytesRead;
- }}
- catch(IOException e) {
- LOG.warn("problem sending {}: {}",fn.getFilename(),e);
- }
- finally {
- if(inputStream!=null) {
- inputStream.close();
- }
- }
- return sumlen;
- }
-
- private static class SortByDateAscComparator implements Comparator<YangFilename> {
-
- private static SortByDateAscComparator instance;
-
- @Override
- public int compare(YangFilename o1, YangFilename o2) {
- return o1.getRevision().compareTo(o2.getRevision());
- }
-
- public static Comparator<YangFilename> getInstance() {
- if (instance == null) {
- instance = new SortByDateAscComparator();
- }
- return instance;
- }
-
- }
-
- public YangFilename getFileForModule(String module, String rev) throws ParseException {
- return this.getYangFile(module, rev);
- }
-
- public YangFilename getFileForModule(String module) throws ParseException {
- return this.getFileForModule(module, null);
- }
-
- public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
- return this.getYangFile(module, version) != null;
- }
+ private static final Logger LOG = LoggerFactory.getLogger(YangFileProvider.class);
+
+ private static final FilenameFilter yangFilenameFilter = new FilenameFilter() {
+
+ @Override
+ public boolean accept(File dir, String name) {
+ return name.toLowerCase().endsWith(".yang");
+ }
+ };
+
+ private static final int BUFFER_SIZE = 1024;
+
+ private final Path mainSourcePath;
+ private final List<Path> additionalSources;
+
+ public YangFileProvider(String path) {
+ this.mainSourcePath = new File(path).toPath();
+ this.additionalSources = new ArrayList<>();
+ }
+
+ public boolean hasFileForModule(String module, String version) {
+ return this.mainSourcePath.resolve(YangFilename.createFilename(module, version)).toFile().exists();
+ }
+
+ public boolean hasFileForModule(String module) {
+ return this.findYangFiles(module).size() > 0;
+ }
+
+ private List<YangFilename> findYangFiles(String module) {
+ List<YangFilename> list = new ArrayList<>();
+ String[] files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ YangFilename yangfile;
+ for (String file : files) {
+ files = this.mainSourcePath.toFile().list(yangFilenameFilter);
+ for (String fn : files) {
+ try {
+ yangfile = new YangFilename(this.mainSourcePath.resolve(fn).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ for (Path addPath : this.additionalSources) {
+ files = addPath.toFile().list(yangFilenameFilter);
+ for (String file : files) {
+ try {
+ yangfile = new YangFilename(addPath.resolve(file).toString());
+ if (yangfile.getModule().equals(module)) {
+ list.add(yangfile);
+ }
+ } catch (ParseException e) {
+ LOG.warn("unable to handle yangfile {}: {}", file, e);
+ }
+ }
+ }
+ return list;
+ }
+
+ /**
+ * get yang file from source with specified version or least newer one if version is null then the latest one
+ *
+ * @param module
+ * @param version
+ * @return
+ * @throws ParseException
+ */
+ private @Nullable YangFilename getYangFile(@Nonnull String module, @Nullable String version) throws ParseException {
+ YangFilename f = null;
+ List<YangFilename> list = this.findYangFiles(module);
+
+ list.sort(SortByDateAscComparator.getInstance());
+
+ // find specific version or nearest oldest
+ if (version != null) {
+ Date rev = YangFilename.parseRevision(version);
+ for (YangFilename item : list) {
+ if (rev.equals(item.getRevision())) {
+ f = item;
+ break;
+ }
+ if (item.getRevision().after(rev)) {
+ f = item;
+ break;
+ }
+ }
+ }
+ // get latest
+ else {
+ f = list.get(list.size() - 1);
+ }
+ return f;
+ }
+
+ /**
+ * write filestream directly to output stream easier for http handling
+ *
+ * @param module
+ * @param version
+ * @param outputStream
+ * @return
+ * @throws IOException
+ * @throws ParseException
+ */
+ public int writeOutput(@Nonnull String module, @Nullable String version, @Nonnull OutputStream outputStream)
+ throws IOException, ParseException {
+ YangFilename fn = this.getYangFile(module, version);
+ if (fn == null) {
+ return 0;
+ }
+ byte[] buffer = new byte[BUFFER_SIZE];
+ int bytesRead = -1;
+ int sumlen = 0;
+ InputStream inputStream = null;
+ try {
+ inputStream = new FileInputStream(fn.getFilename());
+
+ while ((bytesRead = inputStream.read(buffer)) != -1) {
+ outputStream.write(buffer, 0, bytesRead);
+ sumlen += bytesRead;
+ }
+ } catch (IOException e) {
+ LOG.warn("problem sending {}: {}", fn.getFilename(), e);
+ } finally {
+ if (inputStream != null) {
+ inputStream.close();
+ }
+ }
+ return sumlen;
+ }
+
+ private static class SortByDateAscComparator implements Comparator<YangFilename> {
+
+ private static SortByDateAscComparator instance;
+
+ @Override
+ public int compare(YangFilename o1, YangFilename o2) {
+ return o1.getRevision().compareTo(o2.getRevision());
+ }
+
+ public static Comparator<YangFilename> getInstance() {
+ if (instance == null) {
+ instance = new SortByDateAscComparator();
+ }
+ return instance;
+ }
+
+ }
+
+ public YangFilename getFileForModule(String module, String rev) throws ParseException {
+ return this.getYangFile(module, rev);
+ }
+
+ public YangFilename getFileForModule(String module) throws ParseException {
+ return this.getFileForModule(module, null);
+ }
+
+ public boolean hasFileOrNewerForModule(String module, String version) throws ParseException {
+ return this.getYangFile(module, version) != null;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
index fcee3cbdb..e5d0b18cd 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/data/YangFilename.java
@@ -29,39 +29,46 @@ import java.util.regex.Pattern;
public class YangFilename {
- private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
- private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
- private final String filename;
- private final Matcher matcher;
- private Date revision;
- private String module;
- public static Date parseRevision(String sRevision) throws ParseException {
- final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
- return fmt.parse(sRevision);
- }
- public YangFilename(String fn) throws ParseException {
- this.filename = fn;
- matcher = pattern.matcher(this.filename);
- if(!matcher.find()) {
- throw new ParseException("unknown filename format", 0);
- }
- this.module= matcher.group(1);
- this.revision=parseRevision(matcher.group(2));
-
- }
- public static String createFilename(String module, String rev) {
- return String.format("%s@%s.yang", module,rev);
- }
- public YangFilename(String module, String rev) throws ParseException {
- this(createFilename(module, rev));
- }
- public String getFilename() {
- return this.filename;
- }
- public Date getRevision() {
- return this.revision;
- }
- public String getModule() {
- return this.module;
- }
+ private static final String REGEX = "([^\\/]*)@([0-9]{4}-[0-9]{2}-[0-9]{2}).yang";
+ private static final Pattern pattern = Pattern.compile(REGEX, Pattern.MULTILINE);
+ private final String filename;
+ private final Matcher matcher;
+ private Date revision;
+ private String module;
+
+ public static Date parseRevision(String sRevision) throws ParseException {
+ final SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd");
+ return fmt.parse(sRevision);
+ }
+
+ public YangFilename(String fn) throws ParseException {
+ this.filename = fn;
+ matcher = pattern.matcher(this.filename);
+ if (!matcher.find()) {
+ throw new ParseException("unknown filename format", 0);
+ }
+ this.module = matcher.group(1);
+ this.revision = parseRevision(matcher.group(2));
+
+ }
+
+ public static String createFilename(String module, String rev) {
+ return String.format("%s@%s.yang", module, rev);
+ }
+
+ public YangFilename(String module, String rev) throws ParseException {
+ this(createFilename(module, rev));
+ }
+
+ public String getFilename() {
+ return this.filename;
+ }
+
+ public Date getRevision() {
+ return this.revision;
+ }
+
+ public String getModule() {
+ return this.module;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
index cca5eb648..c0518c664 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter.java
@@ -42,239 +42,260 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
- * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
- * This attribute mast be of type String and contains for read and write operations the object id.
- * The function can be used without id handling.
- * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName
+ * is used. This attribute mast be of type String and contains for read and write operations the object id. The function
+ * can be used without id handling. If id handling is required the parameter needs to be specified by class definition
+ * in yang and setting the name by using setAttributeName()
*
* @param <T> Yang tools generated class object.
*/
public class EsDataObjectReaderWriter<T extends DataObject> {
- private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter.class);
-
- /** Typename for elastic search data schema **/
- private String dataTypeName;
-
- /** Elasticsearch Database client to be used **/
- private DatabaseClient db;
-
- /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
- private YangToolsMapper yangtoolsMapper;
-
- /** Class of T as attribute to allow JSON to Class object mapping **/
- private Class<T> clazz;
-
- /** Field is used to write id. If null no id handling **/
- private @Nullable Field field;
-
- /** Attribute that is used as id field for the database object **/
- private @Nullable String esIdAddAtributteName;
-
- /** Interface to be used for write operations. Rule for write: T extends S and **/
- private Class<? extends DataObject> writeInterfaceClazz; // == "S"
-
- /**
- * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
- *
- * @param db Database access client
- * @param dataTypeName typename in database schema
- * @param clazz class of type to be handled
- * @throws ClassNotFoundException
- */
- public EsDataObjectReaderWriter(DatabaseClient db, Entity dataTypeName, Class<T> clazz) throws ClassNotFoundException {
- this(db, dataTypeName.getName(), clazz);
- }
- public EsDataObjectReaderWriter(DatabaseClient db, String dataTypeName, Class<T> clazz) throws ClassNotFoundException {
- LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
-
- this.esIdAddAtributteName = null;
- this.field = null;
- this.writeInterfaceClazz = clazz;
- this.db = db;
- this.dataTypeName = dataTypeName;
- this.yangtoolsMapper = new YangToolsMapper();
- //this.yangtoolsMapper.assertBuilderClass(clazz);
- this.clazz = clazz;
-//
-// if (! db.isExistsIndex(dataTypeName)) {
-// throw new IllegalArgumentException("Index "+dataTypeName+" not existing.");
-// }
- }
-
- public String getDataTypeName() {
- return dataTypeName;
- }
- public Class<T> getClazz() {
- return clazz;
- }
- /**
- * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
- * @param esIdAttributeName is converted to UnderscoreCamelCase
- * @return this for further operations.
- */
- public EsDataObjectReaderWriter<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
- return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
- }
-
- /**
- * Attribute name of class that is containing the object id
- * @param esIdAttributeName of the implementation class for the yangtools interface.
- * Expected attribute name format is CamelCase with leading underline. @
- * @return this for further operations.
- * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
- */
- public EsDataObjectReaderWriter<T> setEsIdAttributeName(String esIdAttributeName) {
- LOG.debug("Set attribute '{}'", esIdAttributeName);
- this.esIdAddAtributteName = null; // Reset status
- this.field = null;
-
- Field attributeField;
- try {
- Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
- T object = builder.build();
- attributeField = object.getClass().getDeclaredField(esIdAttributeName);
- if (attributeField.getType().equals(String.class)) {
- attributeField.setAccessible(true);
- this.esIdAddAtributteName = esIdAttributeName; //Set new status if everything OK
- this.field = attributeField;
- } else {
- String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- }
- } catch (NoSuchFieldException e) {
- // Convert to run-time exception
- String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
- LOG.debug(msg);
- throw new IllegalArgumentException(msg);
- } catch (SecurityException e) {
- LOG.debug("Access problem "+esIdAttributeName,e);
- throw e;
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter.class);
+
+ /** Typename for elastic search data schema **/
+ private String dataTypeName;
+
+ /** Elasticsearch Database client to be used **/
+ private DatabaseClient db;
+
+ /** Mapper with configuration to use opendaylight yang-tools builder pattern for object creation **/
+ private YangToolsMapper yangtoolsMapper;
+
+ /** Class of T as attribute to allow JSON to Class object mapping **/
+ private Class<T> clazz;
+
+ /** Field is used to write id. If null no id handling **/
+ private @Nullable Field field;
+
+ /** Attribute that is used as id field for the database object **/
+ private @Nullable String esIdAddAtributteName;
+
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
+ private Class<? extends DataObject> writeInterfaceClazz; // == "S"
+
+ /**
+ * Elasticsearch database read and write for specific class, defined by opendaylight yang-tools.
+ *
+ * @param db Database access client
+ * @param dataTypeName typename in database schema
+ * @param clazz class of type to be handled
+ * @throws ClassNotFoundException
+ */
+ public EsDataObjectReaderWriter(DatabaseClient db, Entity dataTypeName, Class<T> clazz)
+ throws ClassNotFoundException {
+ this(db, dataTypeName.getName(), clazz);
}
- return this;
- }
-
- /**
- * Specify subclass of T for write operations.
- * @param writeInterfaceClazz
- */
- public EsDataObjectReaderWriter<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
- LOG.debug("Set write interface to {}", writeInterfaceClazz);
- if (writeInterfaceClazz == null)
- throw new IllegalArgumentException("Null not allowed here.");
-
- this.writeInterfaceClazz = writeInterfaceClazz;
- return this;
- }
-
- /**
- * Write child object to database with specific id
- * @param object
- * @param @Nullable esId use the id or if null generate unique id
- * @return String with id or null
- */
- public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doWriteRaw(dataTypeName, esId, json);
- } catch (JsonProcessingException e) {
- LOG.error("Write problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public EsDataObjectReaderWriter(DatabaseClient db, String dataTypeName, Class<T> clazz)
+ throws ClassNotFoundException {
+ LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
+
+ this.esIdAddAtributteName = null;
+ this.field = null;
+ this.writeInterfaceClazz = clazz;
+ this.db = db;
+ this.dataTypeName = dataTypeName;
+ this.yangtoolsMapper = new YangToolsMapper();
+ //this.yangtoolsMapper.assertBuilderClass(clazz);
+ this.clazz = clazz;
+ //
+ // if (! db.isExistsIndex(dataTypeName)) {
+ // throw new IllegalArgumentException("Index "+dataTypeName+" not existing.");
+ // }
}
- return null;
- }
- /**
- * Update partial child object to database with match/term query
- * @param object
- * @param esId
- * @return String with esId or null
- */
- public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdate(this.dataTypeName,json,query);
- } catch (JsonProcessingException e) {
- LOG.error("Update problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public String getDataTypeName() {
+ return dataTypeName;
}
- return false;
- }
- /**
- * Write/ update partial child object to database with specific id Write if not
- * exists, else update
- * @param object
- * @param esId
- * @return String with esId or null
- */
- public @Nullable <S extends DataObject> String update(S object, String esId) {
- return this.update(object, esId,null);
- }
- public @Nullable <S extends DataObject> String update(S object, String esId,List<String> onylForInsert) {
- if (writeInterfaceClazz.isInstance(object)) {
- try {
- String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdateOrCreate(dataTypeName, esId, json,onylForInsert);
- } catch (JsonProcessingException e) {
- LOG.error("Update problem: ", e);
- }
- } else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
- writeInterfaceClazz.getName());
+
+ public Class<T> getClazz() {
+ return clazz;
+ }
+
+ /**
+ * Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ *
+ * @param esIdAttributeName is converted to UnderscoreCamelCase
+ * @return this for further operations.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeNameCamelized(String esIdAttributeName) {
+ return setEsIdAttributeName(YangToolsMapper.toCamelCaseAttributeName(esIdAttributeName));
+ }
+
+ /**
+ * Attribute name of class that is containing the object id
+ *
+ * @param esIdAttributeName of the implementation class for the yangtools interface. Expected attribute name format
+ * is CamelCase with leading underline. @
+ * @return this for further operations.
+ * @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
+ */
+ public EsDataObjectReaderWriter<T> setEsIdAttributeName(String esIdAttributeName) {
+ LOG.debug("Set attribute '{}'", esIdAttributeName);
+ this.esIdAddAtributteName = null; // Reset status
+ this.field = null;
+
+ Field attributeField;
+ try {
+ Builder<T> builder = yangtoolsMapper.getBuilder(clazz);
+ T object = builder.build();
+ attributeField = object.getClass().getDeclaredField(esIdAttributeName);
+ if (attributeField.getType().equals(String.class)) {
+ attributeField.setAccessible(true);
+ this.esIdAddAtributteName = esIdAttributeName; //Set new status if everything OK
+ this.field = attributeField;
+ } else {
+ String msg = "Wrong field type " + attributeField.getType().getName() + " of " + esIdAttributeName;
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ }
+ } catch (NoSuchFieldException e) {
+ // Convert to run-time exception
+ String msg = "NoSuchFieldException for '" + esIdAttributeName + "' in class " + clazz.getName();
+ LOG.debug(msg);
+ throw new IllegalArgumentException(msg);
+ } catch (SecurityException e) {
+ LOG.debug("Access problem " + esIdAttributeName, e);
+ throw e;
+ }
+ return this;
+ }
+
+ /**
+ * Specify subclass of T for write operations.
+ *
+ * @param writeInterfaceClazz
+ */
+ public EsDataObjectReaderWriter<T> setWriteInterface(@Nonnull Class<? extends DataObject> writeInterfaceClazz) {
+ LOG.debug("Set write interface to {}", writeInterfaceClazz);
+ if (writeInterfaceClazz == null)
+ throw new IllegalArgumentException("Null not allowed here.");
+
+ this.writeInterfaceClazz = writeInterfaceClazz;
+ return this;
+ }
+
+ /**
+ * Write child object to database with specific id
+ *
+ * @param object
+ * @param @Nullable esId use the id or if null generate unique id
+ * @return String with id or null
+ */
+ public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doWriteRaw(dataTypeName, esId, json);
+ } catch (JsonProcessingException e) {
+ LOG.error("Write problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
+ }
+
+ /**
+ * Update partial child object to database with match/term query
+ *
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> boolean update(S object, QueryBuilder query) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdate(this.dataTypeName, json, query);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return false;
+ }
+
+ /**
+ * Write/ update partial child object to database with specific id Write if not exists, else update
+ *
+ * @param object
+ * @param esId
+ * @return String with esId or null
+ */
+ public @Nullable <S extends DataObject> String update(S object, String esId) {
+ return this.update(object, esId, null);
+ }
+
+ public @Nullable <S extends DataObject> String update(S object, String esId, List<String> onylForInsert) {
+ if (writeInterfaceClazz.isInstance(object)) {
+ try {
+ String json = yangtoolsMapper.writeValueAsString(object);
+ return db.doUpdateOrCreate(dataTypeName, esId, json, onylForInsert);
+ } catch (JsonProcessingException e) {
+ LOG.error("Update problem: ", e);
+ }
+ } else {
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
+ writeInterfaceClazz.getName());
+ }
+ return null;
}
- return null;
- }
/**
* Read object from database, by using the id field
+ *
* @param object
* @return
*/
public @Nullable T read(String esId) {
- @Nullable T res = (T)null;
- if (esId != null) {
- String json = db.doReadJsonData(dataTypeName, esId);
- try {
- res = yangtoolsMapper.readValue(json.getBytes(), clazz);
- } catch (IOException e) {
- LOG.error("Problem: ", e);
- }
- }
+ @Nullable
+ T res = (T) null;
+ if (esId != null) {
+ String json = db.doReadJsonData(dataTypeName, esId);
+ try {
+ res = yangtoolsMapper.readValue(json.getBytes(), clazz);
+ } catch (IOException e) {
+ LOG.error("Problem: ", e);
+ }
+ }
return res;
}
/**
* Remove object
+ *
* @param esId to identify the object.
* @return success
*/
public boolean remove(String esId) {
- return db.doRemove(this.dataTypeName, esId);
+ return db.doRemove(this.dataTypeName, esId);
+ }
+
+ public int remove(QueryBuilder query) {
+ return this.db.doRemove(this.dataTypeName, query);
}
- public int remove(QueryBuilder query) {
- return this.db.doRemove(this.dataTypeName, query);
- }
/**
* Get all elements of related type
+ *
* @return all Elements
*/
public SearchResult<T> doReadAll() {
return doReadAll(null);
}
+
public SearchResult<T> doReadAll(QueryBuilder query) {
- return this.doReadAll(query,false);
- }
+ return this.doReadAll(query, false);
+ }
+
/**
* Read all existing objects of a type
+ *
* @param query for the elements
* @return the list of all objects
*/
@@ -310,26 +331,27 @@ public class EsDataObjectReaderWriter<T extends DataObject> {
return res;
}
- /* ---------------------------------------------
+ /* ---------------------------------------------
* Private functions
*/
- private void setEsId(T object, String esId) {
- if (field != null) {
- try {
- field.set(object, esId);
- } catch (IllegalArgumentException | IllegalAccessException e) {
- LOG.debug("Field set problem.", e); }
+ private void setEsId(T object, String esId) {
+ if (field != null) {
+ try {
+ field.set(object, esId);
+ } catch (IllegalArgumentException | IllegalAccessException e) {
+ LOG.debug("Field set problem.", e);
+ }
+ }
}
- }
private @Nullable T getT(String jsonString) {
- try {
- return yangtoolsMapper.readValue( jsonString, clazz );
- } catch (IOException e) {
- LOG.info("Mapping problem", e);
- return (T)null;
- }
+ try {
+ return yangtoolsMapper.readValue(jsonString, clazz);
+ } catch (IOException e) {
+ LOG.info("Mapping problem", e);
+ return (T) null;
+ }
}
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
index f11bccb53..e0f6e4aea 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/database/EsDataObjectReaderWriter2.java
@@ -44,20 +44,21 @@ import org.slf4j.LoggerFactory;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
- * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName is used.
- * This attribute mast be of type String and contains for read and write operations the object id.
- * The function can be used without id handling.
- * If id handling is required the parameter needs to be specified by class definition in yang and setting the name by using setAttributeName()
+ * Class to rw yang-tool generated objects into elasticsearch database. For "ES _id" exchange the esIdAddAtributteName
+ * is used. This attribute mast be of type String and contains for read and write operations the object id. The function
+ * can be used without id handling. If id handling is required the parameter needs to be specified by class definition
+ * in yang and setting the name by using setAttributeName()
*
- * Due to using Jackson base interfaces the org.eclipse.jdt.annotation.NonNull needs to be used here to get rid of warnings
+ * Due to using Jackson base interfaces the org.eclipse.jdt.annotation.NonNull needs to be used here to get rid of
+ * warnings
*
* @param <T> Yang tools generated class object.
*/
public class EsDataObjectReaderWriter2<T extends DataObject> {
- private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter2.class);
+ private final Logger LOG = LoggerFactory.getLogger(EsDataObjectReaderWriter2.class);
- /** Typename for elastic search data schema **/
+ /** Typename for elastic search data schema **/
private String dataTypeName;
/** Elasticsearch Database client to be used **/
@@ -75,7 +76,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/** Attribute that is used as id field for the database object **/
private @Nullable String esIdAddAtributteName;
- /** Interface to be used for write operations. Rule for write: T extends S and **/
+ /** Interface to be used for write operations. Rule for write: T extends S and **/
private Class<? extends DataObject> writeInterfaceClazz; // == "S"
/**
@@ -86,13 +87,20 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
* @param clazz class of type to be handled
* @throws ClassNotFoundException
*/
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ Entity dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz)
+ throws ClassNotFoundException {
this(db, dataTypeName.getName(), clazz, builderClazz);
}
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, Entity dataTypeName, @Nonnull Class<T> clazz) throws ClassNotFoundException {
+
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ Entity dataTypeName, @Nonnull Class<T> clazz) throws ClassNotFoundException {
this(db, dataTypeName.getName(), clazz, null);
}
- public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db, String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz) throws ClassNotFoundException {
+
+ public <X extends T, @NonNull B extends Builder<X>> EsDataObjectReaderWriter2(DatabaseClient db,
+ String dataTypeName, @Nonnull Class<T> clazz, @Nullable Class<B> builderClazz)
+ throws ClassNotFoundException {
LOG.info("Create {} for datatype {} class {}", this.getClass().getName(), dataTypeName, clazz.getName());
this.esIdAddAtributteName = null;
@@ -106,6 +114,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Simlar to {@link #setEsIdAttributeName()}, but adapts the parameter to yangtools attribute naming schema
+ *
* @param esIdAttributeName is converted to UnderscoreCamelCase
* @return this for further operations.
*/
@@ -115,8 +124,9 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Attribute name of class that is containing the object id
- * @param esIdAttributeName of the implementation class for the yangtools interface.
- * Expected attribute name format is CamelCase with leading underline. @
+ *
+ * @param esIdAttributeName of the implementation class for the yangtools interface. Expected attribute name format
+ * is CamelCase with leading underline. @
* @return this for further operations.
* @throws SecurityException if no access or IllegalArgumentException if wrong type or no attribute with this name.
*/
@@ -151,7 +161,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
LOG.debug(msg);
throw new IllegalArgumentException(msg);
} catch (SecurityException e) {
- LOG.debug("Access problem "+esIdAttributeName,e);
+ LOG.debug("Access problem " + esIdAttributeName, e);
throw e;
}
return this;
@@ -159,9 +169,10 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Specify subclass of T for write operations.
+ *
* @param writeInterfaceClazz
*/
- public EsDataObjectReaderWriter2<T> setWriteInterface( @Nonnull Class<? extends DataObject> writeInterfaceClazz ) {
+ public EsDataObjectReaderWriter2<T> setWriteInterface(@Nonnull Class<? extends DataObject> writeInterfaceClazz) {
LOG.debug("Set write interface to {}", writeInterfaceClazz);
if (writeInterfaceClazz == null) {
throw new IllegalArgumentException("Null not allowed here.");
@@ -183,11 +194,12 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Write child object to database with specific id
+ *
* @param object to be written
* @param esId use the id or if null generate unique id
* @return String with id or null
*/
- public @Nullable <S extends DataObject> String write( S object, @Nullable String esId) {
+ public @Nullable <S extends DataObject> String write(S object, @Nullable String esId) {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
@@ -196,13 +208,15 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
LOG.error("Write problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return null;
}
+
/**
* Update partial child object to database with match/term query
+ *
* @param <S> of object
* @param object to write
* @param query for write of specific attributes
@@ -212,39 +226,41 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdate(this.dataTypeName,json,query);
+ return db.doUpdate(this.dataTypeName, json, query);
} catch (JsonProcessingException e) {
LOG.error("Update problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return false;
}
+
/**
- * Write/ update partial child object to database with specific id Write if not
- * exists, else update
+ * Write/ update partial child object to database with specific id Write if not exists, else update
+ *
* @param object
* @param esId
* @return String with esId or null
*/
public @Nullable <S extends DataObject> String update(S object, String esId) {
- return this.updateOrCreate(object, esId,null);
+ return this.updateOrCreate(object, esId, null);
}
+
/**
* See {@link doUpdateOrCreate(String dataTypeName, String esId, String json, List<String> doNotUpdateField) }
*/
- public @Nullable <S extends DataObject> String updateOrCreate(S object, String esId,List<String> onlyForInsert) {
+ public @Nullable <S extends DataObject> String updateOrCreate(S object, String esId, List<String> onlyForInsert) {
if (object != null && writeInterfaceClazz.isInstance(object)) {
try {
String json = yangtoolsMapper.writeValueAsString(object);
- return db.doUpdateOrCreate(dataTypeName, esId, json,onlyForInsert);
+ return db.doUpdateOrCreate(dataTypeName, esId, json, onlyForInsert);
} catch (JsonProcessingException e) {
LOG.error("Update problem: ", e);
}
} else {
- LOG.error("Type {} does not provide interface {}", object!=null?object.getClass().getName():"null",
+ LOG.error("Type {} does not provide interface {}", object != null ? object.getClass().getName() : "null",
writeInterfaceClazz.getName());
}
return null;
@@ -252,6 +268,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Read object from database, by using the id field
+ *
* @param object
* @return
*/
@@ -275,6 +292,7 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
/**
* Remove object
+ *
* @param esId to identify the object.
* @return success
*/
@@ -285,18 +303,23 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
public int remove(QueryBuilder query) {
return this.db.doRemove(this.dataTypeName, query);
}
+
/**
* Get all elements of related type
+ *
* @return all Elements
*/
public SearchResult<T> doReadAll() {
return doReadAll(null);
}
+
public SearchResult<T> doReadAll(QueryBuilder query) {
- return this.doReadAll(query,false);
+ return this.doReadAll(query, false);
}
+
/**
* Read all existing objects of a type
+ *
* @param query for the elements
* @return the list of all objects
*/
@@ -304,21 +327,21 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
public SearchResult<T> doReadAll(QueryBuilder query, boolean ignoreException) {
SearchResult<T> res = new SearchResult<>();
- int idx = 0; //Idx for getAll
- int iterateLength = 100; //Step width for iterate
+ int idx = 0; //Idx for getAll
+ int iterateLength = 100; //Step width for iterate
SearchResult<SearchHit> result;
List<SearchHit> hits;
do {
- if(query!=null) {
- LOG.debug("read data in {} with query {}",dataTypeName,query.toJSON());
- result=db.doReadByQueryJsonData( dataTypeName, query,ignoreException);
- }
- else {
- result = db.doReadAllJsonData(dataTypeName,ignoreException);
+ if (query != null) {
+ LOG.debug("read data in {} with query {}", dataTypeName, query.toJSON());
+ result = db.doReadByQueryJsonData(dataTypeName, query, ignoreException);
+ } else {
+ result = db.doReadAllJsonData(dataTypeName, ignoreException);
}
- hits=result.getHits();
- LOG.debug("Read: {} elements: {} Failures: {}",dataTypeName,hits.size(), yangtoolsMapper.getMappingFailures());
+ hits = result.getHits();
+ LOG.debug("Read: {} elements: {} Failures: {}", dataTypeName, hits.size(),
+ yangtoolsMapper.getMappingFailures());
T object;
idx += result.getHits().size();
@@ -349,13 +372,14 @@ public class EsDataObjectReaderWriter2<T extends DataObject> {
try {
field.set(object, esId);
} catch (IllegalArgumentException | IllegalAccessException e) {
- LOG.debug("Field set problem.", e); }
+ LOG.debug("Field set problem.", e);
+ }
}
}
private @Nullable T getT(String jsonString) {
try {
- return yangtoolsMapper.readValue( jsonString, clazz );
+ return yangtoolsMapper.readValue(jsonString, clazz);
} catch (IOException e) {
LOG.info("Mapping problem", e);
return null;
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
index 8c33a29e7..120684298 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/AboutHttpServlet.java
@@ -45,304 +45,312 @@ import org.slf4j.LoggerFactory;
public class AboutHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class);
- private static final String UNKNOWN = "unknown";
- private static final String METAINF_MAVEN = "/META-INF/maven/";
- private static final String EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE = "unable to read inner pom file: {}";
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(AboutHttpServlet.class);
+ private static final String UNKNOWN = "unknown";
+ private static final String METAINF_MAVEN = "/META-INF/maven/";
+ private static final String EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE = "unable to read inner pom file: {}";
- private static final String URI_PRE = "/about";
- private static final String RES_BASEPATH = "about/";
+ private static final String URI_PRE = "/about";
+ private static final String RES_BASEPATH = "about/";
- private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
- private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
- private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
- private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
- private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
- private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
- private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
- private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
- private static final String PLACEHOLDER_CLUSTER_SIZE = "{cluster-size}";
- private static final String PLACEHOLDER_MDSAL_VERSION = "{mdsal-version}";
- private static final String PLACEHOLDER_YANGTOOLS_VERSION = "{yangtools-version}";
- private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
- private static final String README_FILE = "README.md";
+ private static final String PLACEHOLDER_ONAP_RELEASENAME = "{release-name}";
+ private static final String PLACEHOLDER_ONAP_RELEASEVERSION = "{release-version}";
+ private static final String PLACEHOLDER_ODL_RELEASENAME = "{odl-version}";
+ private static final String PLACEHOLDER_BUILD_TIMESTAMP = "{build-time}";
+ private static final String PLACEHOLDER_ODLUX_REVISION = "{odlux-revision}";
+ private static final String PLACEHOLDER_PACKAGE_GITHASH = "{package-githash}";
+ private static final String PLACEHOLDER_PACAKGE_VERSION = "{package-version}";
+ private static final String PLACEHOLDER_CCSDK_VERSION = "{ccsdk-version}";
+ private static final String PLACEHOLDER_CLUSTER_SIZE = "{cluster-size}";
+ private static final String PLACEHOLDER_MDSAL_VERSION = "{mdsal-version}";
+ private static final String PLACEHOLDER_YANGTOOLS_VERSION = "{yangtools-version}";
+ private static final String PLACEHOLDER_KARAF_INFO = "{karaf-info}";
+ private static final String README_FILE = "README.md";
- private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
- private final String artifactId = "sdnr-wt-data-provider-provider";
+ private final String groupId = "org.onap.ccsdk.features.sdnr.wt";
+ private final String artifactId = "sdnr-wt-data-provider-provider";
- private final Map<String, String> data;
- private final String readmeContent;
+ private final Map<String, String> data;
+ private final String readmeContent;
- public AboutHttpServlet() {
+ public AboutHttpServlet() {
- this.data = new HashMap<>();
- this.collectStaticData();
- this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
- }
+ this.data = new HashMap<>();
+ this.collectStaticData();
+ this.readmeContent = this.render(this.getResourceFileContent(README_FILE));
+ }
- /**
- * collect static versioning data
- */
- private void collectStaticData() {
- PomPropertiesFile props = this.getPomProperties();
- final String ccsdkVersion = this.getPomParentVersion();
- this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN));
- this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
- this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno"));
- this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
- this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
- this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "1.8.1-SNAPSHOT");
- this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
- this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
- this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
- }
+ /**
+ * collect static versioning data
+ */
+ private void collectStaticData() {
+ PomPropertiesFile props = this.getPomProperties();
+ final String ccsdkVersion = this.getPomParentVersion();
+ this.data.put(PLACEHOLDER_ONAP_RELEASENAME, ODLVersionLUT.getONAPReleaseName(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_ODL_RELEASENAME, ODLVersionLUT.getOdlVersion(ccsdkVersion, UNKNOWN));
+ this.data.put(PLACEHOLDER_BUILD_TIMESTAMP, props != null ? props.getBuildDate().toString() : "");
+ this.data.put(PLACEHOLDER_ODLUX_REVISION, this.getPomProperty("odlux.buildno"));
+ this.data.put(PLACEHOLDER_PACAKGE_VERSION, this.getManifestValue("Bundle-Version"));
+ this.data.put(PLACEHOLDER_CCSDK_VERSION, ccsdkVersion);
+ this.data.put(PLACEHOLDER_ONAP_RELEASEVERSION, "1.8.1-SNAPSHOT");
+ this.data.put(PLACEHOLDER_MDSAL_VERSION, SystemInfo.getMdSalVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_YANGTOOLS_VERSION, SystemInfo.getYangToolsVersion(UNKNOWN));
+ this.data.put(PLACEHOLDER_PACKAGE_GITHASH, this.getGitHash(UNKNOWN));
+ }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- String uri = req.getRequestURI().substring(URI_PRE.length());
- LOG.debug("request for {}", uri);
- if (uri.length() <= 0 || uri.equals("/")) {
- // collect data
- this.collectData();
- // render readme
- String content = this.render();
- byte[] output = content != null ? content.getBytes() : new byte[0];
- // output
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentLength(output.length);
- resp.setContentType("text/plain");
- ServletOutputStream os = null;
- try{
- os = resp.getOutputStream();
- os.write(output);
- }
- catch(IOException e) {
- LOG.warn("problem writing response for {}: {}",uri,e);
- }
- finally {
- if(os!=null) {
- try{
- os.close();
- }
- catch(IOException e) {
- LOG.warn("problem closing response stream: {}",e);
- }
- }
- }
+ String uri = req.getRequestURI().substring(URI_PRE.length());
+ LOG.debug("request for {}", uri);
+ if (uri.length() <= 0 || uri.equals("/")) {
+ // collect data
+ this.collectData();
+ // render readme
+ String content = this.render();
+ byte[] output = content != null ? content.getBytes() : new byte[0];
+ // output
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentLength(output.length);
+ resp.setContentType("text/plain");
+ ServletOutputStream os = null;
+ try {
+ os = resp.getOutputStream();
+ os.write(output);
+ } catch (IOException e) {
+ LOG.warn("problem writing response for {}: {}", uri, e);
+ } finally {
+ if (os != null) {
+ try {
+ os.close();
+ } catch (IOException e) {
+ LOG.warn("problem closing response stream: {}", e);
+ }
+ }
+ }
- } else {
- this.doGetFile(uri, resp);
- }
- }
+ } else {
+ this.doGetFile(uri, resp);
+ }
+ }
- /**
- * load git.commit.id from jar /META-INF/git.properties
- *
- * @param def
- */
- private String getGitHash(String def) {
- String content = Resources.getFileContent(AboutHttpServlet.class, "/META-INF/git.properties");
- if (content == null) {
- return def;
- }
- String lines[] = content.split("\n");
- for (String line : lines) {
- if (line.startsWith("git.commit.id")) {
- def = line.substring("git.commit.id=".length());
- break;
- }
- }
- return def;
- }
+ /**
+ * load git.commit.id from jar /META-INF/git.properties
+ *
+ * @param def
+ */
+ private String getGitHash(String def) {
+ String content = Resources.getFileContent(AboutHttpServlet.class, "/META-INF/git.properties");
+ if (content == null) {
+ return def;
+ }
+ String lines[] = content.split("\n");
+ for (String line : lines) {
+ if (line.startsWith("git.commit.id")) {
+ def = line.substring("git.commit.id=".length());
+ break;
+ }
+ }
+ return def;
+ }
- private String getResourceFileContent(String filename) {
- LOG.debug("try ti get content of {}", filename);
- return Resources.getFileContent(AboutHttpServlet.class, RES_BASEPATH + filename);
- }
+ private String getResourceFileContent(String filename) {
+ LOG.debug("try ti get content of {}", filename);
+ return Resources.getFileContent(AboutHttpServlet.class, RES_BASEPATH + filename);
+ }
- /**
- * collect dynamic data for about.md
- */
- private void collectData() {
- LOG.info("collecting dynamic data");
- try {
- this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
- } catch (Exception e) {
- LOG.warn("problem collecting system data: {}", e);
- }
- }
+ /**
+ * collect dynamic data for about.md
+ */
+ private void collectData() {
+ LOG.info("collecting dynamic data");
+ try {
+ this.data.put(PLACEHOLDER_KARAF_INFO, SystemInfo.get());
+ } catch (Exception e) {
+ LOG.warn("problem collecting system data: {}", e);
+ }
+ }
- /**
- * get value for key out of /META-INF/MANIFEST.MF
- * @param key
- * @return
- */
- private String getManifestValue(String key) {
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF");
- if (url == null) {
- return null;
- }
- Manifest manifest;
- try {
- manifest = new Manifest(url.openStream());
- Attributes attr = manifest.getMainAttributes();
- return attr.getValue(key);
- } catch (IOException e) {
- LOG.warn("problem reading manifest: {}", e);
- }
- return null;
+ /**
+ * get value for key out of /META-INF/MANIFEST.MF
+ *
+ * @param key
+ * @return
+ */
+ private String getManifestValue(String key) {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class, "/META-INF/MANIFEST.MF");
+ if (url == null) {
+ return null;
+ }
+ Manifest manifest;
+ try {
+ manifest = new Manifest(url.openStream());
+ Attributes attr = manifest.getMainAttributes();
+ return attr.getValue(key);
+ } catch (IOException e) {
+ LOG.warn("problem reading manifest: {}", e);
+ }
+ return null;
- }
- /**
- * get object representation of /META-INF/maven/groupId/artifactId/pom.properties
- * @return
- */
- private PomPropertiesFile getPomProperties() {
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties");
- PomPropertiesFile propfile;
- if (url == null) {
- return null;
- }
- try {
- propfile = new PomPropertiesFile(url.openStream());
- return propfile;
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
- /**
- * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
- * @param key
- * @return
- */
- private String getPomProperty(String key) {
- LOG.info("try to get pom property for {}", key);
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
- if (url == null) {
- return null;
- }
- PomFile pomfile;
- try {
- pomfile = new PomFile(url.openStream());
- return pomfile.getProperty(key);
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
- /**
- * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
- * @return
- */
- private String getPomParentVersion() {
- LOG.info("try to get pom parent version");
- URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
- METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
- if (url == null) {
- return null;
- }
- PomFile pomfile;
- try {
- pomfile = new PomFile(url.openStream());
- return pomfile.getParentVersion();
- } catch (Exception e) {
- LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
- }
- return null;
- }
+ }
- /**
- * get file by uri from resources and write out to response stream
- * @param uri
- * @param resp
- */
- private void doGetFile(String uri, HttpServletResponse resp) {
- String content = this.getResourceFileContent(uri);
- if (content == null) {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- } catch (IOException e) {
- LOG.debug("unable to send error response : {}", e);
- }
- } else {
- byte[] data = content.getBytes();
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType(this.getContentType(uri));
- try {
- resp.getOutputStream().write(data);
- } catch (IOException e) {
- LOG.debug("unable to send data : {}", e);
- }
- }
+ /**
+ * get object representation of /META-INF/maven/groupId/artifactId/pom.properties
+ *
+ * @return
+ */
+ private PomPropertiesFile getPomProperties() {
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.properties");
+ PomPropertiesFile propfile;
+ if (url == null) {
+ return null;
+ }
+ try {
+ propfile = new PomPropertiesFile(url.openStream());
+ return propfile;
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- }
+ /**
+ * get value for key out of /META-INF/maven/groupId/artifactId/pom.xml in properties section
+ *
+ * @param key
+ * @return
+ */
+ private String getPomProperty(String key) {
+ LOG.info("try to get pom property for {}", key);
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getProperty(key);
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- /**
- * create http response contentType by filename
- * @param filename
- * @return
- */
- private String getContentType(String filename) {
- String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
- switch (ext) {
- case "jpg":
- case "jpeg":
- case "svg":
- case "png":
- case "gif":
- case "bmp":
- return "image/" + ext;
- case "json":
- return "application/json";
- case "html":
- case "htm":
- return "text/html";
- case "txt":
- case "md":
- default:
- return "text/plain";
- }
- }
+ /**
+ * get parent pom version out of /META-INF/maven/groupId/artifactId/pom.xml
+ *
+ * @return
+ */
+ private String getPomParentVersion() {
+ LOG.info("try to get pom parent version");
+ URL url = Resources.getUrlForRessource(AboutHttpServlet.class,
+ METAINF_MAVEN + groupId + "/" + artifactId + "/pom.xml");
+ if (url == null) {
+ return null;
+ }
+ PomFile pomfile;
+ try {
+ pomfile = new PomFile(url.openStream());
+ return pomfile.getParentVersion();
+ } catch (Exception e) {
+ LOG.warn(EXCEPTION_FORMAT_UNABLE_TO_READ_INNER_POMFILE, e);
+ }
+ return null;
+ }
- /**
- * render this.readmeContent with this.data
- * @return
- */
- private String render() {
- return this.render(null);
- }
+ /**
+ * get file by uri from resources and write out to response stream
+ *
+ * @param uri
+ * @param resp
+ */
+ private void doGetFile(String uri, HttpServletResponse resp) {
+ String content = this.getResourceFileContent(uri);
+ if (content == null) {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException e) {
+ LOG.debug("unable to send error response : {}", e);
+ }
+ } else {
+ byte[] data = content.getBytes();
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType(this.getContentType(uri));
+ try {
+ resp.getOutputStream().write(data);
+ } catch (IOException e) {
+ LOG.debug("unable to send data : {}", e);
+ }
+ }
- /**
- * render content with this.data
- * @param content
- * @return
- */
- private String render(String content) {
- if (content == null) {
- content = this.readmeContent;
- }
- if (content == null) {
- return null;
- }
- for (Entry<String, String> entry : this.data.entrySet()) {
- if (entry.getValue() != null && content.contains(entry.getKey())) {
- content = content.replace(entry.getKey(), entry.getValue());
- }
- }
+ }
- return content;
- }
+ /**
+ * create http response contentType by filename
+ *
+ * @param filename
+ * @return
+ */
+ private String getContentType(String filename) {
+ String ext = filename.substring(filename.lastIndexOf(".") + 1).toLowerCase();
+ switch (ext) {
+ case "jpg":
+ case "jpeg":
+ case "svg":
+ case "png":
+ case "gif":
+ case "bmp":
+ return "image/" + ext;
+ case "json":
+ return "application/json";
+ case "html":
+ case "htm":
+ return "text/html";
+ case "txt":
+ case "md":
+ default:
+ return "text/plain";
+ }
+ }
- public void setClusterSize(String value) {
- this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
- }
-} \ No newline at end of file
+ /**
+ * render this.readmeContent with this.data
+ *
+ * @return
+ */
+ private String render() {
+ return this.render(null);
+ }
+
+ /**
+ * render content with this.data
+ *
+ * @param content
+ * @return
+ */
+ private String render(String content) {
+ if (content == null) {
+ content = this.readmeContent;
+ }
+ if (content == null) {
+ return null;
+ }
+ for (Entry<String, String> entry : this.data.entrySet()) {
+ if (entry.getValue() != null && content.contains(entry.getKey())) {
+ content = content.replace(entry.getKey(), entry.getValue());
+ }
+ }
+
+ return content;
+ }
+
+ public void setClusterSize(String value) {
+ this.data.put(PLACEHOLDER_CLUSTER_SIZE, value);
+ }
+}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java
index 322392379..490f3cac8 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/DataTreeHttpServlet.java
@@ -34,24 +34,26 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.HtDatabaseClient;
* @author Michael Dürre
*
*/
-public class DataTreeHttpServlet extends HttpServlet{
-
- /**
- * @param rawClient
- */
- public void setDatabaseClient(HtDatabaseClient rawClient) {
-
-
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- final String uri = req.getRequestURI();
- }
- private void readInventoryTree(String filter) {
-
- }
- private void doJsonResponse(HttpServletResponse resp,Object data) {
-
- }
+public class DataTreeHttpServlet extends HttpServlet {
+
+ /**
+ * @param rawClient
+ */
+ public void setDatabaseClient(HtDatabaseClient rawClient) {
+
+
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ final String uri = req.getRequestURI();
+ }
+
+ private void readInventoryTree(String filter) {
+
+ }
+
+ private void doJsonResponse(HttpServletResponse resp, Object data) {
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
index 87210f29a..fd2784804 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/GetYangSchemaRequest.java
@@ -25,37 +25,37 @@ import javax.servlet.http.HttpServletRequest;
public class GetYangSchemaRequest {
- private static final String URI_PREFIX = "/yang-schema/";
- private final String module;
- private final String version;
-
- public String getModule() {
- return this.module;
- }
-
- public String getVersion() {
- return this.version;
- }
-
- public boolean hasVersion() {
- return this.version != null;
- }
-
- public GetYangSchemaRequest(HttpServletRequest req) throws Exception {
- String uri = req.getRequestURI().substring(URI_PREFIX.length());
-
- String[] hlp = uri.split("/");
- if (hlp.length < 1) {
- throw new Exception("no module request found");
-
- } else if (hlp.length == 1) {
- this.module = hlp[0];
- this.version = null;
- } else {
- this.module = hlp[0];
- this.version = hlp[1];
- }
-
- }
+ private static final String URI_PREFIX = "/yang-schema/";
+ private final String module;
+ private final String version;
+
+ public String getModule() {
+ return this.module;
+ }
+
+ public String getVersion() {
+ return this.version;
+ }
+
+ public boolean hasVersion() {
+ return this.version != null;
+ }
+
+ public GetYangSchemaRequest(HttpServletRequest req) throws Exception {
+ String uri = req.getRequestURI().substring(URI_PREFIX.length());
+
+ String[] hlp = uri.split("/");
+ if (hlp.length < 1) {
+ throw new Exception("no module request found");
+
+ } else if (hlp.length == 1) {
+ this.module = hlp[0];
+ this.version = null;
+ } else {
+ this.module = hlp[0];
+ this.version = hlp[1];
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
index ec5661acd..725256b17 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/MsServlet.java
@@ -33,81 +33,86 @@ import org.slf4j.LoggerFactory;
public class MsServlet extends BaseServlet {
- /**
- *
- */
- private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
- private static final long serialVersionUID = -5361461082028405171L;
- private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
- private static boolean trustAll = false;
- private static MediatorServerDataProvider entryProvider;
- public MsServlet() {
- super();
- }
-
- @Override
- protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- resp.setStatus(200);
- }
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- @Override
- protected String getOfflineResponse() {
- return OFFLINE_RESPONSE_MESSAGE;
- }
-
- public void triggerReloadDatabaseEntries() {
- LOG.debug("external reload triggered");
- entryProvider.triggerReloadSync();
- }
-
- @Override
- protected boolean isOff() {
- return false;
- }
-
- @Override
- protected String getRemoteUrl(String uri) {
- String dbServerId = "0";
- if (uri == null)
- uri = "";
- if (uri.length() > 0) {
- uri = uri.substring("/ms/".length());
- int idx= uri.indexOf("/");
- dbServerId = uri.substring(0,idx);
- uri=uri.substring(idx);
- }
- LOG.debug("request for ms server with id={}",dbServerId);
- String url= this.getBaseUrl(dbServerId) + uri;
- LOG.debug("dest-url: {}",url);
- return url;
- }
-
- protected String getBaseUrl(String dbServerId) {
- return entryProvider.getHostUrl(dbServerId);
- }
- @Override
- protected boolean doTrustAll() {
- return trustAll;
- }
- @Override
- protected void trustAll(boolean trust) {
- trustAll = trust;
- }
-
- public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
- entryProvider = mediatorServerDataProvider;
- }
-
- @Override
- protected boolean trustInsecure() {
- return trustAll;
- }
-
- @Override
- protected boolean isCorsEnabled() {
- return false;
- }
+ /**
+ *
+ */
+ private static Logger LOG = LoggerFactory.getLogger(MsServlet.class);
+ private static final long serialVersionUID = -5361461082028405171L;
+ private static final String OFFLINE_RESPONSE_MESSAGE = "MediatorServer interface is offline";
+ private static boolean trustAll = false;
+ private static MediatorServerDataProvider entryProvider;
+
+ public MsServlet() {
+ super();
+ }
+
+ @Override
+ protected void doOptions(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ resp.setStatus(200);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ @Override
+ protected String getOfflineResponse() {
+ return OFFLINE_RESPONSE_MESSAGE;
+ }
+
+ public void triggerReloadDatabaseEntries() {
+ LOG.debug("external reload triggered");
+ entryProvider.triggerReloadSync();
+ }
+
+ @Override
+ protected boolean isOff() {
+ return false;
+ }
+
+ @Override
+ protected String getRemoteUrl(String uri) {
+ String dbServerId = "0";
+ if (uri == null)
+ uri = "";
+ if (uri.length() > 0) {
+ uri = uri.substring("/ms/".length());
+ int idx = uri.indexOf("/");
+ dbServerId = uri.substring(0, idx);
+ uri = uri.substring(idx);
+ }
+ LOG.debug("request for ms server with id={}", dbServerId);
+ String url = this.getBaseUrl(dbServerId) + uri;
+ LOG.debug("dest-url: {}", url);
+ return url;
+ }
+
+ protected String getBaseUrl(String dbServerId) {
+ return entryProvider.getHostUrl(dbServerId);
+ }
+
+ @Override
+ protected boolean doTrustAll() {
+ return trustAll;
+ }
+
+ @Override
+ protected void trustAll(boolean trust) {
+ trustAll = trust;
+ }
+
+ public void setDataProvider(MediatorServerDataProvider mediatorServerDataProvider) {
+ entryProvider = mediatorServerDataProvider;
+ }
+
+ @Override
+ protected boolean trustInsecure() {
+ return trustAll;
+ }
+
+ @Override
+ protected boolean isCorsEnabled() {
+ return false;
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
index 8e1ced7da..e20f453a1 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/ReadyHttpServlet.java
@@ -33,35 +33,34 @@ import org.slf4j.LoggerFactory;
public class ReadyHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
- private static boolean status;
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(ReadyHttpServlet.class);
+ private static boolean status;
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- if(isReady()) {
- resp.setStatus(HttpServletResponse.SC_OK);
- }
- else {
-
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
- }
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- private static boolean isReady() {
- return status;
- }
+ if (isReady()) {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ } else {
- public static void setStatus(boolean s) {
- status = s;
- LOG.info("status is set to ready: {}",status);
- }
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+ }
+
+ private static boolean isReady() {
+ return status;
+ }
+
+ public static void setStatus(boolean s) {
+ status = s;
+ LOG.info("status is set to ready: {}", status);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
index 967ae26cb..075f4f766 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/http/YangSchemaHttpServlet.java
@@ -34,90 +34,90 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class YangSchemaHttpServlet extends HttpServlet {
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
-
- private static final String schemaCachePath = "cache/schema/";
-
- private final YangFileProvider fileProvider;
-
- public YangSchemaHttpServlet() {
- this.fileProvider = new YangFileProvider(schemaCachePath);
- }
-
- @Override
- protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
-
- GetYangSchemaRequest request = null;
- try {
- request = new GetYangSchemaRequest(req);
- } catch (Exception e) {
- LOG.warn("bad request for yang-schema: {}", e);
- }
- if (request != null) {
- int len;
- LOG.debug("request for yang-schema for module {} with version {}", request.getModule(),
- request.getVersion());
- if (request.hasVersion()) {
- boolean has=false;
- try {
- has = this.fileProvider.hasFileOrNewerForModule(request.getModule(), request.getVersion());
- } catch (ParseException e1) {
- LOG.warn("unable to parse revision: {}" ,e1);
- }
- if(has) {
-
- try {
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType("text/plain");
- len = this.fileProvider.writeOutput(request.getModule(), request.getVersion(),
- resp.getOutputStream());
- resp.setContentLength(len);
-
- } catch (ParseException e) {
- LOG.warn("unable to parse revision: {}", e);
- }catch (IOException | IllegalStateException e) {
- LOG.warn("unable to write out module {}@{}: {}",request.getModule(), request.getVersion(), e);
- }
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
-
- } else if (this.fileProvider.hasFileForModule(request.getModule())) {
-
- try {
- resp.setStatus(HttpServletResponse.SC_OK);
- resp.setContentType("text/plain");
- len = this.fileProvider.writeOutput(request.getModule(), null, resp.getOutputStream());
- resp.setContentLength(len);
- } catch (ParseException e) {
- LOG.warn(e.getMessage());
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out module {}: {}",request.getModule(), e);
- }
-
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_NOT_FOUND);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 404 res not found: {}",e);
- }
- }
- } else {
- try {
- resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
- }catch(IOException | IllegalStateException e) {
- LOG.warn("unable to write out 400 bad request: {}",e);
- }
- }
-
- }
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private static final Logger LOG = LoggerFactory.getLogger(YangSchemaHttpServlet.class);
+
+ private static final String schemaCachePath = "cache/schema/";
+
+ private final YangFileProvider fileProvider;
+
+ public YangSchemaHttpServlet() {
+ this.fileProvider = new YangFileProvider(schemaCachePath);
+ }
+
+ @Override
+ protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+
+ GetYangSchemaRequest request = null;
+ try {
+ request = new GetYangSchemaRequest(req);
+ } catch (Exception e) {
+ LOG.warn("bad request for yang-schema: {}", e);
+ }
+ if (request != null) {
+ int len;
+ LOG.debug("request for yang-schema for module {} with version {}", request.getModule(),
+ request.getVersion());
+ if (request.hasVersion()) {
+ boolean has = false;
+ try {
+ has = this.fileProvider.hasFileOrNewerForModule(request.getModule(), request.getVersion());
+ } catch (ParseException e1) {
+ LOG.warn("unable to parse revision: {}", e1);
+ }
+ if (has) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), request.getVersion(),
+ resp.getOutputStream());
+ resp.setContentLength(len);
+
+ } catch (ParseException e) {
+ LOG.warn("unable to parse revision: {}", e);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}@{}: {}", request.getModule(), request.getVersion(), e);
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+
+ } else if (this.fileProvider.hasFileForModule(request.getModule())) {
+
+ try {
+ resp.setStatus(HttpServletResponse.SC_OK);
+ resp.setContentType("text/plain");
+ len = this.fileProvider.writeOutput(request.getModule(), null, resp.getOutputStream());
+ resp.setContentLength(len);
+ } catch (ParseException e) {
+ LOG.warn(e.getMessage());
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out module {}: {}", request.getModule(), e);
+ }
+
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_NOT_FOUND);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 404 res not found: {}", e);
+ }
+ }
+ } else {
+ try {
+ resp.sendError(HttpServletResponse.SC_BAD_REQUEST);
+ } catch (IOException | IllegalStateException e) {
+ LOG.warn("unable to write out 400 bad request: {}", e);
+ }
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
index 2465fc622..286af7aa3 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderImpl.java
@@ -47,7 +47,7 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
private DataProviderServiceImpl rpcApiService;
private AboutHttpServlet aboutServlet;
private HtDatabaseClient dbClient;
-
+
// Blueprint 1
public DataProviderImpl() {
super();
@@ -57,18 +57,21 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
public void setRpcProviderService(RpcProviderService rpcProviderService) {
this.rpcProviderService = rpcProviderService;
}
+
public void setMediatorServerServlet(MsServlet servlet) {
this.mediatorServerServlet = servlet;
}
+
public void setAboutServlet(AboutHttpServlet aboutServlet) {
this.aboutServlet = aboutServlet;
}
+
public void init() throws Exception {
LOG.info("Session Initiated start {}", APPLICATION_NAME);
// Start RPC Service
- this.rpcApiService = new DataProviderServiceImpl(rpcProviderService,this.mediatorServerServlet);
+ this.rpcApiService = new DataProviderServiceImpl(rpcProviderService, this.mediatorServerServlet);
LOG.info("Session Initiated end. Initialization done");
}
@@ -117,13 +120,13 @@ public class DataProviderImpl implements IEntityDataProvider, AutoCloseable {
@Override
public void setReadyStatus(boolean status) {
- ReadyHttpServlet.setStatus(status);
+ ReadyHttpServlet.setStatus(status);
}
@Override
public void setStatus(StatusKey key, String value) {
- if(this.aboutServlet!=null) {
- if(key==StatusKey.CLUSTER_SIZE) {
+ if (this.aboutServlet != null) {
+ if (key == StatusKey.CLUSTER_SIZE) {
this.aboutServlet.setClusterSize(value);
}
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
index 2f3b7ee80..4b8564395 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/DataProviderServiceImpl.java
@@ -100,28 +100,33 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
private static final Logger LOG = LoggerFactory.getLogger(DataProviderServiceImpl.class);
public static final String CONFIGURATIONFILE = "etc/dataprovider.properties";
- private static final long DATABASE_TIMEOUT_MS = 120*1000L;
+ private static final long DATABASE_TIMEOUT_MS = 120 * 1000L;
private final ObjectRegistration<@NonNull DataProviderServiceImpl> rpcReg;
private final ElasticSearchDataProvider dataProvider;
private final ConfigurationFileRepresentation configuration;
private final EsConfig esConfig;
- private final MediatorServerDataProvider mediatorServerDataProvider;
+ private final MediatorServerDataProvider mediatorServerDataProvider;
- DataProviderServiceImpl(final RpcProviderService rpcProviderService,MsServlet mediatorServerServlet) throws Exception {
+ DataProviderServiceImpl(final RpcProviderService rpcProviderService, MsServlet mediatorServerServlet)
+ throws Exception {
this.configuration = new ConfigurationFileRepresentation(CONFIGURATIONFILE);
this.esConfig = new EsConfig(configuration);
- this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword(),esConfig.trustAllCerts());
- this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS,TimeUnit.MILLISECONDS);
- this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),esConfig.getBasicAuthUsername(),esConfig.getBasicAuthPassword());
+ this.dataProvider = new ElasticSearchDataProvider(esConfig.getHosts(), esConfig.getBasicAuthUsername(),
+ esConfig.getBasicAuthPassword(), esConfig.trustAllCerts());
+ this.dataProvider.waitForYellowDatabaseStatus(DATABASE_TIMEOUT_MS, TimeUnit.MILLISECONDS);
+ this.mediatorServerDataProvider = new MediatorServerDataProvider(esConfig.getHosts(),
+ esConfig.getBasicAuthUsername(), esConfig.getBasicAuthPassword());
mediatorServerServlet.setDataProvider(this.mediatorServerDataProvider);
// Register ourselves as the REST API RPC implementation
LOG.info("Register RPC Service " + DataProviderServiceImpl.class.getSimpleName());
this.rpcReg = rpcProviderService.registerRpcImplementation(DataProviderService.class, this);
}
+
private void sendResyncCallbackToApiGateway() {
- mediatorServerDataProvider.triggerReloadSync();
+ mediatorServerDataProvider.triggerReloadSync();
}
+
/**
* @return dataProvider
*/
@@ -130,8 +135,9 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
public HtDatabaseClient getRawClient() {
- return this.dataProvider.getRawClient();
+ return this.dataProvider.getRawClient();
}
+
/**
* @return data provider for Maintenance()
*/
@@ -156,22 +162,27 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
}
@Override
- public ListenableFuture<RpcResult<ReadFaultcurrentListOutput>> readFaultcurrentList(ReadFaultcurrentListInput input) {
+ public ListenableFuture<RpcResult<ReadFaultcurrentListOutput>> readFaultcurrentList(
+ ReadFaultcurrentListInput input) {
LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
- RpcResultBuilder<ReadFaultcurrentListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input));
+ RpcResultBuilder<ReadFaultcurrentListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readFaultCurrentList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadFaultlogListOutput>> readFaultlogList(ReadFaultlogListInput input) {
LOG.debug("RPC Request: getFaultCurrentEntityList with input {}", input);
- RpcResultBuilder<ReadFaultlogListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input));
+ RpcResultBuilder<ReadFaultlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readFaultLogList(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadMaintenanceListOutput>> readMaintenanceList(ReadMaintenanceListInput input) {
LOG.debug("RPC Request: getMaintenanceEntityList with input {}", input);
- RpcResultBuilder<ReadMaintenanceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input));
+ RpcResultBuilder<ReadMaintenanceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readMaintenanceList(input));
return result.buildFuture();
}
@@ -179,7 +190,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<ReadMediatorServerListOutput>> readMediatorServerList(
ReadMediatorServerListInput input) {
LOG.debug("RPC Request: getMediatorServerEntityList with input {}", input);
- RpcResultBuilder<ReadMediatorServerListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input));
+ RpcResultBuilder<ReadMediatorServerListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readMediatorServerList(input));
return result.buildFuture();
}
@@ -187,7 +199,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<ReadNetworkElementConnectionListOutput>> readNetworkElementConnectionList(
ReadNetworkElementConnectionListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadNetworkElementConnectionListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input));
+ RpcResultBuilder<ReadNetworkElementConnectionListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readNetworkElementConnectionList(input));
return result.buildFuture();
}
@@ -195,21 +208,25 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<ReadPmdata15mListOutput>> readPmdata15mList(ReadPmdata15mListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadPmdata15mListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input));
+ RpcResultBuilder<ReadPmdata15mListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadPmdata24hListOutput>> readPmdata24hList(ReadPmdata24hListInput input) {
LOG.debug("RPC Request: getNetworkElementConnectionEntityList with input {}", input);
- RpcResultBuilder<ReadPmdata24hListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input));
+ RpcResultBuilder<ReadPmdata24hListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hList(input));
return result.buildFuture();
}
+
@Override
public ListenableFuture<RpcResult<ReadStatusOutput>> readStatus(ReadStatusInput input) {
LOG.debug("RPC Request: getStatusEntityList with input {}", input);
- RpcResultBuilder<ReadStatusOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readStatus());
+ RpcResultBuilder<ReadStatusOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readStatus());
return result.buildFuture();
}
@@ -217,43 +234,53 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<ReadInventoryListOutput>> readInventoryList(ReadInventoryListInput input) {
LOG.debug("RPC Request: getInventoryEntityList with input {}", input);
- RpcResultBuilder<ReadInventoryListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readInventoryList(input));
+ RpcResultBuilder<ReadInventoryListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readInventoryList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata15mLtpListOutput>> readPmdata15mLtpList(ReadPmdata15mLtpListInput input) {
+ public ListenableFuture<RpcResult<ReadPmdata15mLtpListOutput>> readPmdata15mLtpList(
+ ReadPmdata15mLtpListInput input) {
LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
- RpcResultBuilder<ReadPmdata15mLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input));
+ RpcResultBuilder<ReadPmdata15mLtpListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mLtpList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata15mDeviceListOutput>> readPmdata15mDeviceList(ReadPmdata15mDeviceListInput input) {
- LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
- RpcResultBuilder<ReadPmdata15mDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input));
- return result.buildFuture();
+ public ListenableFuture<RpcResult<ReadPmdata15mDeviceListOutput>> readPmdata15mDeviceList(
+ ReadPmdata15mDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata15mDeviceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata15mDeviceList(input));
+ return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata24hLtpListOutput>> readPmdata24hLtpList(ReadPmdata24hLtpListInput input) {
+ public ListenableFuture<RpcResult<ReadPmdata24hLtpListOutput>> readPmdata24hLtpList(
+ ReadPmdata24hLtpListInput input) {
LOG.debug("RPC Request: readPmdataLtpList with input {}", input);
- RpcResultBuilder<ReadPmdata24hLtpListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input));
+ RpcResultBuilder<ReadPmdata24hLtpListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hLtpList(input));
return result.buildFuture();
}
@Override
- public ListenableFuture<RpcResult<ReadPmdata24hDeviceListOutput>> readPmdata24hDeviceList(ReadPmdata24hDeviceListInput input) {
- LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
- RpcResultBuilder<ReadPmdata24hDeviceListOutput> result = read(()-> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input));
- return result.buildFuture();
+ public ListenableFuture<RpcResult<ReadPmdata24hDeviceListOutput>> readPmdata24hDeviceList(
+ ReadPmdata24hDeviceListInput input) {
+ LOG.debug("RPC Request: readPmdataDeviceList with input {}", input);
+ RpcResultBuilder<ReadPmdata24hDeviceListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readPmdata24hDeviceList(input));
+ return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadConnectionlogListOutput>> readConnectionlogList(
ReadConnectionlogListInput input) {
LOG.debug("RPC Request: readConnectionlogList with input {}", input);
- RpcResultBuilder<ReadConnectionlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readConnectionlogList(input));
+ RpcResultBuilder<ReadConnectionlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readConnectionlogList(input));
return result.buildFuture();
}
@@ -261,7 +288,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<CreateNetworkElementConnectionOutput>> createNetworkElementConnection(
CreateNetworkElementConnectionInput input) {
LOG.debug("RPC Request: createNetworkElementConnection with input {}", input);
- RpcResultBuilder<CreateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createNetworkElementConnection(input));
+ RpcResultBuilder<CreateNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createNetworkElementConnection(input));
return result.buildFuture();
}
@@ -269,14 +297,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<UpdateNetworkElementConnectionOutput>> updateNetworkElementConnection(
UpdateNetworkElementConnectionInput input) {
LOG.debug("RPC Request: updateNetworkElementConnection with input {}", input);
- RpcResultBuilder<UpdateNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateNetworkElementConnection(input));
+ RpcResultBuilder<UpdateNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateNetworkElementConnection(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<DeleteNetworkElementConnectionOutput>> deleteNetworkElementConnection(
DeleteNetworkElementConnectionInput input) {
- RpcResultBuilder<DeleteNetworkElementConnectionOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input));
+ RpcResultBuilder<DeleteNetworkElementConnectionOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteNetworkElementConnection(input));
return result.buildFuture();
}
@@ -284,7 +314,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<DeleteMediatorServerOutput>> deleteMediatorServer(
DeleteMediatorServerInput input) {
LOG.debug("RPC Request: deleteMediatorServer with input {}", input);
- RpcResultBuilder<DeleteMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMediatorServer(input));
+ RpcResultBuilder<DeleteMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -293,7 +324,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<CreateMediatorServerOutput>> createMediatorServer(
CreateMediatorServerInput input) {
LOG.debug("RPC Request: createMediatorServer with input {}", input);
- RpcResultBuilder<CreateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMediatorServer(input));
+ RpcResultBuilder<CreateMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -301,14 +333,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<CreateMaintenanceOutput>> createMaintenance(CreateMaintenanceInput input) {
LOG.debug("RPC Request: createMaintenance with input {}", input);
- RpcResultBuilder<CreateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.createMaintenance(input));
+ RpcResultBuilder<CreateMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.createMaintenance(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<DeleteMaintenanceOutput>> deleteMaintenance(DeleteMaintenanceInput input) {
LOG.debug("RPC Request: deleteMaintenance with input {}", input);
- RpcResultBuilder<DeleteMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.deleteMaintenance(input));
+ RpcResultBuilder<DeleteMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.deleteMaintenance(input));
return result.buildFuture();
}
@@ -316,7 +350,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
public ListenableFuture<RpcResult<UpdateMediatorServerOutput>> updateMediatorServer(
UpdateMediatorServerInput input) {
LOG.debug("RPC Request: updateMediatorServer with input {}", input);
- RpcResultBuilder<UpdateMediatorServerOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMediatorServer(input));
+ RpcResultBuilder<UpdateMediatorServerOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateMediatorServer(input));
this.sendResyncCallbackToApiGateway();
return result.buildFuture();
}
@@ -324,14 +359,16 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
@Override
public ListenableFuture<RpcResult<UpdateMaintenanceOutput>> updateMaintenance(UpdateMaintenanceInput input) {
LOG.debug("RPC Request: updateMaintenance with input {}", input);
- RpcResultBuilder<UpdateMaintenanceOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.updateMaintenance(input));
+ RpcResultBuilder<UpdateMaintenanceOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.updateMaintenance(input));
return result.buildFuture();
}
@Override
public ListenableFuture<RpcResult<ReadEventlogListOutput>> readEventlogList(ReadEventlogListInput input) {
LOG.debug("RPC Request: readEventlogList with input {}", input);
- RpcResultBuilder<ReadEventlogListOutput> result = read(() -> DataProviderServiceImpl.this.dataProvider.readEventlogList(input));
+ RpcResultBuilder<ReadEventlogListOutput> result =
+ read(() -> DataProviderServiceImpl.this.dataProvider.readEventlogList(input));
return result.buildFuture();
}
@@ -352,7 +389,8 @@ public class DataProviderServiceImpl implements DataProviderService, AutoCloseab
Builder<O> get() throws IOException;
}
- private static <O extends DataObject,I extends DataObject> RpcResultBuilder<O> read(GetEntityInput<O> inputgetter ) {
+ private static <O extends DataObject, I extends DataObject> RpcResultBuilder<O> read(
+ GetEntityInput<O> inputgetter) {
RpcResultBuilder<O> result;
try {
Builder<O> outputBuilder = inputgetter.get();
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
index fc3701099..001437771 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/impl/EsConfig.java
@@ -51,7 +51,7 @@ public class EsConfig implements Configuration, IEsConfig {
private static final String PROPERTY_KEY_AUTH_USERNAME = "esAuthUsername";
private static final String PROPERTY_KEY_AUTH_PASSWORD = "esAuthPassword";
-
+
private static String defaultHostinfo = "${SDNRDBURL}";//printHosts(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
private static final String DEFAULT_VALUE_CLUSTER = "";
/** check db data in this interval [in seconds] 0 deactivated */
@@ -59,10 +59,10 @@ public class EsConfig implements Configuration, IEsConfig {
/** keep data for this time [in seconds] 30 days */
private static final String DEFAULT_ARCHIVE_LIMIT_SEC = String.valueOf(60L * 60L * 24L * 30L);
//private static final String DEFAULT_KEY_NODE = "elasticsearchnode";
- private static final String DEFAULT_VALUE_NODE = "elasticsearchnode";
- private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
- private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
- private static final String DEFAULT_VALUE_TRUSTALLCERTS = "${SDNRDBTRUSTALLCERTS}";
+ private static final String DEFAULT_VALUE_NODE = "elasticsearchnode";
+ private static final String DEFAULT_VALUE_DBUSERNAME = "${SDNRDBUSERNAME}";
+ private static final String DEFAULT_VALUE_DBPASSWORD = "${SDNRDBPASSWORD}";
+ private static final String DEFAULT_VALUE_TRUSTALLCERTS = "${SDNRDBTRUSTALLCERTS}";
private final ConfigurationFileRepresentation configuration;
@@ -93,9 +93,11 @@ public class EsConfig implements Configuration, IEsConfig {
String dbHosts = configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS);
return parseHosts(dbHosts);
}
+
public void setHosts(HostInfo[] hosts) {
this.configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_DBHOSTS, printHosts(hosts));
}
+
@Override
public String getCluster() {
return configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL);
@@ -106,22 +108,27 @@ public class EsConfig implements Configuration, IEsConfig {
}
public boolean hasBasicAuthCredentials() {
- return this.getBasicAuthUsername()!=null && this.getBasicAuthPassword()!=null &&
- !this.getBasicAuthUsername().isEmpty() && !this.getBasicAuthPassword().isEmpty() ;
+ return this.getBasicAuthUsername() != null && this.getBasicAuthPassword() != null
+ && !this.getBasicAuthUsername().isEmpty() && !this.getBasicAuthPassword().isEmpty();
}
+
public String getBasicAuthUsername() {
- return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME);
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME);
}
+
public String getBasicAuthPassword() {
- return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD);
+ return this.configuration.getProperty(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD);
}
+
@Override
public long getArchiveCheckIntervalSeconds() {
return configuration.getPropertyLong(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL).orElse(0L);
}
+
public boolean trustAllCerts() {
- return configuration.getPropertyBoolean(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS);
+ return configuration.getPropertyBoolean(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS);
}
+
public void setArchiveCheckIntervalSeconds(long seconds) {
configuration.setProperty(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL, seconds);
}
@@ -150,10 +157,13 @@ public class EsConfig implements Configuration, IEsConfig {
configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_ARCHIVE_INTERVAL,
DEFAULT_ARCHIVE_INTERVAL_SEC);
configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_NODE, DEFAULT_VALUE_NODE);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME, DEFAULT_VALUE_DBUSERNAME);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD, DEFAULT_VALUE_DBPASSWORD);
- configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS, DEFAULT_VALUE_TRUSTALLCERTS);
-
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_USERNAME,
+ DEFAULT_VALUE_DBUSERNAME);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_AUTH_PASSWORD,
+ DEFAULT_VALUE_DBPASSWORD);
+ configuration.setPropertyIfNotAvailable(SECTION_MARKER_ES, PROPERTY_KEY_TRUSTALLCERTS,
+ DEFAULT_VALUE_TRUSTALLCERTS);
+
}
@Override
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
index 555b38533..a9a658387 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsCloner.java
@@ -46,12 +46,15 @@ public class YangToolsCloner {
private YangToolsCloner(int ac) {
this.accessor = ac;
}
+
public static YangToolsCloner instance() {
return instance(ACCESSOR_METHOD);
}
+
public static YangToolsCloner instance(int ac) {
return new YangToolsCloner(ac);
}
+
/**
*
* @param source source object
@@ -88,9 +91,10 @@ public class YangToolsCloner {
* @param clazz Class of return object
* @return cloned object
*/
- public <S , T extends DataObject> T clone(S source, Class<T> clazz) {
+ public <S, T extends DataObject> T clone(S source, Class<T> clazz) {
return clone(source, clazz, null);
}
+
/**
*
* @param source source object
@@ -98,10 +102,9 @@ public class YangToolsCloner {
* @attrList if empty copy all else list of attribute Names to clone
* @return cloned object
*/
- public <S, T extends DataObject> T clone(S source, Class<T> clazz,
- @Nullable List<String> attrList) {
+ public <S, T extends DataObject> T clone(S source, Class<T> clazz, @Nullable List<String> attrList) {
if (source == null) {
- return (T)null;
+ return (T) null;
}
Field[] attributeFields;
Field sourceField;
@@ -121,7 +124,7 @@ public class YangToolsCloner {
attributeField.setAccessible(true);
try {
- if(accessor==ACCESSOR_FIELD) {
+ if (accessor == ACCESSOR_FIELD) {
sourceField = source.getClass().getDeclaredField(attributeField.getName());
sourceField.setAccessible(true);
if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
@@ -129,10 +132,9 @@ public class YangToolsCloner {
} else {
attributeField.set(object, sourceField.get(source));
}
- }
- else if(accessor==ACCESSOR_METHOD) {
+ } else if (accessor == ACCESSOR_METHOD) {
String getter = getter(attributeField.getName());
- System.out.println("getter="+getter);
+ System.out.println("getter=" + getter);
m = source.getClass().getDeclaredMethod(getter);
m.setAccessible(true);
if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
@@ -147,7 +149,7 @@ public class YangToolsCloner {
String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
LOG.debug(msg);
// throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException|SecurityException e) {
+ } catch (IllegalAccessException | SecurityException e) {
LOG.debug("Access problem " + attributeField.getName(), e);
} catch (IllegalArgumentException e) {
LOG.debug("argument problem " + attributeField.getName(), e);
@@ -160,12 +162,14 @@ public class YangToolsCloner {
}
private static String getter(String name) {
- return String.format("%s%s%s","get",name.substring(1, 2).toUpperCase(),name.substring(2));
+ return String.format("%s%s%s", "get", name.substring(1, 2).toUpperCase(), name.substring(2));
}
- public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder){
- return cloneToBuilder(source, builder,null);
+
+ public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder) {
+ return cloneToBuilder(source, builder, null);
}
- public <S extends DataObject, T extends DataObject,B extends Builder<T>> B cloneToBuilder(S source, B builder,
+
+ public <S extends DataObject, T extends DataObject, B extends Builder<T>> B cloneToBuilder(S source, B builder,
@Nullable List<String> attrList) {
Field[] attributeFields;
Field sourceField;
@@ -183,7 +187,7 @@ public class YangToolsCloner {
attributeField.setAccessible(true);
try {
- if(accessor==ACCESSOR_FIELD) {
+ if (accessor == ACCESSOR_FIELD) {
sourceField = source.getClass().getDeclaredField(attributeField.getName());
sourceField.setAccessible(true);
if (attributeField.getType().equals(String.class) && !sourceField.getType().equals(String.class)) {
@@ -191,8 +195,7 @@ public class YangToolsCloner {
} else {
attributeField.set(builder, sourceField.get(source));
}
- }
- else if(accessor==ACCESSOR_METHOD) {
+ } else if (accessor == ACCESSOR_METHOD) {
m = source.getClass().getDeclaredMethod(getter(attributeField.getName()));
m.setAccessible(true);
if (attributeField.getType().equals(String.class) && !m.getReturnType().equals(String.class)) {
@@ -207,7 +210,7 @@ public class YangToolsCloner {
String msg = "no such field " + attributeField.getName() + " in class " + source.getClass().getName();
LOG.debug(msg);
// throw new IllegalArgumentException(msg);
- } catch (IllegalAccessException|SecurityException e) {
+ } catch (IllegalAccessException | SecurityException e) {
LOG.debug("Access problem " + attributeField.getName(), e);
} catch (IllegalArgumentException e) {
LOG.debug("argument problem " + attributeField.getName(), e);
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java
index 768e6683b..0b1e7d520 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper.java
@@ -48,183 +48,190 @@ import com.fasterxml.jackson.databind.module.SimpleModule;
import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
/**
- * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
- * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or
+ * deserialization of DataObject to/from JSON TODO ChoiceIn and Credentials deserialization only for
+ * LoginPasswordBuilder
*/
public class YangToolsMapper extends ObjectMapper {
- private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class);
- private static final long serialVersionUID = 1L;
- private static BundleContext context;
-
- public YangToolsMapper() {
- super();
- configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
- setSerializationInclusion(Include.NON_NULL);
- setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
- SimpleModule dateAndTimeSerializerModule = new SimpleModule();
- dateAndTimeSerializerModule.addSerializer(DateAndTime.class,new CustomDateAndTimeSerializer());
- registerModule(dateAndTimeSerializerModule );
- Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper.class);
- context = bundle != null ? bundle.getBundleContext() : null;
- }
-
- @Override
- public String writeValueAsString(Object value) throws JsonProcessingException {
- // TODO Auto-generated method stub
- return super.writeValueAsString(value);
- }
- /**
- * Get Builder object for yang tools interface.
- * @param <T> yang-tools base datatype
- * @param clazz class with interface.
- * @return builder for interface or null if not existing
- */
- @SuppressWarnings("unchecked")
- public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
- String builder = clazz.getName() + "Builder";
- try {
- Class<?> clazzBuilder = findClass(builder);
- return (Builder<T>) clazzBuilder.newInstance();
- } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
- LOG.debug("Problem ", e);
- return null;
- }
- }
-
- /**
- * Callback for handling mapping failures.
- * @return
- */
- public int getMappingFailures() {
- return 0;
- }
-
- /**
- * Provide mapping of string to attribute names, generated by yang-tools.
- * "netconf-id" converted to "_netconfId"
- * @param name with attribute name, not null or empty
- * @return converted string or null if name was empty or null
- */
- public @Nullable static String toCamelCaseAttributeName(final String name) {
- if (name == null || name.isEmpty())
- return null;
-
- final StringBuilder ret = new StringBuilder(name.length());
- if (!name.startsWith("_"))
- ret.append('_');
- int start = 0;
- for (final String word : name.split("-")) {
- if (!word.isEmpty()) {
- if (start++ == 0) {
- ret.append(Character.toLowerCase(word.charAt(0)));
- } else {
- ret.append(Character.toUpperCase(word.charAt(0)));
- }
- ret.append(word.substring(1));
- }
- }
- return ret.toString();
- }
-
- /**
- * Adapted Builder callbacks
- */
- private static class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
- private static final long serialVersionUID = 1L;
-
- @Override
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper.class);
+ private static final long serialVersionUID = 1L;
+ private static BundleContext context;
+
+ public YangToolsMapper() {
+ super();
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
+ setSerializationInclusion(Include.NON_NULL);
+ setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
+ SimpleModule dateAndTimeSerializerModule = new SimpleModule();
+ dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer());
+ registerModule(dateAndTimeSerializerModule);
+ Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper.class);
+ context = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ @Override
+ public String writeValueAsString(Object value) throws JsonProcessingException {
+ // TODO Auto-generated method stub
+ return super.writeValueAsString(value);
+ }
+
+ /**
+ * Get Builder object for yang tools interface.
+ *
+ * @param <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ String builder = clazz.getName() + "Builder";
+ try {
+ Class<?> clazzBuilder = findClass(builder);
+ return (Builder<T>) clazzBuilder.newInstance();
+ } catch (InstantiationException | IllegalAccessException | ClassNotFoundException e) {
+ LOG.debug("Problem ", e);
+ return null;
+ }
+ }
+
+ /**
+ * Callback for handling mapping failures.
+ *
+ * @return
+ */
+ public int getMappingFailures() {
+ return 0;
+ }
+
+ /**
+ * Provide mapping of string to attribute names, generated by yang-tools. "netconf-id" converted to "_netconfId"
+ *
+ * @param name with attribute name, not null or empty
+ * @return converted string or null if name was empty or null
+ */
+ public @Nullable static String toCamelCaseAttributeName(final String name) {
+ if (name == null || name.isEmpty())
+ return null;
+
+ final StringBuilder ret = new StringBuilder(name.length());
+ if (!name.startsWith("_"))
+ ret.append('_');
+ int start = 0;
+ for (final String word : name.split("-")) {
+ if (!word.isEmpty()) {
+ if (start++ == 0) {
+ ret.append(Character.toLowerCase(word.charAt(0)));
+ } else {
+ ret.append(Character.toUpperCase(word.charAt(0)));
+ }
+ ret.append(word.substring(1));
+ }
+ }
+ return ret.toString();
+ }
+
+ /**
+ * Adapted Builder callbacks
+ */
+ private static class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
+ private static final long serialVersionUID = 1L;
+
+ @Override
public Class<?> findPOJOBuilder(AnnotatedClass ac) {
- try {
- String builder = null;
- if (ac.getRawType().equals(Credentials.class)) {
- builder = "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder";
- //System.out.println(DataContainer.class.isAssignableFrom(ac.getRawType()));
- //System.out.println(ChoiceIn.class.isAssignableFrom(ac.getRawType()));
-
- }
- else if(ac.getRawType().equals(DateAndTime.class)) {
- builder = DateAndTimeBuilder.class.getName();
- }
-
- else {
- if (ac.getRawType().isInterface()) {
- builder = ac.getName()+"Builder";
- }
- }
- if (builder != null) {
- //System.out.println("XX1: "+ac.getRawType());
- //System.out.println("XX2: "+builder);
- //Class<?> innerBuilder = Class.forName(builder);
- Class<?> innerBuilder = findClass(builder);
- //System.out.println("Builder found: "+ innerBuilder);
- return innerBuilder;
- }
- } catch( ClassNotFoundException e ) {
- // No problem .. try next
- }
- return super.findPOJOBuilder(ac);
+ try {
+ String builder = null;
+ if (ac.getRawType().equals(Credentials.class)) {
+ builder =
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder";
+ //System.out.println(DataContainer.class.isAssignableFrom(ac.getRawType()));
+ //System.out.println(ChoiceIn.class.isAssignableFrom(ac.getRawType()));
+
+ } else if (ac.getRawType().equals(DateAndTime.class)) {
+ builder = DateAndTimeBuilder.class.getName();
+ }
+
+ else {
+ if (ac.getRawType().isInterface()) {
+ builder = ac.getName() + "Builder";
+ }
+ }
+ if (builder != null) {
+ //System.out.println("XX1: "+ac.getRawType());
+ //System.out.println("XX2: "+builder);
+ //Class<?> innerBuilder = Class.forName(builder);
+ Class<?> innerBuilder = findClass(builder);
+ //System.out.println("Builder found: "+ innerBuilder);
+ return innerBuilder;
+ }
+ } catch (ClassNotFoundException e) {
+ // No problem .. try next
+ }
+ return super.findPOJOBuilder(ac);
+ }
+
+ @Override
+ public Value findPOJOBuilderConfig(AnnotatedClass ac) {
+ if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
+ return super.findPOJOBuilderConfig(ac);
+ }
+ return new JsonPOJOBuilder.Value("build", "set");
+ }
+ }
+
+ private static Class<?> findClass(String name) throws ClassNotFoundException {
+ // Try to find in other bundles
+ if (context != null) {
+ //OSGi environment
+ for (Bundle b : context.getBundles()) {
+ try {
+ return b.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // No problem, this bundle doesn't have the class
+ }
+ }
+ throw new ClassNotFoundException("Can not find Class in OSGi context.");
+ } else {
+ return Class.forName(name);
+ }
+ // not found in any bundle
+ }
+
+ public static class DateAndTimeBuilder {
+
+ private final String _value;
+
+ public DateAndTimeBuilder(String v) {
+ this._value = v;
+ }
+
+ public DateAndTime build() {
+ return new DateAndTime(_value);
+ }
+
+ }
+ public static class CustomDateAndTimeSerializer extends StdSerializer<DateAndTime> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
}
- @Override
- public Value findPOJOBuilderConfig(AnnotatedClass ac) {
- if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
- return super.findPOJOBuilderConfig(ac);
- }
- return new JsonPOJOBuilder.Value("build", "set");
- }
- }
-
- private static Class<?> findClass(String name) throws ClassNotFoundException {
- // Try to find in other bundles
- if (context != null) {
- //OSGi environment
- for (Bundle b : context.getBundles()) {
- try {
- return b.loadClass(name);
- } catch (ClassNotFoundException e) {
- // No problem, this bundle doesn't have the class
- }
- }
- throw new ClassNotFoundException("Can not find Class in OSGi context.");
- } else {
- return Class.forName(name);
- }
- // not found in any bundle
- }
- public static class DateAndTimeBuilder{
-
- private final String _value;
-
- public DateAndTimeBuilder(String v) {
- this._value= v;
- }
-
- public DateAndTime build() {
- return new DateAndTime(_value);
- }
-
- }
- public static class CustomDateAndTimeSerializer extends StdSerializer<DateAndTime>{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- public CustomDateAndTimeSerializer() {
- this(null);
- }
- protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
- super(t);
- }
-
- @Override
- public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeString(value.getValue());
- }
-
- }
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java
index 8f0de4f73..ce67c39dd 100644
--- a/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java
+++ b/sdnr/wt/data-provider/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/yangtools/YangToolsMapper2.java
@@ -49,219 +49,231 @@ import com.fasterxml.jackson.databind.ser.std.StdSerializer;
import org.eclipse.jdt.annotation.NonNull;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.yang.types.rev130715.DateAndTime;
+
/**
- * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or deserialization of DataObject to/from JSON
- * TODO ChoiceIn and Credentials deserialization only for LoginPasswordBuilder
+ * YangToolsMapper is a specific Jackson mapper configuration for opendaylight yangtools serialization or
+ * deserialization of DataObject to/from JSON TODO ChoiceIn and Credentials deserialization only for
+ * LoginPasswordBuilder
*/
public class YangToolsMapper2<T extends DataObject> extends ObjectMapper {
- private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
- private static final long serialVersionUID = 1L;
- private static String ENTITY = "Entity";
- private static String BUILDER = "Builder";
-
- private @Nullable Class<T> clazz;
- private @Nullable Class<? extends Builder<? extends T>> builderClazz;
-
- private BundleContext context;
-
- public <X extends T, B extends Builder<X>> YangToolsMapper2(Class<T> clazz, Class<B> builderClazz) throws ClassNotFoundException {
- super();
- configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
- setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
- setSerializationInclusion(Include.NON_NULL);
- setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
- SimpleModule dateAndTimeSerializerModule = new SimpleModule();
- dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer());
- registerModule(dateAndTimeSerializerModule );
- Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class);
-
- this.clazz = clazz;
- this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz)) ;
- context = bundle != null ? bundle.getBundleContext() : null;
- }
-
- public YangToolsMapper2() throws ClassNotFoundException {
- this(null, null);
- }
-
-
- @Override
- public String writeValueAsString(Object value) throws JsonProcessingException {
- return super.writeValueAsString(value);
- }
- /**
- * Get Builder object for yang tools interface.
- * @param <T> yang-tools base datatype
- * @param clazz class with interface.
- * @return builder for interface or null if not existing
- */
- @SuppressWarnings("unchecked")
- public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
- try {
- //Class<?> clazzBuilder = getBuilderClass(getBuilderClassName(clazz));
- return (Builder<T>) builderClazz.newInstance();
- } catch (InstantiationException | IllegalAccessException e) {
- LOG.debug("Problem ", e);
- return null;
- }
- }
-
- /**
- * Callback for handling mapping failures.
- * @return
- */
- public int getMappingFailures() {
- return 0;
- }
-
- /**
- * Provide mapping of string to attribute names, generated by yang-tools.
- * "netconf-id" converted to "_netconfId"
- * @param name with attribute name, not null or empty
- * @return converted string or null if name was empty or null
- */
- public @Nullable static String toCamelCaseAttributeName(final String name) {
- if (name == null || name.isEmpty())
- return null;
-
- final StringBuilder ret = new StringBuilder(name.length());
- if (!name.startsWith("_"))
- ret.append('_');
- int start = 0;
- for (final String word : name.split("-")) {
- if (!word.isEmpty()) {
- if (start++ == 0) {
- ret.append(Character.toLowerCase(word.charAt(0)));
- } else {
- ret.append(Character.toUpperCase(word.charAt(0)));
- }
- ret.append(word.substring(1));
- }
- }
- return ret.toString();
- }
-
- /** Verify if builder is available
- * @throws ClassNotFoundException **/
- public Class<?> assertBuilderClass(Class<?> clazz) throws ClassNotFoundException {
- return getBuilderClass(getBuilderClassName(clazz));
- }
-
- // --- Private functions
-
- /**
- * Create name of builder class
- * @param <T>
- * @param clazz
- * @return builders class name
- * @throws ClassNotFoundException
- */
- private static String getBuilderClassName(Class<?> clazz) {
- return clazz.getName() + BUILDER;
-// String clazzName = clazz.getName();
-// if (clazzName.endsWith(ENTITY)) {
-// return clazzName.replace(ENTITY, BUILDER);
-// } else {
-// return clazzName + BUILDER;
-// }
- }
-
- /**
- * Search builder in context
- * @param name
- * @return
- * @throws ClassNotFoundException
- */
- @SuppressWarnings("unchecked")
- private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
- // Try to find in other bundles
- if (context != null) {
- //OSGi environment
- for (Bundle b : context.getBundles()) {
- try {
- return (Class<B>) b.loadClass(name);
- } catch (ClassNotFoundException e) {
- // No problem, this bundle doesn't have the class
- }
- }
- throw new ClassNotFoundException("Can not find Class in OSGi context.");
- } else {
- return (Class<B>) Class.forName(name);
- }
- // not found in any bundle
- }
-
- // --- Classes
-
- /**
- * Adapted Builder callbacks
- */
- private class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
- private static final long serialVersionUID = 1L;
-
- @Override
- public Class<?> findPOJOBuilder(AnnotatedClass ac) {
-
- if (ac.getRawType().equals(Credentials.class)) {
- return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class;
-
- } else if (ac.getRawType().equals(DateAndTime.class)) {
- return DateAndTimeBuilder.class;
-
- } else if (ac.getRawType().equals(clazz)) {
- return builderClazz;
- }
-
- if (ac.getRawType().isInterface()) {
- String builder = getBuilderClassName(ac.getRawType());
- try {
- Class<?> innerBuilder = getBuilderClass(builder);
- return innerBuilder;
- } catch (ClassNotFoundException e) {
- // No problem .. try next
- }
- }
- return super.findPOJOBuilder(ac);
- }
-
- @Override
- public Value findPOJOBuilderConfig(AnnotatedClass ac) {
- if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
- return super.findPOJOBuilderConfig(ac);
- }
- return new JsonPOJOBuilder.Value("build", "set");
- }
- }
-
- public static class DateAndTimeBuilder{
-
- private final String _value;
-
- public DateAndTimeBuilder(String v) {
- this._value= v;
- }
-
- public DateAndTime build() {
- return new DateAndTime(_value);
- }
-
- }
- public static class CustomDateAndTimeSerializer extends StdSerializer<@NonNull DateAndTime>{
-
- private static final long serialVersionUID = 1L;
-
- public CustomDateAndTimeSerializer() {
- this(null);
- }
- protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
- super(t);
- }
-
- @Override
- public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
- gen.writeString(value.getValue());
- }
-
- }
+ private final Logger LOG = LoggerFactory.getLogger(YangToolsMapper2.class);
+ private static final long serialVersionUID = 1L;
+ private static String ENTITY = "Entity";
+ private static String BUILDER = "Builder";
+
+ private @Nullable Class<T> clazz;
+ private @Nullable Class<? extends Builder<? extends T>> builderClazz;
+
+ private BundleContext context;
+
+ public <X extends T, B extends Builder<X>> YangToolsMapper2(Class<T> clazz, Class<B> builderClazz)
+ throws ClassNotFoundException {
+ super();
+ configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
+ setPropertyNamingStrategy(PropertyNamingStrategy.KEBAB_CASE);
+ setSerializationInclusion(Include.NON_NULL);
+ setAnnotationIntrospector(new YangToolsBuilderAnnotationIntrospector());
+ SimpleModule dateAndTimeSerializerModule = new SimpleModule();
+ dateAndTimeSerializerModule.addSerializer(DateAndTime.class, new CustomDateAndTimeSerializer());
+ registerModule(dateAndTimeSerializerModule);
+ Bundle bundle = FrameworkUtil.getBundle(YangToolsMapper2.class);
+
+ this.clazz = clazz;
+ this.builderClazz = builderClazz != null ? builderClazz : getBuilderClass(getBuilderClassName(clazz));
+ context = bundle != null ? bundle.getBundleContext() : null;
+ }
+
+ public YangToolsMapper2() throws ClassNotFoundException {
+ this(null, null);
+ }
+
+
+ @Override
+ public String writeValueAsString(Object value) throws JsonProcessingException {
+ return super.writeValueAsString(value);
+ }
+
+ /**
+ * Get Builder object for yang tools interface.
+ *
+ * @param <T> yang-tools base datatype
+ * @param clazz class with interface.
+ * @return builder for interface or null if not existing
+ */
+ @SuppressWarnings("unchecked")
+ public @Nullable <T extends DataObject> Builder<T> getBuilder(Class<T> clazz) {
+ try {
+ //Class<?> clazzBuilder = getBuilderClass(getBuilderClassName(clazz));
+ return (Builder<T>) builderClazz.newInstance();
+ } catch (InstantiationException | IllegalAccessException e) {
+ LOG.debug("Problem ", e);
+ return null;
+ }
+ }
+
+ /**
+ * Callback for handling mapping failures.
+ *
+ * @return
+ */
+ public int getMappingFailures() {
+ return 0;
+ }
+
+ /**
+ * Provide mapping of string to attribute names, generated by yang-tools. "netconf-id" converted to "_netconfId"
+ *
+ * @param name with attribute name, not null or empty
+ * @return converted string or null if name was empty or null
+ */
+ public @Nullable static String toCamelCaseAttributeName(final String name) {
+ if (name == null || name.isEmpty())
+ return null;
+
+ final StringBuilder ret = new StringBuilder(name.length());
+ if (!name.startsWith("_"))
+ ret.append('_');
+ int start = 0;
+ for (final String word : name.split("-")) {
+ if (!word.isEmpty()) {
+ if (start++ == 0) {
+ ret.append(Character.toLowerCase(word.charAt(0)));
+ } else {
+ ret.append(Character.toUpperCase(word.charAt(0)));
+ }
+ ret.append(word.substring(1));
+ }
+ }
+ return ret.toString();
+ }
+
+ /**
+ * Verify if builder is available
+ *
+ * @throws ClassNotFoundException
+ **/
+ public Class<?> assertBuilderClass(Class<?> clazz) throws ClassNotFoundException {
+ return getBuilderClass(getBuilderClassName(clazz));
+ }
+
+ // --- Private functions
+
+ /**
+ * Create name of builder class
+ *
+ * @param <T>
+ * @param clazz
+ * @return builders class name
+ * @throws ClassNotFoundException
+ */
+ private static String getBuilderClassName(Class<?> clazz) {
+ return clazz.getName() + BUILDER;
+ // String clazzName = clazz.getName();
+ // if (clazzName.endsWith(ENTITY)) {
+ // return clazzName.replace(ENTITY, BUILDER);
+ // } else {
+ // return clazzName + BUILDER;
+ // }
+ }
+
+ /**
+ * Search builder in context
+ *
+ * @param name
+ * @return
+ * @throws ClassNotFoundException
+ */
+ @SuppressWarnings("unchecked")
+ private <X extends T, B extends Builder<X>> Class<B> getBuilderClass(String name) throws ClassNotFoundException {
+ // Try to find in other bundles
+ if (context != null) {
+ //OSGi environment
+ for (Bundle b : context.getBundles()) {
+ try {
+ return (Class<B>) b.loadClass(name);
+ } catch (ClassNotFoundException e) {
+ // No problem, this bundle doesn't have the class
+ }
+ }
+ throw new ClassNotFoundException("Can not find Class in OSGi context.");
+ } else {
+ return (Class<B>) Class.forName(name);
+ }
+ // not found in any bundle
+ }
+
+ // --- Classes
+
+ /**
+ * Adapted Builder callbacks
+ */
+ private class YangToolsBuilderAnnotationIntrospector extends JacksonAnnotationIntrospector {
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public Class<?> findPOJOBuilder(AnnotatedClass ac) {
+
+ if (ac.getRawType().equals(Credentials.class)) {
+ return org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.credentials.credentials.LoginPasswordBuilder.class;
+
+ } else if (ac.getRawType().equals(DateAndTime.class)) {
+ return DateAndTimeBuilder.class;
+
+ } else if (ac.getRawType().equals(clazz)) {
+ return builderClazz;
+ }
+
+ if (ac.getRawType().isInterface()) {
+ String builder = getBuilderClassName(ac.getRawType());
+ try {
+ Class<?> innerBuilder = getBuilderClass(builder);
+ return innerBuilder;
+ } catch (ClassNotFoundException e) {
+ // No problem .. try next
+ }
+ }
+ return super.findPOJOBuilder(ac);
+ }
+
+ @Override
+ public Value findPOJOBuilderConfig(AnnotatedClass ac) {
+ if (ac.hasAnnotation(JsonPOJOBuilder.class)) {
+ return super.findPOJOBuilderConfig(ac);
+ }
+ return new JsonPOJOBuilder.Value("build", "set");
+ }
+ }
+
+ public static class DateAndTimeBuilder {
+
+ private final String _value;
+
+ public DateAndTimeBuilder(String v) {
+ this._value = v;
+ }
+
+ public DateAndTime build() {
+ return new DateAndTime(_value);
+ }
+
+ }
+ public static class CustomDateAndTimeSerializer extends StdSerializer<@NonNull DateAndTime> {
+
+ private static final long serialVersionUID = 1L;
+
+ public CustomDateAndTimeSerializer() {
+ this(null);
+ }
+
+ protected CustomDateAndTimeSerializer(Class<DateAndTime> t) {
+ super(t);
+ }
+
+ @Override
+ public void serialize(DateAndTime value, JsonGenerator gen, SerializerProvider serializers) throws IOException {
+ gen.writeString(value.getValue());
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
index 372435343..f147e8724 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestAbout.java
@@ -43,92 +43,96 @@ import javax.servlet.http.HttpServletResponse;
public class TestAbout {
- private static final String REPO_MDSAL_DIR = "system/org/opendaylight/mdsal/mdsal-binding-api/3.0.9/";
- private static final String REPO_YANGTOOLS_DIR = "system/org/opendaylight/yangtools/odl-yangtools-common/2.1.11";
- @BeforeClass
- public static void before() throws IOException {
- //create temporary odl folder structure in tmp
- Files.createDirectories(new File(REPO_MDSAL_DIR).toPath() );
- Files.createDirectories(new File(REPO_YANGTOOLS_DIR).toPath() );
- }
- @AfterClass
- public static void after() throws IOException {
- //delete created dirs
- delete(new File("system/"));
- }
- private static void delete(File file) throws IOException {
-
- for (File childFile : file.listFiles()) {
-
- if (childFile.isDirectory()) {
- delete(childFile);
- } else {
- if (!childFile.delete()) {
- throw new IOException();
- }
- }
- }
-
- if (!file.delete()) {
- throw new IOException();
- }
- }
- @Test
- public void testReadmeRequest() throws IOException, ServletException {
- AboutHelperServlet servlet =new AboutHelperServlet();
- HttpServletRequest request = mock(HttpServletRequest.class);
- HttpServletResponse response = mock(HttpServletResponse.class);
- when(request.getRequestURI()).thenReturn("/about");
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- when(response.getOutputStream()).thenReturn(printOut);
- servlet.doGet(request,response);
- verify(response).setStatus(200);
- verify(response).setContentType("text/plain");
- System.out.println(out.getBuffer().toString());
- assertTrue(out.getBuffer().length()>0);
- }
-
- @Test
- public void testReadmeResourceRequest() throws IOException, ServletException {
- AboutHelperServlet servlet =new AboutHelperServlet();
- HttpServletRequest request = mock(HttpServletRequest.class);
- HttpServletResponse response = mock(HttpServletResponse.class);
- when(request.getRequestURI()).thenReturn("/about/test.bmp");
- ByteArrayOutputStream out = new ByteArrayOutputStream();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- when(response.getOutputStream()).thenReturn(printOut);
- servlet.doGet(request,response);
- verify(response).setStatus(200);
- verify(response).setContentType("image/bmp");
- assertTrue(out.size()>0);
- }
-
-
-
- private class AboutHelperServlet extends AboutHttpServlet{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
-
- }
+ private static final String REPO_MDSAL_DIR = "system/org/opendaylight/mdsal/mdsal-binding-api/3.0.9/";
+ private static final String REPO_YANGTOOLS_DIR = "system/org/opendaylight/yangtools/odl-yangtools-common/2.1.11";
+
+ @BeforeClass
+ public static void before() throws IOException {
+ //create temporary odl folder structure in tmp
+ Files.createDirectories(new File(REPO_MDSAL_DIR).toPath());
+ Files.createDirectories(new File(REPO_YANGTOOLS_DIR).toPath());
+ }
+
+ @AfterClass
+ public static void after() throws IOException {
+ //delete created dirs
+ delete(new File("system/"));
+ }
+
+ private static void delete(File file) throws IOException {
+
+ for (File childFile : file.listFiles()) {
+
+ if (childFile.isDirectory()) {
+ delete(childFile);
+ } else {
+ if (!childFile.delete()) {
+ throw new IOException();
+ }
+ }
+ }
+
+ if (!file.delete()) {
+ throw new IOException();
+ }
+ }
+
+ @Test
+ public void testReadmeRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet = new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request, response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("text/plain");
+ System.out.println(out.getBuffer().toString());
+ assertTrue(out.getBuffer().length() > 0);
+ }
+
+ @Test
+ public void testReadmeResourceRequest() throws IOException, ServletException {
+ AboutHelperServlet servlet = new AboutHelperServlet();
+ HttpServletRequest request = mock(HttpServletRequest.class);
+ HttpServletResponse response = mock(HttpServletResponse.class);
+ when(request.getRequestURI()).thenReturn("/about/test.bmp");
+ ByteArrayOutputStream out = new ByteArrayOutputStream();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(response.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(request, response);
+ verify(response).setStatus(200);
+ verify(response).setContentType("image/bmp");
+ assertTrue(out.size() > 0);
+ }
+
+
+
+ private class AboutHelperServlet extends AboutHttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
index ce3ff6694..0294c6e50 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestCRUDforDatabase.java
@@ -122,8 +122,8 @@ public class TestCRUDforDatabase {
private static ElasticSearchDataProvider dbProvider;
private static HtDatabaseClient dbRawProvider;
- public static HostInfo[] hosts = new HostInfo[] { new HostInfo("localhost", Integer
- .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200")) };
+ public static HostInfo[] hosts = new HostInfo[] {new HostInfo("localhost", Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200"))};
@BeforeClass
public static void init() throws Exception {
@@ -149,40 +149,49 @@ public class TestCRUDforDatabase {
public void testStatus() throws IOException {
//== CLEAR AND CREATE ================================
- clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Critical);
- createFaultEntity("Lorem Ipsum", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Major);
- createFaultEntity("3", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Minor);
- createFaultEntity("4", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Warning);
+ clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.Critical);
+ createFaultEntity("Lorem Ipsum", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.Major);
+ createFaultEntity("3", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.Minor);
+ createFaultEntity("4", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.Warning);
//== READ ================================
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> readOutput = dbProvider.readStatus().getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.status.output.Data> readOutput =
+ dbProvider.readStatus().getData();
System.out.println(readOutput);
- assertEquals(1,readOutput.get(0).getFaults().getMajors().intValue());
- assertEquals(1,readOutput.get(0).getFaults().getMinors().intValue());
- assertEquals(1,readOutput.get(0).getFaults().getWarnings().intValue());
- assertEquals(1,readOutput.get(0).getFaults().getCriticals().intValue());
+ assertEquals(1, readOutput.get(0).getFaults().getMajors().intValue());
+ assertEquals(1, readOutput.get(0).getFaults().getMinors().intValue());
+ assertEquals(1, readOutput.get(0).getFaults().getWarnings().intValue());
+ assertEquals(1, readOutput.get(0).getFaults().getCriticals().intValue());
//== DELETE ================================
- System.out.println("try to delete entries");
- try {
- dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
-
- //== VERIFY DELETE ===========================
- System.out.println("verify entries were deleted");
- readOutput = dbProvider.readStatus().getData();
- assertEquals(0,readOutput.get(0).getFaults().getMajors().intValue());
- assertEquals(0,readOutput.get(0).getFaults().getMinors().intValue());
- assertEquals(0,readOutput.get(0).getFaults().getWarnings().intValue());
- assertEquals(0,readOutput.get(0).getFaults().getCriticals().intValue());
+ System.out.println("try to delete entries");
+ try {
+ dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
+
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries were deleted");
+ readOutput = dbProvider.readStatus().getData();
+ assertEquals(0, readOutput.get(0).getFaults().getMajors().intValue());
+ assertEquals(0, readOutput.get(0).getFaults().getMinors().intValue());
+ assertEquals(0, readOutput.get(0).getFaults().getWarnings().intValue());
+ assertEquals(0, readOutput.get(0).getFaults().getCriticals().intValue());
}
- @Test
+ @Test
public void testMediatorServer() {
final String NAME = "ms1";
final String URL = "http://11.23.45.55:4599";
@@ -229,8 +238,8 @@ public class TestCRUDforDatabase {
System.out.println(data);
// ==UPDATE============================
System.out.println("try to update entry");
- UpdateMediatorServerInput updateInput = new UpdateMediatorServerInputBuilder().setId(dbId2).setName(NAME2)
- .setUrl(URL2).build();
+ UpdateMediatorServerInput updateInput =
+ new UpdateMediatorServerInputBuilder().setId(dbId2).setName(NAME2).setUrl(URL2).build();
UpdateMediatorServerOutputBuilder updateOutput = null;
try {
updateOutput = dbProvider.updateMediatorServer(updateInput);
@@ -274,7 +283,7 @@ public class TestCRUDforDatabase {
assertEquals("delete not verifiied", 0, data.size());
}
- @Test
+ @Test
public void testNetworkElementConnectionCurrent() {
System.out.println("networkElementConnection test start");
@@ -314,10 +323,10 @@ public class TestCRUDforDatabase {
.setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
.setPagination(getPagination(20, 1)).build();
- ReadNetworkElementConnectionListOutputBuilder readOperation = dbProvider
- .readNetworkElementConnectionList(readInput);
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> data = readOperation
- .getData();
+ ReadNetworkElementConnectionListOutputBuilder readOperation =
+ dbProvider.readNetworkElementConnectionList(readInput);
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.network.element.connection.list.output.Data> data =
+ readOperation.getData();
assertNotNull(data);
assertEquals(dbId, data.get(0).getId());
@@ -331,7 +340,8 @@ public class TestCRUDforDatabase {
final String url2 = "10.5.10.2";
final long port2 = 5960;
- UpdateNetworkElementConnectionInput updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId).setHost(url2).setPort(port2).setIsRequired(false).build();
+ UpdateNetworkElementConnectionInput updateInput = new UpdateNetworkElementConnectionInputBuilder().setId(dbId)
+ .setHost(url2).setPort(port2).setIsRequired(false).build();
UpdateNetworkElementConnectionOutputBuilder updateOutput = null;
try {
updateOutput = dbProvider.updateNetworkElementConnection(updateInput);
@@ -373,12 +383,12 @@ public class TestCRUDforDatabase {
// ==DELETE============================
System.out.println("Try delete...");
- DeleteNetworkElementConnectionInput deleteInput = new DeleteNetworkElementConnectionInputBuilder().setId(dbId)
- .build();
+ DeleteNetworkElementConnectionInput deleteInput =
+ new DeleteNetworkElementConnectionInputBuilder().setId(dbId).build();
try {
dbProvider.deleteNetworkElementConnection(deleteInput);
} catch (Exception e) {
- fail("problem deleting "+e.getMessage());
+ fail("problem deleting " + e.getMessage());
}
readInput = new ReadNetworkElementConnectionListInputBuilder()
@@ -390,7 +400,7 @@ public class TestCRUDforDatabase {
}
- @Test
+ @Test
public void testMaintenance() {
System.out.println("Starting Maintenance tests...");
@@ -408,8 +418,8 @@ public class TestCRUDforDatabase {
final boolean isActive = true;
CreateMaintenanceOutputBuilder create = null;
- CreateMaintenanceInput input = new CreateMaintenanceInputBuilder().setNodeId(nodeId).setActive(isActive)
- .build();
+ CreateMaintenanceInput input =
+ new CreateMaintenanceInputBuilder().setNodeId(nodeId).setActive(isActive).build();
String dbId = null;
try {
create = dbProvider.createMaintenance(input);
@@ -429,8 +439,8 @@ public class TestCRUDforDatabase {
.setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
.setPagination(getPagination(20, 1)).build();
ReadMaintenanceListOutputBuilder readResult = dbProvider.readMaintenanceList(readinput);
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.maintenance.list.output.Data> data =
+ readResult.getData();
assertNotEquals(0, data.size());
assertNotNull(data);
@@ -443,8 +453,8 @@ public class TestCRUDforDatabase {
final String nodeId2 = "Name2";
final boolean isActive2 = false;
- UpdateMaintenanceInput updateInput = new UpdateMaintenanceInputBuilder().setId(dbId).setNodeId(nodeId2)
- .setActive(isActive2).build();
+ UpdateMaintenanceInput updateInput =
+ new UpdateMaintenanceInputBuilder().setId(dbId).setNodeId(nodeId2).setActive(isActive2).build();
UpdateMaintenanceOutputBuilder updateResult = null;
try {
updateResult = dbProvider.updateMaintenance(updateInput);
@@ -483,7 +493,9 @@ public class TestCRUDforDatabase {
public void testFaultLog() {
System.out.println("Starting fault log tests...");
- String dbId = clearAndCreatefaultEntity("1", Entity.Faultlog.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput", SeverityType.Critical);
+ String dbId = clearAndCreatefaultEntity("1", Entity.Faultlog.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput",
+ SeverityType.Critical);
// ==READ===========================
System.out.println("try to read entry");
@@ -500,8 +512,8 @@ public class TestCRUDforDatabase {
fail("Fault log not read: " + e.getMessage());
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultlog.list.output.Data> data =
+ readResult.getData();
assertNotNull(data);
assertEquals(1, data.size());
@@ -509,17 +521,18 @@ public class TestCRUDforDatabase {
assertEquals("Critical", data.get(0).getSeverity().toString());
assertEquals("s1", data.get(0).getNodeId());
- //== UPDATE ================================
+ //== UPDATE ================================
System.out.println("try to update entry");
- dbRawProvider.doUpdateOrCreate(Entity.Faultlog.getName(), "1", "{'problem': 'CableLOS', 'severity': 'Major', 'node-id': 'test4657-78'}");
+ dbRawProvider.doUpdateOrCreate(Entity.Faultlog.getName(), "1",
+ "{'problem': 'CableLOS', 'severity': 'Major', 'node-id': 'test4657-78'}");
System.out.println("try to search entry 1");
readinput = new ReadFaultlogListInputBuilder()
.setFilter(Arrays.asList(new FilterBuilder().setProperty("node-id").setFiltervalue("test").build()))
.setPagination(getPagination(20, 1)).build();
- //== VERIFY UPDATE ================================
+ //== VERIFY UPDATE ================================
readResult = dbProvider.readFaultLogList(readinput);
data = readResult.getData();
@@ -544,7 +557,7 @@ public class TestCRUDforDatabase {
assertEquals("Major", data.get(0).getSeverity().toString());
assertEquals("test4657-78", data.get(0).getNodeId());
- //== DELETE ================================
+ //== DELETE ================================
System.out.println("try to clear entry");
try {
@@ -553,9 +566,10 @@ public class TestCRUDforDatabase {
fail("problem deleting entry: " + e.getMessage());
}
- //== VERIFY DELETE ===========================
+ //== VERIFY DELETE ===========================
System.out.println("verify entries deleted");
- readResult = dbProvider.readFaultLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ readResult = dbProvider
+ .readFaultLogList(new ReadFaultlogListInputBuilder().setPagination(getPagination(20, 1)).build());
data = readResult.getData();
assertEquals(0, data.size());
}
@@ -563,12 +577,14 @@ public class TestCRUDforDatabase {
@Test
public void testFaultCurrent() {
System.out.println("Starting faultCurrent test...");
- String dbId = null;
- dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.NonAlarmed);
- assertEquals("1", dbId);
+ String dbId = null;
+ dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.NonAlarmed);
+ assertEquals("1", dbId);
// ==READ===========================
- System.out.println("Trying to read...");
+ System.out.println("Trying to read...");
ReadFaultcurrentListInput readinput = new ReadFaultcurrentListInputBuilder()
@@ -583,8 +599,8 @@ public class TestCRUDforDatabase {
fail("Fault log not read: " + e.getMessage());
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.faultcurrent.list.output.Data> data =
+ readResult.getData();
assertNotNull(data);
@@ -601,12 +617,8 @@ public class TestCRUDforDatabase {
// ==UPDATE============================
System.out.println("Trying to update...");
- String json = "{\n" +
- "\"timestamp\": \"2019-12-28T11:55:58.3Z\",\n" +
- "\"node-id\": \"SDN-Controller-0\",\n" +
- "\"counter\": 75,\n" +
- "\"problem\": \"connectionLossNeOAM\",\n" +
- "}";
+ String json = "{\n" + "\"timestamp\": \"2019-12-28T11:55:58.3Z\",\n" + "\"node-id\": \"SDN-Controller-0\",\n"
+ + "\"counter\": 75,\n" + "\"problem\": \"connectionLossNeOAM\",\n" + "}";
String updatedDbId = dbRawProvider.doUpdateOrCreate(Entity.Faultcurrent.getName(), dbId, json);
assertEquals(dbId, updatedDbId);
@@ -656,23 +668,21 @@ public class TestCRUDforDatabase {
// ==CLEAR================================
System.out.println("Clear before test");
- try {
- dbRawProvider.doRemove(Entity.Connectionlog.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Connectionlog.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
// ==CREATE================================
System.out.println("Try create entry");
final String initialDbId = "1";
String dbId = null;
- String json ="{\n" +
- "\"timestamp\": \"2019-11-01T11:28:34.7Z\",\n" +
- "\"status\": \"Connecting\",\n" +
- "\"node-id\": \"sim2230\",\n" +
- "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateConnectionlogInput\"\n" +
- "}";
+ String json = "{\n" + "\"timestamp\": \"2019-11-01T11:28:34.7Z\",\n" + "\"status\": \"Connecting\",\n"
+ + "\"node-id\": \"sim2230\",\n"
+ + "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateConnectionlogInput\"\n"
+ + "}";
dbId = dbRawProvider.doUpdateOrCreate(Entity.Connectionlog.getName(), initialDbId, json);
@@ -693,8 +703,8 @@ public class TestCRUDforDatabase {
fail("Connection log not read: " + e.getMessage());
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.connectionlog.list.output.Data> data =
+ readResult.getData();
assertNotNull(data);
assertEquals(1, data.size());
@@ -728,46 +738,42 @@ public class TestCRUDforDatabase {
assertEquals("Connected", data.get(0).getStatus().toString());
assertEquals("sim2230", data.get(0).getNodeId());
- //== DELETE ================================
+ //== DELETE ================================
- System.out.println("try to clear entry");
- try {
- dbRawProvider.doRemove(Entity.Connectionlog.getName(), dbId);
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Connectionlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
- //== VERIFY DELETE ===========================
- System.out.println("verify entries deleted");
- readResult = dbProvider.readConnectionlogList(new ReadConnectionlogListInputBuilder().setPagination(getPagination(20, 1)).build());
- data = readResult.getData();
- assertEquals(0, data.size());
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider.readConnectionlogList(
+ new ReadConnectionlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
}
- @Test
+ @Test
public void testEventLog() {
System.out.println("Test event log starting...");
// ==CLEAR================================
System.out.println("Clear before test");
- try {
- dbRawProvider.doRemove(Entity.Eventlog.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Eventlog.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
// ==CREATE============================
- String dbId = null;
- String json = " {\n" +
- "\"timestamp\": \"2019-11-08T16:39:23.0Z\",\n" +
- "\"new-value\": \"done\",\n" +
- "\"object-id\": \"SDN-Controller-0\",\n" +
- "\"attribute-name\": \"startup\",\n" +
- "\"counter\": 0,\n" +
- "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Eventlog\",\n" +
- "\"node-id\": \"SDN-Controller-0\"\n" +
- "}";
+ String dbId = null;
+ String json = " {\n" + "\"timestamp\": \"2019-11-08T16:39:23.0Z\",\n" + "\"new-value\": \"done\",\n"
+ + "\"object-id\": \"SDN-Controller-0\",\n" + "\"attribute-name\": \"startup\",\n" + "\"counter\": 0,\n"
+ + "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Eventlog\",\n"
+ + "\"node-id\": \"SDN-Controller-0\"\n" + "}";
dbId = dbRawProvider.doUpdateOrCreate(Entity.Eventlog.getName(), "1", json);
assertNotNull(dbId);
@@ -779,86 +785,83 @@ public class TestCRUDforDatabase {
.setPagination(getPagination(20, 1)).build();
ReadEventlogListOutputBuilder readResult = null;
try {
- readResult = dbProvider.readEventlogList(readinput);
+ readResult = dbProvider.readEventlogList(readinput);
} catch (Exception e) {
fail("problem reading eventlog");
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> data = readResult.getData();
- assertEquals(1,data.size());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.eventlog.list.output.Data> data =
+ readResult.getData();
+ assertEquals(1, data.size());
//== DELETE ================================
- System.out.println("try to clear entry");
- try {
- dbRawProvider.doRemove(Entity.Eventlog.getName(), dbId);
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Eventlog.getName(), dbId);
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
//== VERIFY DELETE ===========================
- System.out.println("verify entries deleted");
- try {
- readResult = dbProvider.readEventlogList(new ReadEventlogListInputBuilder().setPagination(getPagination(20, 1)).build());
+ System.out.println("verify entries deleted");
+ try {
+ readResult = dbProvider
+ .readEventlogList(new ReadEventlogListInputBuilder().setPagination(getPagination(20, 1)).build());
} catch (IOException e) {
fail("problem reading eventlog");
}
- data = readResult.getData();
- assertEquals(0, data.size());
+ data = readResult.getData();
+ assertEquals(0, data.size());
}
- @Test
+ @Test
public void testInventory() {
- System.out.println("Test inventory starting...");
+ System.out.println("Test inventory starting...");
- // ==CLEAR================================
- System.out.println("Clear before test");
- try {
- dbRawProvider.doRemove(Entity.Inventoryequipment.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ // ==CLEAR================================
+ System.out.println("Clear before test");
+ try {
+ dbRawProvider.doRemove(Entity.Inventoryequipment.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
// ==CREATE============================
- String dbId = null;
- String json = " {\"tree-level\": 1,\n" +
- " \"parent-uuid\": \"SHELF-1.1.0.0\",\n" +
- " \"node-id\": \"sim2\",\n" +
- " \"uuid\": \"CARD-1.1.8.0\",\n" +
- " \"contained-holder\": [ ],\n" +
- " \"manufacturer-name\": \"Lorem Ipsum\",\n" +
- " \"manufacturer-identifier\": \"ONF-Wireless-Transport\",\n" +
- " \"serial\": \"sd-dsa-eqw\",\n" +
- " \"date\": \"2008-10-21T00:00:00.0Z\",\n" +
- "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory\",\n" +
- " \"version\": \"unknown\",\n" +
- " \"description\": \"WS/DS3\",\n" +
- " \"part-type-id\": \"unknown\",\n" +
- " \"model-identifier\": \"model-id-s3s\",\n" +
- " \"type-name\": \"p4.module\"}";
-
- dbId = dbRawProvider.doUpdateOrCreate(Entity.Inventoryequipment.getName(), "1 1", json);
- assertNotNull(dbId);
+ String dbId = null;
+ String json = " {\"tree-level\": 1,\n" + " \"parent-uuid\": \"SHELF-1.1.0.0\",\n"
+ + " \"node-id\": \"sim2\",\n" + " \"uuid\": \"CARD-1.1.8.0\",\n"
+ + " \"contained-holder\": [ ],\n" + " \"manufacturer-name\": \"Lorem Ipsum\",\n"
+ + " \"manufacturer-identifier\": \"ONF-Wireless-Transport\",\n" + " \"serial\": \"sd-dsa-eqw\",\n"
+ + " \"date\": \"2008-10-21T00:00:00.0Z\",\n"
+ + "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Inventory\",\n"
+ + " \"version\": \"unknown\",\n" + " \"description\": \"WS/DS3\",\n"
+ + " \"part-type-id\": \"unknown\",\n" + " \"model-identifier\": \"model-id-s3s\",\n"
+ + " \"type-name\": \"p4.module\"}";
+
+ dbId = dbRawProvider.doUpdateOrCreate(Entity.Inventoryequipment.getName(), "1 1", json);
+ assertNotNull(dbId);
// ==READ===========================
- ReadInventoryListInput readinput = new ReadInventoryListInputBuilder()
+ ReadInventoryListInput readinput = new ReadInventoryListInputBuilder()
.setFilter(Arrays.asList(new FilterBuilder().setProperty("id").setFiltervalue(dbId).build()))
.setPagination(getPagination(20, 1)).build();
ReadInventoryListOutputBuilder readResult = null;
try {
- readResult = dbProvider.readInventoryList(readinput);
+ readResult = dbProvider.readInventoryList(readinput);
} catch (Exception e) {
- fail("Problem reading inventory list"+e.getMessage());
+ fail("Problem reading inventory list" + e.getMessage());
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> data = readResult.getData();
- assertEquals(1,data.size());
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> data =
+ readResult.getData();
+ assertEquals(1, data.size());
assertEquals("Lorem Ipsum", data.get(0).getManufacturerName());
assertEquals("ONF-Wireless-Transport", data.get(0).getManufacturerIdentifier());
assertEquals("sim2", data.get(0).getNodeId());
@@ -869,15 +872,12 @@ public class TestCRUDforDatabase {
System.out.println(data.get(0).getDate());
// ==UPDATE============================
- String updatedDbId=null;
+ String updatedDbId = null;
final String[] holderArray = {"Lorem Ipsum 1", "Lorem Ipsum 2", "Lorem Ipsum &%/$_2"};
- String updatejson = " {" +
- " \"node-id\": \"sim5\",\n" +
- " \"contained-holder\": [ \"Lorem Ipsum 1\", \"Lorem Ipsum 2\", \"Lorem Ipsum &%/$_2\" ],\n" +
- " \"serial\": \"sd-dsa-eww\",\n" +
- " \"date\": \"2008-11-21T00:00:00.0Z\",\n" +
- " \"part-type-id\": \"not unknown\",\n" +
- "}";
+ String updatejson = " {" + " \"node-id\": \"sim5\",\n"
+ + " \"contained-holder\": [ \"Lorem Ipsum 1\", \"Lorem Ipsum 2\", \"Lorem Ipsum &%/$_2\" ],\n"
+ + " \"serial\": \"sd-dsa-eww\",\n" + " \"date\": \"2008-11-21T00:00:00.0Z\",\n"
+ + " \"part-type-id\": \"not unknown\",\n" + "}";
updatedDbId = dbRawProvider.doUpdateOrCreate(Entity.Inventoryequipment.getName(), dbId, updatejson);
assertEquals(dbId, updatedDbId);
@@ -886,12 +886,12 @@ public class TestCRUDforDatabase {
readResult = dbProvider.readInventoryList(readinput);
} catch (Exception e) {
- fail("Problem reading inventory list"+e.getMessage());
+ fail("Problem reading inventory list" + e.getMessage());
}
data = readResult.getData();
- assertEquals(1,data.size());
+ assertEquals(1, data.size());
assertEquals("Lorem Ipsum", data.get(0).getManufacturerName());
assertEquals("ONF-Wireless-Transport", data.get(0).getManufacturerIdentifier());
assertEquals("sim5", data.get(0).getNodeId());
@@ -899,10 +899,10 @@ public class TestCRUDforDatabase {
assertEquals("WS/DS3", data.get(0).getDescription());
assertEquals("2008-11-21T00:00:00.0Z", data.get(0).getDate());
assertEquals("sd-dsa-eww", data.get(0).getSerial());
- assertEquals(holderArray.length,data.get(0).getContainedHolder().size());
- assertEquals(holderArray[0],data.get(0).getContainedHolder().get(0));
- assertEquals(holderArray[1],data.get(0).getContainedHolder().get(1));
- assertEquals(holderArray[2],data.get(0).getContainedHolder().get(2));
+ assertEquals(holderArray.length, data.get(0).getContainedHolder().size());
+ assertEquals(holderArray[0], data.get(0).getContainedHolder().get(0));
+ assertEquals(holderArray[1], data.get(0).getContainedHolder().get(1));
+ assertEquals(holderArray[2], data.get(0).getContainedHolder().get(2));
// ==DELETE============================
@@ -913,50 +913,50 @@ public class TestCRUDforDatabase {
fail("problem deleting: " + e.getMessage());
}
- // ==VERIFY DELETE ============================
+ // ==VERIFY DELETE ============================
try {
- readResult = dbProvider.readInventoryList(readinput);
+ readResult = dbProvider.readInventoryList(readinput);
- } catch (Exception e) {
- fail("Problem reading inventory list"+e.getMessage());
- }
+ } catch (Exception e) {
+ fail("Problem reading inventory list" + e.getMessage());
+ }
- data = readResult.getData();
- assertEquals(0,data.size());
+ data = readResult.getData();
+ assertEquals(0, data.size());
}
- @Test
- public void test15MinPerformanceReadLtpListWithoutNodeIdSetThrowsException() {
+ @Test
+ public void test15MinPerformanceReadLtpListWithoutNodeIdSetThrowsException() {
- System.out.println("Reading 15m ltp list without node id filter set throws an exception test start...");
+ System.out.println("Reading 15m ltp list without node id filter set throws an exception test start...");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
- System.out.println("create entries...");
+ System.out.println("create entries...");
- createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+ createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
- createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+ createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
- System.out.println("trying to read, should throw exception...");
+ System.out.println("trying to read, should throw exception...");
- ReadPmdata15mLtpListInput readLtp = new ReadPmdata15mLtpListInputBuilder()
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata15mLtpListInput readLtp =
+ new ReadPmdata15mLtpListInputBuilder().setPagination(getPagination(20, 1)).build();
- ReadPmdata15mLtpListOutputBuilder readltpResult = null;
+ ReadPmdata15mLtpListOutputBuilder readltpResult = null;
- try {
+ try {
readltpResult = dbProvider.readPmdata15mLtpList(readLtp);
fail("No exception thrown!");
} catch (Exception e) {
@@ -965,299 +965,302 @@ public class TestCRUDforDatabase {
assertEquals("no nodename in filter found ", e.getMessage());
}
- assertNull(readltpResult);
+ assertNull(readltpResult);
- //== DELETE ================================
+ //== DELETE ================================
- System.out.println("try to clear entry");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
- //== VERIFY DELETE ===========================
- System.out.println("verify entries deleted");
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data = dbProvider.readPmdata15mList(new ReadPmdata15mListInputBuilder()
- .setPagination(getPagination(20, 1)).build()).getData();
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data =
+ dbProvider
+ .readPmdata15mList(
+ new ReadPmdata15mListInputBuilder().setPagination(getPagination(20, 1)).build())
+ .getData();
- assertEquals(0, data.size());
- }
+ assertEquals(0, data.size());
+ }
- @Test
- public void test15MinPerformanceData() {
+ @Test
+ public void test15MinPerformanceData() {
// == CLEAR BEFORE TESTS ============================
- System.out.println("Test 15 min performance...");
+ System.out.println("Test 15 min performance...");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
// == CREATE ============================
- System.out.println("create entries...");
+ System.out.println("create entries...");
- createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+ createPerformanceData("1", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
- createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+ createPerformanceData("4", GranularityPeriodType.Period15Min, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", GranularityPeriodType.Period15Min, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", GranularityPeriodType.Period15Min, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
// == READ ============================
- System.out.println("read list entries...");
+ System.out.println("read list entries...");
- ReadPmdata15mListInput read = new ReadPmdata15mListInputBuilder()
- .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata15mListInput read = new ReadPmdata15mListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
- ReadPmdata15mListOutputBuilder readResult = null;
+ ReadPmdata15mListOutputBuilder readResult = null;
- try {
- readResult = dbProvider.readPmdata15mList(read);
+ try {
+ readResult = dbProvider.readPmdata15mList(read);
} catch (Exception e) {
fail("Problem reading 15m data");
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> data =
+ readResult.getData();
- assertNotNull(data);
- assertEquals(2, data.size());
+ assertNotNull(data);
+ assertEquals(2, data.size());
- System.out.println("read ltp entries with node name set...");
+ System.out.println("read ltp entries with node name set...");
- ReadPmdata15mLtpListInput readLtp = new ReadPmdata15mLtpListInputBuilder()
- .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata15mLtpListInput readLtp = new ReadPmdata15mLtpListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
- ReadPmdata15mLtpListOutputBuilder readltpResult = null;
+ ReadPmdata15mLtpListOutputBuilder readltpResult = null;
- try {
- readltpResult = dbProvider.readPmdata15mLtpList(readLtp);
- } catch (Exception e) {
- fail("Problem reading 15m ltp data");
- }
+ try {
+ readltpResult = dbProvider.readPmdata15mLtpList(readLtp);
+ } catch (Exception e) {
+ fail("Problem reading 15m ltp data");
+ }
- List<String> dataLtp = readltpResult.getData();
+ List<String> dataLtp = readltpResult.getData();
- assertNotNull(dataLtp);
- assertEquals(2, dataLtp.size());
- assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
- assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+ assertNotNull(dataLtp);
+ assertEquals(2, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
- System.out.println("read device entries...");
+ System.out.println("read device entries...");
- ReadPmdata15mDeviceListInput readDevices = new ReadPmdata15mDeviceListInputBuilder()
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata15mDeviceListInput readDevices =
+ new ReadPmdata15mDeviceListInputBuilder().setPagination(getPagination(20, 1)).build();
- ReadPmdata15mDeviceListOutputBuilder readDeviceResult = null;
+ ReadPmdata15mDeviceListOutputBuilder readDeviceResult = null;
- try {
- readDeviceResult = dbProvider.readPmdata15mDeviceList(readDevices);
- } catch (Exception e) {
- fail("Problem reading 15m device data");
- }
+ try {
+ readDeviceResult = dbProvider.readPmdata15mDeviceList(readDevices);
+ } catch (Exception e) {
+ fail("Problem reading 15m device data");
+ }
- List<String> dataDevice = readDeviceResult.getData();
+ List<String> dataDevice = readDeviceResult.getData();
- assertNotNull(dataDevice);
- assertEquals(2, dataDevice.size());
- assertTrue(dataDevice.contains("a2"));
- assertTrue(dataDevice.contains("a3"));
+ assertNotNull(dataDevice);
+ assertEquals(2, dataDevice.size());
+ assertTrue(dataDevice.contains("a2"));
+ assertTrue(dataDevice.contains("a3"));
- //== DELETE ================================
+ //== DELETE ================================
- System.out.println("try to clear entry");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
+ System.out.println("try to clear entry");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance15min.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
- //== VERIFY DELETE ===========================
- System.out.println("verify entries deleted");
- readResult = dbProvider.readPmdata15mList(new ReadPmdata15mListInputBuilder()
- .setPagination(getPagination(20, 1)).build());
- data = readResult.getData();
- assertEquals(0, data.size());
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider
+ .readPmdata15mList(new ReadPmdata15mListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
- }
+ }
- @Test
- public void test24hPerformanceData() {
- System.out.println("Test 24h performance...");
+ @Test
+ public void test24hPerformanceData() {
+ System.out.println("Test 24h performance...");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
- System.out.println("create entries...");
- GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
- createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
- String aDbId = createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-06", "a2");
+ System.out.println("create entries...");
+ GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
+ createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+ String aDbId = createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-06", "a2");
- createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+ createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
- System.out.println("read all list entries...");
+ System.out.println("read all list entries...");
- ReadPmdata24hListInput read = new ReadPmdata24hListInputBuilder()
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata24hListInput read = new ReadPmdata24hListInputBuilder().setPagination(getPagination(20, 1)).build();
- ReadPmdata24hListOutputBuilder readResult = null;
+ ReadPmdata24hListOutputBuilder readResult = null;
- try {
- readResult = dbProvider.readPmdata24hList(read);
+ try {
+ readResult = dbProvider.readPmdata24hList(read);
} catch (Exception e) {
fail("Problem reading 24h data");
}
- List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> data = readResult
- .getData();
+ List<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._24h.list.output.Data> data =
+ readResult.getData();
- assertNotNull(data);
- assertEquals(6, data.size());
+ assertNotNull(data);
+ assertEquals(6, data.size());
- System.out.println("filter list entries...");
+ System.out.println("filter list entries...");
- read = new ReadPmdata24hListInputBuilder()
- .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
- .setPagination(getPagination(20, 1)).build();
+ read = new ReadPmdata24hListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
- readResult = null;
+ readResult = null;
- try {
- readResult = dbProvider.readPmdata24hList(read);
+ try {
+ readResult = dbProvider.readPmdata24hList(read);
} catch (Exception e) {
fail("Problem reading 24h data");
}
- data = readResult.getData();
+ data = readResult.getData();
- assertNotNull(data);
- assertEquals(3, data.size());
+ assertNotNull(data);
+ assertEquals(3, data.size());
- System.out.println("read ltp entries with node name set...");
+ System.out.println("read ltp entries with node name set...");
- ReadPmdata24hLtpListInput readLtp = new ReadPmdata24hLtpListInputBuilder()
- .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata24hLtpListInput readLtp = new ReadPmdata24hLtpListInputBuilder()
+ .setFilter(Arrays.asList(new FilterBuilder().setProperty("node-name").setFiltervalue("a2").build()))
+ .setPagination(getPagination(20, 1)).build();
- ReadPmdata24hLtpListOutputBuilder readltpResult = null;
+ ReadPmdata24hLtpListOutputBuilder readltpResult = null;
- try {
- readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
- } catch (Exception e) {
- fail("Problem reading 24h ltp data");
- }
+ try {
+ readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
+ } catch (Exception e) {
+ fail("Problem reading 24h ltp data");
+ }
- List<String> dataLtp = readltpResult.getData();
+ List<String> dataLtp = readltpResult.getData();
- assertNotNull(dataLtp);
- assertEquals(3, dataLtp.size());
- assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
- assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
- assertTrue(dataLtp.contains("LP-MWPS-TTP-06"));
+ assertNotNull(dataLtp);
+ assertEquals(3, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-06"));
- System.out.println("read device entries...");
+ System.out.println("read device entries...");
- ReadPmdata24hDeviceListInput readDevices = new ReadPmdata24hDeviceListInputBuilder()
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata24hDeviceListInput readDevices =
+ new ReadPmdata24hDeviceListInputBuilder().setPagination(getPagination(20, 1)).build();
- ReadPmdata24hDeviceListOutputBuilder readDeviceResult = null;
+ ReadPmdata24hDeviceListOutputBuilder readDeviceResult = null;
- try {
- readDeviceResult = dbProvider.readPmdata24hDeviceList(readDevices);
- } catch (Exception e) {
- fail("Problem reading 24h device data");
- }
+ try {
+ readDeviceResult = dbProvider.readPmdata24hDeviceList(readDevices);
+ } catch (Exception e) {
+ fail("Problem reading 24h device data");
+ }
- List<String> dataDevice = readDeviceResult.getData();
+ List<String> dataDevice = readDeviceResult.getData();
- assertNotNull(dataDevice);
- assertEquals(2, dataDevice.size());
- assertTrue(dataDevice.contains("a2"));
- assertTrue(dataDevice.contains("a3"));
+ assertNotNull(dataDevice);
+ assertEquals(2, dataDevice.size());
+ assertTrue(dataDevice.contains("a2"));
+ assertTrue(dataDevice.contains("a3"));
- // == UPDATE ==============================
+ // == UPDATE ==============================
- boolean success = dbRawProvider.doUpdate(Entity.Historicalperformance24h.getName(), "{'uuid-interface':'LTP-TEST-MWP-097'}", QueryBuilders.termQuery("_id", aDbId));
- assertTrue("update dbentry not succeeded",success);
- try {
- readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
+ boolean success = dbRawProvider.doUpdate(Entity.Historicalperformance24h.getName(),
+ "{'uuid-interface':'LTP-TEST-MWP-097'}", QueryBuilders.termQuery("_id", aDbId));
+ assertTrue("update dbentry not succeeded", success);
+ try {
+ readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
} catch (Exception e) {
fail("Problem reading 24h ltp data");
}
- // == VERIFY UPDATE ==============================
+ // == VERIFY UPDATE ==============================
- dataLtp = readltpResult.getData();
+ dataLtp = readltpResult.getData();
- assertNotNull(dataLtp);
- assertEquals(3, dataLtp.size());
- assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
- assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
- assertTrue(dataLtp.contains("LTP-TEST-MWP-097"));
+ assertNotNull(dataLtp);
+ assertEquals(3, dataLtp.size());
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-02"));
+ assertTrue(dataLtp.contains("LP-MWPS-TTP-01"));
+ assertTrue(dataLtp.contains("LTP-TEST-MWP-097"));
- //== DELETE ===========================
+ //== DELETE ===========================
- System.out.println("try to clear entries");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting entry: " + e.getMessage());
- }
+ System.out.println("try to clear entries");
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting entry: " + e.getMessage());
+ }
- //== VERIFY DELETE ===========================
- System.out.println("verify entries deleted");
- readResult = dbProvider.readPmdata24hList(new ReadPmdata24hListInputBuilder()
- .setPagination(getPagination(20, 1)).build());
- data = readResult.getData();
- assertEquals(0, data.size());
- }
+ //== VERIFY DELETE ===========================
+ System.out.println("verify entries deleted");
+ readResult = dbProvider
+ .readPmdata24hList(new ReadPmdata24hListInputBuilder().setPagination(getPagination(20, 1)).build());
+ data = readResult.getData();
+ assertEquals(0, data.size());
+ }
- @Test
- public void test24hPerformanceDataReadLtpListWithoutNodeIdSetThrowsException() {
- System.out.println("Test 24 hour tp list without node id filter set throws an exception test start...\"...");
+ @Test
+ public void test24hPerformanceDataReadLtpListWithoutNodeIdSetThrowsException() {
+ System.out.println("Test 24 hour tp list without node id filter set throws an exception test start...\"...");
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
- System.out.println("create entries...");
+ System.out.println("create entries...");
- GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
- createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
- createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
+ GranularityPeriodType timeInterval = GranularityPeriodType.Period24Hours;
+ createPerformanceData("1", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a2");
+ createPerformanceData("2", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a2");
- createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
- createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
- createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
- createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
+ createPerformanceData("4", timeInterval, "PM_RADIO_15M_6", "LP-MWPS-TTP-02", "a3");
+ createPerformanceData("5", timeInterval, "PM_RADIO_15M_4", "LP-MWPS-TTP-01", "a3");
+ createPerformanceData("6", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-03", "a3");
+ createPerformanceData("3", timeInterval, "PM_RADIO_15M_7", "LP-MWPS-TTP-05", "a3");
- System.out.println("trying to read, should throw exception...");
+ System.out.println("trying to read, should throw exception...");
- ReadPmdata24hLtpListInput readLtp = new ReadPmdata24hLtpListInputBuilder()
- .setPagination(getPagination(20, 1)).build();
+ ReadPmdata24hLtpListInput readLtp =
+ new ReadPmdata24hLtpListInputBuilder().setPagination(getPagination(20, 1)).build();
- ReadPmdata24hLtpListOutputBuilder readltpResult = null;
+ ReadPmdata24hLtpListOutputBuilder readltpResult = null;
- try {
+ try {
readltpResult = dbProvider.readPmdata24hLtpList(readLtp);
fail("No exception thrown!");
} catch (Exception e) {
@@ -1266,14 +1269,14 @@ public class TestCRUDforDatabase {
assertEquals("no nodename in filter found ", e.getMessage());
}
- assertNull(readltpResult);
+ assertNull(readltpResult);
- try {
- dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
- }
+ try {
+ dbRawProvider.doRemove(Entity.Historicalperformance24h.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ }
@Test
public void testUrlEncoding() {
@@ -1294,7 +1297,9 @@ public class TestCRUDforDatabase {
public void testDoUpdateOrCreateWithNullId() {
System.out.println("Test DoUpdateOrCreate doesn't create new database entry if null is passed");
- String dbId = clearAndCreatefaultEntity(null, Entity.Faultlog.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput", SeverityType.Critical);
+ String dbId = clearAndCreatefaultEntity(null, Entity.Faultlog.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultlogInput",
+ SeverityType.Critical);
assertNull(dbId);
}
@@ -1302,44 +1307,47 @@ public class TestCRUDforDatabase {
public void readTestFaultCurrentViaRawDbProvider() {
System.out.println("Starting faultCurrent test...");
String dbId = null;
- dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(), "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput", SeverityType.Critical);
+ dbId = clearAndCreatefaultEntity("1", Entity.Faultcurrent.getName(),
+ "org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput",
+ SeverityType.Critical);
assertEquals("1", dbId);
- // ==READ===========================
+ // ==READ===========================
System.out.println("Trying to read...");
- String readResult = null;
- try {
- readResult = dbRawProvider.doReadJsonData(Entity.Faultcurrent.getName(), dbId);
+ String readResult = null;
+ try {
+ readResult = dbRawProvider.doReadJsonData(Entity.Faultcurrent.getName(), dbId);
- } catch (Exception e) {
- fail("Fault log not read: " + e.getMessage());
- }
+ } catch (Exception e) {
+ fail("Fault log not read: " + e.getMessage());
+ }
- String expectedDbResult ="{\"severity\":\"Critical\",\"node-id\":\"s1\",\"problem\":\"signalIsLost\",\"counter\":4340,\"object-id\":\"LP-MWPS-RADIO\",\"implemented-interface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput\",\"type\":\"ProblemNotificationXml\",\"timestamp\":\"2019-10-28T11:55:58.3Z\"}";
+ String expectedDbResult =
+ "{\"severity\":\"Critical\",\"node-id\":\"s1\",\"problem\":\"signalIsLost\",\"counter\":4340,\"object-id\":\"LP-MWPS-RADIO\",\"implemented-interface\":\"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.CreateFaultcurrentInput\",\"type\":\"ProblemNotificationXml\",\"timestamp\":\"2019-10-28T11:55:58.3Z\"}";
- System.out.println(readResult);
- assertNotNull(readResult);
- assertEquals(expectedDbResult, readResult);
+ System.out.println(readResult);
+ assertNotNull(readResult);
+ assertEquals(expectedDbResult, readResult);
- SearchResult<SearchHit> searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
- assertNotNull(searchResult);
+ SearchResult<SearchHit> searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
+ assertNotNull(searchResult);
- List<SearchHit> hits = searchResult.getHits();
+ List<SearchHit> hits = searchResult.getHits();
- assertNotNull(hits);
- assertEquals(1, searchResult.getTotal());
- assertEquals(expectedDbResult, hits.get(0).getSourceAsString());
+ assertNotNull(hits);
+ assertEquals(1, searchResult.getTotal());
+ assertEquals(expectedDbResult, hits.get(0).getSourceAsString());
- //== DELETE ==============================
- try {
- dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
- } catch (Exception e) {
- fail("problem deleting: " + e.getMessage());
- }
- //== VERIFY DELETE ========================
- searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
+ //== DELETE ==============================
+ try {
+ dbRawProvider.doRemove(Entity.Faultcurrent.getName(), QueryBuilders.matchAllQuery());
+ } catch (Exception e) {
+ fail("problem deleting: " + e.getMessage());
+ }
+ //== VERIFY DELETE ========================
+ searchResult = dbRawProvider.doReadAllJsonData(Entity.Faultcurrent.getName());
hits = searchResult.getHits();
assertNotNull(hits);
assertEquals(0, searchResult.getTotal());
@@ -1348,25 +1356,20 @@ public class TestCRUDforDatabase {
@Test
public void testOutputCamelCase() {
- try {
- String jsonString="{\n" +
- "\"timestamp\": \"2020-02-20T09:31:22.3Z\",\n" +
- "\"object-id\": \"LP-MWPS-RADIO\",\n" +
- "\"severity\": \"Critical\",\n" +
- "\"counter\": 10,\n" +
- "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultlog\",\n" +
- "\"source-type\": \"Netconf\",\n" +
- "\"node-id\": \"sim4\",\n" +
- "\"problem\": \"signalIsLost\"\n" +
- "}";
- YangToolsMapper yangtoolsMapper = new YangToolsMapper();
- FaultlogEntity log = yangtoolsMapper.readValue( jsonString, Faultlog.class );
- System.out.println(log );
- System.out.println(yangtoolsMapper.writeValueAsString(log));
- } catch (IOException e) {
- fail(e.getMessage());
- }
-
+ try {
+ String jsonString = "{\n" + "\"timestamp\": \"2020-02-20T09:31:22.3Z\",\n"
+ + "\"object-id\": \"LP-MWPS-RADIO\",\n" + "\"severity\": \"Critical\",\n" + "\"counter\": 10,\n"
+ + "\"implemented-interface\": \"org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.Faultlog\",\n"
+ + "\"source-type\": \"Netconf\",\n" + "\"node-id\": \"sim4\",\n" + "\"problem\": \"signalIsLost\"\n"
+ + "}";
+ YangToolsMapper yangtoolsMapper = new YangToolsMapper();
+ FaultlogEntity log = yangtoolsMapper.readValue(jsonString, Faultlog.class);
+ System.out.println(log);
+ System.out.println(yangtoolsMapper.writeValueAsString(log));
+ } catch (IOException e) {
+ fail(e.getMessage());
+ }
+
}
private Pagination getPagination(long pageSize, int page) {
@@ -1374,7 +1377,8 @@ public class TestCRUDforDatabase {
}
- private String clearAndCreatefaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) {
+ private String clearAndCreatefaultEntity(String initialDbId, String entityType, String implementedInterface,
+ SeverityType severity) {
// ==CLEAR BEFORE TEST============================
System.out.println("try to clear entry");
try {
@@ -1387,23 +1391,19 @@ public class TestCRUDforDatabase {
return createFaultEntity(initialDbId, entityType, implementedInterface, severity);
}
- private String createFaultEntity(String initialDbId, String entityType, String implementedInterface, SeverityType severity) {
- // ==CREATE============================
+ private String createFaultEntity(String initialDbId, String entityType, String implementedInterface,
+ SeverityType severity) {
+ // ==CREATE============================
System.out.println("try to create entry");
String dbId = null;
try {
- dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId,"{\n" +
- "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" +
- "\"object-id\": \"LP-MWPS-RADIO\",\n" +
- "\"severity\": \""+severity.toString()+"\",\n" +
- "\"node-id\": \"s1\",\n" +
- "\"implemented-interface\": \""+implementedInterface+"\",\n" +
- "\"counter\": 4340,\n" +
- "\"problem\": \"signalIsLost\",\n" +
- "\"type\": \"ProblemNotificationXml\"\n" +
- "}");
+ dbId = dbRawProvider.doUpdateOrCreate(entityType, initialDbId,
+ "{\n" + "\"timestamp\": \"2019-10-28T11:55:58.3Z\",\n" + "\"object-id\": \"LP-MWPS-RADIO\",\n"
+ + "\"severity\": \"" + severity.toString() + "\",\n" + "\"node-id\": \"s1\",\n"
+ + "\"implemented-interface\": \"" + implementedInterface + "\",\n" + "\"counter\": 4340,\n"
+ + "\"problem\": \"signalIsLost\",\n" + "\"type\": \"ProblemNotificationXml\"\n" + "}");
@@ -1414,65 +1414,31 @@ public class TestCRUDforDatabase {
return dbId;
}
- private String createPerformanceData(String initialDbId, GranularityPeriodType timeInterval, String scannerId, String uuidInterface, String nodename) {
-
- String json = "{\n" +
- "\"node-name\": \""+nodename+"\",\n" +
- "\"uuid-interface\": \""+uuidInterface+"\",\n" +
- "\"layer-protocol-name\": \"MWPS\",\n" +
- "\"radio-signal-id\": \"Test8\",\n" +
- "\"time-stamp\": \"2017-03-01T06:15:00.0Z\",\n" +
- "\"granularity-period\": \""+timeInterval.toString()+"\",\n" +
- "\"scanner-id\": \""+scannerId+"\",\n" +
- "\"performance-data\": {\n" +
- "\"cses\": 0,\n" +
- "\"ses\": 0,\n" +
- "\"es\": 0,\n" +
- "\"tx-level-max\": 3,\n" +
- "\"tx-level-avg\": 3,\n" +
- "\"rx-level-min\": -44,\n" +
- "\"rx-level-max\": -45,\n" +
- "\"rx-level-avg\": -44,\n" +
- "\"time2-states\": 0,\n" +
- "\"time4-states-s\": 0,\n" +
- "\"time4-states\": 0,\n" +
- "\"time8-states\": -1,\n" +
- "\"time16-states-s\": -1,\n" +
- "\"time16-states\": 0,\n" +
- "\"time32-states\": -1,\n" +
- "\"time64-states\": 900,\n" +
- "\"time128-states\": -1,\n" +
- "\"time256-states\": -1,\n" +
- "\"time512-states\": -1,\n" +
- "\"time512-states-l\": -1,\n" +
- "\"unavailability\": 0,\n" +
- "\"tx-level-min\": 3,\n" +
- "\"time1024-states\": -1,\n" +
- "\"time1024-states-l\": -1,\n" +
- "\"time2048-states\": -1,\n" +
- "\"time2048-states-l\": -1,\n" +
- "\"time4096-states\": -1,\n" +
- "\"time4096-states-l\": -1,\n" +
- "\"time8192-states\": -1,\n" +
- "\"time8192-states-l\": -1,\n" +
- "\"snir-min\": -99,\n" +
- "\"snir-max\": -99,\n" +
- "\"snir-avg\": -99,\n" +
- "\"xpd-min\": -99,\n" +
- "\"xpd-max\": -99,\n" +
- "\"xpd-avg\": -99,\n" +
- "\"rf-temp-min\": -99,\n" +
- "\"rf-temp-max\": -99,\n" +
- "\"rf-temp-avg\": -99,\n" +
- "\"defect-blocks-sum\": -1,\n" +
- "\"time-period\": 900\n" +
- "},\n" +
- "\"suspect-interval-flag\": false\n" +
- "}";
-
- if(timeInterval.equals(GranularityPeriodType.Period15Min)) {
+ private String createPerformanceData(String initialDbId, GranularityPeriodType timeInterval, String scannerId,
+ String uuidInterface, String nodename) {
+
+ String json = "{\n" + "\"node-name\": \"" + nodename + "\",\n" + "\"uuid-interface\": \"" + uuidInterface
+ + "\",\n" + "\"layer-protocol-name\": \"MWPS\",\n" + "\"radio-signal-id\": \"Test8\",\n"
+ + "\"time-stamp\": \"2017-03-01T06:15:00.0Z\",\n" + "\"granularity-period\": \""
+ + timeInterval.toString() + "\",\n" + "\"scanner-id\": \"" + scannerId + "\",\n"
+ + "\"performance-data\": {\n" + "\"cses\": 0,\n" + "\"ses\": 0,\n" + "\"es\": 0,\n"
+ + "\"tx-level-max\": 3,\n" + "\"tx-level-avg\": 3,\n" + "\"rx-level-min\": -44,\n"
+ + "\"rx-level-max\": -45,\n" + "\"rx-level-avg\": -44,\n" + "\"time2-states\": 0,\n"
+ + "\"time4-states-s\": 0,\n" + "\"time4-states\": 0,\n" + "\"time8-states\": -1,\n"
+ + "\"time16-states-s\": -1,\n" + "\"time16-states\": 0,\n" + "\"time32-states\": -1,\n"
+ + "\"time64-states\": 900,\n" + "\"time128-states\": -1,\n" + "\"time256-states\": -1,\n"
+ + "\"time512-states\": -1,\n" + "\"time512-states-l\": -1,\n" + "\"unavailability\": 0,\n"
+ + "\"tx-level-min\": 3,\n" + "\"time1024-states\": -1,\n" + "\"time1024-states-l\": -1,\n"
+ + "\"time2048-states\": -1,\n" + "\"time2048-states-l\": -1,\n" + "\"time4096-states\": -1,\n"
+ + "\"time4096-states-l\": -1,\n" + "\"time8192-states\": -1,\n" + "\"time8192-states-l\": -1,\n"
+ + "\"snir-min\": -99,\n" + "\"snir-max\": -99,\n" + "\"snir-avg\": -99,\n" + "\"xpd-min\": -99,\n"
+ + "\"xpd-max\": -99,\n" + "\"xpd-avg\": -99,\n" + "\"rf-temp-min\": -99,\n" + "\"rf-temp-max\": -99,\n"
+ + "\"rf-temp-avg\": -99,\n" + "\"defect-blocks-sum\": -1,\n" + "\"time-period\": 900\n" + "},\n"
+ + "\"suspect-interval-flag\": false\n" + "}";
+
+ if (timeInterval.equals(GranularityPeriodType.Period15Min)) {
return dbRawProvider.doUpdateOrCreate(Entity.Historicalperformance15min.getName(), initialDbId, json);
- }else {
+ } else {
return dbRawProvider.doUpdateOrCreate(Entity.Historicalperformance24h.getName(), initialDbId, json);
}
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
index 1b5e1afa7..c0234bfce 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfig.java
@@ -44,15 +44,16 @@ public class TestConfig {
@After
@Before
public void afterAndBefore() {
- File f=new File(TESTFILENAME);
- if(f.exists()) {
+ File f = new File(TESTFILENAME);
+ if (f.exists()) {
LOG.info("Remove {}", f.getAbsolutePath());
f.delete();
}
}
+
@Test
public void test() {
- ConfigurationFileRepresentation configuration=new ConfigurationFileRepresentation(TESTFILENAME);
+ ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(TESTFILENAME);
setSDNRDBURLEnv();
EsConfig esConfig = new EsConfig(configuration);
LOG.info("Defaultconfiguration: {}", esConfig.toString());
@@ -61,19 +62,21 @@ public class TestConfig {
assertEquals("sdnrdb", esConfig.getHosts()[0].hostname);
}
+
public static void setSDNRDBURLEnv() {
- setEnv("SDNRDBURL","http://sdnrdb:9200");
+ setEnv("SDNRDBURL", "http://sdnrdb:9200");
+ }
+
+ public static void setEnv(String key, String value) {
+ try {
+ Map<String, String> env = System.getenv();
+ Class<?> cl = env.getClass();
+ Field field = cl.getDeclaredField("m");
+ field.setAccessible(true);
+ Map<String, String> writableEnv = (Map<String, String>) field.get(env);
+ writableEnv.put(key, value);
+ } catch (Exception e) {
+ throw new IllegalStateException("Failed to set environment variable", e);
+ }
}
- public static void setEnv(String key, String value) {
- try {
- Map<String, String> env = System.getenv();
- Class<?> cl = env.getClass();
- Field field = cl.getDeclaredField("m");
- field.setAccessible(true);
- Map<String, String> writableEnv = (Map<String, String>) field.get(env);
- writableEnv.put(key, value);
- } catch (Exception e) {
- throw new IllegalStateException("Failed to set environment variable", e);
- }
- }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java
index 30b1003c2..d06486550 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestConfiguration.java
@@ -39,14 +39,14 @@ public class TestConfiguration {
System.out.println("Configuration file " + CONFIGURATIONTESTFILE);
File testConfigurationFile = ResourceFileLoader.getFile(this, CONFIGURATIONTESTFILE);
- System.out.println("Located at: "+testConfigurationFile.getAbsolutePath());
+ System.out.println("Located at: " + testConfigurationFile.getAbsolutePath());
ConfigurationFileRepresentation configuration = new ConfigurationFileRepresentation(testConfigurationFile);
System.out.println("Configuration: " + configuration.getSection(EsConfig.SECTION_MARKER_ES));
EsConfig esConfig1 = new EsConfig(configuration);
- System.out.println("ES config getArchiveLifetimeSeconds: "+esConfig1.getArchiveLifetimeSeconds());
+ System.out.println("ES config getArchiveLifetimeSeconds: " + esConfig1.getArchiveLifetimeSeconds());
// fail("Not yet implemented");
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
index f68a6e8f3..a4b284e4f 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataMappings.java
@@ -39,172 +39,121 @@ import org.opendaylight.yangtools.yang.binding.DataObject;
public class TestDataMappings {
- private static final HostInfo[] HOSTINFOS = new HostInfo[] {HostInfo.getDefault()};
- //public static final String ESDATATYPENAME = "faultcurrent";
-
- private static class HtDatabaseClientHelper extends HtDatabaseClient {
-
- private final String json;
-
- public HtDatabaseClientHelper(String jsonResponse, HostInfo[] hosts) {
- super(hosts);
- this.json = jsonResponse;
-
- }
-
- @Override
- public SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder qb) {
- return new SearchResult<>(new SearchResponse(this.json).getHits());
- }
- }
-
- private static class MapResult<T extends DataObject> {
- public final List<T> mappedData;
- public MapResult(String dataType, Class<T> cls, String dbJson) throws ClassNotFoundException {
- System.out.println(dbJson);
- DatabaseClient db = new HtDatabaseClientHelper(dbJson,HOSTINFOS);
- EsDataObjectReaderWriter<T> dbrw=new EsDataObjectReaderWriter<>(db,dataType,cls);
- this.mappedData=dbrw.doReadAll().getHits();
- }
- }
-
- private static final String SEARCHJSON_FORMAT = "{\n" +
- "\"took\": 0,\n" +
- "\"timed_out\": false,\n" +
- "\"_shards\": {\n" +
- "\"total\": 5,\n" +
- "\"successful\": 5,\n" +
- "\"skipped\": 0,\n" +
- "\"failed\": 0\n" +
- "},\n" +
- "\"hits\": {\n" +
- "\"total\": 1,\n" +
- "\"max_score\": 1,\n" +
- "\"hits\": [\n" +
- "{\n" +
- "\"_index\": \"%s\",\n" +
- "\"_type\": \"%s\",\n" +
- "\"_id\": \"%s\",\n" +
- "\"_score\": 1,\n" +
- "\"_source\": %s}\n" +
- "]\n" +
- "}\n" +
- "}";
-
- private static final String MEDIATORSERVER_DB_ID="LumwSG0BFvcE3yf8MBM5";
- private static final String MEDIATOR_SERVERDB_JSON = "{\"url\":\"https://10.45.44.223:7590\",\"name\":\"test mediator server\"}";
-
- private static final String FAULTCURRENT_DB_ID="LumwSG0BFvcE3yf8MBM5";
- private static final String FAULTCURRENT_DB_NODEID = "sim1";
- private static final int FAULTCURRENT_DB_COUNTER = 3;
- private static final String FAULTCURRENT_DB_OBJECTID = "LPS-MWT-01";
- private static final String FAULTCURRENT_DB_PROBLEM = "rlsExceeded";
- private static final String FAULTCURRENT_DB_SEVERITY = "critical";
- private static final DateAndTime FAULTCURRENT_DB_TIMESTAMP = DateAndTime.getDefaultInstance("2019-09-18T13:07:05.8Z");
-
- private static final String FAULTCURRENT_SERVERDB_JSON = "{\"node-id\":\""+FAULTCURRENT_DB_NODEID+"\","+
- "\"counter\":"+FAULTCURRENT_DB_COUNTER+","+
- "\"object-id\":\""+FAULTCURRENT_DB_OBJECTID+"\","+
- "\"problem\":\""+FAULTCURRENT_DB_PROBLEM+"\","+
- "\"timestamp\":\""+FAULTCURRENT_DB_TIMESTAMP.getValue()+"\","+
- "\"severity\":\""+FAULTCURRENT_DB_SEVERITY+"\""+
- "}";
-
-
- private static final String PMDATA15M_SERVERDB_JSON="{\n" +
- "\"node-name\": \"sim2\",\n" +
- "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n" +
- "\"layer-protocol-name\": \"MWPS\",\n" +
- "\"radio-signal-id\": \"Test11\",\n" +
- "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n" +
- "\"granularity-period\": \"PERIOD_15MIN\",\n" +
- "\"scanner-id\": \"PM_RADIO_15M_9\",\n" +
- "\"performance-data\": {\n" +
- "\"es\": 0,\n" +
- "\"rx-level-avg\": -41,\n" +
- "\"time2-states\": -1,\n" +
- "\"time4-states-s\": 0,\n" +
- "\"time4-states\": 0,\n" +
- "\"time8-states\": 0,\n" +
- "\"time16-states-s\": -1,\n" +
- "\"time16-states\": 0,\n" +
- "\"time32-states\": 0,\n" +
- "\"time64-states\": 0,\n" +
- "\"time128-states\": 0,\n" +
- "\"time256-states\": 900,\n" +
- "\"time512-states\": -1,\n" +
- "\"time512-states-l\": -1,\n" +
- "\"time1024-states\": -1,\n" +
- "\"time1024-states-l\": -1,\n" +
- "\"time2048-states\": -1,\n" +
- "\"time2048-states-l\": -1,\n" +
- "\"time4096-states\": -1,\n" +
- "\"time4096-states-l\": -1,\n" +
- "\"time8192-states\": -1,\n" +
- "\"time8192-states-l\": -1,\n" +
- "\"snir-min\": -99,\n" +
- "\"snir-max\": -99,\n" +
- "\"snir-avg\": -99,\n" +
- "\"xpd-min\": -99,\n" +
- "\"xpd-max\": -99,\n" +
- "\"xpd-avg\": -99,\n" +
- "\"rf-temp-min\": -99,\n" +
- "\"rf-temp-max\": -99,\n" +
- "\"rf-temp-avg\": -99,\n" +
- "\"defect-blocks-sum\": -1,\n" +
- "\"time-period\": 900,\n" +
- "\"tx-level-min\": 25,\n" +
- "\"tx-level-max\": 25,\n" +
- "\"tx-level-avg\": 25,\n" +
- "\"rx-level-min\": -41,\n" +
- "\"rx-level-max\": -41,\n" +
- "\"unavailability\": 0,\n" +
- "\"ses\": 0,\n" +
- "\"cses\": 0\n" +
- "},\n" +
- "\"suspect-interval-flag\": false\n" +
- "}";
-
- //@Test
-// public void testMediatorServer() throws ClassNotFoundException {
-//
-// MapResult<EsMediatorServer> result = new MapResult<EsMediatorServer>(EsMediatorServer.ESDATATYPENAME,
-// EsMediatorServer.class,
-// getSearchJson(EsMediatorServer.ESDATATYPENAME,MEDIATORSERVER_DB_ID,MEDIATOR_SERVERDB_JSON));
-// assertEquals("test mediator server", result.mappedData.get(0).getName());
-// assertEquals("https://10.45.44.223:7590", result.mappedData.get(0).getUrl());
-// assertEquals(MEDIATORSERVER_DB_ID, result.mappedData.get(0).getId());
-//
-// }
- //@Test
-// public void testFaultCurrent() {
-//
-// MapResult<FaultcurrentEntity> result = new MapResult<FaultcurrentEntity>(ESDATATYPENAME, EsFaultCurrent.class,
-// getSearchJson(ESDATATYPENAME, FAULTCURRENT_DB_ID, FAULTCURRENT_SERVERDB_JSON));
-// assertEquals(FAULTCURRENT_DB_ID, result.mappedData.get(0).getId());
-// assertEquals(FAULTCURRENT_DB_NODEID, result.mappedData.get(0).getNodeId());
-// assertEquals(FAULTCURRENT_DB_COUNTER, result.mappedData.get(0).getCounter().intValue());
-// assertEquals(FAULTCURRENT_DB_OBJECTID, result.mappedData.get(0).getObjectId());
-// assertEquals(FAULTCURRENT_DB_PROBLEM, result.mappedData.get(0).getProblem());
-// assertEquals(FAULTCURRENT_DB_SEVERITY, result.mappedData.get(0).getSeverity());
-// assertEquals(FAULTCURRENT_DB_TIMESTAMP, result.mappedData.get(0).getTimestamp());
-// }
-//
- @Test
- public void testPmData15m() {
-
- YangToolsMapper mapper = new YangToolsMapper();
- try {
- Data data =mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class);
- System.out.println(data);
- } catch (IOException e) {
- e.printStackTrace();
- }
-
-
- }
- private String getSearchJson(String dataType,String dbId, String source) {
- return String.format(SEARCHJSON_FORMAT,dataType,dataType, dbId,source);
- }
+ private static final HostInfo[] HOSTINFOS = new HostInfo[] {HostInfo.getDefault()};
+ //public static final String ESDATATYPENAME = "faultcurrent";
+
+ private static class HtDatabaseClientHelper extends HtDatabaseClient {
+
+ private final String json;
+
+ public HtDatabaseClientHelper(String jsonResponse, HostInfo[] hosts) {
+ super(hosts);
+ this.json = jsonResponse;
+
+ }
+
+ @Override
+ public SearchResult<SearchHit> doReadByQueryJsonData(String dataTypeName, QueryBuilder qb) {
+ return new SearchResult<>(new SearchResponse(this.json).getHits());
+ }
+ }
+
+ private static class MapResult<T extends DataObject> {
+ public final List<T> mappedData;
+
+ public MapResult(String dataType, Class<T> cls, String dbJson) throws ClassNotFoundException {
+ System.out.println(dbJson);
+ DatabaseClient db = new HtDatabaseClientHelper(dbJson, HOSTINFOS);
+ EsDataObjectReaderWriter<T> dbrw = new EsDataObjectReaderWriter<>(db, dataType, cls);
+ this.mappedData = dbrw.doReadAll().getHits();
+ }
+ }
+
+ private static final String SEARCHJSON_FORMAT = "{\n" + "\"took\": 0,\n" + "\"timed_out\": false,\n"
+ + "\"_shards\": {\n" + "\"total\": 5,\n" + "\"successful\": 5,\n" + "\"skipped\": 0,\n" + "\"failed\": 0\n"
+ + "},\n" + "\"hits\": {\n" + "\"total\": 1,\n" + "\"max_score\": 1,\n" + "\"hits\": [\n" + "{\n"
+ + "\"_index\": \"%s\",\n" + "\"_type\": \"%s\",\n" + "\"_id\": \"%s\",\n" + "\"_score\": 1,\n"
+ + "\"_source\": %s}\n" + "]\n" + "}\n" + "}";
+
+ private static final String MEDIATORSERVER_DB_ID = "LumwSG0BFvcE3yf8MBM5";
+ private static final String MEDIATOR_SERVERDB_JSON =
+ "{\"url\":\"https://10.45.44.223:7590\",\"name\":\"test mediator server\"}";
+
+ private static final String FAULTCURRENT_DB_ID = "LumwSG0BFvcE3yf8MBM5";
+ private static final String FAULTCURRENT_DB_NODEID = "sim1";
+ private static final int FAULTCURRENT_DB_COUNTER = 3;
+ private static final String FAULTCURRENT_DB_OBJECTID = "LPS-MWT-01";
+ private static final String FAULTCURRENT_DB_PROBLEM = "rlsExceeded";
+ private static final String FAULTCURRENT_DB_SEVERITY = "critical";
+ private static final DateAndTime FAULTCURRENT_DB_TIMESTAMP =
+ DateAndTime.getDefaultInstance("2019-09-18T13:07:05.8Z");
+
+ private static final String FAULTCURRENT_SERVERDB_JSON = "{\"node-id\":\"" + FAULTCURRENT_DB_NODEID + "\","
+ + "\"counter\":" + FAULTCURRENT_DB_COUNTER + "," + "\"object-id\":\"" + FAULTCURRENT_DB_OBJECTID + "\","
+ + "\"problem\":\"" + FAULTCURRENT_DB_PROBLEM + "\"," + "\"timestamp\":\""
+ + FAULTCURRENT_DB_TIMESTAMP.getValue() + "\"," + "\"severity\":\"" + FAULTCURRENT_DB_SEVERITY + "\"" + "}";
+
+
+ private static final String PMDATA15M_SERVERDB_JSON = "{\n" + "\"node-name\": \"sim2\",\n"
+ + "\"uuid-interface\": \"LP-MWPS-TTP-01\",\n" + "\"layer-protocol-name\": \"MWPS\",\n"
+ + "\"radio-signal-id\": \"Test11\",\n" + "\"time-stamp\": \"2017-07-04T14:00:00.0Z\",\n"
+ + "\"granularity-period\": \"PERIOD_15MIN\",\n" + "\"scanner-id\": \"PM_RADIO_15M_9\",\n"
+ + "\"performance-data\": {\n" + "\"es\": 0,\n" + "\"rx-level-avg\": -41,\n" + "\"time2-states\": -1,\n"
+ + "\"time4-states-s\": 0,\n" + "\"time4-states\": 0,\n" + "\"time8-states\": 0,\n"
+ + "\"time16-states-s\": -1,\n" + "\"time16-states\": 0,\n" + "\"time32-states\": 0,\n"
+ + "\"time64-states\": 0,\n" + "\"time128-states\": 0,\n" + "\"time256-states\": 900,\n"
+ + "\"time512-states\": -1,\n" + "\"time512-states-l\": -1,\n" + "\"time1024-states\": -1,\n"
+ + "\"time1024-states-l\": -1,\n" + "\"time2048-states\": -1,\n" + "\"time2048-states-l\": -1,\n"
+ + "\"time4096-states\": -1,\n" + "\"time4096-states-l\": -1,\n" + "\"time8192-states\": -1,\n"
+ + "\"time8192-states-l\": -1,\n" + "\"snir-min\": -99,\n" + "\"snir-max\": -99,\n" + "\"snir-avg\": -99,\n"
+ + "\"xpd-min\": -99,\n" + "\"xpd-max\": -99,\n" + "\"xpd-avg\": -99,\n" + "\"rf-temp-min\": -99,\n"
+ + "\"rf-temp-max\": -99,\n" + "\"rf-temp-avg\": -99,\n" + "\"defect-blocks-sum\": -1,\n"
+ + "\"time-period\": 900,\n" + "\"tx-level-min\": 25,\n" + "\"tx-level-max\": 25,\n"
+ + "\"tx-level-avg\": 25,\n" + "\"rx-level-min\": -41,\n" + "\"rx-level-max\": -41,\n"
+ + "\"unavailability\": 0,\n" + "\"ses\": 0,\n" + "\"cses\": 0\n" + "},\n"
+ + "\"suspect-interval-flag\": false\n" + "}";
+
+ //@Test
+ // public void testMediatorServer() throws ClassNotFoundException {
+ //
+ // MapResult<EsMediatorServer> result = new MapResult<EsMediatorServer>(EsMediatorServer.ESDATATYPENAME,
+ // EsMediatorServer.class,
+ // getSearchJson(EsMediatorServer.ESDATATYPENAME,MEDIATORSERVER_DB_ID,MEDIATOR_SERVERDB_JSON));
+ // assertEquals("test mediator server", result.mappedData.get(0).getName());
+ // assertEquals("https://10.45.44.223:7590", result.mappedData.get(0).getUrl());
+ // assertEquals(MEDIATORSERVER_DB_ID, result.mappedData.get(0).getId());
+ //
+ // }
+ //@Test
+ // public void testFaultCurrent() {
+ //
+ // MapResult<FaultcurrentEntity> result = new MapResult<FaultcurrentEntity>(ESDATATYPENAME, EsFaultCurrent.class,
+ // getSearchJson(ESDATATYPENAME, FAULTCURRENT_DB_ID, FAULTCURRENT_SERVERDB_JSON));
+ // assertEquals(FAULTCURRENT_DB_ID, result.mappedData.get(0).getId());
+ // assertEquals(FAULTCURRENT_DB_NODEID, result.mappedData.get(0).getNodeId());
+ // assertEquals(FAULTCURRENT_DB_COUNTER, result.mappedData.get(0).getCounter().intValue());
+ // assertEquals(FAULTCURRENT_DB_OBJECTID, result.mappedData.get(0).getObjectId());
+ // assertEquals(FAULTCURRENT_DB_PROBLEM, result.mappedData.get(0).getProblem());
+ // assertEquals(FAULTCURRENT_DB_SEVERITY, result.mappedData.get(0).getSeverity());
+ // assertEquals(FAULTCURRENT_DB_TIMESTAMP, result.mappedData.get(0).getTimestamp());
+ // }
+ //
+ @Test
+ public void testPmData15m() {
+
+ YangToolsMapper mapper = new YangToolsMapper();
+ try {
+ Data data = mapper.readValue(PMDATA15M_SERVERDB_JSON.getBytes(), Data.class);
+ System.out.println(data);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+
+
+ }
+
+ private String getSearchJson(String dataType, String dbId, String source) {
+ return String.format(SEARCHJSON_FORMAT, dataType, dataType, dbId, source);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java
index 54b2dc00d..60a2c50e4 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestDataTreeSerialization.java
@@ -29,5 +29,5 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.yangtools.YangToolsMapper;
*/
public class TestDataTreeSerialization {
- //YangToolsMapper
+ //YangToolsMapper
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
index c528e3552..308bbf663 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestEventService.java
@@ -70,251 +70,251 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
*
*/
public class TestEventService {
- private static ElasticSearchDataProvider dbProvider;
- private static HtDatabaseClient dbRawProvider;
- private static HtDatabaseEventsService service = null;
+ private static ElasticSearchDataProvider dbProvider;
+ private static HtDatabaseClient dbRawProvider;
+ private static HtDatabaseEventsService service = null;
- private static final String NODEID = "node1";
- private static final String NODEID2 = "node2";
- private static final String OBJECTREFID1 = "objid1";
- private static final String OBJECTREFID2 = "objid2";
+ private static final String NODEID = "node1";
+ private static final String NODEID2 = "node2";
+ private static final String OBJECTREFID1 = "objid1";
+ private static final String OBJECTREFID2 = "objid2";
- @BeforeClass
- public static void init() throws Exception {
+ @BeforeClass
+ public static void init() throws Exception {
- dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
- dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
+ dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
+ dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
+ dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
- try {
- service = new HtDatabaseEventsService(dbRawProvider, dbProvider);
- } catch (Exception e) {
- e.printStackTrace();
- fail(e.getMessage());
- }
- }
+ try {
+ service = new HtDatabaseEventsService(dbRawProvider, dbProvider);
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail(e.getMessage());
+ }
+ }
- @Test
- public void testClearFaultsCurrent() {
+ @Test
+ public void testClearFaultsCurrent() {
- service.clearFaultsCurrentOfNode(NODEID);
- service.clearFaultsCurrentOfNode(NODEID2);
+ service.clearFaultsCurrentOfNode(NODEID);
+ service.clearFaultsCurrentOfNode(NODEID2);
- List<String> nodeIds = service.getAllNodesWithCurrentAlarms();
- if (nodeIds.size() > 0) {
- for (String nodeId : nodeIds) {
- service.clearFaultsCurrentOfNode(nodeId);
- }
- }
- service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abc", SeverityType.Major));
- service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abcde", SeverityType.Major));
- service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.Major));
- service.updateFaultCurrent(createFault(NODEID2, OBJECTREFID2, "abcde", SeverityType.Major));
- nodeIds = service.getAllNodesWithCurrentAlarms();
- assertTrue(nodeIds.size() == 2);
- service.clearFaultsCurrentOfNodeWithObjectId(NODEID, OBJECTREFID1);
- nodeIds = service.getAllNodesWithCurrentAlarms();
- assertTrue(nodeIds.size() == 2);
- service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.NonAlarmed));
- nodeIds = service.getAllNodesWithCurrentAlarms();
- assertTrue(nodeIds.size() == 1);
- }
+ List<String> nodeIds = service.getAllNodesWithCurrentAlarms();
+ if (nodeIds.size() > 0) {
+ for (String nodeId : nodeIds) {
+ service.clearFaultsCurrentOfNode(nodeId);
+ }
+ }
+ service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abc", SeverityType.Major));
+ service.updateFaultCurrent(createFault(NODEID, OBJECTREFID1, "abcde", SeverityType.Major));
+ service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.Major));
+ service.updateFaultCurrent(createFault(NODEID2, OBJECTREFID2, "abcde", SeverityType.Major));
+ nodeIds = service.getAllNodesWithCurrentAlarms();
+ assertTrue(nodeIds.size() == 2);
+ service.clearFaultsCurrentOfNodeWithObjectId(NODEID, OBJECTREFID1);
+ nodeIds = service.getAllNodesWithCurrentAlarms();
+ assertTrue(nodeIds.size() == 2);
+ service.updateFaultCurrent(createFault(NODEID, OBJECTREFID2, "abcde", SeverityType.NonAlarmed));
+ nodeIds = service.getAllNodesWithCurrentAlarms();
+ assertTrue(nodeIds.size() == 1);
+ }
- private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
- SeverityType severity) {
- return createFault(nodeId, objectRefId, problem, severity, NetconfTimeStampImpl.getConverter().getTimeStamp());
- }
+ private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
+ SeverityType severity) {
+ return createFault(nodeId, objectRefId, problem, severity, NetconfTimeStampImpl.getConverter().getTimeStamp());
+ }
- /**
- * @param nODENAME
- * @param problem
- * @param ts
- * @param severity
- * @return
- */
- private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
- SeverityType severity, DateAndTime ts) {
- return new FaultcurrentBuilder().setNodeId(nodeId).setObjectId(objectRefId).setTimestamp(ts)
- .setSeverity(severity).setProblem(problem).build();
- }
+ /**
+ * @param nODENAME
+ * @param problem
+ * @param ts
+ * @param severity
+ * @return
+ */
+ private static FaultcurrentEntity createFault(String nodeId, String objectRefId, String problem,
+ SeverityType severity, DateAndTime ts) {
+ return new FaultcurrentBuilder().setNodeId(nodeId).setObjectId(objectRefId).setTimestamp(ts)
+ .setSeverity(severity).setProblem(problem).build();
+ }
- @Test
- public void testIndexClean() {
- Date now = new Date();
- service.doIndexClean(now);
- clearDbEntity(Entity.Eventlog);
- clearDbEntity(Entity.Faultlog);
- TestCRUDforDatabase.trySleep(1000);
- service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "abc", 1));
- service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "avasvas", 2));
+ @Test
+ public void testIndexClean() {
+ Date now = new Date();
+ service.doIndexClean(now);
+ clearDbEntity(Entity.Eventlog);
+ clearDbEntity(Entity.Faultlog);
+ TestCRUDforDatabase.trySleep(1000);
+ service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "abc", 1));
+ service.writeEventLog(createEventLog(NODEID, OBJECTREFID1, "aaa", "avasvas", 2));
- service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 1));
- service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 2));
- service.writeFaultLog(createFaultLog(NODEID2, OBJECTREFID2, "problem", SeverityType.Major, 1));
- TestCRUDforDatabase.trySleep(100);
- now = new Date();
- int numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
- TestCRUDforDatabase.trySleep(100);
- service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 3));
- service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 5));
- service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 6));
- numOlds = service.getNumberOfOldObjects(now);
- assertEquals(5, numOlds);
- now = new Date();
- numOlds = service.getNumberOfOldObjects(now);
- assertEquals(8, numOlds);
- service.doIndexClean(now);
- numOlds = service.getNumberOfOldObjects(now);
- assertEquals(0, numOlds);
+ service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 1));
+ service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 2));
+ service.writeFaultLog(createFaultLog(NODEID2, OBJECTREFID2, "problem", SeverityType.Major, 1));
+ TestCRUDforDatabase.trySleep(100);
+ now = new Date();
+ int numOlds = service.getNumberOfOldObjects(now);
+ assertEquals(5, numOlds);
+ TestCRUDforDatabase.trySleep(100);
+ service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 3));
+ service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.NonAlarmed, 5));
+ service.writeFaultLog(createFaultLog(NODEID, OBJECTREFID2, "problem", SeverityType.Major, 6));
+ numOlds = service.getNumberOfOldObjects(now);
+ assertEquals(5, numOlds);
+ now = new Date();
+ numOlds = service.getNumberOfOldObjects(now);
+ assertEquals(8, numOlds);
+ service.doIndexClean(now);
+ numOlds = service.getNumberOfOldObjects(now);
+ assertEquals(0, numOlds);
- }
+ }
- @Test
- public void testPm() {
- final String IFNAME1 = "if1";
- final String SCNID1 = "scn1";
- List<PmdataEntity> list = Arrays.asList(createPmData(NODEID, IFNAME1, SCNID1),
- createPmData(NODEID, IFNAME1, SCNID1), createPmData(NODEID, IFNAME1, SCNID1),
- createPmData(NODEID, IFNAME1, SCNID1)
+ @Test
+ public void testPm() {
+ final String IFNAME1 = "if1";
+ final String SCNID1 = "scn1";
+ List<PmdataEntity> list =
+ Arrays.asList(createPmData(NODEID, IFNAME1, SCNID1), createPmData(NODEID, IFNAME1, SCNID1),
+ createPmData(NODEID, IFNAME1, SCNID1), createPmData(NODEID, IFNAME1, SCNID1)
- );
- service.doWritePerformanceData(list);
- }
+ );
+ service.doWritePerformanceData(list);
+ }
- /**
- * @param ifname
- * @param ifUuid
- * @param scannerId
- * @param nodename3
- * @return
- */
- private static PmdataEntity createPmData(String nodeId, String ifUuid, String scannerId) {
- return new PmdataEntityBuilder().setNodeName(nodeId).setGranularityPeriod(GranularityPeriodType.Period15Min)
- .setUuidInterface(ifUuid).setScannerId(scannerId).setLayerProtocolName("NETCONF")
- .setPerformanceData(null).setSuspectIntervalFlag(true)
- .setTimeStamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).build();
- }
+ /**
+ * @param ifname
+ * @param ifUuid
+ * @param scannerId
+ * @param nodename3
+ * @return
+ */
+ private static PmdataEntity createPmData(String nodeId, String ifUuid, String scannerId) {
+ return new PmdataEntityBuilder().setNodeName(nodeId).setGranularityPeriod(GranularityPeriodType.Period15Min)
+ .setUuidInterface(ifUuid).setScannerId(scannerId).setLayerProtocolName("NETCONF")
+ .setPerformanceData(null).setSuspectIntervalFlag(true)
+ .setTimeStamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).build();
+ }
- @Test
- public void testNeConnection() {
- service.removeNetworkConnection(NODEID);
- service.removeNetworkConnection(NODEID2);
+ @Test
+ public void testNeConnection() {
+ service.removeNetworkConnection(NODEID);
+ service.removeNetworkConnection(NODEID2);
- clearDbEntity(Entity.NetworkelementConnection);
- List<NetworkElementConnectionEntity> nes = service.getNetworkElementConnections();
- assertEquals(0, nes.size());
- service.updateNetworkConnection22(createNeConnection(NODEID, NetworkElementDeviceType.Unknown), NODEID);
- service.updateNetworkConnection22(createNeConnection(NODEID2, NetworkElementDeviceType.ORAN), NODEID2);
- nes = service.getNetworkElementConnections();
- assertEquals(2, nes.size());
- service.updateNetworkConnectionDeviceType(createNeConnection(NODEID, NetworkElementDeviceType.Wireless),
- NODEID);
- nes = service.getNetworkElementConnections();
- assertEquals(2, nes.size());
- boolean found = false;
- for (NetworkElementConnectionEntity ne : nes) {
- if (NODEID.equals(ne.getNodeId()) && ne.getDeviceType() == NetworkElementDeviceType.Wireless) {
- found = true;
- }
- }
- assertTrue(found);
+ clearDbEntity(Entity.NetworkelementConnection);
+ List<NetworkElementConnectionEntity> nes = service.getNetworkElementConnections();
+ assertEquals(0, nes.size());
+ service.updateNetworkConnection22(createNeConnection(NODEID, NetworkElementDeviceType.Unknown), NODEID);
+ service.updateNetworkConnection22(createNeConnection(NODEID2, NetworkElementDeviceType.ORAN), NODEID2);
+ nes = service.getNetworkElementConnections();
+ assertEquals(2, nes.size());
+ service.updateNetworkConnectionDeviceType(createNeConnection(NODEID, NetworkElementDeviceType.Wireless),
+ NODEID);
+ nes = service.getNetworkElementConnections();
+ assertEquals(2, nes.size());
+ boolean found = false;
+ for (NetworkElementConnectionEntity ne : nes) {
+ if (NODEID.equals(ne.getNodeId()) && ne.getDeviceType() == NetworkElementDeviceType.Wireless) {
+ found = true;
+ }
+ }
+ assertTrue(found);
- }
+ }
- @Test
- public void testConnectionLog() {
- clearDbEntity(Entity.Connectionlog);
- service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted));
- service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted));
- assertEquals(2, getDbEntityEntries(Entity.Connectionlog).getTotal());
- }
+ @Test
+ public void testConnectionLog() {
+ clearDbEntity(Entity.Connectionlog);
+ service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted));
+ service.writeConnectionLog(createConnectionLog(NODEID, ConnectionLogStatus.Mounted));
+ assertEquals(2, getDbEntityEntries(Entity.Connectionlog).getTotal());
+ }
- /**
- * @param nodeId
- * @param status
- * @return
- */
- private static ConnectionlogEntity createConnectionLog(String nodeId, ConnectionLogStatus status) {
- return new ConnectionlogBuilder().setNodeId(nodeId)
- .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setStatus(status).build();
- }
+ /**
+ * @param nodeId
+ * @param status
+ * @return
+ */
+ private static ConnectionlogEntity createConnectionLog(String nodeId, ConnectionLogStatus status) {
+ return new ConnectionlogBuilder().setNodeId(nodeId)
+ .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setStatus(status).build();
+ }
- @Test
- public void testInventory() {
- clearDbEntity(Entity.Inventoryequipment);
- service.writeInventory(createEquipment(NODEID, "uuid1"));
- service.writeInventory(createEquipment(NODEID, "uuid2"));
- service.writeInventory(createEquipment(NODEID2, "uuid3"));
- service.writeInventory(createEquipment(NODEID2, "uuid4"));
- service.writeInventory(createEquipment(NODEID2, "uuid5"));
- assertEquals(5, getDbEntityEntries(Entity.Inventoryequipment).getTotal());
- }
+ @Test
+ public void testInventory() {
+ clearDbEntity(Entity.Inventoryequipment);
+ service.writeInventory(createEquipment(NODEID, "uuid1"));
+ service.writeInventory(createEquipment(NODEID, "uuid2"));
+ service.writeInventory(createEquipment(NODEID2, "uuid3"));
+ service.writeInventory(createEquipment(NODEID2, "uuid4"));
+ service.writeInventory(createEquipment(NODEID2, "uuid5"));
+ assertEquals(5, getDbEntityEntries(Entity.Inventoryequipment).getTotal());
+ }
- private static SearchResult<SearchHit> getDbEntityEntries(Entity entity) {
- return dbRawProvider.doReadAllJsonData(entity.getName());
- }
+ private static SearchResult<SearchHit> getDbEntityEntries(Entity entity) {
+ return dbRawProvider.doReadAllJsonData(entity.getName());
+ }
- private static void clearDbEntity(Entity entity) {
- DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName());
- query.setQuery(QueryBuilders.matchAllQuery().toJSON());
- try {
- dbRawProvider.deleteByQuery(query);
- } catch (IOException e) {
- e.printStackTrace();
- }
- TestCRUDforDatabase.trySleep(1000);
- }
+ private static void clearDbEntity(Entity entity) {
+ DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName());
+ query.setQuery(QueryBuilders.matchAllQuery().toJSON());
+ try {
+ dbRawProvider.deleteByQuery(query);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ TestCRUDforDatabase.trySleep(1000);
+ }
- /**
- * @param nodeId
- * @param uuid
- * @return
- */
- private Inventory createEquipment(String nodeId, String uuid) {
- return new InventoryBuilder().setNodeId(nodeId).setParentUuid("").setDescription("desc")
- .setManufacturerName("manu").setUuid(uuid).build();
- }
+ /**
+ * @param nodeId
+ * @param uuid
+ * @return
+ */
+ private Inventory createEquipment(String nodeId, String uuid) {
+ return new InventoryBuilder().setNodeId(nodeId).setParentUuid("").setDescription("desc")
+ .setManufacturerName("manu").setUuid(uuid).build();
+ }
- /**
- * @param devType
- * @param nodename3
- * @return
- */
- private static NetworkElementConnectionEntity createNeConnection(String nodeId, NetworkElementDeviceType devType) {
- return new NetworkElementConnectionBuilder().setNodeId(nodeId).setHost("host").setPort(1234L)
- .setCoreModelCapability("123").setStatus(ConnectionLogStatus.Connected).setDeviceType(devType)
- .setIsRequired(true).build();
- }
+ /**
+ * @param devType
+ * @param nodename3
+ * @return
+ */
+ private static NetworkElementConnectionEntity createNeConnection(String nodeId, NetworkElementDeviceType devType) {
+ return new NetworkElementConnectionBuilder().setNodeId(nodeId).setHost("host").setPort(1234L)
+ .setCoreModelCapability("123").setStatus(ConnectionLogStatus.Connected).setDeviceType(devType)
+ .setIsRequired(true).build();
+ }
- /**
- * @param nodeId
- * @param objectId
- * @param problem
- * @param severity
- * @param counter
- * @return
- */
- private static FaultlogEntity createFaultLog(String nodeId, String objectId, String problem, SeverityType severity,
- int counter) {
- return new FaultlogBuilder().setNodeId(nodeId).setObjectId(objectId).setProblem(problem).setSeverity(severity)
- .setCounter(counter).setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp())
- .setSourceType(SourceType.Netconf).build();
- }
+ /**
+ * @param nodeId
+ * @param objectId
+ * @param problem
+ * @param severity
+ * @param counter
+ * @return
+ */
+ private static FaultlogEntity createFaultLog(String nodeId, String objectId, String problem, SeverityType severity,
+ int counter) {
+ return new FaultlogBuilder().setNodeId(nodeId).setObjectId(objectId).setProblem(problem).setSeverity(severity)
+ .setCounter(counter).setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp())
+ .setSourceType(SourceType.Netconf).build();
+ }
- /**
- * @param nodeId
- * @param objectId
- * @param attributeName
- * @param newValue
- * @param counter
- * @return
- */
- private static EventlogEntity createEventLog(String nodeId, String objectId, String attributeName, String newValue,
- int counter) {
- return new EventlogBuilder().setNodeId(nodeId).setObjectId(objectId).setAttributeName(attributeName)
- .setNewValue(newValue).setCounter(counter)
- .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setSourceType(SourceType.Netconf)
- .build();
- }
+ /**
+ * @param nodeId
+ * @param objectId
+ * @param attributeName
+ * @param newValue
+ * @param counter
+ * @return
+ */
+ private static EventlogEntity createEventLog(String nodeId, String objectId, String attributeName, String newValue,
+ int counter) {
+ return new EventlogBuilder().setNodeId(nodeId).setObjectId(objectId).setAttributeName(attributeName)
+ .setNewValue(newValue).setCounter(counter)
+ .setTimestamp(NetconfTimeStampImpl.getConverter().getTimeStamp()).setSourceType(SourceType.Netconf)
+ .build();
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
index e2009411a..52ca2999d 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestFilterConversion.java
@@ -39,36 +39,39 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public class TestFilterConversion {
- private static final String PROPERTY = "node-id";
- private static final String PROPERTY2 = "_id";
- private static final String PROPERTY3 = "timestamp";
+ private static final String PROPERTY = "node-id";
+ private static final String PROPERTY2 = "_id";
+ private static final String PROPERTY3 = "timestamp";
- @Test
- public void testQuestionMark() {
- List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
- QueryBuilder query = QueryByFilter.fromFilter(filters);
- System.out.println(query.toJSON());
- assertTrue(query.toJSON().contains("{1,1}"));
- assertNotNull(QueryByFilter.getFilter(filters, PROPERTY));
- assertNull(QueryByFilter.getFilter(filters, PROPERTY2));
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
- new FilterBuilder().setProperty(PROPERTY2).setFiltervalue("abc").build());
- query = QueryByFilter.fromFilter(filters);
- System.out.println(query.toJSON());
- assertNotNull(QueryByFilter.getFilter(filters, PROPERTY2));
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
- new FilterBuilder().setProperty(PROPERTY3).setFiltervalue("<2019-06-13T15:00:12.0Z").build());
- query = QueryByFilter.fromFilter(filters);
- List<Sortorder> sortorder = Arrays
- .asList(new SortorderBuilder().setProperty(PROPERTY).setSortorder(SortOrder.Ascending).build());
- QueryByFilter.setSortOrder(query, sortorder);
- assertNotNull(QueryByFilter.getSortOrder(sortorder, PROPERTY));
- }
- @Test
- public void testSortorder() {
- String f = "{\"input\":{\"filter\":[],\"sortorder\":[{\"property\":\"source-type\",\"sortorder\":\"ascending\"}],\"pagination\":{\"size\":10,\"page\":1}}}";
-
- QueryBuilder query = QueryByFilter.setSortOrder(QueryByFilter.fromFilter(null), Arrays.asList(new SortorderBuilder().setProperty("source-type").setSortorder(SortOrder.Ascending).build()));
- System.out.println(query.toJSON());
- }
+ @Test
+ public void testQuestionMark() {
+ List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build());
+ QueryBuilder query = QueryByFilter.fromFilter(filters);
+ System.out.println(query.toJSON());
+ assertTrue(query.toJSON().contains("{1,1}"));
+ assertNotNull(QueryByFilter.getFilter(filters, PROPERTY));
+ assertNull(QueryByFilter.getFilter(filters, PROPERTY2));
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
+ new FilterBuilder().setProperty(PROPERTY2).setFiltervalue("abc").build());
+ query = QueryByFilter.fromFilter(filters);
+ System.out.println(query.toJSON());
+ assertNotNull(QueryByFilter.getFilter(filters, PROPERTY2));
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY).setFiltervalue("si?ba").build(),
+ new FilterBuilder().setProperty(PROPERTY3).setFiltervalue("<2019-06-13T15:00:12.0Z").build());
+ query = QueryByFilter.fromFilter(filters);
+ List<Sortorder> sortorder =
+ Arrays.asList(new SortorderBuilder().setProperty(PROPERTY).setSortorder(SortOrder.Ascending).build());
+ QueryByFilter.setSortOrder(query, sortorder);
+ assertNotNull(QueryByFilter.getSortOrder(sortorder, PROPERTY));
+ }
+
+ @Test
+ public void testSortorder() {
+ String f =
+ "{\"input\":{\"filter\":[],\"sortorder\":[{\"property\":\"source-type\",\"sortorder\":\"ascending\"}],\"pagination\":{\"size\":10,\"page\":1}}}";
+
+ QueryBuilder query = QueryByFilter.setSortOrder(QueryByFilter.fromFilter(null), Arrays
+ .asList(new SortorderBuilder().setProperty("source-type").setSortorder(SortOrder.Ascending).build()));
+ System.out.println(query.toJSON());
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
index 57e1438cc..cc880d1ad 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestImplementation.java
@@ -44,43 +44,43 @@ import net.bytebuddy.implementation.bytecode.StackSize;
*/
public class TestImplementation {
- @Test
- public void test() {
- TestConfig.setSDNRDBURLEnv();
- DataProviderImpl impl = new DataProviderImpl();
- impl.setRpcProviderService(new RpcProviderService() {
-
- @Override
- public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
- T implementation, Set<InstanceIdentifier<?>> paths) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
- T implementation) {
- // TODO Auto-generated method stub
- return null;
- }
- });
- impl.setMediatorServerServlet(new MsServlet());
- impl.setAboutServlet(new AboutHttpServlet());
- try {
- impl.init();
- } catch (Exception e) {
- e.printStackTrace();
- fail("failed to init impl: "+e.getMessage());
- }
-
- impl.setStatus(StatusKey.CLUSTER_SIZE, "3");
- impl.setReadyStatus(true);
- try {
- impl.close();
- } catch (Exception e) {
- e.printStackTrace();
- fail("failed to close impl: "+e.getMessage());
- }
- }
-
+ @Test
+ public void test() {
+ TestConfig.setSDNRDBURLEnv();
+ DataProviderImpl impl = new DataProviderImpl();
+ impl.setRpcProviderService(new RpcProviderService() {
+
+ @Override
+ public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
+ T implementation, Set<InstanceIdentifier<?>> paths) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <S extends RpcService, T extends S> ObjectRegistration<T> registerRpcImplementation(Class<S> type,
+ T implementation) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ });
+ impl.setMediatorServerServlet(new MsServlet());
+ impl.setAboutServlet(new AboutHttpServlet());
+ try {
+ impl.init();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("failed to init impl: " + e.getMessage());
+ }
+
+ impl.setStatus(StatusKey.CLUSTER_SIZE, "3");
+ impl.setReadyStatus(true);
+ try {
+ impl.close();
+ } catch (Exception e) {
+ e.printStackTrace();
+ fail("failed to close impl: " + e.getMessage());
+ }
+ }
+
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
index 271fe2858..6c22b0ea1 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMaintenanceServiceData.java
@@ -49,14 +49,16 @@ public class TestMaintenanceServiceData {
private static final String NODEID = "tmsnode1";
private static final String NODEID2 = "tmsnode2";
+
@BeforeClass
public static void init() throws Exception {
dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
- service = dbProvider.getHtDatabaseMaintenance();
+ service = dbProvider.getHtDatabaseMaintenance();
}
+
@Test
public void test() throws InterruptedException {
clearDbEntity(Entity.Maintenancemode);
@@ -67,25 +69,29 @@ public class TestMaintenanceServiceData {
obj = service.getMaintenance(NODEID);
assertNotNull(obj);
List<MaintenanceEntity> list = service.getAll();
- assertEquals("Verify for two ids", 2,list.size());
+ assertEquals("Verify for two ids", 2, list.size());
service.deleteIfNotRequired(NODEID);
obj = service.getMaintenance(NODEID);
assertNull("Check if first id was removed", obj);
- obj = service.setMaintenance(createMaintenance(NODEID,true));
+ obj = service.setMaintenance(createMaintenance(NODEID, true));
}
+
/**
* @param nodeId
* @param active
* @return
*/
private static MaintenanceEntity createMaintenance(String nodeId, Boolean active) {
- return new MaintenanceBuilder().setNodeId(nodeId).setActive(active).setProblem("problem").setObjectIdRef("idref").build();
+ return new MaintenanceBuilder().setNodeId(nodeId).setActive(active).setProblem("problem")
+ .setObjectIdRef("idref").build();
}
+
/**
* Delete
+ *
* @param entity
*/
private static void clearDbEntity(Entity entity) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
index 3192b7f7d..edd0f9edb 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestMediatorServerService.java
@@ -45,52 +45,54 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
*
*/
public class TestMediatorServerService {
- private static final String SERVERID = null;
- private static ElasticSearchDataProvider dbProvider;
- private static HtDatabaseClient dbRawProvider;
- private static MediatorServerDataProvider service = null;
+ private static final String SERVERID = null;
+ private static ElasticSearchDataProvider dbProvider;
+ private static HtDatabaseClient dbRawProvider;
+ private static MediatorServerDataProvider service = null;
-
- @BeforeClass
- public static void init() throws Exception {
- dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
- dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
- dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
- service = new MediatorServerDataProvider(TestCRUDforDatabase.hosts);
-
-
- }
- @Test
- public void test() {
- clearDbEntity(Entity.MediatorServer);
- System.out.println(service.triggerReloadSync());
- String dbServerId="abc";
- String host = service.getHostUrl(dbServerId);
- assertNull(host);
- final String NAME="ms1";
- final String HOST = "http://10.20.30.40:7070";
- CreateMediatorServerOutputBuilder output = null;
- try {
- output = dbProvider.createMediatorServer(new CreateMediatorServerInputBuilder().setName(NAME).setUrl(HOST).build());
- } catch (IOException e) {
- e.printStackTrace();
- fail("unable to create ms entry: "+e.getMessage());
- }
- System.out.println(service.triggerReloadSync());
- host = service.getHostUrl(output.getId());
- assertEquals(HOST, host);
-
- }
-
- private static void clearDbEntity(Entity entity) {
- DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName());
- query.setQuery(QueryBuilders.matchAllQuery().toJSON());
- try {
- dbRawProvider.deleteByQuery(query);
- } catch (IOException e) {
- e.printStackTrace();
- }
- TestCRUDforDatabase.trySleep(1000);
- }
+ @BeforeClass
+ public static void init() throws Exception {
+
+ dbProvider = new ElasticSearchDataProvider(TestCRUDforDatabase.hosts);
+ dbProvider.waitForYellowDatabaseStatus(30, TimeUnit.SECONDS);
+ dbRawProvider = new HtDatabaseClient(TestCRUDforDatabase.hosts);
+ service = new MediatorServerDataProvider(TestCRUDforDatabase.hosts);
+
+
+ }
+
+ @Test
+ public void test() {
+ clearDbEntity(Entity.MediatorServer);
+ System.out.println(service.triggerReloadSync());
+ String dbServerId = "abc";
+ String host = service.getHostUrl(dbServerId);
+ assertNull(host);
+ final String NAME = "ms1";
+ final String HOST = "http://10.20.30.40:7070";
+ CreateMediatorServerOutputBuilder output = null;
+ try {
+ output = dbProvider
+ .createMediatorServer(new CreateMediatorServerInputBuilder().setName(NAME).setUrl(HOST).build());
+ } catch (IOException e) {
+ e.printStackTrace();
+ fail("unable to create ms entry: " + e.getMessage());
+ }
+ System.out.println(service.triggerReloadSync());
+ host = service.getHostUrl(output.getId());
+ assertEquals(HOST, host);
+
+ }
+
+ private static void clearDbEntity(Entity entity) {
+ DeleteByQueryRequest query = new DeleteByQueryRequest(entity.getName());
+ query.setQuery(QueryBuilders.matchAllQuery().toJSON());
+ try {
+ dbRawProvider.deleteByQuery(query);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ TestCRUDforDatabase.trySleep(1000);
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java
index 83b28a29f..f7a5a841c 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfNodeBuilder.java
@@ -44,11 +44,11 @@ public class TestNetconfNodeBuilder {
System.out.println(netconfNode);
Credentials credentials = netconfNode.getCredentials();
- System.out.println("Class: "+credentials.getClass()+"\nContent: "+credentials);
+ System.out.println("Class: " + credentials.getClass() + "\nContent: " + credentials);
if (credentials instanceof LoginPassword) {
- LoginPassword loginPassword = (LoginPassword)credentials;
- System.out.println("User: "+loginPassword.getUsername()+" Password"+loginPassword.getPassword());
+ LoginPassword loginPassword = (LoginPassword) credentials;
+ System.out.println("User: " + loginPassword.getUsername() + " Password" + loginPassword.getPassword());
} else {
System.out.println("Not expected class");
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java
index 104f2272f..1081e3cfe 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNetconfTimestamp.java
@@ -45,48 +45,51 @@ public class TestNetconfTimestamp {
private static final String NETCONF_DEF4_MILLIS_STRING_MALFORMAED = "2020-01-09T05:40:41.0000Z";
private static final long NETCONF_DEF_MILLIS_LONG = 1578548441100L;
- private static NetconfTimeStamp converter =NetconfTimeStampImpl.getConverter();
+ private static NetconfTimeStamp converter = NetconfTimeStampImpl.getConverter();
- @Test
+ @Test
public void test() {
String ts = converter.getTimeStampAsNetconfString();
final Pattern pattern = Pattern.compile(regex, Pattern.MULTILINE);
final Matcher matcher = pattern.matcher(ts);
assertTrue(matcher.find());
}
- @Test
- public void testMillis() {
- long millis=converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING);
- assertEquals(NETCONF_DEF_MILLIS_LONG,millis);
-
- }
- @Test(expected = IllegalArgumentException.class)
- public void testMillisMalformed() {
- long millis=converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING_MALFORMAED);
-
- }
-
- @Test
- public void test2() {
- assertEquals(NETCONF_DEF_MILLIS_STRING,converter.getTimeStampFromNetconf(NETCONF_DEF2_MILLIS_STRING));
- assertEquals(NETCONF_DEF3_MILLIS_STRING_CORRECTED,converter.getTimeStampFromNetconf(NETCONF_DEF3_MILLIS_STRING));
- assertTrue(converter.getTimeStampFromNetconf(NETCONF_DEF4_MILLIS_STRING_MALFORMAED).startsWith("Malformed"));
- }
-
- @Test
- public void test3() {
- Date dt = converter.getDateFromNetconf(NETCONF_DEF_MILLIS_STRING);
- final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
- c.setTime(dt);
- assertEquals(2020,c.get(Calendar.YEAR));
- assertEquals(0,c.get(Calendar.MONTH));
- assertEquals(9,c.get(Calendar.DAY_OF_MONTH));
- assertEquals(5,c.get(Calendar.HOUR_OF_DAY));
- assertEquals(40,c.get(Calendar.MINUTE));
- assertEquals(41,c.get(Calendar.SECOND));
- assertEquals(100,c.get(Calendar.MILLISECOND));
-
-
- assertEquals(NETCONF_DEF_MILLIS_STRING,converter.getTimeStampAsNetconfString(dt));
- }
+
+ @Test
+ public void testMillis() {
+ long millis = converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING);
+ assertEquals(NETCONF_DEF_MILLIS_LONG, millis);
+
+ }
+
+ @Test(expected = IllegalArgumentException.class)
+ public void testMillisMalformed() {
+ long millis = converter.getTimeStampFromNetconfAsMilliseconds(NETCONF_DEF_MILLIS_STRING_MALFORMAED);
+
+ }
+
+ @Test
+ public void test2() {
+ assertEquals(NETCONF_DEF_MILLIS_STRING, converter.getTimeStampFromNetconf(NETCONF_DEF2_MILLIS_STRING));
+ assertEquals(NETCONF_DEF3_MILLIS_STRING_CORRECTED,
+ converter.getTimeStampFromNetconf(NETCONF_DEF3_MILLIS_STRING));
+ assertTrue(converter.getTimeStampFromNetconf(NETCONF_DEF4_MILLIS_STRING_MALFORMAED).startsWith("Malformed"));
+ }
+
+ @Test
+ public void test3() {
+ Date dt = converter.getDateFromNetconf(NETCONF_DEF_MILLIS_STRING);
+ final Calendar c = Calendar.getInstance(TimeZone.getTimeZone("GMT"));
+ c.setTime(dt);
+ assertEquals(2020, c.get(Calendar.YEAR));
+ assertEquals(0, c.get(Calendar.MONTH));
+ assertEquals(9, c.get(Calendar.DAY_OF_MONTH));
+ assertEquals(5, c.get(Calendar.HOUR_OF_DAY));
+ assertEquals(40, c.get(Calendar.MINUTE));
+ assertEquals(41, c.get(Calendar.SECOND));
+ assertEquals(100, c.get(Calendar.MILLISECOND));
+
+
+ assertEquals(NETCONF_DEF_MILLIS_STRING, converter.getTimeStampAsNetconfString(dt));
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
index a21b01b28..f9c8812a8 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestNuMappings.java
@@ -38,13 +38,13 @@ public class TestNuMappings {
Faultcurrent c = new FaultcurrentBuilder().setSeverity(SeverityType.Critical).build();
YangToolsMapper mapper = new YangToolsMapper();
try {
- System.out.println(mapper.writeValueAsString(c)+"<=>"+SeverityType.Critical.getName());
+ System.out.println(mapper.writeValueAsString(c) + "<=>" + SeverityType.Critical.getName());
} catch (JsonProcessingException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
try {
- Faultcurrent f=mapper.readValue( "{\"severity\":\"Critical\"}", Faultcurrent.class);
+ Faultcurrent f = mapper.readValue("{\"severity\":\"Critical\"}", Faultcurrent.class);
System.out.println(f);
System.out.println(mapper.writeValueAsString(f));
} catch (JsonParseException e) {
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
index a71bfc824..39377d730 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestTimestampFilter.java
@@ -36,121 +36,138 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.entity.input.FilterBuilder;
public class TestTimestampFilter {
-
- @Test
- public void testTimestampRange() {
- final String PROPERTY_TIMESTAMP = "timestamp";
- List<Filter> filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2017*").build());
- QueryBuilder query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2017-01-01T00:00:00.0Z", "2018-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "3000-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("20*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "2100-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("205*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2060-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-1*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-0*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-10-10T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-02*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-02T00:00:00.0Z", "2050-10-03T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T1*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T10:00:00.0Z", "2050-10-14T20:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:4*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:40:00.0Z", "2050-10-14T12:50:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:5*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:50.0Z", "2050-10-14T12:43:00.0Z");
-
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:56*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:56.0Z", "2050-10-14T12:42:57.0Z");
- }
-
- @Test
- public void testExtra() {
- final String PROPERTY_TIMESTAMP = "end";
- List<Filter> filters = null;
- QueryBuilder query= null;
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19T*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
- filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020*").build());
- query= QueryByFilter.fromFilter(filters );
- assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-01-01T00:00:00.0Z", "2021-01-01T00:00:00.0Z");
-
- }
- private void assertRange(JSONObject rangeQuery,String property,String lower,String upper) {
- System.out.println("==test for "+rangeQuery.toString());
- assertTrue(rangeQuery.has("range"));
- assertTrue(rangeQuery.getJSONObject("range").has(property));
- JSONObject o=rangeQuery.getJSONObject("range").getJSONObject(property);
- assertNotNull(o);
- assertTrue(o.has("lt"));
- assertEquals(upper, o.getString("lt"));
- assertTrue(o.has("gte"));
- assertEquals(lower, o.getString("gte"));
- System.out.println("succeeded");
- }
+
+ @Test
+ public void testTimestampRange() {
+ final String PROPERTY_TIMESTAMP = "timestamp";
+ List<Filter> filters =
+ Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2017*").build());
+ QueryBuilder query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2017-01-01T00:00:00.0Z", "2018-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "3000-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("20*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2000-01-01T00:00:00.0Z", "2100-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("205*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2060-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-01-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-1*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2051-01-01T00:00:00.0Z");
+
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters =
+ Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-11-01T00:00:00.0Z");
+
+ filters =
+ Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-0*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-01T00:00:00.0Z", "2050-10-10T00:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-02*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-02T00:00:00.0Z", "2050-10-03T00:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T00:00:00.0Z", "2050-10-15T00:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T1*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T10:00:00.0Z", "2050-10-14T20:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:00:00.0Z", "2050-10-14T13:00:00.0Z");
+
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:4*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:40:00.0Z", "2050-10-14T12:50:00.0Z");
+
+ filters = Arrays.asList(
+ new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(
+ new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:00.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(
+ new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:5*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:50.0Z", "2050-10-14T12:43:00.0Z");
+
+ filters = Arrays.asList(
+ new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2050-10-14T12:42:56*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2050-10-14T12:42:56.0Z", "2050-10-14T12:42:57.0Z");
+ }
+
+ @Test
+ public void testExtra() {
+ final String PROPERTY_TIMESTAMP = "end";
+ List<Filter> filters = null;
+ QueryBuilder query = null;
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19T*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
+ filters = Arrays
+ .asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020-02-19*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-02-19T00:00:00.0Z", "2020-02-20T00:00:00.0Z");
+ filters = Arrays.asList(new FilterBuilder().setProperty(PROPERTY_TIMESTAMP).setFiltervalue("2020*").build());
+ query = QueryByFilter.fromFilter(filters);
+ assertRange(query.getInner(), PROPERTY_TIMESTAMP, "2020-01-01T00:00:00.0Z", "2021-01-01T00:00:00.0Z");
+
+ }
+
+ private void assertRange(JSONObject rangeQuery, String property, String lower, String upper) {
+ System.out.println("==test for " + rangeQuery.toString());
+ assertTrue(rangeQuery.has("range"));
+ assertTrue(rangeQuery.getJSONObject("range").has(property));
+ JSONObject o = rangeQuery.getJSONObject("range").getJSONObject(property);
+ assertNotNull(o);
+ assertTrue(o.has("lt"));
+ assertEquals(upper, o.getString("lt"));
+ assertTrue(o.has("gte"));
+ assertEquals(lower, o.getString("gte"));
+ System.out.println("succeeded");
+ }
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java
index f9267179b..ac97cfe0e 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangCloning.java
@@ -22,7 +22,7 @@
package org.onap.ccsdk.features.sdnr.wt.dataprovider.test;
public class TestYangCloning {
-/*
+ /*
@Test
public void testEquipment() {
EquipmentBuilder equipmentBuilder = new EquipmentBuilder();
@@ -35,20 +35,20 @@ public class TestYangCloning {
Equipment equipment = equipmentBuilder.build();
InventoryEntity output = YangToolsCloner.instance().cloneToBuilder(equipment, new InventoryBuilder())
.setNodeId("node1").setUuid("a.a.a").setId("node1"+"/"+"a.a.a").build();
-
-
+
+
System.out.println("source:");
System.out.println(equipment);
System.out.println("result:");
System.out.println(output);
-
-
+
+
}
@Test
public void testFaultCurrent() {
ProblemNotificationXml source = new ProblemNotificationXml("node", "uuid", "problem", InternalSeverity.Critical,54,InternalDateAndTime.getTestpattern());
FaultcurrentEntity output = YangToolsCloner.instance().clone(source,Faultcurrent.class);
-
+
System.out.println("source:");
System.out.println(source);
System.out.println("result:");
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
index 2561a670b..4a0834248 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangGenSalMapping.java
@@ -80,9 +80,10 @@ public class TestYangGenSalMapping {
loginPasswordBuilder.setPassword("myTestPassword");
netconfNodeBuilder.setCredentials(loginPasswordBuilder.build());
- OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder = new OdlHelloMessageCapabilitiesBuilder();
+ OdlHelloMessageCapabilitiesBuilder odlHelloMessageCapabilitiesBuilder =
+ new OdlHelloMessageCapabilitiesBuilder();
List<Uri> uriList = new ArrayList<>();
- uriList.add( new Uri("test.uri") );
+ uriList.add(new Uri("test.uri"));
odlHelloMessageCapabilitiesBuilder.setCapability(uriList);
netconfNodeBuilder.setOdlHelloMessageCapabilities(odlHelloMessageCapabilitiesBuilder.build());
@@ -98,7 +99,7 @@ public class TestYangGenSalMapping {
NetconfNode generatedNode = mapper.readValue(res.getBytes(), NetconfNode.class);
out(generatedNode.toString()); // Print it with specified indentation
// Compare result
- out("Equal? "+netconfNode.equals(generatedNode));
+ out("Equal? " + netconfNode.equals(generatedNode));
}
static class TestDataObjectBuilder implements Builder<TestDataObject> {
@@ -118,20 +119,22 @@ public class TestYangGenSalMapping {
}
@Test
- public void test2() throws ClassNotFoundException {
+ public void test2() throws ClassNotFoundException {
- int databasePort = Integer.valueOf(System.getProperty("databaseport")!=null?System.getProperty("databaseport"):"49200");
- System.out.println("DB Port: "+databasePort);
+ int databasePort = Integer
+ .valueOf(System.getProperty("databaseport") != null ? System.getProperty("databaseport") : "49200");
+ System.out.println("DB Port: " + databasePort);
- HostInfo[] HOSTINFOS = new HostInfo[] { new HostInfo("localhost", databasePort ,Protocol.HTTP)};
+ HostInfo[] HOSTINFOS = new HostInfo[] {new HostInfo("localhost", databasePort, Protocol.HTTP)};
DatabaseClient db = new HtDatabaseClient(HOSTINFOS);
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data> dataRW =
- new EsDataObjectReaderWriter<>(db, "inventorytest", org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
+ new EsDataObjectReaderWriter<>(db, "inventorytest",
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data.class);
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d1;
d1 = getInventoryDataBuilder("MyDescription", 23L).build();
- String id = dataRW.write(d1,null);
+ String id = dataRW.write(d1, null);
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.Data d2;
d2 = dataRW.read(id);
@@ -141,7 +144,7 @@ public class TestYangGenSalMapping {
}
@Test
- public void test3() throws IOException {
+ public void test3() throws IOException {
PerformanceDataBuilder performanceBuilder = new PerformanceDataBuilder();
performanceBuilder.setEs(99);
@@ -190,59 +193,29 @@ public class TestYangGenSalMapping {
@Test
public void test5() throws IOException {
- String jsonString = "{\n" +
- " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n" +
- " \"node-name\": \"Sim2230\",\n" +
- " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n" +
- " \"scanner-id\": \"PM_RADIO_15M_14\",\n" +
- " \"layer-protocol-name\": \"MWPS\",\n" +
- " \"granularity-period\": \"Period15Min\",\n" +
- " \"radio-signal-id\": \"Test8\",\n" +
- " \"suspect-interval-flag\": false,\n" +
- " \"performance-data\": {\n" +
- " \"time4096-states-l\": -1,\n" +
- " \"time16-states-s\": -1,\n" +
- " \"tx-level-max\": 3,\n" +
- " \"snir-max\": -99,\n" +
- " \"time16-states\": 0,\n" +
- " \"time64-states\": 900,\n" +
- " \"unavailability\": 0,\n" +
- " \"time8192-states-l\": -1,\n" +
- " \"time512-states\": -1,\n" +
- " \"xpd-min\": -99,\n" +
- " \"xpd-avg\": -99,\n" +
- " \"tx-level-avg\": 3,\n" +
- " \"tx-level-min\": 3,\n" +
- " \"rf-temp-min\": -99,\n" +
- " \"rf-temp-avg\": -99,\n" +
- " \"snir-avg\": -99,\n" +
- " \"snir-min\": -99,\n" +
- " \"time-period\": 900,\n" +
- " \"time2-states\": 0,\n" +
- " \"time4-states\": 0,\n" +
- " \"time8-states\": -1,\n" +
- " \"ses\": 0,\n" +
- " \"time2048-states-l\": -1,\n" +
- " \"time2048-states\": -1,\n" +
- " \"xpd-max\": -99,\n" +
- " \"rf-temp-max\": -99,\n" +
- " \"time8192-states\": -1,\n" +
- " \"time128-states\": -1,\n" +
- " \"time256-states\": -1,\n" +
- " \"rx-level-min\": -44,\n" +
- " \"rx-level-avg\": -44,\n" +
- " \"time1024-states-l\": -1,\n" +
- " \"es\": 0,\n" +
- " \"cses\": 0,\n" +
- " \"time4-states-s\": 0,\n" +
- " \"time1024-states\": -1,\n" +
- " \"time512-states-l\": -1,\n" +
- " \"time4096-states\": -1,\n" +
- " \"rx-level-max\": -45,\n" +
- " \"defect-blocks-sum\": -1,\n" +
- " \"time32-states\": -1\n" +
- " }\n" +
- "}";
+ String jsonString = "{\n" + " \"time-stamp\": \"2017-03-01T06:45:00.0Z\",\n"
+ + " \"node-name\": \"Sim2230\",\n" + " \"uuid-interface\": \"LP-MWPS-TTP-RADIO\",\n"
+ + " \"scanner-id\": \"PM_RADIO_15M_14\",\n" + " \"layer-protocol-name\": \"MWPS\",\n"
+ + " \"granularity-period\": \"Period15Min\",\n" + " \"radio-signal-id\": \"Test8\",\n"
+ + " \"suspect-interval-flag\": false,\n" + " \"performance-data\": {\n"
+ + " \"time4096-states-l\": -1,\n" + " \"time16-states-s\": -1,\n"
+ + " \"tx-level-max\": 3,\n" + " \"snir-max\": -99,\n" + " \"time16-states\": 0,\n"
+ + " \"time64-states\": 900,\n" + " \"unavailability\": 0,\n"
+ + " \"time8192-states-l\": -1,\n" + " \"time512-states\": -1,\n"
+ + " \"xpd-min\": -99,\n" + " \"xpd-avg\": -99,\n" + " \"tx-level-avg\": 3,\n"
+ + " \"tx-level-min\": 3,\n" + " \"rf-temp-min\": -99,\n"
+ + " \"rf-temp-avg\": -99,\n" + " \"snir-avg\": -99,\n" + " \"snir-min\": -99,\n"
+ + " \"time-period\": 900,\n" + " \"time2-states\": 0,\n"
+ + " \"time4-states\": 0,\n" + " \"time8-states\": -1,\n" + " \"ses\": 0,\n"
+ + " \"time2048-states-l\": -1,\n" + " \"time2048-states\": -1,\n"
+ + " \"xpd-max\": -99,\n" + " \"rf-temp-max\": -99,\n"
+ + " \"time8192-states\": -1,\n" + " \"time128-states\": -1,\n"
+ + " \"time256-states\": -1,\n" + " \"rx-level-min\": -44,\n"
+ + " \"rx-level-avg\": -44,\n" + " \"time1024-states-l\": -1,\n" + " \"es\": 0,\n"
+ + " \"cses\": 0,\n" + " \"time4-states-s\": 0,\n" + " \"time1024-states\": -1,\n"
+ + " \"time512-states-l\": -1,\n" + " \"time4096-states\": -1,\n"
+ + " \"rx-level-max\": -45,\n" + " \"defect-blocks-sum\": -1,\n"
+ + " \"time32-states\": -1\n" + " }\n" + "}";
// Map to JSON String to Object
Data generatedNode = mapper.readValue(jsonString.getBytes(), Data.class);
@@ -254,11 +227,12 @@ public class TestYangGenSalMapping {
@Test
public void test6() throws IOException, ClassNotFoundException {
out(method());
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
+ HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] {new HostInfo("sdnrdb", 9200, Protocol.HTTP)});
String PMDATA15M_TYPE = "historicalperformance15min";
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> pm15mRW =
- new EsDataObjectReaderWriter<>(dbClient, PMDATA15M_TYPE, org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
+ new EsDataObjectReaderWriter<>(dbClient, PMDATA15M_TYPE,
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data.class);
pm15mRW.setEsIdAttributeName("_nodeName");
ReadPmdata15mListInputBuilder inputBuilder = new ReadPmdata15mListInputBuilder();
@@ -277,12 +251,13 @@ public class TestYangGenSalMapping {
QueryBuilder query = fromFilter(input.getFilter()).from((page - 1) * pageSize).size(pageSize);
setSortOrder(query, input.getSortorder());
- SearchResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result=pm15mRW.doReadAll(query);
+ SearchResult<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Data> result =
+ pm15mRW.doReadAll(query);
- out("Found: "+result.getHits().size());
- int t=0;
+ out("Found: " + result.getHits().size());
+ int t = 0;
for (Data hit : result.getHits()) {
- out("Hit "+t+++":"+hit);
+ out("Hit " + t++ + ":" + hit);
}
setPagination(outputBuilder, page, pageSize, result.getTotal());
outputBuilder.setData(result.getHits());
@@ -292,19 +267,20 @@ public class TestYangGenSalMapping {
public void test7() throws IOException, ClassNotFoundException {
out(method());
String ESDATATYPE_MEDIATORSERVER = Entity.MediatorServer.getName();
- HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] { new HostInfo("sdnrdb", 9200, Protocol.HTTP) });
+ HtDatabaseClient dbClient = new HtDatabaseClient(new HostInfo[] {new HostInfo("sdnrdb", 9200, Protocol.HTTP)});
EsDataObjectReaderWriter<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data> mediatorserverRW;
mediatorserverRW = new EsDataObjectReaderWriter<>(dbClient, ESDATATYPE_MEDIATORSERVER,
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.mediator.server.list.output.Data.class)
- .setWriteInterface(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity.class)
- .setEsIdAttributeName("_id");
+ .setWriteInterface(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.MediatorServerEntity.class)
+ .setEsIdAttributeName("_id");
CreateMediatorServerInputBuilder inputBuilder = new CreateMediatorServerInputBuilder();
inputBuilder.setName("Hans");
inputBuilder.setUrl("MyGreatUrl");
- String id = mediatorserverRW.write(inputBuilder.build(),"testid");
+ String id = mediatorserverRW.write(inputBuilder.build(), "testid");
System.out.println(id);
}
@@ -314,15 +290,15 @@ public class TestYangGenSalMapping {
out(method());
String input;
input = "id-dd-dd";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
input = "idDdGg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
input = "_idDdGg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
input = "--ff--gfg";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
input = "";
- System.out.println("Map " + input + " to "+YangToolsMapper.toCamelCaseAttributeName(input));
+ System.out.println("Map " + input + " to " + YangToolsMapper.toCamelCaseAttributeName(input));
}
/* ---------------------------------
@@ -333,7 +309,8 @@ public class TestYangGenSalMapping {
return nameofCurrMethod;
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder getInventoryDataBuilder(String description, long treeLevel) {
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder getInventoryDataBuilder(
+ String description, long treeLevel) {
org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder dataBuilder =
new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.inventory.list.output.DataBuilder();
dataBuilder.setDescription(description);
@@ -371,10 +348,9 @@ public class TestYangGenSalMapping {
if (filters == null || filters.size() == 0) {
return QueryBuilders.matchAllQuery();
- } else if(filters.size()==1){
+ } else if (filters.size() == 1) {
return QueryBuilders.matchQuery(filters.get(0).getProperty(), filters.get(0).getFiltervalue());
- }
- else {
+ } else {
BoolQueryBuilder query = new BoolQueryBuilder();
for (Filter fi : filters) {
query.must(QueryBuilders.matchQuery((prefix != null ? prefix : "") + fi.getProperty(),
@@ -384,6 +360,7 @@ public class TestYangGenSalMapping {
}
}
+
private static QueryBuilder setSortOrder(QueryBuilder query, @Nullable List<Sortorder> sortorder) {
return setSortOrder(query, sortorder, "");
}
@@ -401,9 +378,12 @@ public class TestYangGenSalMapping {
}
- private static void setPagination(ReadPmdata15mListOutputBuilder outputBuilder, long page, long pageSize, long totalSize) {
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Pagination value = new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder()
- .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize)).build();
+ private static void setPagination(ReadPmdata15mListOutputBuilder outputBuilder, long page, long pageSize,
+ long totalSize) {
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.Pagination value =
+ new org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.read.pmdata._15m.list.output.PaginationBuilder()
+ .setPage(BigInteger.valueOf(page)).setSize(pageSize).setTotal(BigInteger.valueOf(totalSize))
+ .build();
outputBuilder.setPagination(value);
}
diff --git a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
index 7341d5a33..19bd76cae 100644
--- a/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
+++ b/sdnr/wt/data-provider/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/test/TestYangProvider.java
@@ -55,145 +55,150 @@ import static org.mockito.Mockito.when;
public class TestYangProvider {
- private static final String TESTPATH = "cache/schema/";
-
-
- @BeforeClass
- public static void init() {
- Set<PosixFilePermission> perms;
- FileAttribute<?> attr;
- perms = EnumSet.noneOf(PosixFilePermission.class);
-
- perms.add(PosixFilePermission.OWNER_READ);
- perms.add(PosixFilePermission.OWNER_WRITE);
- perms.add(PosixFilePermission.OWNER_EXECUTE);
-
- attr = PosixFilePermissions.asFileAttribute(perms);
- try {
- Files.createDirectories(new File(TESTPATH).toPath(),attr);
- new File(TESTPATH+new YangFilename("module1","2010-01-01").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module2","2010-01-01").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module2","2010-04-01").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module3","2010-01-01").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module4","2010-05-01").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module5","2010-01-11").getFilename()).createNewFile();
- new File(TESTPATH+new YangFilename("module6","2010-01-01").getFilename()).createNewFile();
- } catch (IOException | ParseException e) {
-
- }
- }
- @AfterClass
- public static void deinit() {
- try {
- Files.walk(new File("cache").toPath())
- .sorted(Comparator.reverseOrder())
- .map(Path::toFile)
- .forEach(File::delete);
- } catch (IOException e) {
- System.err.println(e);
- }
- }
- @Test
- public void testExisting() {
- YangFileProvider provider= new YangFileProvider(TESTPATH);
- assertTrue(provider.hasFileForModule("module1","2010-01-01"));
- assertTrue(provider.hasFileForModule("module2"));
- assertTrue(provider.hasFileForModule("module3"));
- assertFalse(provider.hasFileForModule("module5","2010-01-01"));
- }
- @Test
- public void testRevision() throws ParseException {
- SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd");
- YangFileProvider provider= new YangFileProvider(TESTPATH);
- YangFilename f1 = provider.getFileForModule("module1","2010-01-01");
- assertEquals("module1",f1.getModule());
- assertEquals(sdf.parse("2010-01-01"),f1.getRevision());
- YangFilename f2 = provider.getFileForModule("module2");
- assertEquals("module2",f2.getModule());
- assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
- f2 = provider.getFileForModule("module2","2010-02-01");
- assertEquals("module2",f2.getModule());
- assertEquals(sdf.parse("2010-04-01"),f2.getRevision());
- YangFilename f3 = provider.getFileForModule("module3");
- assertEquals("module3",f3.getModule());
- assertEquals(sdf.parse("2010-01-01"),f3.getRevision());
- f3 = provider.getFileForModule("module3","2010-04-01");
- assertNull(f3);
- }
- @Test
- public void testServlet() throws IOException, ServletException {
- HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
- HttpServletRequest req = mock(HttpServletRequest.class);
- HttpServletResponse resp = mock(HttpServletResponse.class);
-
- when(req.getRequestURI()).thenReturn("/yang-schema/module1");
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- when(resp.getOutputStream()).thenReturn(printOut);
- servlet.doGet(req,resp);
- verify(resp).setStatus(200);
- verify(resp).setContentType("text/plain");
-
- }
- @Test
- public void testServletBad() throws IOException, ServletException {
- HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
- HttpServletRequest req = mock(HttpServletRequest.class);
- HttpServletResponse resp = mock(HttpServletResponse.class);
-
- when(req.getRequestURI()).thenReturn("/yang-schema/module1/2020-01-01");
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- when(resp.getOutputStream()).thenReturn(printOut);
- servlet.doGet(req,resp);
- verify(resp).sendError(HttpServletResponse.SC_NOT_FOUND);
-
- }
- @Test
- public void testServletNear() throws IOException, ServletException {
- HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
- HttpServletRequest req = mock(HttpServletRequest.class);
- HttpServletResponse resp = mock(HttpServletResponse.class);
-
- when(req.getRequestURI()).thenReturn("/yang-schema/module2/2010-03-01");
- StringWriter out = new StringWriter();
- ServletOutputStream printOut = new ServletOutputStream() {
-
- @Override
- public void write(int arg0) throws IOException {
- out.write(arg0);
- }
- };
- when(resp.getOutputStream()).thenReturn(printOut);
- servlet.doGet(req,resp);
- verify(resp).setStatus(200);
- verify(resp).setContentType("text/plain");
-
- }
- private static class HelpYangSchemaHttpServlet extends YangSchemaHttpServlet{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
-
- @Override
- public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
- super.doGet(req, resp);
- }
- }
+ private static final String TESTPATH = "cache/schema/";
+
+
+ @BeforeClass
+ public static void init() {
+ Set<PosixFilePermission> perms;
+ FileAttribute<?> attr;
+ perms = EnumSet.noneOf(PosixFilePermission.class);
+
+ perms.add(PosixFilePermission.OWNER_READ);
+ perms.add(PosixFilePermission.OWNER_WRITE);
+ perms.add(PosixFilePermission.OWNER_EXECUTE);
+
+ attr = PosixFilePermissions.asFileAttribute(perms);
+ try {
+ Files.createDirectories(new File(TESTPATH).toPath(), attr);
+ new File(TESTPATH + new YangFilename("module1", "2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module2", "2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module2", "2010-04-01").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module3", "2010-01-01").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module4", "2010-05-01").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module5", "2010-01-11").getFilename()).createNewFile();
+ new File(TESTPATH + new YangFilename("module6", "2010-01-01").getFilename()).createNewFile();
+ } catch (IOException | ParseException e) {
+
+ }
+ }
+
+ @AfterClass
+ public static void deinit() {
+ try {
+ Files.walk(new File("cache").toPath()).sorted(Comparator.reverseOrder()).map(Path::toFile)
+ .forEach(File::delete);
+ } catch (IOException e) {
+ System.err.println(e);
+ }
+ }
+
+ @Test
+ public void testExisting() {
+ YangFileProvider provider = new YangFileProvider(TESTPATH);
+ assertTrue(provider.hasFileForModule("module1", "2010-01-01"));
+ assertTrue(provider.hasFileForModule("module2"));
+ assertTrue(provider.hasFileForModule("module3"));
+ assertFalse(provider.hasFileForModule("module5", "2010-01-01"));
+ }
+
+ @Test
+ public void testRevision() throws ParseException {
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+ YangFileProvider provider = new YangFileProvider(TESTPATH);
+ YangFilename f1 = provider.getFileForModule("module1", "2010-01-01");
+ assertEquals("module1", f1.getModule());
+ assertEquals(sdf.parse("2010-01-01"), f1.getRevision());
+ YangFilename f2 = provider.getFileForModule("module2");
+ assertEquals("module2", f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"), f2.getRevision());
+ f2 = provider.getFileForModule("module2", "2010-02-01");
+ assertEquals("module2", f2.getModule());
+ assertEquals(sdf.parse("2010-04-01"), f2.getRevision());
+ YangFilename f3 = provider.getFileForModule("module3");
+ assertEquals("module3", f3.getModule());
+ assertEquals(sdf.parse("2010-01-01"), f3.getRevision());
+ f3 = provider.getFileForModule("module3", "2010-04-01");
+ assertNull(f3);
+ }
+
+ @Test
+ public void testServlet() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req, resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+
+ @Test
+ public void testServletBad() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module1/2020-01-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req, resp);
+ verify(resp).sendError(HttpServletResponse.SC_NOT_FOUND);
+
+ }
+
+ @Test
+ public void testServletNear() throws IOException, ServletException {
+ HelpYangSchemaHttpServlet servlet = new HelpYangSchemaHttpServlet();
+ HttpServletRequest req = mock(HttpServletRequest.class);
+ HttpServletResponse resp = mock(HttpServletResponse.class);
+
+ when(req.getRequestURI()).thenReturn("/yang-schema/module2/2010-03-01");
+ StringWriter out = new StringWriter();
+ ServletOutputStream printOut = new ServletOutputStream() {
+
+ @Override
+ public void write(int arg0) throws IOException {
+ out.write(arg0);
+ }
+ };
+ when(resp.getOutputStream()).thenReturn(printOut);
+ servlet.doGet(req, resp);
+ verify(resp).setStatus(200);
+ verify(resp).setContentType("text/plain");
+
+ }
+
+ private static class HelpYangSchemaHttpServlet extends YangSchemaHttpServlet {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+
+ @Override
+ public void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
+ super.doGet(req, resp);
+ }
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
index a336c0f6f..821e3ec1e 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderImpl.java
@@ -62,14 +62,15 @@ import org.slf4j.LoggerFactory;
public class DataMigrationProviderImpl implements DataMigrationProviderService {
-
+
private static final Logger LOG = LoggerFactory.getLogger(DataMigrationProviderImpl.class);
private final HtDatabaseClient dbClient;
- public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll, long timeoutms) {
+ public DataMigrationProviderImpl(HostInfo[] hosts, String username, String password, boolean trustAll,
+ long timeoutms) {
- if(timeoutms>0) {
- Portstatus.waitSecondsTillAvailable(timeoutms/1000, hosts);
+ if (timeoutms > 0) {
+ Portstatus.waitSecondsTillAvailable(timeoutms / 1000, hosts);
}
this.dbClient = new HtDatabaseClient(hosts, username, password, trustAll);
}
@@ -148,8 +149,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
/**
- * export data
- * if file exists .1 (.n) will be created
+ * export data if file exists .1 (.n) will be created
*
*/
@Override
@@ -162,17 +162,17 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
LOG.info("output will be written to {}", filename);
//autodetect version
Release dbRelease = this.autoDetectRelease();
- if(dbRelease==null) {
+ if (dbRelease == null) {
report.error("unbable to detect db release. is database initialized?");
return report;
}
ReleaseInformation ri = ReleaseInformation.getInstance(dbRelease);
boolean componentsSucceeded = true;
- for(ComponentName c: ri.getComponents()) {
+ for (ComponentName c : ri.getComponents()) {
ComponentData data = new ComponentData(c);
- SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c),ri.getDataType(c),false);
+ SearchResult<SearchHit> result = this.dbClient.doReadAllJsonData(ri.getAlias(c), ri.getDataType(c), false);
data.addAll(result.getHits());
- container.addComponent(c, data );
+ container.addComponent(c, data);
}
try {
Files.write(new File(filename).toPath(), Arrays.asList(container.toJSON()), StandardCharsets.UTF_8);
@@ -192,7 +192,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
}
private String checkFilenameForWrite(String filename, int apdx) {
- File f = new File(String.format("$s.$d",filename,apdx));
+ File f = new File(String.format("$s.$d", filename, apdx));
if (!f.exists()) {
return filename;
}
@@ -209,18 +209,18 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
EsVersion dbVersion = this.readActualVersion();
AliasesEntryList aliases = this.readAliases();
IndicesEntryList indices = this.readIndices();
- if(indices==null) {
+ if (indices == null) {
return null;
}
List<Release> foundReleases = new ArrayList<>();
//if there are active aliases reduce indices to the active ones
- if(aliases!=null && aliases.size()>0) {
+ if (aliases != null && aliases.size() > 0) {
indices = indices.subList(aliases.getLinkedIndices());
}
- for(Release r:Release.values()) {
- if(r.isDbInRange(dbVersion)) {
+ for (Release r : Release.values()) {
+ if (r.isDbInRange(dbVersion)) {
ReleaseInformation ri = ReleaseInformation.getInstance(r);
- if(ri!=null && ri.containsIndices(indices)) {
+ if (ri != null && ri.containsIndices(indices)) {
foundReleases.add(r);
}
}
@@ -228,9 +228,11 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
if (foundReleases.size() == 1) {
return foundReleases.get(0);
}
- LOG.error("detect {} releases: {}. unable to detect for which one to do sth.",foundReleases.size(), foundReleases);
+ LOG.error("detect {} releases: {}. unable to detect for which one to do sth.", foundReleases.size(),
+ foundReleases);
return null;
}
+
private EsVersion readActualVersion() {
try {
GetInfoResponse response = this.dbClient.getInfo();
@@ -264,9 +266,9 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
}
@Override
- public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix,
- boolean forceRecreate,long timeoutms) {
- if(timeoutms>0) {
+ public boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate,
+ long timeoutms) {
+ if (timeoutms > 0) {
this.dbClient.waitForYellowStatus(timeoutms);
}
EsVersion dbVersion = this.readActualVersion();
@@ -278,7 +280,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return false;
}
if (forceRecreate) {
- this.clearDatabase(release, dbPrefix,0);
+ this.clearDatabase(release, dbPrefix, 0);
}
ReleaseInformation ri = ReleaseInformation.getInstance(release);
AliasesEntryList aliases = this.readAliases();
@@ -287,7 +289,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return false;
}
AcknowledgedResponse response = null;
- if(!ri.runPreInitCommands(this.dbClient)) {
+ if (!ri.runPreInitCommands(this.dbClient)) {
return false;
}
for (ComponentName component : ri.getComponents()) {
@@ -320,7 +322,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return false;
}
}
- if(!ri.runPostInitCommands(this.dbClient)) {
+ if (!ri.runPostInitCommands(this.dbClient)) {
return false;
}
return true;
@@ -329,7 +331,7 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
@Override
public boolean clearDatabase(Release release, String dbPrefix, long timeoutms) {
- if(timeoutms>0) {
+ if (timeoutms > 0) {
this.dbClient.waitForYellowStatus(timeoutms);
}
//check aliases
@@ -349,9 +351,9 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
if (entryToDelete != null) {
try {
LOG.info("deleting alias {} for index {}", entryToDelete.getAlias(), entryToDelete.getIndex());
- response=this.dbClient.deleteAlias(
+ response = this.dbClient.deleteAlias(
new DeleteAliasRequest(entryToDelete.getIndex(), entryToDelete.getAlias()));
- LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+ LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed");
} catch (IOException e) {
LOG.error(e.getMessage());
return false;
@@ -373,8 +375,8 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
if (entryToDelete != null) {
try {
LOG.info("deleting index {}", entryToDelete.getName());
- response=this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
- LOG.info(response.isResponseSucceeded()?"succeeded":"failed");
+ response = this.dbClient.deleteIndex(new DeleteIndexRequest(entryToDelete.getName()));
+ LOG.info(response.isResponseSucceeded() ? "succeeded" : "failed");
} catch (IOException e) {
LOG.error(e.getMessage());
return false;
@@ -386,39 +388,39 @@ public class DataMigrationProviderImpl implements DataMigrationProviderService {
return true;
}
- /**
- * @param timeoutms
- * @return
- */
- public boolean clearCompleteDatabase(long timeoutms) {
- if(timeoutms>0) {
+ /**
+ * @param timeoutms
+ * @return
+ */
+ public boolean clearCompleteDatabase(long timeoutms) {
+ if (timeoutms > 0) {
this.dbClient.waitForYellowStatus(timeoutms);
}
//check aliases and indices
- AliasesEntryList aliases = this.readAliases();
+ AliasesEntryList aliases = this.readAliases();
IndicesEntryList indices = this.readIndices();
if (aliases == null || indices == null) {
return false;
}
- for(AliasesEntry alias:aliases) {
- try {
- LOG.info("deleting alias {} for index {}",alias.getAlias(),alias.getIndex());
- this.dbClient.deleteAlias(new DeleteAliasRequest(alias.getIndex(), alias.getAlias()));
- } catch (IOException e) {
- LOG.error("problem deleting alias {}: {}",alias.getAlias(),e);
- return false;
- }
- }
- for(IndicesEntry index : indices) {
- try {
- LOG.info("deleting index {}",index.getName());
- this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName()));
- } catch (IOException e) {
- LOG.error("problem deleting index {}: {}",index.getName(),e);
- return false;
- }
+ for (AliasesEntry alias : aliases) {
+ try {
+ LOG.info("deleting alias {} for index {}", alias.getAlias(), alias.getIndex());
+ this.dbClient.deleteAlias(new DeleteAliasRequest(alias.getIndex(), alias.getAlias()));
+ } catch (IOException e) {
+ LOG.error("problem deleting alias {}: {}", alias.getAlias(), e);
+ return false;
+ }
+ }
+ for (IndicesEntry index : indices) {
+ try {
+ LOG.info("deleting index {}", index.getName());
+ this.dbClient.deleteIndex(new DeleteIndexRequest(index.getName()));
+ } catch (IOException e) {
+ LOG.error("problem deleting index {}: {}", index.getName(), e);
+ return false;
+ }
}
return true;
- }
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
index 5a0ec3b6a..0f1fc6c73 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/DataMigrationProviderService.java
@@ -29,43 +29,46 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
public interface DataMigrationProviderService {
- /**
- * import data from file and write these to database
- * @param filename source
- * @param dryrun only loading file and check consistency, not pushing into database
- * @return report
- * @throws FileNotFoundException
- * @throws Exception
- */
- DataMigrationReport importData(String filename,boolean dryrun) throws FileNotFoundException, Exception;
- /**
- * export current data to file
- * @param filename
- */
- DataMigrationReport exportData(String filename);
-
- /**
- *
- * @return
- */
- Release getCurrentVersion();
-
- /**
- * @param release
- * @param numShards
- * @param numReplicas
- * @param dbPrefix
- * @param forceRecreate
- * @param timeoutms
- * @return
- */
- boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate,
- long timeoutms);
- /**
- * clean up the database
- * all data will be removed
- * complete structure will be destroyed
- * @return
- */
- boolean clearDatabase(Release release, String dbPrefix, long timeoutms);
+ /**
+ * import data from file and write these to database
+ *
+ * @param filename source
+ * @param dryrun only loading file and check consistency, not pushing into database
+ * @return report
+ * @throws FileNotFoundException
+ * @throws Exception
+ */
+ DataMigrationReport importData(String filename, boolean dryrun) throws FileNotFoundException, Exception;
+
+ /**
+ * export current data to file
+ *
+ * @param filename
+ */
+ DataMigrationReport exportData(String filename);
+
+ /**
+ *
+ * @return
+ */
+ Release getCurrentVersion();
+
+ /**
+ * @param release
+ * @param numShards
+ * @param numReplicas
+ * @param dbPrefix
+ * @param forceRecreate
+ * @param timeoutms
+ * @return
+ */
+ boolean initDatabase(Release release, int numShards, int numReplicas, String dbPrefix, boolean forceRecreate,
+ long timeoutms);
+
+ /**
+ * clean up the database all data will be removed complete structure will be destroyed
+ *
+ * @return
+ */
+ boolean clearDatabase(Release release, String dbPrefix, long timeoutms);
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
index d06ffe1ee..c7775a96b 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/Program.java
@@ -43,7 +43,7 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.Release;
*/
public class Program {
- // constants
+ // constants
private static final String CMD_INITDB = "init";
private static final String CMD_CLEAR_DB = "delete";
private static final String CMD_CLEAR_DB_COMPLETE = "clear";
@@ -59,11 +59,11 @@ public class Program {
private static final String CMD_EXPORT_DESCRIPTION = "export data from database";
private static final String CMD_LIST_VERSION_DESCRIPTION = "list release versions";
- private static final List<String[]> commands = Arrays.asList(new String[] { CMD_INITDB, CMD_INITDB_DESCRIPTION },
- new String[] { CMD_CLEAR_DB, CMD_CLEAR_DB_DESCRIPTION },
- new String[] { CMD_CREATE_PLUGIN_INIT_FILE, CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION },
- new String[] { CMD_IMPORT, CMD_IMPORT_DESCRIPTION }, new String[] { CMD_EXPORT, CMD_EXPORT_DESCRIPTION },
- new String[] { CMD_LIST_VERSION, CMD_LIST_VERSION_DESCRIPTION });
+ private static final List<String[]> commands = Arrays.asList(new String[] {CMD_INITDB, CMD_INITDB_DESCRIPTION},
+ new String[] {CMD_CLEAR_DB, CMD_CLEAR_DB_DESCRIPTION},
+ new String[] {CMD_CREATE_PLUGIN_INIT_FILE, CMD_CREATE_PLUGIN_INIT_FILE_DESCRIPTION},
+ new String[] {CMD_IMPORT, CMD_IMPORT_DESCRIPTION}, new String[] {CMD_EXPORT, CMD_EXPORT_DESCRIPTION},
+ new String[] {CMD_LIST_VERSION, CMD_LIST_VERSION_DESCRIPTION});
private static final String APPLICATION_NAME = "SDNR DataMigrationTool";
private static final int DEFAULT_SHARDS = 5;
private static final int DEFAULT_REPLICAS = 1;
@@ -81,24 +81,24 @@ public class Program {
private static final String OPTION_TRUSTINSECURESSL_SHORT = "k";
private static final String OPTION_DATABASE_SHORT = "db";
private static final String OPTION_COMMAND_SHORT = "c";
- private static final String OPTION_DATABASEUSER_SHORT = "dbu";
- private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp";
- private static final String OPTION_DATABASEPREFIX_SHORT = "p";
- private static final String OPTION_DATABASEWAIT_SHORT = "w";
- private static final String OPTION_HELP_SHORT = "h";
+ private static final String OPTION_DATABASEUSER_SHORT = "dbu";
+ private static final String OPTION_DATABASEPASSWORD_SHORT = "dbp";
+ private static final String OPTION_DATABASEPREFIX_SHORT = "p";
+ private static final String OPTION_DATABASEWAIT_SHORT = "w";
+ private static final String OPTION_HELP_SHORT = "h";
// end of constants
-
- // variables
+
+ // variables
private static Options options = init();
private static Log LOG = null;
// end of variables
-
+
// public methods
public static void main(String[] args) {
- System.exit( main2(args) );
+ System.exit(main2(args));
}
// end of public methods
-
+
// private methods
@SuppressWarnings("unchecked")
private static <T> T getOptionOrDefault(CommandLine cmd, String option, T def) throws ParseException {
@@ -156,7 +156,7 @@ public class Program {
CommandLineParser parser = new DefaultParser();
HelpFormatter formatter = new HelpFormatter();
CommandLine cmd = null;
-
+
try {
cmd = parser.parse(options, args);
} catch (ParseException e) {
@@ -175,72 +175,72 @@ public class Program {
}
try {
- if(getOptionOrDefault(cmd, OPTION_HELP_SHORT, false)) {
- printHelp(formatter);
- return 0;
- }
- } catch (ParseException e2) {
- return exit(e2);
- }
+ if (getOptionOrDefault(cmd, OPTION_HELP_SHORT, false)) {
+ printHelp(formatter);
+ return 0;
+ }
+ } catch (ParseException e2) {
+ return exit(e2);
+ }
final String command = cmd.getOptionValue(OPTION_COMMAND_SHORT);
- if(command==null) {
- printHelp(formatter);
+ if (command == null) {
+ printHelp(formatter);
return 1;
}
switch (command) {
- case CMD_INITDB:
- try {
- cmd_init_db(cmd);
- } catch (Exception e1) {
- return exit(e1);
- }
- break;
- case CMD_CLEAR_DB:
- try {
- cmd_clear_db(cmd);
- } catch (Exception e1) {
- return exit(e1);
- }
- break;
- case CMD_CLEAR_DB_COMPLETE:
- try {
- cmd_clear_db_complete(cmd);
- } catch (Exception e1) {
- return exit(e1);
- }
- break;
- case CMD_CREATE_PLUGIN_INIT_FILE:
- try {
- String of = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
- if (of == null) {
- throw new Exception("please add the parameter output-file");
+ case CMD_INITDB:
+ try {
+ cmd_init_db(cmd);
+ } catch (Exception e1) {
+ return exit(e1);
}
- MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
- } catch (Exception e) {
- return exit(e);
- }
- break;
- case CMD_IMPORT:
- try {
- cmd_dbimport(cmd);
- } catch (Exception e1) {
- return exit(e1);
- }
- break;
- case CMD_EXPORT:
- try {
- cmd_dbexport(cmd);
- } catch (Exception e) {
- return exit(e);
- }
- break;
- case CMD_LIST_VERSION:
- cmd_listversion();
- break;
+ break;
+ case CMD_CLEAR_DB:
+ try {
+ cmd_clear_db(cmd);
+ } catch (Exception e1) {
+ return exit(e1);
+ }
+ break;
+ case CMD_CLEAR_DB_COMPLETE:
+ try {
+ cmd_clear_db_complete(cmd);
+ } catch (Exception e1) {
+ return exit(e1);
+ }
+ break;
+ case CMD_CREATE_PLUGIN_INIT_FILE:
+ try {
+ String of = getOptionOrDefault(cmd, OPTION_OUTPUTFILE_SHORT, null);
+ if (of == null) {
+ throw new Exception("please add the parameter output-file");
+ }
+ MavenDatabasePluginInitFile.create(Release.CURRENT_RELEASE, of);
+ } catch (Exception e) {
+ return exit(e);
+ }
+ break;
+ case CMD_IMPORT:
+ try {
+ cmd_dbimport(cmd);
+ } catch (Exception e1) {
+ return exit(e1);
+ }
+ break;
+ case CMD_EXPORT:
+ try {
+ cmd_dbexport(cmd);
+ } catch (Exception e) {
+ return exit(e);
+ }
+ break;
+ case CMD_LIST_VERSION:
+ cmd_listversion();
+ break;
- default:
- printHelp(formatter);
- return 1;
+ default:
+ printHelp(formatter);
+ return 1;
}
return 0;
}
@@ -266,7 +266,7 @@ public class Program {
}
- private static void cmd_dbimport(CommandLine cmd) throws Exception {
+ private static void cmd_dbimport(CommandLine cmd) throws Exception {
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
@@ -275,12 +275,12 @@ public class Program {
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
DataMigrationReport report = service.importData(filename, false);
LOG.info(report);
- if(!report.completed()) {
+ if (!report.completed()) {
throw new Exception("db import seems to be not executed completed");
}
}
@@ -294,12 +294,12 @@ public class Program {
if (filename == null) {
throw new Exception("please add output file parameter");
}
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
DataMigrationReport report = service.exportData(filename);
LOG.info(report);
- if(!report.completed()) {
+ if (!report.completed()) {
throw new Exception("db export seems to be not executed completed");
}
@@ -321,23 +321,24 @@ public class Program {
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
- if (!service.clearDatabase(r, dbPrefix,timeoutms)) {
+ if (!service.clearDatabase(r, dbPrefix, timeoutms)) {
throw new Exception("failed to init database");
}
}
+
private static void cmd_clear_db_complete(CommandLine cmd) throws Exception {
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
if (!service.clearCompleteDatabase(timeoutms)) {
- throw new Exception("failed to init database");
+ throw new Exception("failed to init database");
}
}
@@ -348,13 +349,13 @@ public class Program {
String dbUrl = getOptionOrDefault(cmd, OPTION_DATABASE_SHORT, DEFAULT_DBURL);
String dbPrefix = getOptionOrDefault(cmd, OPTION_DATABASEPREFIX_SHORT, DEFAULT_DBPREFIX);
String username = getOptionOrDefault(cmd, OPTION_DATABASEUSER_SHORT, null);
- String password = getOptionOrDefault(cmd,OPTION_DATABASEPASSWORD_SHORT, null);
+ String password = getOptionOrDefault(cmd, OPTION_DATABASEPASSWORD_SHORT, null);
boolean trustAll = getOptionOrDefault(cmd, OPTION_TRUSTINSECURESSL_SHORT, false);
- long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30)*1000;
- DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] { HostInfo.parse(dbUrl) },
+ long timeoutms = getOptionOrDefault(cmd, OPTION_DATABASEWAIT_SHORT, 30) * 1000;
+ DataMigrationProviderImpl service = new DataMigrationProviderImpl(new HostInfo[] {HostInfo.parse(dbUrl)},
username, password, trustAll, timeoutms);
boolean forceRecreate = cmd.hasOption(OPTION_FORCE_RECREATE_SHORT);
- if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate,timeoutms)) {
+ if (!service.initDatabase(r, numShards, numReplicas, dbPrefix, forceRecreate, timeoutms)) {
throw new Exception("failed to init database");
}
@@ -364,8 +365,10 @@ public class Program {
Options result = new Options();
result.addOption(createOption(OPTION_COMMAND_SHORT, "cmd", true, "command to execute", false));
result.addOption(createOption(OPTION_DATABASE_SHORT, "dburl", true, "database url", false));
- result.addOption(createOption(OPTION_DATABASEUSER_SHORT, "db-username", true, "database basic auth username", false));
- result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, "db-password", true, "database basic auth password", false));
+ result.addOption(
+ createOption(OPTION_DATABASEUSER_SHORT, "db-username", true, "database basic auth username", false));
+ result.addOption(createOption(OPTION_DATABASEPASSWORD_SHORT, "db-password", true,
+ "database basic auth password", false));
result.addOption(createOption(OPTION_REPLICAS_SHORT, "replicas", true, "amount of replicas", false));
result.addOption(createOption(OPTION_SHARDS_SHORT, "shards", true, "amount of shards", false));
result.addOption(createOption(OPTION_DATABASEPREFIX_SHORT, "prefix", true, "prefix for db indices", false));
@@ -373,13 +376,14 @@ public class Program {
result.addOption(createOption(OPTION_DEBUG_SHORT, "verbose", false, "verbose mode", false));
result.addOption(createOption(OPTION_TRUSTINSECURESSL_SHORT, "trust-insecure", false,
"trust insecure ssl certs", false));
- result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, "wait", true, "wait for yellow status with timeout in seconds", false));
+ result.addOption(createOption(OPTION_DATABASEWAIT_SHORT, "wait", true,
+ "wait for yellow status with timeout in seconds", false));
result.addOption(
createOption(OPTION_FORCE_RECREATE_SHORT, "force-recreate", false, "delete if sth exists", false));
result.addOption(createOption(OPTION_SILENT_SHORT, OPTION_SILENT, false, "prevent console output", false));
result.addOption(createOption(OPTION_OUTPUTFILE_SHORT, "output-file", true, "file to write into", false));
result.addOption(createOption(OPTION_INPUTFILE_SHORT, "input-file", true, "file to read from", false));
- result.addOption(createOption(OPTION_HELP_SHORT,"help",false,"show help",false));
+ result.addOption(createOption(OPTION_HELP_SHORT, "help", false, "show help", false));
return result;
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
index ccae07c0e..cb20025ff 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/ReleaseInformation.java
@@ -37,152 +37,159 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseIn
public abstract class ReleaseInformation {
- // variables
- private final Release release;
- private final Map<ComponentName, DatabaseInfo> dbMap;
- // end of variables
-
- // constructors
- public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) {
- this.release = r;
- this.dbMap = dbMap;
- }
- // end of constructors
-
- /**
- * get database alias for component
- * @param name
- * @return alias or null if not exists
- */
- public String getAlias(ComponentName name) {
- return this.getAlias(name, "");
- }
-
- public String getAlias(ComponentName name, String prefix) {
- return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias;
- }
-
- /**
- * get index name for component
- * @param comp
- * @return null if component does not exists in this release, otherwise index name
- */
- public String getIndex(ComponentName comp) {
- return this.getIndex(comp, "");
- }
-
- /**
- * get index name for component with prefix
- * @param comp
- * @param prefix
- * @return null if component does not exists in this release, otherwise index name
- */
- public String getIndex(ComponentName comp, String prefix) {
- return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix()));
- }
-
- /**
- * get database datatype (doctype) for component
- * @param name
- * @return datatype or null if not exists
- */
- public String getDataType(ComponentName name) {
- return dbMap.get(name) == null ? null : dbMap.get(name).doctype;
- }
-
- public String getDatabaseMapping(ComponentName name) {
- return dbMap.get(name) == null ? null : dbMap.get(name).getMapping();
- }
-
- /**
- * get database doctype definition for component
- * @param name
- * @return mappings or null if not exists
- */
- public String getDatabaseMapping(ComponentName name, boolean useStrict) {
- return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict);
- }
-
- /**
- * get database settings definition for component
- * @param name
- * @return settings or null if not exists
- */
- public String getDatabaseSettings(ComponentName name, int shards, int replicas) {
- return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas);
- }
-
- /**
- * get converter for component data
- * @param dst destination release
- * @param comp component to convert
- * @return
- */
- public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- if (dst == this.release && this.getComponents().contains(comp)) {
- return new KeepDataSearchHitConverter(comp);
- }
- return null;
- }
-
- public static ReleaseInformation getInstance(Release r) {
- switch (r) {
- case EL_ALTO:
- return new ElAltoReleaseInformation();
- case FRANKFURT_R1:
- return new FrankfurtReleaseInformation();
- case GUILIN:
- return new GuilinReleaseInformation();
- default:
- return null;
- }
- }
-
- /**
- * @return
- */
- public Set<ComponentName> getComponents() {
- return dbMap.keySet();
- }
-
- /**
- * @param component
- * @return
- */
- public boolean hasOwnDbIndex(ComponentName component) {
- return this.getDatabaseMapping(component) != null;
- }
-
- /**
- * @param indices
- * @return true if components of this release are covered by the given indices
- */
- protected boolean containsIndices(IndicesEntryList indices) {
-
- if (this.dbMap.size() <= 0) {
- return false;
- }
- for (DatabaseInfo entry : this.dbMap.values()) {
- String dbIndexName = entry.getIndex(this.release.getDBSuffix());
- if (indices.findByIndex(dbIndexName) == null) {
- return false;
- }
- }
- return true;
-
- }
-
- /**
- * @param dbClient
- * @return if succeeded or not
- */
- protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient);
-
- /**
- *
- * @param dbClient
- * @return if succeeded or not
- */
- protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient);
+ // variables
+ private final Release release;
+ private final Map<ComponentName, DatabaseInfo> dbMap;
+ // end of variables
+
+ // constructors
+ public ReleaseInformation(Release r, Map<ComponentName, DatabaseInfo> dbMap) {
+ this.release = r;
+ this.dbMap = dbMap;
+ }
+ // end of constructors
+
+ /**
+ * get database alias for component
+ *
+ * @param name
+ * @return alias or null if not exists
+ */
+ public String getAlias(ComponentName name) {
+ return this.getAlias(name, "");
+ }
+
+ public String getAlias(ComponentName name, String prefix) {
+ return dbMap.get(name) == null ? null : prefix + dbMap.get(name).alias;
+ }
+
+ /**
+ * get index name for component
+ *
+ * @param comp
+ * @return null if component does not exists in this release, otherwise index name
+ */
+ public String getIndex(ComponentName comp) {
+ return this.getIndex(comp, "");
+ }
+
+ /**
+ * get index name for component with prefix
+ *
+ * @param comp
+ * @param prefix
+ * @return null if component does not exists in this release, otherwise index name
+ */
+ public String getIndex(ComponentName comp, String prefix) {
+ return dbMap.get(comp) == null ? null : (prefix + dbMap.get(comp).getIndex(this.release.getDBSuffix()));
+ }
+
+ /**
+ * get database datatype (doctype) for component
+ *
+ * @param name
+ * @return datatype or null if not exists
+ */
+ public String getDataType(ComponentName name) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).doctype;
+ }
+
+ public String getDatabaseMapping(ComponentName name) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).getMapping();
+ }
+
+ /**
+ * get database doctype definition for component
+ *
+ * @param name
+ * @return mappings or null if not exists
+ */
+ public String getDatabaseMapping(ComponentName name, boolean useStrict) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).getMapping(useStrict);
+ }
+
+ /**
+ * get database settings definition for component
+ *
+ * @param name
+ * @return settings or null if not exists
+ */
+ public String getDatabaseSettings(ComponentName name, int shards, int replicas) {
+ return dbMap.get(name) == null ? null : dbMap.get(name).getSettings(shards, replicas);
+ }
+
+ /**
+ * get converter for component data
+ *
+ * @param dst destination release
+ * @param comp component to convert
+ * @return
+ */
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ if (dst == this.release && this.getComponents().contains(comp)) {
+ return new KeepDataSearchHitConverter(comp);
+ }
+ return null;
+ }
+
+ public static ReleaseInformation getInstance(Release r) {
+ switch (r) {
+ case EL_ALTO:
+ return new ElAltoReleaseInformation();
+ case FRANKFURT_R1:
+ return new FrankfurtReleaseInformation();
+ case GUILIN:
+ return new GuilinReleaseInformation();
+ default:
+ return null;
+ }
+ }
+
+ /**
+ * @return
+ */
+ public Set<ComponentName> getComponents() {
+ return dbMap.keySet();
+ }
+
+ /**
+ * @param component
+ * @return
+ */
+ public boolean hasOwnDbIndex(ComponentName component) {
+ return this.getDatabaseMapping(component) != null;
+ }
+
+ /**
+ * @param indices
+ * @return true if components of this release are covered by the given indices
+ */
+ protected boolean containsIndices(IndicesEntryList indices) {
+
+ if (this.dbMap.size() <= 0) {
+ return false;
+ }
+ for (DatabaseInfo entry : this.dbMap.values()) {
+ String dbIndexName = entry.getIndex(this.release.getDBSuffix());
+ if (indices.findByIndex(dbIndexName) == null) {
+ return false;
+ }
+ }
+ return true;
+
+ }
+
+ /**
+ * @param dbClient
+ * @return if succeeded or not
+ */
+ protected abstract boolean runPreInitCommands(HtDatabaseClient dbClient);
+
+ /**
+ *
+ * @param dbClient
+ * @return if succeeded or not
+ */
+ protected abstract boolean runPostInitCommands(HtDatabaseClient dbClient);
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java
index 2f4f067bd..c58c3cdf7 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/BaseSearchHitConverter.java
@@ -26,26 +26,28 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
public abstract class BaseSearchHitConverter implements SearchHitConverter {
- private ComponentName name;
- public BaseSearchHitConverter(ComponentName name) {
- this.name = name;
- }
-
- protected SearchHit getSearchHit(String index, String type, String id, JSONObject data) {
- JSONObject o = new JSONObject();
- o.put("_index", index);
- o.put("_type", type);
- o.put("_id", id);
- o.put("_source", data);
- return new SearchHit(o);
- }
- @Override
- public ComponentData convert(DataContainer container) {
- ComponentData srcData = container.getComponents().get(this.name);
- ComponentData dstData = new ComponentData(srcData.getName());
- for(SearchHit sh:srcData) {
- dstData.add(this.convert(sh));
- }
- return dstData;
- }
+ private ComponentName name;
+
+ public BaseSearchHitConverter(ComponentName name) {
+ this.name = name;
+ }
+
+ protected SearchHit getSearchHit(String index, String type, String id, JSONObject data) {
+ JSONObject o = new JSONObject();
+ o.put("_index", index);
+ o.put("_type", type);
+ o.put("_id", id);
+ o.put("_source", data);
+ return new SearchHit(o);
+ }
+
+ @Override
+ public ComponentData convert(DataContainer container) {
+ ComponentData srcData = container.getComponents().get(this.name);
+ ComponentData dstData = new ComponentData(srcData.getName());
+ for (SearchHit sh : srcData) {
+ dstData.add(this.convert(sh));
+ }
+ return dstData;
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java
index fd361843c..5d6f0079f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentData.java
@@ -25,38 +25,38 @@ import java.util.ArrayList;
import org.json.JSONArray;
import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
-public class ComponentData extends ArrayList<SearchHit>{
-
- /**
- *
- */
- private static final long serialVersionUID = 1L;
- private final ComponentName name;
-
- public ComponentData(ComponentName name) {
- this(name,null);
- }
-
- public ComponentData(ComponentName name,JSONArray a) {
- this.name = name;
- if(a!=null) {
- for(int i=0;i<a.length();i++) {
- this.add(new SearchHit(a.getJSONObject(i)));
- }
- }
-
- }
-
- public ComponentName getName() {
- return this.name;
- }
-
- public JSONArray toJsonArray() {
- JSONArray a = new JSONArray();
- for(SearchHit h:this) {
- a.put(h.getRaw());
- }
- return a;
- }
-
+public class ComponentData extends ArrayList<SearchHit> {
+
+ /**
+ *
+ */
+ private static final long serialVersionUID = 1L;
+ private final ComponentName name;
+
+ public ComponentData(ComponentName name) {
+ this(name, null);
+ }
+
+ public ComponentData(ComponentName name, JSONArray a) {
+ this.name = name;
+ if (a != null) {
+ for (int i = 0; i < a.length(); i++) {
+ this.add(new SearchHit(a.getJSONObject(i)));
+ }
+ }
+
+ }
+
+ public ComponentName getName() {
+ return this.name;
+ }
+
+ public JSONArray toJsonArray() {
+ JSONArray a = new JSONArray();
+ for (SearchHit h : this) {
+ a.put(h.getRaw());
+ }
+ return a;
+ }
+
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
index 9c5ef5c53..ab3f311a1 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ComponentName.java
@@ -23,37 +23,34 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
public enum ComponentName {
- CONNECTIONLOG("connectionlog"),
- EVENTLOG("eventlog"),
- FAULTLOG("faultlog"),
- FAULTCURRENT("faultcurrent"),
- HISTORICAL_PERFORMANCE_15M("historicalperformance15m"),
- HISTORICAL_PERFORMANCE_24H("historicalperformance24h"),
- INVENTORY("inventory"),
- INVENTORYTOPLEVEL("inventorytoplevel"),
- MAINTENANCE("maintenance"),
- MEDIATOR_SERVER("mediator-server"),
- REQUIRED_NETWORKELEMENT("required-networkelement");
-
- private final String value;
+ CONNECTIONLOG("connectionlog"), EVENTLOG("eventlog"), FAULTLOG("faultlog"), FAULTCURRENT(
+ "faultcurrent"), HISTORICAL_PERFORMANCE_15M("historicalperformance15m"), HISTORICAL_PERFORMANCE_24H(
+ "historicalperformance24h"), INVENTORY("inventory"), INVENTORYTOPLEVEL(
+ "inventorytoplevel"), MAINTENANCE("maintenance"), MEDIATOR_SERVER(
+ "mediator-server"), REQUIRED_NETWORKELEMENT("required-networkelement");
- private ComponentName(String s) {
- this.value = s;
- }
- @Override
- public String toString() {
- return this.value;
- }
- public String getValue() {
- return value;
- }
- public static ComponentName getValueOf(String s) throws Exception {
- s = s.toLowerCase();
- for(ComponentName p:ComponentName.values()) {
- if(p.value.equals(s)) {
- return p;
- }
- }
- throw new Exception("value not found for "+s);
- }
-} \ No newline at end of file
+ private final String value;
+
+ private ComponentName(String s) {
+ this.value = s;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static ComponentName getValueOf(String s) throws Exception {
+ s = s.toLowerCase();
+ for (ComponentName p : ComponentName.values()) {
+ if (p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found for " + s);
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java
index 95c483736..49600320f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigData.java
@@ -23,13 +23,14 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
public class ConfigData {
- private final String[] lines;
+ private final String[] lines;
- public String[] getLines() {
- return this.lines;
- }
- public ConfigData(String content) {
- this.lines = content.split("\n");
- }
+ public String[] getLines() {
+ return this.lines;
+ }
+
+ public ConfigData(String content) {
+ this.lines = content.split("\n");
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java
index 181fe2006..da00cb24a 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/ConfigName.java
@@ -23,30 +23,31 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
public enum ConfigName {
- APIGATEWAY("apigateway"),
- DEVICEMANAGER("devicemanager"),
- DATAPROVIDER("dataprovider");
-
-
- private final String value;
-
- private ConfigName(String s) {
- this.value = s;
- }
- @Override
- public String toString() {
- return this.value;
- }
- public String getValue() {
- return value;
- }
- public static ConfigName getValueOf(String s) throws Exception {
- s = s.toLowerCase();
- for(ConfigName p:ConfigName.values()) {
- if(p.value.equals(s)) {
- return p;
- }
- }
- throw new Exception("value not found");
- }
-} \ No newline at end of file
+ APIGATEWAY("apigateway"), DEVICEMANAGER("devicemanager"), DATAPROVIDER("dataprovider");
+
+
+ private final String value;
+
+ private ConfigName(String s) {
+ this.value = s;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static ConfigName getValueOf(String s) throws Exception {
+ s = s.toLowerCase();
+ for (ConfigName p : ConfigName.values()) {
+ if (p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found");
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java
index f50969ed6..f23723773 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataContainer.java
@@ -41,101 +41,101 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.model.types.NetconfTimeStamp
*/
public class DataContainer {
- private final Release release;
- private final Date created;
- private final Map<ComponentName, ComponentData> components;
- private final Map<ConfigName, ConfigData> configs;
-
- public Release getRelease() {
- return this.release;
- }
-
- public boolean isCurrentRelease() {
- return this.release.equals(Release.CURRENT_RELEASE);
- }
-
- public Date getCreated() {
- return this.created;
- }
-
- public Map<ComponentName, ComponentData> getComponents() {
- return this.components;
- }
-
- public Map<ConfigName, ConfigData> getConfigs() {
- return this.configs;
- }
-
- public DataContainer() {
- this(Release.CURRENT_RELEASE);
- }
-
- public DataContainer(Release release) {
- this(release, new Date());
- }
-
- public DataContainer(Release release, Date dt) {
- this.release = release;
- this.created = dt;
- this.components = new HashMap<>();
- this.configs = new HashMap<>();
- }
-
- public void addComponent(ComponentName name, ComponentData data) {
- this.components.put(name, data);
- }
-
- public void addConfig(ConfigName name, ConfigData data) {
- this.configs.put(name, data);
- }
-
- public static DataContainer load(File file) throws Exception {
- if(!file.exists()) {
- throw new FileNotFoundException();
- }
- SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
- JSONObject o = new JSONObject(new String(Files.readAllBytes(file.toPath())));
- DataContainer c = new DataContainer(Release.getValueOf(o.getString("release")),
- format.parse(o.getString("created")));
- JSONObject comps = o.getJSONObject("components");
-
- String k;
- ComponentName compKey;
- JSONArray compData;
- for (Object key : comps.keySet()) {
- k = String.valueOf(key);
- // check component if exists
- compKey = ComponentName.getValueOf(k);
- compData = comps.getJSONArray(k);
- c.addComponent(compKey, new ComponentData(compKey, compData));
- }
- ConfigName confKey;
- ConfigData confData;
- JSONObject confs = o.getJSONObject("configs");
- for (Object key : confs.keySet()) {
- k = String.valueOf(key);
- confKey = ConfigName.getValueOf(k);
- confData = new ConfigData(confs.getString(k));
- c.addConfig(confKey, confData);
- }
- return c;
- }
-
- public String toJSON() {
- JSONObject o = new JSONObject();
- o.put("release", this.release.getValue());
- o.put("created", NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(this.created));
- JSONObject compsJson = new JSONObject();
- JSONObject confsJson = new JSONObject();
- for (Entry<ComponentName, ComponentData> entry : this.components.entrySet()) {
- compsJson.put(entry.getKey().getValue(), entry.getValue().toJsonArray());
- }
- for (Entry<ConfigName, ConfigData> entry : this.configs.entrySet()) {
- confsJson.put(entry.getKey().getValue(), entry.getValue().toString());
- }
- o.put("components", compsJson);
- o.put("configs", confsJson);
- return o.toString();
- }
-
-} \ No newline at end of file
+ private final Release release;
+ private final Date created;
+ private final Map<ComponentName, ComponentData> components;
+ private final Map<ConfigName, ConfigData> configs;
+
+ public Release getRelease() {
+ return this.release;
+ }
+
+ public boolean isCurrentRelease() {
+ return this.release.equals(Release.CURRENT_RELEASE);
+ }
+
+ public Date getCreated() {
+ return this.created;
+ }
+
+ public Map<ComponentName, ComponentData> getComponents() {
+ return this.components;
+ }
+
+ public Map<ConfigName, ConfigData> getConfigs() {
+ return this.configs;
+ }
+
+ public DataContainer() {
+ this(Release.CURRENT_RELEASE);
+ }
+
+ public DataContainer(Release release) {
+ this(release, new Date());
+ }
+
+ public DataContainer(Release release, Date dt) {
+ this.release = release;
+ this.created = dt;
+ this.components = new HashMap<>();
+ this.configs = new HashMap<>();
+ }
+
+ public void addComponent(ComponentName name, ComponentData data) {
+ this.components.put(name, data);
+ }
+
+ public void addConfig(ConfigName name, ConfigData data) {
+ this.configs.put(name, data);
+ }
+
+ public static DataContainer load(File file) throws Exception {
+ if (!file.exists()) {
+ throw new FileNotFoundException();
+ }
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.S'Z'");
+ JSONObject o = new JSONObject(new String(Files.readAllBytes(file.toPath())));
+ DataContainer c =
+ new DataContainer(Release.getValueOf(o.getString("release")), format.parse(o.getString("created")));
+ JSONObject comps = o.getJSONObject("components");
+
+ String k;
+ ComponentName compKey;
+ JSONArray compData;
+ for (Object key : comps.keySet()) {
+ k = String.valueOf(key);
+ // check component if exists
+ compKey = ComponentName.getValueOf(k);
+ compData = comps.getJSONArray(k);
+ c.addComponent(compKey, new ComponentData(compKey, compData));
+ }
+ ConfigName confKey;
+ ConfigData confData;
+ JSONObject confs = o.getJSONObject("configs");
+ for (Object key : confs.keySet()) {
+ k = String.valueOf(key);
+ confKey = ConfigName.getValueOf(k);
+ confData = new ConfigData(confs.getString(k));
+ c.addConfig(confKey, confData);
+ }
+ return c;
+ }
+
+ public String toJSON() {
+ JSONObject o = new JSONObject();
+ o.put("release", this.release.getValue());
+ o.put("created", NetconfTimeStampImpl.getConverter().getTimeStampAsNetconfString(this.created));
+ JSONObject compsJson = new JSONObject();
+ JSONObject confsJson = new JSONObject();
+ for (Entry<ComponentName, ComponentData> entry : this.components.entrySet()) {
+ compsJson.put(entry.getKey().getValue(), entry.getValue().toJsonArray());
+ }
+ for (Entry<ConfigName, ConfigData> entry : this.configs.entrySet()) {
+ confsJson.put(entry.getKey().getValue(), entry.getValue().toString());
+ }
+ o.put("components", compsJson);
+ o.put("configs", confsJson);
+ return o.toString();
+ }
+
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java
index c8270bad6..9e0831631 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DataMigrationReport.java
@@ -26,29 +26,35 @@ import java.util.List;
public class DataMigrationReport {
- private boolean completed;
- private final List<String> logs;
- private final List<String> errors;
- public void setCompleted(boolean s) {
- this.completed = s;
- }
- public boolean completed() {
- return this.completed;
- }
- public void log(String format,Object ...params) {
- this.logs.add(String.format(format, params));
- }
- public void error(String format,Object ...params) {
- this.errors.add(String.format(format, params));
- }
- public DataMigrationReport() {
- this.completed = false;
- this.logs = new ArrayList<>();
- this.errors = new ArrayList<>();
- }
- @Override
- public String toString() {
- return "DataMigrationReport [completed=" + completed + ", logs=" + logs + ", errors=" + errors + "]";
- }
+ private boolean completed;
+ private final List<String> logs;
+ private final List<String> errors;
+
+ public void setCompleted(boolean s) {
+ this.completed = s;
+ }
+
+ public boolean completed() {
+ return this.completed;
+ }
+
+ public void log(String format, Object... params) {
+ this.logs.add(String.format(format, params));
+ }
+
+ public void error(String format, Object... params) {
+ this.errors.add(String.format(format, params));
+ }
+
+ public DataMigrationReport() {
+ this.completed = false;
+ this.logs = new ArrayList<>();
+ this.errors = new ArrayList<>();
+ }
+
+ @Override
+ public String toString() {
+ return "DataMigrationReport [completed=" + completed + ", logs=" + logs + ", errors=" + errors + "]";
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java
index 4d82a0901..4c38b5032 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/DatabaseInfo.java
@@ -26,43 +26,45 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data;
*
*/
public class DatabaseInfo {
- public final String doctype;
- public final String alias;
- private final String mapping;
- private final String settingsFormat;
- private final String index;
+ public final String doctype;
+ public final String alias;
+ private final String mapping;
+ private final String settingsFormat;
+ private final String index;
- public String getIndex(String version) {
- return this.index + version;
- }
+ public String getIndex(String version) {
+ return this.index + version;
+ }
- public DatabaseInfo(String alias, String doctype, String mapping) {
- this(alias, alias, doctype, mapping);
- }
+ public DatabaseInfo(String alias, String doctype, String mapping) {
+ this(alias, alias, doctype, mapping);
+ }
- public DatabaseInfo(String index, String alias, String doctype, String mapping) {
- this(index, alias, doctype, mapping,
- "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"
- + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}");
- }
+ public DatabaseInfo(String index, String alias, String doctype, String mapping) {
+ this(index, alias, doctype, mapping,
+ "{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"
+ + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}");
+ }
- public DatabaseInfo(String index, String alias, String doctype, String mapping, String settingsformat) {
- this.index = index;
- this.alias = alias;
- this.doctype = doctype;
- this.mapping = mapping;
- this.settingsFormat = settingsformat;
- }
-
- public String getMapping() {
- return this.getMapping(false);
- }
- public String getMapping(boolean useStrict) {
- return this.mapping == null ? null
- : String.format("{\"%s\":{%s\"properties\":%s}}", this.doctype,useStrict?"\"dynamic\": \"strict\",":"", this.mapping);
- }
+ public DatabaseInfo(String index, String alias, String doctype, String mapping, String settingsformat) {
+ this.index = index;
+ this.alias = alias;
+ this.doctype = doctype;
+ this.mapping = mapping;
+ this.settingsFormat = settingsformat;
+ }
- public String getSettings(int shards, int replicas) {
- return String.format(this.settingsFormat, shards, replicas);
- }
-} \ No newline at end of file
+ public String getMapping() {
+ return this.getMapping(false);
+ }
+
+ public String getMapping(boolean useStrict) {
+ return this.mapping == null ? null
+ : String.format("{\"%s\":{%s\"properties\":%s}}", this.doctype,
+ useStrict ? "\"dynamic\": \"strict\"," : "", this.mapping);
+ }
+
+ public String getSettings(int shards, int replicas) {
+ return String.format(this.settingsFormat, shards, replicas);
+ }
+}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java
index fa86c90e2..04bdfd38f 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/KeepDataSearchHitConverter.java
@@ -25,19 +25,20 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.SearchHit;
public class KeepDataSearchHitConverter implements SearchHitConverter {
-
- private final ComponentName name;
- public KeepDataSearchHitConverter(ComponentName name) {
- this.name = name;
- }
- @Override
- public SearchHit convert(SearchHit source) {
- return source;
- }
+ private final ComponentName name;
- @Override
- public ComponentData convert(DataContainer container) {
- return container.getComponents().get(this.name);
- }
+ public KeepDataSearchHitConverter(ComponentName name) {
+ this.name = name;
+ }
+
+ @Override
+ public SearchHit convert(SearchHit source) {
+ return source;
+ }
+
+ @Override
+ public ComponentData convert(DataContainer container) {
+ return container.getComponents().get(this.name);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java
index e923b2728..66a5e16d0 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/MavenDatabasePluginInitFile.java
@@ -38,27 +38,29 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
*
*/
public class MavenDatabasePluginInitFile {
- private static final int replicas=1;
- private static final int shards=5;
- private static final String mappings="\"mappings\":%s";
- private static final String settings="\"settings\":{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"+
- "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}";
+ private static final int replicas = 1;
+ private static final int shards = 5;
+ private static final String mappings = "\"mappings\":%s";
+ private static final String settings =
+ "\"settings\":{\"index\":{\"number_of_shards\":%d,\"number_of_replicas\":%d},\"analysis\":{\"analyzer\":{\"content\":"
+ + "{\"type\":\"custom\",\"tokenizer\":\"whitespace\"}}}}";
- public static void create(Release release, String filename) throws IOException {
+ public static void create(Release release, String filename) throws IOException {
- ReleaseInformation ri = ReleaseInformation.getInstance(release);
- Set<ComponentName> comps=ri.getComponents();
- List<String> lines = new ArrayList<>();
- for(ComponentName c:comps) {
- lines.add(String.format("PUT:%s/:{"+settings+","+mappings+"}",ri.getIndex(c),shards,replicas,ri.getDatabaseMapping(c)));
- lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c),ri.getAlias(c)));
- }
+ ReleaseInformation ri = ReleaseInformation.getInstance(release);
+ Set<ComponentName> comps = ri.getComponents();
+ List<String> lines = new ArrayList<>();
+ for (ComponentName c : comps) {
+ lines.add(String.format("PUT:%s/:{" + settings + "," + mappings + "}", ri.getIndex(c), shards, replicas,
+ ri.getDatabaseMapping(c)));
+ lines.add(String.format("PUT:%s/_alias/%s/:{}", ri.getIndex(c), ri.getAlias(c)));
+ }
- File filePath = new File(filename);
- if (filePath.getParentFile() != null && !filePath.getParentFile().exists()){
- //Crate Directory if missing
- filePath.getParentFile().mkdirs();
- }
- Files.write(filePath.toPath(), lines);
- }
+ File filePath = new File(filename);
+ if (filePath.getParentFile() != null && !filePath.getParentFile().exists()) {
+ //Crate Directory if missing
+ filePath.getParentFile().mkdirs();
+ }
+ Files.write(filePath.toPath(), lines);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
index ae4522dc5..13c604716 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/Release.java
@@ -25,74 +25,82 @@ import org.onap.ccsdk.features.sdnr.wt.common.database.data.AliasesEntry;
import org.onap.ccsdk.features.sdnr.wt.common.database.data.EsVersion;
public enum Release {
-
- EL_ALTO("el alto","_v1",new EsVersion(2,2,0),new EsVersion(2,2,0)),
- FRANKFURT_R1("frankfurt-R1","-v2",new EsVersion(6,4,3),new EsVersion(6,8,6)),
- FRANKFURT_R2("frankfurt-R2","",new EsVersion(6,4,3),new EsVersion(6,8,6)),
- FRANKFURT_R3("frankfurt-R3","",new EsVersion(6,4,3),new EsVersion(6,8,6)),
-
- GUILIN("guilin","",new EsVersion(6,4,3),new EsVersion(6,8,6));
-
- public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1;
-
- private final String value;
- private final String dbSuffix;
- private final EsVersion minDbVersion;
- private final EsVersion maxDbVersion;
-
- private Release(String s,String dbsuffix,EsVersion minDbVersion,EsVersion maxDbVersion) {
- this.value = s;
- this.dbSuffix=dbsuffix;
- this.minDbVersion = minDbVersion;
- this.maxDbVersion = maxDbVersion;
- }
- @Override
- public String toString() {
- return this.value;
- }
- public String getValue() {
- return value;
- }
- public static Release getValueOf(String s) throws Exception {
- //s = s.toLowerCase();
- for(Release p:Release.values()) {
- if(p.value.equals(s)) {
- return p;
- }
- }
- throw new Exception("value not found");
- }
- public static Release getValueBySuffix(String suffix) {
- for(Release r:Release.values()) {
- if(r.dbSuffix.equals(suffix))
- return r;
- }
- return null;
- }
- public static String getDbSuffix(AliasesEntry entry) throws Exception {
- ComponentName comp = ComponentName.getValueOf(entry.getAlias());
- if(comp!=null) {
- return entry.getIndex().substring(entry.getAlias().length());
- }
- return null;
- }
- /**
- * @return
- */
- public String getDBSuffix() {
- return this.dbSuffix;
- }
- /**
- * @return
- */
- public EsVersion getDBVersion() {
- return this.minDbVersion;
- }
- /**
- * @param dbVersion2
- * @return
- */
- public boolean isDbInRange(EsVersion dbVersion) {
- return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion);
- }
+
+ EL_ALTO("el alto", "_v1", new EsVersion(2, 2, 0), new EsVersion(2, 2, 0)), FRANKFURT_R1("frankfurt-R1", "-v2",
+ new EsVersion(6, 4, 3), new EsVersion(6, 8, 6)), FRANKFURT_R2("frankfurt-R2", "", new EsVersion(6, 4, 3),
+ new EsVersion(6, 8, 6)), FRANKFURT_R3("frankfurt-R3", "", new EsVersion(6, 4, 3),
+ new EsVersion(6, 8, 6)),
+
+ GUILIN("guilin", "", new EsVersion(6, 4, 3), new EsVersion(6, 8, 6));
+
+ public static final Release CURRENT_RELEASE = Release.FRANKFURT_R1;
+
+ private final String value;
+ private final String dbSuffix;
+ private final EsVersion minDbVersion;
+ private final EsVersion maxDbVersion;
+
+ private Release(String s, String dbsuffix, EsVersion minDbVersion, EsVersion maxDbVersion) {
+ this.value = s;
+ this.dbSuffix = dbsuffix;
+ this.minDbVersion = minDbVersion;
+ this.maxDbVersion = maxDbVersion;
+ }
+
+ @Override
+ public String toString() {
+ return this.value;
+ }
+
+ public String getValue() {
+ return value;
+ }
+
+ public static Release getValueOf(String s) throws Exception {
+ //s = s.toLowerCase();
+ for (Release p : Release.values()) {
+ if (p.value.equals(s)) {
+ return p;
+ }
+ }
+ throw new Exception("value not found");
+ }
+
+ public static Release getValueBySuffix(String suffix) {
+ for (Release r : Release.values()) {
+ if (r.dbSuffix.equals(suffix))
+ return r;
+ }
+ return null;
+ }
+
+ public static String getDbSuffix(AliasesEntry entry) throws Exception {
+ ComponentName comp = ComponentName.getValueOf(entry.getAlias());
+ if (comp != null) {
+ return entry.getIndex().substring(entry.getAlias().length());
+ }
+ return null;
+ }
+
+ /**
+ * @return
+ */
+ public String getDBSuffix() {
+ return this.dbSuffix;
+ }
+
+ /**
+ * @return
+ */
+ public EsVersion getDBVersion() {
+ return this.minDbVersion;
+ }
+
+ /**
+ * @param dbVersion2
+ * @return
+ */
+ public boolean isDbInRange(EsVersion dbVersion) {
+ return dbVersion.isNewerOrEqualThan(minDbVersion) && dbVersion.isOlderOrEqualThan(maxDbVersion);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java
index 7a549ca86..a95a405d6 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/data/SearchHitConverter.java
@@ -28,37 +28,38 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.guilin.GuilinReleaseIn
public interface SearchHitConverter {
- /**
- * convert single entry of database
- * @param source
- * @return
- */
- public SearchHit convert(SearchHit source);
-
- /**
- * @param component destination component
- * @param container source data
- * @return data for destination component
- */
- public ComponentData convert(DataContainer container);
+ /**
+ * convert single entry of database
+ *
+ * @param source
+ * @return
+ */
+ public SearchHit convert(SearchHit source);
+
+ /**
+ * @param component destination component
+ * @param container source data
+ * @return data for destination component
+ */
+ public ComponentData convert(DataContainer container);
+
+
+ public static class Factory {
+ public static SearchHitConverter getInstance(Release src, Release dst, ComponentName component) {
+ switch (src) {
+ case EL_ALTO:
+ return new ElAltoReleaseInformation().getConverter(dst, component);
+ case FRANKFURT_R1:
+ return new FrankfurtReleaseInformation().getConverter(dst, component);
+ case GUILIN:
+ return new GuilinReleaseInformation().getConverter(dst, component);
+ default:
+ return null;
+
+ }
+ }
+ }
-
- public static class Factory{
- public static SearchHitConverter getInstance(Release src,Release dst, ComponentName component) {
- switch(src) {
- case EL_ALTO:
- return new ElAltoReleaseInformation().getConverter(dst, component);
- case FRANKFURT_R1:
- return new FrankfurtReleaseInformation().getConverter(dst, component);
- case GUILIN:
- return new GuilinReleaseInformation().getConverter(dst, component);
- default:
- return null;
-
- }
- }
- }
-
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java
index 1236bd8e5..739afaf0e 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/ElAltoReleaseInformation.java
@@ -33,70 +33,76 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
public class ElAltoReleaseInformation extends ReleaseInformation {
-
- private Map<Release, Map<ComponentName, SearchHitConverter>> converters;
- public ElAltoReleaseInformation() {
- super(Release.EL_ALTO, createDbInfos());
- this.converters = generateConverters();
- }
+ private Map<Release, Map<ComponentName, SearchHitConverter>> converters;
- private static Map<ComponentName, DatabaseInfo> createDbInfos() {
- Map<ComponentName,DatabaseInfo> map = new HashMap<>();
- map.put(ComponentName.EVENTLOG, new DatabaseInfo("sdnevents","eventlog",""));
- map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("sdnevents","faultcurrent",""));
- map.put(ComponentName.FAULTLOG, new DatabaseInfo("sdnevents","faultlog",""));
- map.put(ComponentName.INVENTORY, new DatabaseInfo("sdnevents","inventoryequipment",""));
- map.put(ComponentName.INVENTORYTOPLEVEL, new DatabaseInfo("sdnevents","inventorytoplevel",""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("sdnperformance","historicalperformance15min",""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("sdnperformance","historicalperformance24h",""));
- map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("mwtn","required-networkelement","{\"required-networkelement\": {\"date_detection\": false }}"));
- map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mwtn","mediator-server",""));
- map.put(ComponentName.MAINTENANCE, new DatabaseInfo("mwtn","maintenancemode",""));
- return map;
- }
+ public ElAltoReleaseInformation() {
+ super(Release.EL_ALTO, createDbInfos());
+ this.converters = generateConverters();
+ }
- /**
- * @return components used in el alto
- */
-
-
- private static Map<Release, Map<ComponentName, SearchHitConverter>> generateConverters() {
- Map<Release, Map<ComponentName, SearchHitConverter>> c = new HashMap<>();
- Map<ComponentName, SearchHitConverter> frankfurtConverters = new HashMap<>();
- frankfurtConverters.put(ComponentName.EVENTLOG, new FrankfurtEventlogConverter());
- frankfurtConverters.put(ComponentName.FAULTCURRENT, new FrankfurtFaultcurrentConverter());
- frankfurtConverters.put(ComponentName.FAULTLOG, new FrankfurtFaultlogConverter());
- frankfurtConverters.put(ComponentName.INVENTORY, new KeepDataSearchHitConverter(ComponentName.INVENTORY));
- //obsolete in frankfurt
- //frankfurtConverters.put(ComponentName.INVENTORYTOPLEVEL, new KeepDataSearchHitConverter(ComponentName.INVENTORYTOPLEVEL));
- frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_15M));
- frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_24H));
- frankfurtConverters.put(ComponentName.MAINTENANCE, new FrankfurtMaintenanceConverter());
- frankfurtConverters.put(ComponentName.MEDIATOR_SERVER, new KeepDataSearchHitConverter(ComponentName.MEDIATOR_SERVER));
- frankfurtConverters.put(ComponentName.REQUIRED_NETWORKELEMENT, new FrankfurtRequiredNetworkElementConverter());
- frankfurtConverters.put(ComponentName.CONNECTIONLOG,new FrankfurtConnectionlogConverter());
- c.put(Release.FRANKFURT_R1,frankfurtConverters);
- return c;
- }
+ private static Map<ComponentName, DatabaseInfo> createDbInfos() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("sdnevents", "eventlog", ""));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("sdnevents", "faultcurrent", ""));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("sdnevents", "faultlog", ""));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("sdnevents", "inventoryequipment", ""));
+ map.put(ComponentName.INVENTORYTOPLEVEL, new DatabaseInfo("sdnevents", "inventorytoplevel", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
+ new DatabaseInfo("sdnperformance", "historicalperformance15min", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
+ new DatabaseInfo("sdnperformance", "historicalperformance24h", ""));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("mwtn", "required-networkelement",
+ "{\"required-networkelement\": {\"date_detection\": false }}"));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mwtn", "mediator-server", ""));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("mwtn", "maintenancemode", ""));
+ return map;
+ }
- @Override
- public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- SearchHitConverter c=this.converters.containsKey(dst)?this.converters.get(dst).get(comp):null;
- if(c==null) {
- c=super.getConverter(dst, comp);
- }
- return c;
- }
+ /**
+ * @return components used in el alto
+ */
- @Override
- protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
- @Override
- protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
-
+ private static Map<Release, Map<ComponentName, SearchHitConverter>> generateConverters() {
+ Map<Release, Map<ComponentName, SearchHitConverter>> c = new HashMap<>();
+ Map<ComponentName, SearchHitConverter> frankfurtConverters = new HashMap<>();
+ frankfurtConverters.put(ComponentName.EVENTLOG, new FrankfurtEventlogConverter());
+ frankfurtConverters.put(ComponentName.FAULTCURRENT, new FrankfurtFaultcurrentConverter());
+ frankfurtConverters.put(ComponentName.FAULTLOG, new FrankfurtFaultlogConverter());
+ frankfurtConverters.put(ComponentName.INVENTORY, new KeepDataSearchHitConverter(ComponentName.INVENTORY));
+ //obsolete in frankfurt
+ //frankfurtConverters.put(ComponentName.INVENTORYTOPLEVEL, new KeepDataSearchHitConverter(ComponentName.INVENTORYTOPLEVEL));
+ frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
+ new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_15M));
+ frankfurtConverters.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
+ new KeepDataSearchHitConverter(ComponentName.HISTORICAL_PERFORMANCE_24H));
+ frankfurtConverters.put(ComponentName.MAINTENANCE, new FrankfurtMaintenanceConverter());
+ frankfurtConverters.put(ComponentName.MEDIATOR_SERVER,
+ new KeepDataSearchHitConverter(ComponentName.MEDIATOR_SERVER));
+ frankfurtConverters.put(ComponentName.REQUIRED_NETWORKELEMENT, new FrankfurtRequiredNetworkElementConverter());
+ frankfurtConverters.put(ComponentName.CONNECTIONLOG, new FrankfurtConnectionlogConverter());
+ c.put(Release.FRANKFURT_R1, frankfurtConverters);
+ return c;
+ }
+
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ SearchHitConverter c = this.converters.containsKey(dst) ? this.converters.get(dst).get(comp) : null;
+ if (c == null) {
+ c = super.getConverter(dst, comp);
+ }
+ return c;
+ }
+
+ @Override
+ protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
+
+ @Override
+ protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
+
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java
index d68373199..55fa0d88a 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtConnectionlogConverter.java
@@ -35,86 +35,73 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.Connect
*
* @author Michael Dürre
*
- * Convert data from el alto to frankfurt
+ * Convert data from el alto to frankfurt
*
- * src: eventlog
- * dst: connectionlog
+ * src: eventlog dst: connectionlog
*
*
- * {
- * "event": {
- * "nodeName": "SDN-Controller-5a150173d678",
- * "counter": "48",
- * "timeStamp": "2019-10-07T09:57:08.2Z",
- * "objectId": "Sim2230",
- * "attributeName": "ConnectionStatus",
- * "newValue": "connecting",
- * "type": "AttributeValueChangedNotificationXml"
- * }
- * }
+ * { "event": { "nodeName": "SDN-Controller-5a150173d678", "counter": "48", "timeStamp":
+ * "2019-10-07T09:57:08.2Z", "objectId": "Sim2230", "attributeName": "ConnectionStatus", "newValue":
+ * "connecting", "type": "AttributeValueChangedNotificationXml" } }
*
- * =>
+ * =>
*
- * {
- * "timestamp": "2020-01-28T12:00:10.2Z",
- * "status": "Connected",
- * "node-id": "sim1"
- * }
+ * { "timestamp": "2020-01-28T12:00:10.2Z", "status": "Connected", "node-id": "sim1" }
*
*/
public class FrankfurtConnectionlogConverter extends BaseSearchHitConverter {
- public FrankfurtConnectionlogConverter() {
- super(ComponentName.CONNECTIONLOG);
- }
+ public FrankfurtConnectionlogConverter() {
+ super(ComponentName.CONNECTIONLOG);
+ }
- /**
- * @source eventlog searchhit converted to connectionlog entry
- */
- @Override
- public SearchHit convert(SearchHit source) {
+ /**
+ * @source eventlog searchhit converted to connectionlog entry
+ */
+ @Override
+ public SearchHit convert(SearchHit source) {
- JSONObject data = new JSONObject();
- JSONObject inner = source.getSource().getJSONObject("event");
- String eventType = inner.getString("type");
- String eventSource = inner.getString("nodeName");
- if (!eventSource.startsWith("SDN-Controller")) {
- return null;
- }
- data.put("node-id", inner.getString("objectId"));
- data.put("timestamp", inner.getString("timeStamp"));
- if (eventType.equals("AttributeValueChangedNotificationXml")) {
- String event = inner.getString("newValue").toLowerCase();
- if (event.equals("connected")) {
- data.put("status", ConnectionLogStatus.Connected.getName());
- } else if (event.equals("connecting")) {
- data.put("status", ConnectionLogStatus.Connecting.getName());
- } else {
- data.put("status", ConnectionLogStatus.UnableToConnect.getName());
- }
+ JSONObject data = new JSONObject();
+ JSONObject inner = source.getSource().getJSONObject("event");
+ String eventType = inner.getString("type");
+ String eventSource = inner.getString("nodeName");
+ if (!eventSource.startsWith("SDN-Controller")) {
+ return null;
+ }
+ data.put("node-id", inner.getString("objectId"));
+ data.put("timestamp", inner.getString("timeStamp"));
+ if (eventType.equals("AttributeValueChangedNotificationXml")) {
+ String event = inner.getString("newValue").toLowerCase();
+ if (event.equals("connected")) {
+ data.put("status", ConnectionLogStatus.Connected.getName());
+ } else if (event.equals("connecting")) {
+ data.put("status", ConnectionLogStatus.Connecting.getName());
+ } else {
+ data.put("status", ConnectionLogStatus.UnableToConnect.getName());
+ }
- } else if (eventType.equals("ObjectCreationNotificationXml")) {
- data.put("status", ConnectionLogStatus.Mounted.getName());
+ } else if (eventType.equals("ObjectCreationNotificationXml")) {
+ data.put("status", ConnectionLogStatus.Mounted.getName());
- } else if (eventType.equals("ObjectDeletionNotificationXml")) {
- data.put("status", ConnectionLogStatus.Unmounted.getName());
- }
+ } else if (eventType.equals("ObjectDeletionNotificationXml")) {
+ data.put("status", ConnectionLogStatus.Unmounted.getName());
+ }
- return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
- }
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
- @Override
- public ComponentData convert(DataContainer container) {
- Map<ComponentName, ComponentData> src = container.getComponents();
- if (!src.containsKey(ComponentName.EVENTLOG)) {
- return null;
- }
- ComponentData eventData = src.get(ComponentName.EVENTLOG);
- ComponentData dstData = new ComponentData(ComponentName.CONNECTIONLOG);
- for (SearchHit sh : eventData) {
- dstData.add(this.convert(sh));
- }
- return dstData;
- }
+ @Override
+ public ComponentData convert(DataContainer container) {
+ Map<ComponentName, ComponentData> src = container.getComponents();
+ if (!src.containsKey(ComponentName.EVENTLOG)) {
+ return null;
+ }
+ ComponentData eventData = src.get(ComponentName.EVENTLOG);
+ ComponentData dstData = new ComponentData(ComponentName.CONNECTIONLOG);
+ for (SearchHit sh : eventData) {
+ dstData.add(this.convert(sh));
+ }
+ return dstData;
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java
index e04378bbe..3bd70dd95 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtEventlogConverter.java
@@ -32,24 +32,23 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DataContainer;
* @author Michael Dürre
*
*
- * Cannot be converted from el alto to frankfurt
- * most of the entries are in connectionlog
+ * Cannot be converted from el alto to frankfurt most of the entries are in connectionlog
*
*/
-public class FrankfurtEventlogConverter extends BaseSearchHitConverter{
+public class FrankfurtEventlogConverter extends BaseSearchHitConverter {
- public FrankfurtEventlogConverter() {
- super(ComponentName.EVENTLOG);
- }
+ public FrankfurtEventlogConverter() {
+ super(ComponentName.EVENTLOG);
+ }
- @Override
- public SearchHit convert(SearchHit source) {
- return null;
- }
+ @Override
+ public SearchHit convert(SearchHit source) {
+ return null;
+ }
- @Override
- public ComponentData convert(DataContainer container) {
- return null;
- }
+ @Override
+ public ComponentData convert(DataContainer container) {
+ return null;
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java
index 060434fe9..40541dcae 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultcurrentConverter.java
@@ -30,51 +30,36 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
*
* @author Michael Dürre
*
- * {
- * "faultCurrent": {
- * "nodeName": "sim9090",
- * "counter": "50443",
- * "timeStamp": "2017-07-27T13:33:49.0Z",
- * "objectId": "a2.module-1.1.5.6",
- * "problem": "Ais",
- * "severity": "Major",
- * "type": "ProblemNotificationXml"
- * }
- * }
+ * { "faultCurrent": { "nodeName": "sim9090", "counter": "50443", "timeStamp": "2017-07-27T13:33:49.0Z",
+ * "objectId": "a2.module-1.1.5.6", "problem": "Ais", "severity": "Major", "type": "ProblemNotificationXml" } }
*
- * =>
+ * =>
*
- * {
- * "timestamp": "2017-01-01T00:00:00.0Z",
- * "object-id": "LP-MWS-TTP-01",
- * "severity": "Warning",
- * "counter": 2,
- * "node-id": "sim1",
- * "problem": "unknownProblem2"
- * }
+ * { "timestamp": "2017-01-01T00:00:00.0Z", "object-id": "LP-MWS-TTP-01", "severity": "Warning", "counter": 2,
+ * "node-id": "sim1", "problem": "unknownProblem2" }
*/
public class FrankfurtFaultcurrentConverter extends BaseSearchHitConverter {
- /**
- * @param name
- */
- public FrankfurtFaultcurrentConverter() {
- super(ComponentName.FAULTCURRENT);
- }
+ /**
+ * @param name
+ */
+ public FrankfurtFaultcurrentConverter() {
+ super(ComponentName.FAULTCURRENT);
+ }
- @Override
- public SearchHit convert(SearchHit source) {
-
- JSONObject data = new JSONObject();
- JSONObject src = source.getSource();
- JSONObject srcInner = src.getJSONObject("faultCurrent");
- data.put("node-id", srcInner.getString("nodeName"));
- data.put("severity", srcInner.getString("severity"));
- data.put("counter", Long.parseLong(srcInner.getString("counter")));
- data.put("timestamp", srcInner.getString("timeStamp"));
- data.put("object-id",srcInner.getString("objectId"));
- data.put("problem", srcInner.getString("problem"));
-
- return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
- }
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ JSONObject srcInner = src.getJSONObject("faultCurrent");
+ data.put("node-id", srcInner.getString("nodeName"));
+ data.put("severity", srcInner.getString("severity"));
+ data.put("counter", Long.parseLong(srcInner.getString("counter")));
+ data.put("timestamp", srcInner.getString("timeStamp"));
+ data.put("object-id", srcInner.getString("objectId"));
+ data.put("problem", srcInner.getString("problem"));
+
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java
index 87e71c612..f8319020d 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtFaultlogConverter.java
@@ -28,51 +28,34 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
/**
*
- * @author Michael Dürre
- *{
- * "fault": {
- * "nodeName": "SDN-Controller-5a150173d678",
- * "counter": "380",
- * "timeStamp": "2019-10-18T18:40:25.0Z",
- * "objectId": "ADVA-DTAG-Nuernberg-3",
- * "problem": "connectionLossOAM",
- * "severity": "Major",
- * "type": "ProblemNotificationXml"
- * }
- *}
+ * @author Michael Dürre { "fault": { "nodeName": "SDN-Controller-5a150173d678", "counter": "380", "timeStamp":
+ * "2019-10-18T18:40:25.0Z", "objectId": "ADVA-DTAG-Nuernberg-3", "problem": "connectionLossOAM", "severity":
+ * "Major", "type": "ProblemNotificationXml" } }
*
- * =>
- *{
- * "timestamp": "2017-01-01T00:00:00.0Z",
- * "object-id": "LP-MWPS-RADIO",
- * "severity": "Critical",
- * "counter": -1,
- * "node-id": "sim1",
- * "source-type": "Netconf",
- * "problem": "signalIsLost"
- *}
+ * => { "timestamp": "2017-01-01T00:00:00.0Z", "object-id": "LP-MWPS-RADIO", "severity": "Critical", "counter":
+ * -1, "node-id": "sim1", "source-type": "Netconf", "problem": "signalIsLost" }
*
*/
-public class FrankfurtFaultlogConverter extends BaseSearchHitConverter{
+public class FrankfurtFaultlogConverter extends BaseSearchHitConverter {
- public FrankfurtFaultlogConverter() {
- super(ComponentName.FAULTLOG);
- }
+ public FrankfurtFaultlogConverter() {
+ super(ComponentName.FAULTLOG);
+ }
- @Override
- public SearchHit convert(SearchHit source) {
-
- JSONObject data = new JSONObject();
- JSONObject src = source.getSource();
- JSONObject srcInner = src.getJSONObject("fault");
- data.put("node-id", srcInner.getString("nodeName"));
- data.put("severity", srcInner.getString("severity"));
- data.put("counter", Long.parseLong(srcInner.getString("counter")));
- data.put("timestamp", srcInner.getString("timeStamp"));
- data.put("object-id",srcInner.getString("objectId"));
- data.put("problem", srcInner.getString("problem"));
- data.put("type", "Netconf");
- return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
- }
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ JSONObject srcInner = src.getJSONObject("fault");
+ data.put("node-id", srcInner.getString("nodeName"));
+ data.put("severity", srcInner.getString("severity"));
+ data.put("counter", Long.parseLong(srcInner.getString("counter")));
+ data.put("timestamp", srcInner.getString("timeStamp"));
+ data.put("object-id", srcInner.getString("objectId"));
+ data.put("problem", srcInner.getString("problem"));
+ data.put("type", "Netconf");
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java
index 16be5d97b..69b9a9934 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtMaintenanceConverter.java
@@ -31,56 +31,37 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.ComponentName;
*
* @author jack
*
- *{
- * "node": "ddd",
- * "filter": [
- * {
- * "definition": {
- * "object-id-ref": "",
- * "problem": ""
- * },
- * "description": "",
- * "start": "2019-11-26T15:37+00:00",
- * "end": "2019-11-26T23:37+00:00"
- * }],
- * "active": false
- *}
- * =>
- *{
- * "id": "sim1"
- * "node-id": "sim1",
- * "description": "",
- * "start": "2020-01-28T12:00:17.6Z",
- * "end": "2020-01-28T12:00:17.6Z",
- * "active": false,
- * "object-id-ref": "",
- * "problem": ""
+ * { "node": "ddd", "filter": [ { "definition": { "object-id-ref": "", "problem": "" }, "description": "",
+ * "start": "2019-11-26T15:37+00:00", "end": "2019-11-26T23:37+00:00" }], "active": false } => { "id": "sim1"
+ * "node-id": "sim1", "description": "", "start": "2020-01-28T12:00:17.6Z", "end": "2020-01-28T12:00:17.6Z",
+ * "active": false, "object-id-ref": "", "problem": ""
*
*/
public class FrankfurtMaintenanceConverter extends BaseSearchHitConverter {
- public FrankfurtMaintenanceConverter() {
- super(ComponentName.MAINTENANCE);
- }
+ public FrankfurtMaintenanceConverter() {
+ super(ComponentName.MAINTENANCE);
+ }
- @Override
- public SearchHit convert(SearchHit source) {
+ @Override
+ public SearchHit convert(SearchHit source) {
- JSONObject src = source.getSource();
- JSONObject data = new JSONObject();
- data.put("id", src.getString("node"));
- data.put("node-id", src.getString("node"));
- data.put("active", src.getBoolean("active"));
- JSONObject filter = null;
- if (src.has("filter")) {
- filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null;
- }
- data.put("start", filter != null ? filter.getString("start") : "");
- data.put("end", filter != null ? filter.getString("end") : "");
- data.put("description", filter != null ? filter.getString("description") : "");
- JSONObject definition = filter!=null?filter.has("definition")?filter.getJSONObject("definition"):null:null;
- data.put("problem", definition!=null?definition.getString("problem"):"");
- data.put("object-id-ref", definition!=null?definition.getString("object-id-ref"):"");
- return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
- }
+ JSONObject src = source.getSource();
+ JSONObject data = new JSONObject();
+ data.put("id", src.getString("node"));
+ data.put("node-id", src.getString("node"));
+ data.put("active", src.getBoolean("active"));
+ JSONObject filter = null;
+ if (src.has("filter")) {
+ filter = src.getJSONArray("filter").length() > 0 ? src.getJSONArray("filter").getJSONObject(0) : null;
+ }
+ data.put("start", filter != null ? filter.getString("start") : "");
+ data.put("end", filter != null ? filter.getString("end") : "");
+ data.put("description", filter != null ? filter.getString("description") : "");
+ JSONObject definition =
+ filter != null ? filter.has("definition") ? filter.getJSONObject("definition") : null : null;
+ data.put("problem", definition != null ? definition.getString("problem") : "");
+ data.put("object-id-ref", definition != null ? definition.getString("object-id-ref") : "");
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java
index ef6de907e..7cf18dd43 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/elalto/FrankfurtRequiredNetworkElementConverter.java
@@ -31,48 +31,35 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data.Connect
*
* @author Michael Dürre
*
- * {
- * "mountId":"nts-manager-dev-micha",
- * "host":"10.20.5.2",
- * "port":8300,
- * "username":"netconf",
- * "password":"netconf"
- * }
+ * { "mountId":"nts-manager-dev-micha", "host":"10.20.5.2", "port":8300, "username":"netconf",
+ * "password":"netconf" }
*
- * =>
+ * =>
*
- * {
- * "node-id": "sim1",
- * "is-required": true,
- * "password": "ads",
- * "port": 12600,
- * "host": "10.20.5.2",
- * "id": "sim1",
- * "username": "ad",
- * "status": "Connected"
- * }
+ * { "node-id": "sim1", "is-required": true, "password": "ads", "port": 12600, "host": "10.20.5.2", "id":
+ * "sim1", "username": "ad", "status": "Connected" }
*
*/
-public class FrankfurtRequiredNetworkElementConverter extends BaseSearchHitConverter{
+public class FrankfurtRequiredNetworkElementConverter extends BaseSearchHitConverter {
- public FrankfurtRequiredNetworkElementConverter() {
- super(ComponentName.REQUIRED_NETWORKELEMENT);
- }
+ public FrankfurtRequiredNetworkElementConverter() {
+ super(ComponentName.REQUIRED_NETWORKELEMENT);
+ }
- @Override
- public SearchHit convert(SearchHit source) {
-
- JSONObject data = new JSONObject();
- JSONObject src = source.getSource();
- data.put("id", src.getString("mountId"));
- data.put("node-id", src.getString("mountId"));
- data.put("username", src.getString("username"));
- data.put("password", src.getString("password"));
- data.put("host", src.getString("host"));
- data.put("port", src.getInt("port"));
- data.put("status", ConnectionLogStatus.Undefined.getName());
- data.put("is-required", true);
- return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data );
- }
+ @Override
+ public SearchHit convert(SearchHit source) {
+
+ JSONObject data = new JSONObject();
+ JSONObject src = source.getSource();
+ data.put("id", src.getString("mountId"));
+ data.put("node-id", src.getString("mountId"));
+ data.put("username", src.getString("username"));
+ data.put("password", src.getString("password"));
+ data.put("host", src.getString("host"));
+ data.put("port", src.getInt("port"));
+ data.put("status", ConnectionLogStatus.Undefined.getName());
+ data.put("is-required", true);
+ return this.getSearchHit(source.getIndex(), source.getType(), source.getId(), data);
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
index bbbde1f22..ad0abee89 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/FrankfurtReleaseInformation.java
@@ -37,65 +37,65 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.ReleaseInformation;
public class FrankfurtReleaseInformation extends ReleaseInformation {
- private final Logger LOG = LoggerFactory.getLogger(FrankfurtReleaseInformation.class);
- private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>();
+ private final Logger LOG = LoggerFactory.getLogger(FrankfurtReleaseInformation.class);
+ private final Map<Release, Map<ComponentName, SearchHitConverter>> converters = new HashMap<>();
- public FrankfurtReleaseInformation() {
- super(Release.FRANKFURT_R1, createDBMap());
- }
+ public FrankfurtReleaseInformation() {
+ super(Release.FRANKFURT_R1, createDBMap());
+ }
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
- Map<ComponentName, DatabaseInfo> map = new HashMap<>();
- map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo("connectionlog", "connectionlog",
- "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}"));
- map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog",
- "{\"node-id\": {\"type\": \"keyword\"},\"source-type\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"new-value\": {\"type\": \"keyword\"},\"attribute-name\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\": {\"type\": \"keyword\"}}"));
- map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent",
- "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"}}"));
- map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog",
- "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"},\"source-type\":{\"type\": \"keyword\"}}"));
- map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment",
- "{\"date\": {\"type\": \"keyword\"},\"model-identifier\": {\"type\": \"keyword\"},\"manufacturer-identifier\": {\"type\": \"keyword\"},\"type-name\": {\"type\": \"keyword\"},\"description\": {\"type\": \"keyword\"},\"uuid\": {\"type\": \"keyword\"},\"version\": {\"type\": \"keyword\"},\"parent-uuid\": {\"type\": \"keyword\"},\"contained-holder\": {\"type\": \"keyword\"},\"node-id\": {\"type\": \"keyword\"},\"tree-level\": {\"type\": \"long\"},\"part-type-id\": {\"type\": \"keyword\"},\"serial\": {\"type\": \"keyword\"}}"));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("historicalperformance15min",
- "historicalperformance15min",
- "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("historicalperformance24h",
- "historicalperformance24h",
- "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
- map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("networkelement-connection",
- "networkelement-connection",
- "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": {\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},\"status\": {\"type\": \"keyword\"}}"));
- map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server",
- "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}"));
- map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode",
- "{\"node-id\": {\"type\": \"keyword\"},\"start\": {\"type\": \"date\"},\"end\": {\"type\": \"date\"},\"description\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}"));
- return map;
- }
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.CONNECTIONLOG, new DatabaseInfo("connectionlog", "connectionlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"status\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"source-type\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"new-value\": {\"type\": \"keyword\"},\"attribute-name\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent",
+ "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog",
+ "{\"node-id\": {\"type\": \"keyword\"},\"severity\": {\"type\": \"keyword\"},\"timestamp\": {\"type\": \"date\"},\"problem\": {\"type\": \"keyword\"},\"counter\": {\"type\": \"long\"},\"object-id\":{\"type\": \"keyword\"},\"source-type\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment",
+ "{\"date\": {\"type\": \"keyword\"},\"model-identifier\": {\"type\": \"keyword\"},\"manufacturer-identifier\": {\"type\": \"keyword\"},\"type-name\": {\"type\": \"keyword\"},\"description\": {\"type\": \"keyword\"},\"uuid\": {\"type\": \"keyword\"},\"version\": {\"type\": \"keyword\"},\"parent-uuid\": {\"type\": \"keyword\"},\"contained-holder\": {\"type\": \"keyword\"},\"node-id\": {\"type\": \"keyword\"},\"tree-level\": {\"type\": \"long\"},\"part-type-id\": {\"type\": \"keyword\"},\"serial\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M, new DatabaseInfo("historicalperformance15min",
+ "historicalperformance15min",
+ "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H, new DatabaseInfo("historicalperformance24h",
+ "historicalperformance24h",
+ "{\"node-name\":{\"type\": \"keyword\"},\"timestamp\":{\"type\": \"date\"},\"suspect-interval-flag\":{\"type\":\"boolean\"},\"scanner-id\":{\"type\": \"keyword\"},\"uuid-interface\":{\"type\": \"keyword\"},\"layer-protocol-name\":{\"type\": \"keyword\"},\"granularity-period\":{\"type\": \"keyword\"},\"radio-signal-id\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT, new DatabaseInfo("networkelement-connection",
+ "networkelement-connection",
+ "{\"node-id\": {\"type\": \"keyword\"},\"host\": {\"type\": \"keyword\"},\"port\": {\"type\": \"long\"},\"username\": {\"type\": \"keyword\"},\"password\": {\"type\": \"keyword\"},\"core-model-capability\": {\"type\": \"keyword\"},\"device-type\": {\"type\": \"keyword\"},\"is-required\": {\"type\": \"boolean\"},\"status\": {\"type\": \"keyword\"}}"));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server",
+ "{\"url\":{\"type\": \"keyword\"},\"name\":{\"type\": \"keyword\"}}"));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode",
+ "{\"node-id\": {\"type\": \"keyword\"},\"start\": {\"type\": \"date\"},\"end\": {\"type\": \"date\"},\"description\": {\"type\": \"keyword\"},\"active\": {\"type\": \"boolean\"}},\"date_detection\":false}}"));
+ return map;
+ }
- @Override
- public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- SearchHitConverter c = this.converters.containsKey(dst) ? this.converters.get(dst).get(comp) : null;
- if (c == null) {
- c = super.getConverter(dst, comp);
- }
- return c;
- }
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ SearchHitConverter c = this.converters.containsKey(dst) ? this.converters.get(dst).get(comp) : null;
+ if (c == null) {
+ c = super.getConverter(dst, comp);
+ }
+ return c;
+ }
- @Override
- protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
+ @Override
+ protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
- ClusterSettingsResponse response = null;
- try {
- response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
- } catch (IOException e) {
- LOG.warn("problem setting up cluster: {}", e);
- }
- return response == null ? false : response.isAcknowledged();
- }
+ ClusterSettingsResponse response = null;
+ try {
+ response = dbClient.setupClusterSettings(new ClusterSettingsRequest(false));
+ } catch (IOException e) {
+ LOG.warn("problem setting up cluster: {}", e);
+ }
+ return response == null ? false : response.isAcknowledged();
+ }
- @Override
- protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
+ @Override
+ protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java
index 7615c4452..1ecae6782 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/frankfurt/data/ConnectionLogStatus.java
@@ -26,13 +26,13 @@ package org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.frankfurt.data;
*
*/
public enum ConnectionLogStatus {
- Connected, Connecting, UnableToConnect, Mounted, Unmounted, Undefined;
+ Connected, Connecting, UnableToConnect, Mounted, Unmounted, Undefined;
- /**
- * @return
- */
- public String getName() {
- return this.name();
- }
+ /**
+ * @return
+ */
+ public String getName() {
+ return this.name();
+ }
}
diff --git a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
index 7b5e38116..a81a6f0fd 100644
--- a/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
+++ b/sdnr/wt/data-provider/setup/src/main/java/org/onap/ccsdk/features/sdnr/wt/dataprovider/setup/guilin/GuilinReleaseInformation.java
@@ -35,48 +35,48 @@ import org.onap.ccsdk.features.sdnr.wt.dataprovider.setup.data.DatabaseInfo;
public class GuilinReleaseInformation extends ReleaseInformation {
- /**
- * @param r
- * @param dbMap
- */
- public GuilinReleaseInformation() {
- super(Release.GUILIN, createDBMap());
+ /**
+ * @param r
+ * @param dbMap
+ */
+ public GuilinReleaseInformation() {
+ super(Release.GUILIN, createDBMap());
- }
+ }
- private static Map<ComponentName, DatabaseInfo> createDBMap() {
- Map<ComponentName, DatabaseInfo> map = new HashMap<>();
- map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", ""));
- map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", ""));
- map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", ""));
- map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
- new DatabaseInfo("historicalperformance15min", "historicalperformance15min", ""));
- map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
- new DatabaseInfo("historicalperformance24h", "historicalperformance24h", ""));
- map.put(ComponentName.REQUIRED_NETWORKELEMENT,
- new DatabaseInfo("networkelement-connection", "networkelement-connection", ""));
- map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", ""));
- map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", ""));
- return map;
- }
+ private static Map<ComponentName, DatabaseInfo> createDBMap() {
+ Map<ComponentName, DatabaseInfo> map = new HashMap<>();
+ map.put(ComponentName.EVENTLOG, new DatabaseInfo("eventlog", "eventlog", ""));
+ map.put(ComponentName.FAULTCURRENT, new DatabaseInfo("faultcurrent", "faultcurrent", ""));
+ map.put(ComponentName.FAULTLOG, new DatabaseInfo("faultlog", "faultlog", ""));
+ map.put(ComponentName.INVENTORY, new DatabaseInfo("inventoryequipment", "inventoryequipment", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_15M,
+ new DatabaseInfo("historicalperformance15min", "historicalperformance15min", ""));
+ map.put(ComponentName.HISTORICAL_PERFORMANCE_24H,
+ new DatabaseInfo("historicalperformance24h", "historicalperformance24h", ""));
+ map.put(ComponentName.REQUIRED_NETWORKELEMENT,
+ new DatabaseInfo("networkelement-connection", "networkelement-connection", ""));
+ map.put(ComponentName.MEDIATOR_SERVER, new DatabaseInfo("mediator-server", "mediator-server", ""));
+ map.put(ComponentName.MAINTENANCE, new DatabaseInfo("maintenancemode", "maintenancemode", ""));
+ return map;
+ }
- @Override
- public SearchHitConverter getConverter(Release dst, ComponentName comp) {
- if (dst == Release.GUILIN) {
- return new KeepDataSearchHitConverter(comp);
- }
- return null;
- }
+ @Override
+ public SearchHitConverter getConverter(Release dst, ComponentName comp) {
+ if (dst == Release.GUILIN) {
+ return new KeepDataSearchHitConverter(comp);
+ }
+ return null;
+ }
- @Override
- protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
+ @Override
+ protected boolean runPreInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
- @Override
- protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
- return true;
- }
+ @Override
+ protected boolean runPostInitCommands(HtDatabaseClient dbClient) {
+ return true;
+ }
}
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());
diff --git a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
index 239711f0a..7698a4a8e 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElement.java
@@ -40,7 +40,7 @@ public class GRanNetworkElement implements NetworkElement {
private final DataProvider databaseService;
public GRanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) {
- log.info("Create {}",GRanNetworkElement.class.getSimpleName());
+ log.info("Create {}", GRanNetworkElement.class.getSimpleName());
this.netconfAccessor = netconfAccess;
this.databaseService = databaseService;
}
@@ -52,12 +52,12 @@ public class GRanNetworkElement implements NetworkElement {
@Override
public void deregister() {
- log.info("deRegister actions should be here");
+ log.info("deRegister actions should be here");
}
@Override
public void warmstart() {
- log.info("Warmstart actions should be here");
+ log.info("Warmstart actions should be here");
}
@Override
diff --git a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElementFactory.java b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElementFactory.java
index 6c54e4213..81cdf7536 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/GRanNetworkElementFactory.java
@@ -31,13 +31,13 @@ public class GRanNetworkElementFactory implements NetworkElementFactory {
private static final Logger log = LoggerFactory.getLogger(GRanNetworkElementFactory.class);
- @Override
- public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) {
+ @Override
+ public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) {
if (acessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)) {
- log.info("Create device {} ",GRanNetworkElement.class.getName());
+ log.info("Create device {} ", GRanNetworkElement.class.getName());
return Optional.of(new GRanNetworkElement(acessor, serviceProvider.getDataProvider()));
} else {
return Optional.empty();
}
- }
+ }
}
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java
index aeb50e83f..86865277f 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestDeviceManagerGRanImpl.java
@@ -27,22 +27,22 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.DeviceManagerServic
import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
public class TestDeviceManagerGRanImpl {
- GRanNetworkElementFactory factory = new GRanNetworkElementFactory();
- DeviceManagerServiceProvider serviceProvider;
-
- @Test
- public void test() throws Exception {
- serviceProvider = mock(DeviceManagerServiceProvider.class);
- NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class);
- when(netconfNetworkElementService.registerNetworkElementFactory(factory)).thenReturn(null);
- when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider);
-
- DeviceManagerGRanImpl devMgrGRan = new DeviceManagerGRanImpl();
-
- devMgrGRan.setNetconfNetworkElementService(netconfNetworkElementService);
- devMgrGRan.init();
- devMgrGRan.close();
-
- }
+ GRanNetworkElementFactory factory = new GRanNetworkElementFactory();
+ DeviceManagerServiceProvider serviceProvider;
+
+ @Test
+ public void test() throws Exception {
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ NetconfNetworkElementService netconfNetworkElementService = mock(NetconfNetworkElementService.class);
+ when(netconfNetworkElementService.registerNetworkElementFactory(factory)).thenReturn(null);
+ when(netconfNetworkElementService.getServiceProvider()).thenReturn(serviceProvider);
+
+ DeviceManagerGRanImpl devMgrGRan = new DeviceManagerGRanImpl();
+
+ devMgrGRan.setNetconfNetworkElementService(netconfNetworkElementService);
+ devMgrGRan.init();
+ devMgrGRan.close();
+
+ }
}
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java
index b13965933..a9393cd0e 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElement.java
@@ -29,27 +29,27 @@ import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.
public class TestGRanNetworkElement {
- private static final String NODEID = "node1";
-
- @Test
- public void test() {
- NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
- DataProvider databaseService = mock(DataProvider.class);
-
- when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
-
- GRanNetworkElement gRanNe = new GRanNetworkElement(netconfAccessor, databaseService);
- assertEquals(3, gRanNe.getDeviceType().getIntValue());
- assertEquals("RAN3GPP", gRanNe.getDeviceType().getName());
- assertEquals(NODEID, gRanNe.getNodeId().getValue());
-
- gRanNe.register();
- gRanNe.deregister();
- gRanNe.warmstart();
- gRanNe.getAcessor();
- gRanNe.getService(null);
-
- }
+ private static final String NODEID = "node1";
+
+ @Test
+ public void test() {
+ NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
+ DataProvider databaseService = mock(DataProvider.class);
+
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
+
+ GRanNetworkElement gRanNe = new GRanNetworkElement(netconfAccessor, databaseService);
+ assertEquals(3, gRanNe.getDeviceType().getIntValue());
+ assertEquals("RAN3GPP", gRanNe.getDeviceType().getName());
+ assertEquals(NODEID, gRanNe.getNodeId().getValue());
+
+ gRanNe.register();
+ gRanNe.deregister();
+ gRanNe.warmstart();
+ gRanNe.getAcessor();
+ gRanNe.getService(null);
+
+ }
}
diff --git a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java
index 4d0417bf7..b307d8877 100644
--- a/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-gran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/gran/test/TestGRanNetworkElementFactory.java
@@ -33,36 +33,36 @@ import org.opendaylight.yang.gen.v1.urn._3gpp.tsg.sa5.nrm.top.rev180731.TopGrp;
public class TestGRanNetworkElementFactory {
- Capabilities capabilities;
- NetconfAccessor netconfAccessor;
- DeviceManagerServiceProvider devMgrService;
-
- @SuppressWarnings("unused")
- @Before
- public void init() {
- capabilities = mock(Capabilities.class);
- netconfAccessor = mock(NetconfAccessor.class);
- devMgrService = mock(DeviceManagerServiceProvider.class);
-
- when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
- when(devMgrService.getDataProvider()).thenReturn(null);
-
- }
-
- @Test
- public void testCreate() throws Exception {
- when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(true);
-
- GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
- assertTrue((gRanNeFactory.create(netconfAccessor, devMgrService)).isPresent());
- }
+ Capabilities capabilities;
+ NetconfAccessor netconfAccessor;
+ DeviceManagerServiceProvider devMgrService;
- @Test
- public void testCreateNone() throws Exception {
- when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(false);
-
- GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
- assertTrue(!(gRanNeFactory.create(netconfAccessor, devMgrService).isPresent()));
- }
+ @SuppressWarnings("unused")
+ @Before
+ public void init() {
+ capabilities = mock(Capabilities.class);
+ netconfAccessor = mock(NetconfAccessor.class);
+ devMgrService = mock(DeviceManagerServiceProvider.class);
+
+ when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
+ when(devMgrService.getDataProvider()).thenReturn(null);
+
+ }
+
+ @Test
+ public void testCreate() throws Exception {
+ when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(true);
+
+ GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
+ assertTrue((gRanNeFactory.create(netconfAccessor, devMgrService)).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(netconfAccessor.getCapabilites().isSupportingNamespace(TopGrp.QNAME)).thenReturn(false);
+
+ GRanNetworkElementFactory gRanNeFactory = new GRanNetworkElementFactory();
+ assertTrue(!(gRanNeFactory.create(netconfAccessor, devMgrService).isPresent()));
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java
index 0537ec828..c349ad3ba 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/NetworkElementCoreData.java
@@ -25,8 +25,11 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.pro
public interface NetworkElementCoreData {
public String getMountpoint();
+
public DataBroker getDataBroker();
+
public Optional<NetworkElement> getOptionalNetworkElement();
+
public NetworkElementDeviceType getDeviceType();
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java
index 4122a7190..a460853c6 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ONFCoreNetworkElementRepresentation.java
@@ -27,9 +27,8 @@ public interface ONFCoreNetworkElementRepresentation
extends DeviceMonitoredNe, PerformanceDataProvider, NetworkElementCoreData, InventoryProvider, NetworkElement {
/**
- * Read during startup all relevant structure and status parameters from device.
- * Remove all currentAlarms, read structure from networkElement with all
- * interfacePacs, read current alarm status
+ * Read during startup all relevant structure and status parameters from device. Remove all currentAlarms, read
+ * structure from networkElement with all interfacePacs, read current alarm status
*/
public void initialReadFromNetworkElement();
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java
index 4d9c8b14d..7b0409a1f 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/OnfInterfacePac.java
@@ -24,14 +24,13 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170
public interface OnfInterfacePac {
/**
- * Read problems of specific interfaces. TODO Goal for future implementation
- * without usage of explicit new. Key is generated by newInstance() function
- * here to verify this approach.
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
+ * generated by newInstance() function here to verify this approach.
*
* @param interfacePacUuid Universal index of Interfacepac
* @param resultList List to add fault. If null new list is created.
* @return list of alarms
*/
- public FaultData readTheFaults(@NonNull UniversalId interfacePacUuid, @NonNull FaultData resultList);
+ public FaultData readTheFaults(@NonNull UniversalId interfacePacUuid, @NonNull FaultData resultList);
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java
index 1d25b4be0..4359401c6 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/WrapperPTPModelRev170208.java
@@ -39,8 +39,8 @@ public class WrapperPTPModelRev170208 {
private static final Logger LOG = LoggerFactory.getLogger(WrapperPTPModelRev170208.class);
- protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier
- .builder(InstanceList.class, new InstanceListKey(1)).build();
+ protected static final InstanceIdentifier<InstanceList> PTPINSTANCES_IID =
+ InstanceIdentifier.builder(InstanceList.class, new InstanceListKey(1)).build();
/**
* Query synchronization information out of NE
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java
index 56e616e9b..2ca2a9d63 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ExtendedEquipment.java
@@ -44,6 +44,7 @@ public class ExtendedEquipment {
private final Equipment equipment;
private final String nodeId;
private final String path;
+
/**
* Equipment with additional information beside NETCONF equipment
*
@@ -71,6 +72,7 @@ public class ExtendedEquipment {
public int getTreeLevel() {
return treeLevel;
}
+
public String getNodeId() {
return nodeId;
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java
index aa88d98ad..5641f2873 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ONFCoreNetworkElement12Equipment.java
@@ -62,7 +62,8 @@ public class ONFCoreNetworkElement12Equipment {
private final @NonNull FaultData globalProblemList;
private final @NonNull List<ExtendedEquipment> globalEquipmentList;
- public ONFCoreNetworkElement12Equipment(NetconfAccessor acessor, NetworkElementCoreData coreData, Capabilities capabilities) {
+ public ONFCoreNetworkElement12Equipment(NetconfAccessor acessor, NetworkElementCoreData coreData,
+ Capabilities capabilities) {
LOG.debug("Initialize class: {} " + ONFCoreNetworkElement12Equipment.class.getName());
this.acessor = acessor;
this.coreData = coreData;
@@ -188,7 +189,8 @@ public class ONFCoreNetworkElement12Equipment {
Equipment equipment = this.readEquipment(uuid);
if (equipment != null) {
- equipmentList.add(new ExtendedEquipment(this.getMountpoint(),parentUuid.getValue(), equipment, path, treeLevel));
+ equipmentList.add(
+ new ExtendedEquipment(this.getMountpoint(), parentUuid.getValue(), equipment, path, treeLevel));
if (this.equipmentPac != null) {
this.equipmentPac.readTheFaults(uuid, problemList);
@@ -196,8 +198,8 @@ public class ONFCoreNetworkElement12Equipment {
List<ContainedHolder> containedHolderListe = equipment.getContainedHolder();
if (containedHolderListe != null) {
for (ContainedHolder containedHolder : containedHolderListe) {
- recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid, path+"/"+uuid.getValue(), treeLevel + 1,
- problemList, equipmentList);
+ recurseReadEquipmentProblems(containedHolder.getOccupyingFru(), uuid,
+ path + "/" + uuid.getValue(), treeLevel + 1, problemList, equipmentList);
}
}
}
@@ -205,7 +207,8 @@ public class ONFCoreNetworkElement12Equipment {
}
}
- private @NonNull InventoryInformationDcae getInventoryInformationDcae(ValueNameList extensions, List<String> uuids) {
+ private @NonNull InventoryInformationDcae getInventoryInformationDcae(ValueNameList extensions,
+ List<String> uuids) {
InventoryInformationDcae inventoryInformation = new InventoryInformationDcae();
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java
index 1deb4fa1e..b79d0aa2b 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/ValueNameList.java
@@ -25,8 +25,7 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170
import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.extension.g.Extension;
/**
- * ValueNameList is an access Wrapper to NETCONF Extension lists
- * Class is a specialized HashMap.
+ * ValueNameList is an access Wrapper to NETCONF Extension lists Class is a specialized HashMap.
*/
public class ValueNameList extends HashMap<String, String> {
@@ -34,6 +33,7 @@ public class ValueNameList extends HashMap<String, String> {
/**
* Create ValueNameList for NETCONF extensions
+ *
* @param extensionList Parameters as received from device. Could be null.
*/
public void put(@Nullable List<Extension> extensionList) {
@@ -54,6 +54,7 @@ public class ValueNameList extends HashMap<String, String> {
/**
* Return value or null
+ *
* @param name key for element
* @return value if key exists; if not nul
*/
@@ -63,11 +64,12 @@ public class ValueNameList extends HashMap<String, String> {
/**
* Get element as id list
+ *
* @param name key of element
* @param topLevelEqUuidList as input to add elements
* @return List<UniversalId>
*/
- public @NonNull List<UniversalId> getAsUniversalIdList(String name, List<UniversalId> topLevelEqUuidList) {
+ public @NonNull List<UniversalId> getAsUniversalIdList(String name, List<UniversalId> topLevelEqUuidList) {
if (containsKey(name)) {
String[] result = get(name).split(",\\s*");
if (result.length > 0) {
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java
index 28042668c..840d8bf12 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/WrapperEquipmentPacRev170402.java
@@ -54,8 +54,8 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac {
}
/**
- * Read problems of specific interfaces. TODO Goal for future implementation without usage of
- * explicit new. Key is generated by newInstance() function here to verify this approach.
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
+ * generated by newInstance() function here to verify this approach.
*
* @param interfacePacUuid Universal index of onf interface-pac
* @param resultList list to add, or null for new list.
@@ -67,7 +67,7 @@ public class WrapperEquipmentPacRev170402 implements OnfInterfacePac {
final Class<EquipmentPac> clazzPac = EquipmentPac.class;
final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class;
final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
acessor.getNodeId(), interfacePacUuid.getValue());
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java
index 79e95cc59..406884475 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/OnfMicrowaveModel.java
@@ -39,16 +39,18 @@ public interface OnfMicrowaveModel {
// -- Frankfurt below
- /** Get performancedata from LTP
- *
- * @param lpName filter for layerprotocol
- * @param lp to get pm from
- * @return the pm data object
- */
- @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp);
-
- /** Set notificationqueue worker for specific notification that needs to be forwarded **/
- void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue);
+ /**
+ * Get performancedata from LTP
+ *
+ * @param lpName filter for layerprotocol
+ * @param lp to get pm from
+ * @return the pm data object
+ */
+ @NonNull
+ PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp);
+
+ /** Set notificationqueue worker for specific notification that needs to be forwarded **/
+ void setNotificationQueue(NotificationWorker<EventlogEntity> notificationQueue);
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java
index 8aad824b0..891aa3d6d 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev170324.java
@@ -96,7 +96,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
/**
* @param acessor to access device
*/
- public WrapperMicrowaveModelRev170324(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
+ public WrapperMicrowaveModelRev170324(@NonNull NetconfAccessor acessor,
+ @NonNull DeviceManagerServiceProvider serviceProvider) {
this.acessor = acessor;
this.genericTransactionUtils = acessor.getTransactionUtils();
this.microwaveModelListener = serviceProvider.getNotificationService();
@@ -111,7 +112,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
@SuppressWarnings("unchecked")
@Override
public <T extends NotificationListener> T getNotificationListener() {
- return (T)this;
+ return (T) this;
}
@Override
@@ -128,43 +129,44 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
FaultData resultList) {
switch (lpName) {
- case MWAIRINTERFACE:
- readTheFaultsOfMwAirInterfacePac(uuid, resultList);
- break;
+ case MWAIRINTERFACE:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
- case ETHERNETCONTAINER12:
- readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
- break;
+ case ETHERNETCONTAINER12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
- case TDMCONTAINER:
- readTheFaultsOfMwTdmContainerPac(uuid, resultList);
- break;
+ case TDMCONTAINER:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
- case STRUCTURE:
- if (lpClass == MwHybridMwStructurePac.class) {
- readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+ case STRUCTURE:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
- } else if (lpClass == MwAirInterfaceDiversityPac.class) {
- readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
- } else if (lpClass == MwPureEthernetStructurePac.class) {
- readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
- } else {
- LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
- }
- break;
- case ETHERNET:
- // No alarms supported
- break;
- case ETHERNETCONTAINER10:
- default:
- LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case ETHERNET:
+ // No alarms supported
+ break;
+ case ETHERNETCONTAINER10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
}
}
@Override
- public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) {
+ public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
+ @NonNull Lp lp) {
PerformanceDataLtp res = new PerformanceDataLtp();
readAirInterfacePerformanceData(lp, res);
readEthernetContainerPerformanceData(lp, res);
@@ -202,7 +204,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
}
@Override
- public void onObjectDeletionNotification( ObjectDeletionNotification notification) {
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
if (notification != null) {
microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
@@ -228,9 +230,9 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
- faultService.faultNotification(acessor.getNodeId(), notification.getCounter(),
- notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(),
- notification.getProblem(), mapSeverity(notification.getSeverity()));
+ faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(),
+ Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), notification.getProblem(),
+ mapSeverity(notification.getSeverity()));
}
/*-----------------------------------------------------------------------------
@@ -246,15 +248,15 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
- .child(AirInterfaceCurrentProblems.class).build();
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
// Step 2.3: read to the config data store
AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
@@ -265,7 +267,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -281,7 +284,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -297,7 +300,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -309,12 +313,11 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -329,7 +332,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -341,12 +345,11 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -361,7 +364,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -377,7 +381,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -392,16 +396,16 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
}
/**
- * Read problems of specific interfaces. TODO Goal for future implementation
- * without usage of explicit new. Key is generated by newInstance() function
- * here to verify this approach.
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
+ * generated by newInstance() function here to verify this approach.
*
* @param uuId Universal index of Interfacepac
* @return number of alarms
@@ -417,7 +421,7 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
+
String mountpointId = acessor.getNodeId().getValue();
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -437,7 +441,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
// -- Specific part 3
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
@@ -447,8 +452,9 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
return resultList;
}
- /**
+ /**
* Read and add performance data
+ *
* @param lp to read from
* @param result Object to be filled with data
* @return result
@@ -459,9 +465,9 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
// ----
UniversalId mwAirInterfacePacuuId = lp.getUuid();
// Step 2.1: construct data and the relative iid
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceConfiguration.class).build();
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
@@ -470,9 +476,9 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
} else {
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceHistoricalPerformances.class).build();
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
// Step 2.3: read to the config data store
AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
@@ -483,13 +489,14 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
mwAirInterfacePacuuId);
} else {
// org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
airHistPMList.size());
for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
.nonnullHistoricalPerformanceDataList()) {
- result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration));
+ result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord,
+ airConfiguration));
}
}
}
@@ -518,8 +525,8 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
if (ethContainerHistoricalPerformanceData == null) {
LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
} else {
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
result.add(new PerformanceDataAirInterface170324Builder(acessor.getNodeId(), lp, pmRecord));
@@ -529,11 +536,14 @@ public class WrapperMicrowaveModelRev170324 implements OnfMicrowaveModel, Microw
return result;
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) {
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity(
+ SeverityType severity) {
Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name());
- return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType
+ .forName(severity.name());
+ return res.orElse(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
}
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java
index 0f200e91c..10abc8e7a 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev180907.java
@@ -97,10 +97,12 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
/**
* Handle specific version of microwave model
+ *
* @param acessor to access device
* @param serviceProvider for devicemanager services
*/
- public WrapperMicrowaveModelRev180907(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
+ public WrapperMicrowaveModelRev180907(@NonNull NetconfAccessor acessor,
+ @NonNull DeviceManagerServiceProvider serviceProvider) {
this.acessor = acessor;
this.mountpointId = acessor.getNodeId().getValue();
this.genericTransactionUtil = acessor.getTransactionUtils();
@@ -133,61 +135,63 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
FaultData resultList) {
switch (lpName) {
- case MWAIRINTERFACE:
- readTheFaultsOfMwAirInterfacePac(uuid, resultList);
- break;
+ case MWAIRINTERFACE:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
- case ETHERNETCONTAINER12:
- readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
- break;
+ case ETHERNETCONTAINER12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
- case TDMCONTAINER:
- readTheFaultsOfMwTdmContainerPac(uuid, resultList);
- break;
+ case TDMCONTAINER:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
- case STRUCTURE:
- if (lpClass == MwHybridMwStructurePac.class) {
- readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+ case STRUCTURE:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
- } else if (lpClass == MwAirInterfaceDiversityPac.class) {
- readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
- } else if (lpClass == MwPureEthernetStructurePac.class) {
- readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
- } else {
- LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
- }
- break;
- case ETHERNET:
- // No alarms supported
- break;
- case ETHERNETCONTAINER10:
- default:
- LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case ETHERNET:
+ // No alarms supported
+ break;
+ case ETHERNETCONTAINER10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
}
}
@Override
- public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) {
+ public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
+ @NonNull Lp lp) {
PerformanceDataLtp res = new PerformanceDataLtp();
switch (lpName) {
- case MWAIRINTERFACE:
- readAirInterfacePerformanceData(lp, res);
- break;
-
- case ETHERNETCONTAINER12:
- readEthernetContainerPerformanceData(lp, res);
- break;
-
- case ETHERNETCONTAINER10:
- case ETHERNETPHYSICAL:
- case ETHERNET:
- case TDMCONTAINER:
- case STRUCTURE:
- case UNKNOWN:
- LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue());
- break;
+ case MWAIRINTERFACE:
+ readAirInterfacePerformanceData(lp, res);
+ break;
+
+ case ETHERNETCONTAINER12:
+ readEthernetContainerPerformanceData(lp, res);
+ break;
+
+ case ETHERNETCONTAINER10:
+ case ETHERNETPHYSICAL:
+ case ETHERNET:
+ case TDMCONTAINER:
+ case STRUCTURE:
+ case UNKNOWN:
+ LOG.debug("Do not read HistoricalPM data for {} {}", lpName,
+ Helper.nnGetUniversalId(lp.getUuid()).getValue());
+ break;
}
return res;
}
@@ -222,7 +226,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
}
@Override
- public void onObjectDeletionNotification( ObjectDeletionNotification notification) {
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
if (notification != null) {
microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
@@ -248,9 +252,9 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
- faultService.faultNotification(acessor.getNodeId(), notification.getCounter(),
- notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(),
- notification.getProblem(), mapSeverity(notification.getSeverity()));
+ faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(),
+ Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), notification.getProblem(),
+ mapSeverity(notification.getSeverity()));
}
/*-----------------------------------------------------------------------------
@@ -263,18 +267,17 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @param uuId Universal Id String of the interface
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
- .child(AirInterfaceCurrentProblems.class).build();
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
// Step 2.3: read to the config data store
AirInterfaceCurrentProblems problems = genericTransactionUtil.readData(acessor.getDataBroker(),
@@ -285,7 +288,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -297,11 +301,10 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -316,7 +319,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -328,12 +332,11 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -347,7 +350,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -359,12 +363,11 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -378,7 +381,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -390,12 +394,11 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -409,16 +412,16 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
}
/**
- * Read problems of specific interfaces. TODO Goal for future implementation
- * without usage of explicit new. Key is generated by newInstance() function
- * here to verify this approach.
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
+ * generated by newInstance() function here to verify this approach.
*
* @param uuId Universal index of Interfacepac
* @return number of alarms
@@ -429,13 +432,12 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
* @throws IllegalAccessException
* @throws InstantiationException
*/
- private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -454,7 +456,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
// -- Specific part 3
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
@@ -466,6 +469,7 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
/**
* Read and add performance data
+ *
* @param lp to read from
* @param result Object to be filled with data
* @return result
@@ -476,9 +480,9 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
// ----
UniversalId mwAirInterfacePacuuId = lp.getUuid();
// Step 2.1: construct data and the relative iid
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceConfiguration.class).build();
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
@@ -487,9 +491,9 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
} else {
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceHistoricalPerformances.class).build();
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
// Step 2.3: read to the config data store
AirInterfaceHistoricalPerformances airHistoricalPerformanceData = acessor.getTransactionUtils().readData(
@@ -500,13 +504,14 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
mwAirInterfacePacuuId);
} else {
// org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
airHistPMList.size());
for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
.nonnullHistoricalPerformanceDataList()) {
- result.add(new PerformanceDataAirInterface180907Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration));
+ result.add(new PerformanceDataAirInterface180907Builder(acessor.getNodeId(), lp, pmRecord,
+ airConfiguration));
}
}
}
@@ -532,8 +537,8 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
if (ethContainerHistoricalPerformanceData == null) {
LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
} else {
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
result.add(new PerformanceDataAirInterface180907Builder(acessor.getNodeId(), lp, pmRecord));
@@ -543,11 +548,14 @@ public class WrapperMicrowaveModelRev180907 implements OnfMicrowaveModel, Microw
return result;
}
- private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) {
+ private org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity(
+ SeverityType severity) {
Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name());
- return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType
+ .forName(severity.name());
+ return res.orElse(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
}
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java
index 2531baaac..f0f5bf117 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/WrapperMicrowaveModelRev181010.java
@@ -96,10 +96,12 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
/**
* Handle specific version of microwave model
+ *
* @param acessor to access device
* @param serviceProvider for devicemanager services
*/
- public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor, @NonNull DeviceManagerServiceProvider serviceProvider) {
+ public WrapperMicrowaveModelRev181010(@NonNull NetconfAccessor acessor,
+ @NonNull DeviceManagerServiceProvider serviceProvider) {
this.acessor = acessor;
this.genericTransactionUtils = acessor.getTransactionUtils();
this.mountpointId = acessor.getNodeId().getValue();
@@ -132,58 +134,60 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
FaultData resultList) {
switch (lpName) {
- case MWAIRINTERFACE:
- readTheFaultsOfMwAirInterfacePac(uuid, resultList);
- break;
+ case MWAIRINTERFACE:
+ readTheFaultsOfMwAirInterfacePac(uuid, resultList);
+ break;
- case ETHERNETCONTAINER12:
- readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
- break;
+ case ETHERNETCONTAINER12:
+ readTheFaultsOfMwEthernetContainerPac(uuid, resultList);
+ break;
- case TDMCONTAINER:
- readTheFaultsOfMwTdmContainerPac(uuid, resultList);
- break;
+ case TDMCONTAINER:
+ readTheFaultsOfMwTdmContainerPac(uuid, resultList);
+ break;
- case STRUCTURE:
- if (lpClass == MwHybridMwStructurePac.class) {
- readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
+ case STRUCTURE:
+ if (lpClass == MwHybridMwStructurePac.class) {
+ readTheFaultsOfMwHybridMwStructurePac(uuid, resultList);
- } else if (lpClass == MwAirInterfaceDiversityPac.class) {
- readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
+ } else if (lpClass == MwAirInterfaceDiversityPac.class) {
+ readTheFaultsOfMwAirInterfaceDiversityPac(uuid, resultList);
- } else if (lpClass == MwPureEthernetStructurePac.class) {
- readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
+ } else if (lpClass == MwPureEthernetStructurePac.class) {
+ readTheFaultsOfMwPureEthernetStructurePac(uuid, resultList);
- } else {
- LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
- }
- break;
- case ETHERNET:
- // No alarms supported
- break;
- case ETHERNETCONTAINER10:
- default:
- LOG.warn("Unassigned or not expected lp in model {}", lpName);
+ } else {
+ LOG.warn("Unassigned lp model {} class {}", lpName, lpClass);
+ }
+ break;
+ case ETHERNET:
+ // No alarms supported
+ break;
+ case ETHERNETCONTAINER10:
+ default:
+ LOG.warn("Unassigned or not expected lp in model {}", lpName);
}
}
@Override
- public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName, @NonNull Lp lp) {
+ public @NonNull PerformanceDataLtp getLtpHistoricalPerformanceData(@NonNull ONFLayerProtocolName lpName,
+ @NonNull Lp lp) {
PerformanceDataLtp res = new PerformanceDataLtp();
switch (lpName) {
- case MWAIRINTERFACE:
- return readAirInterfacePerformanceData(lp, res);
-
- case ETHERNETCONTAINER12:
- return readEthernetContainerPerformanceData(lp, res);
-
- case ETHERNETCONTAINER10:
- case ETHERNETPHYSICAL:
- case ETHERNET:
- case TDMCONTAINER:
- case STRUCTURE:
- case UNKNOWN:
- LOG.debug("Do not read HistoricalPM data for {} {}", lpName, Helper.nnGetUniversalId(lp.getUuid()).getValue());
+ case MWAIRINTERFACE:
+ return readAirInterfacePerformanceData(lp, res);
+
+ case ETHERNETCONTAINER12:
+ return readEthernetContainerPerformanceData(lp, res);
+
+ case ETHERNETCONTAINER10:
+ case ETHERNETPHYSICAL:
+ case ETHERNET:
+ case TDMCONTAINER:
+ case STRUCTURE:
+ case UNKNOWN:
+ LOG.debug("Do not read HistoricalPM data for {} {}", lpName,
+ Helper.nnGetUniversalId(lp.getUuid()).getValue());
}
return res;
}
@@ -218,7 +222,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
}
@Override
- public void onObjectDeletionNotification( ObjectDeletionNotification notification) {
+ public void onObjectDeletionNotification(ObjectDeletionNotification notification) {
LOG.debug("Got event of type :: {}", ObjectDeletionNotification.class.getSimpleName());
if (notification != null) {
microwaveModelListener.deletionNotification(acessor.getNodeId(), notification.getCounter(),
@@ -244,9 +248,9 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
LOG.debug("Got event of type :: {}", ProblemNotification.class.getSimpleName());
- faultService.faultNotification(acessor.getNodeId(), notification.getCounter(),
- notification.getTimeStamp(), Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(),
- notification.getProblem(), mapSeverity(notification.getSeverity()));
+ faultService.faultNotification(acessor.getNodeId(), notification.getCounter(), notification.getTimeStamp(),
+ Helper.nnGetUniversalId(notification.getObjectIdRef()).getValue(), notification.getProblem(),
+ mapSeverity(notification.getSeverity()));
}
/*-----------------------------------------------------------------------------
@@ -259,18 +263,17 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @param uuId Universal Id String of the interface
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwAirInterfacePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfacePac> clazzPac = MwAirInterfacePac.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
- .child(AirInterfaceCurrentProblems.class).build();
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(interfacePacUuid))
+ .child(AirInterfaceCurrentProblems.class).build();
// Step 2.3: read to the config data store
AirInterfaceCurrentProblems problems = genericTransactionUtils.readData(acessor.getDataBroker(),
@@ -283,7 +286,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -295,11 +299,10 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwEthernetContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwEthernetContainerPac> clazzPac = MwEthernetContainerPac.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -316,7 +319,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -328,12 +332,11 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwAirInterfaceDiversityPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -349,7 +352,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
for (AirInterfaceDiversityCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -361,12 +365,11 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwPureEthernetStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -382,7 +385,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
@@ -394,12 +398,11 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @param uuId Universal index of Interfacepac
* @return number of alarms
*/
- private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwHybridMwStructurePac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -415,16 +418,16 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
for (StructureCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
return resultList;
}
/**
- * Read problems of specific interfaces. TODO Goal for future implementation
- * without usage of explicit new. Key is generated by newInstance() function
- * here to verify this approach.
+ * Read problems of specific interfaces. TODO Goal for future implementation without usage of explicit new. Key is
+ * generated by newInstance() function here to verify this approach.
*
* @param uuId Universal index of Interfacepac
* @return number of alarms
@@ -435,13 +438,12 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
* @throws IllegalAccessException
* @throws InstantiationException
*/
- private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid,
- FaultData resultList) {
+ private FaultData readTheFaultsOfMwTdmContainerPac(UniversalId interfacePacUuid, FaultData resultList) {
final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
+
LOG.info("DBRead Get problems for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
mountpointId, interfacePacUuid.getValue());
@@ -460,7 +462,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
// -- Specific part 3
for (ContainerCurrentProblemTypeG problem : problems.nonnullCurrentProblemList()) {
resultList.add(acessor.getNodeId(), problem.getSequenceNumber(), problem.getTimeStamp(),
- interfacePacUuid.getValue(), problem.getProblemName(), mapSeverity(problem.getProblemSeverity()));
+ interfacePacUuid.getValue(), problem.getProblemName(),
+ mapSeverity(problem.getProblemSeverity()));
}
}
} catch (NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException
@@ -476,6 +479,7 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
/**
* Read and add performance data
+ *
* @param lp to read from
* @param result Object to be filled with data
* @return result
@@ -486,9 +490,9 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
// ----
UniversalId mwAirInterfacePacuuId = lp.getUuid();
// Step 2.1: construct data and the relative iid
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceConfiguration.class).build();
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceConfiguration.class).build();
AirInterfaceConfiguration airConfiguration = acessor.getTransactionUtils().readData(acessor.getDataBroker(),
LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID);
@@ -497,9 +501,9 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
} else {
// Step 2.2: construct data and the relative iid
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
- .child(AirInterfaceHistoricalPerformances.class).build();
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(mwAirInterfacePacuuId))
+ .child(AirInterfaceHistoricalPerformances.class).build();
// Step 2.3: read to the config data store
AirInterfaceHistoricalPerformances airHistoricalPerformanceData = genericTransactionUtils.readData(
@@ -510,13 +514,14 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
mwAirInterfacePacuuId);
} else {
// org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170320.air._interface.historical.performances.g.HistoricalPerformanceDataList
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = airHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ airHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead MWAirInterfacePac Id {} Records intermediate: {}", mwAirInterfacePacuuId,
airHistPMList.size());
for (AirInterfaceHistoricalPerformanceTypeG pmRecord : airHistoricalPerformanceData
.nonnullHistoricalPerformanceDataList()) {
- result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord, airConfiguration));
+ result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord,
+ airConfiguration));
}
}
}
@@ -542,8 +547,8 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
if (ethContainerHistoricalPerformanceData == null) {
LOG.debug("DBRead {} Id {} no HistoricalPerformances", myName, ethContainerPacuuId);
} else {
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList = ethContainerHistoricalPerformanceData
- .nonnullHistoricalPerformanceDataList();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ ethContainerHistoricalPerformanceData.nonnullHistoricalPerformanceDataList();
LOG.debug("DBRead {} Id {} Records intermediate: {}", myName, ethContainerPacuuId, airHistPMList.size());
for (ContainerHistoricalPerformanceTypeG pmRecord : airHistPMList) {
result.add(new PerformanceDataAirInterface181010Builder(acessor.getNodeId(), lp, pmRecord));
@@ -553,11 +558,14 @@ public class WrapperMicrowaveModelRev181010 implements OnfMicrowaveModel, Microw
return result;
}
- public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity( SeverityType severity) {
+ public static org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType mapSeverity(
+ SeverityType severity) {
Optional<org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType> res =
- org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.forName(severity.name());
- return res.orElse(org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType
+ .forName(severity.name());
+ return res.orElse(
+ org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.data.provider.rev190801.SeverityType.NonAlarmed);
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java
index 6f9fd63c4..792f62011 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface170324Builder.java
@@ -34,7 +34,8 @@ public class PerformanceDataAirInterface170324Builder extends PmdataEntityBuilde
private PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) {
super();
- Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
+ Optional<GranularityPeriodType> gp = GranularityPeriodType
+ .forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown));
this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue());
this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue());
@@ -46,13 +47,14 @@ public class PerformanceDataAirInterface170324Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
* @param airConfiguration configuration for additional parameter
*/
- public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord,
- AirInterfaceConfiguration airConfiguration) {
+ public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp,
+ AirInterfaceHistoricalPerformanceTypeG pmRecord, AirInterfaceConfiguration airConfiguration) {
this(nodeId, lp, pmRecord);
this.setRadioSignalId(airConfiguration.getRadioSignalId());
@@ -106,14 +108,16 @@ public class PerformanceDataAirInterface170324Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
*/
- public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) {
+ public PerformanceDataAirInterface170324Builder(NodeId nodeId, Lp lp,
+ ContainerHistoricalPerformanceTypeG pmRecord) {
this(nodeId, lp, (OtnHistoryDataG) pmRecord);
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData pmr = pmRecord
- .getPerformanceData();
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData pmr =
+ pmRecord.getPerformanceData();
if (pmr != null) {
PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder();
bPerformanceData.setTimePeriod(pmr.getTimePeriod());
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java
index 022f3f160..7aeddc963 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface180907Builder.java
@@ -34,7 +34,8 @@ public class PerformanceDataAirInterface180907Builder extends PmdataEntityBuilde
private PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) {
super();
- Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
+ Optional<GranularityPeriodType> gp = GranularityPeriodType
+ .forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown));
this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue());
this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue());
@@ -46,13 +47,14 @@ public class PerformanceDataAirInterface180907Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
* @param airConfiguration configuration for additional parameter
*/
- public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord,
- AirInterfaceConfiguration airConfiguration) {
+ public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp,
+ AirInterfaceHistoricalPerformanceTypeG pmRecord, AirInterfaceConfiguration airConfiguration) {
this(nodeId, lp, pmRecord);
this.setRadioSignalId(airConfiguration.getRadioSignalId());
@@ -106,14 +108,16 @@ public class PerformanceDataAirInterface180907Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
*/
- public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) {
+ public PerformanceDataAirInterface180907Builder(NodeId nodeId, Lp lp,
+ ContainerHistoricalPerformanceTypeG pmRecord) {
this(nodeId, lp, (OtnHistoryDataG) pmRecord);
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData pmr = pmRecord
- .getPerformanceData();
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData pmr =
+ pmRecord.getPerformanceData();
if (pmr != null) {
PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder();
bPerformanceData.setTimePeriod(pmr.getTimePeriod());
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java
index 83e3e72fd..68fdb1812 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/pm/PerformanceDataAirInterface181010Builder.java
@@ -34,7 +34,8 @@ public class PerformanceDataAirInterface181010Builder extends PmdataEntityBuilde
private PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, OtnHistoryDataG pmRecord) {
super();
- Optional<GranularityPeriodType> gp = GranularityPeriodType.forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
+ Optional<GranularityPeriodType> gp = GranularityPeriodType
+ .forName(Helper.nnGetGranularityPeriodType(pmRecord.getGranularityPeriod()).getName());
this.setGranularityPeriod(gp.orElse(GranularityPeriodType.Unknown));
this.setUuidInterface(Helper.nnGetUniversalId(lp.getUuid()).getValue());
this.setLayerProtocolName(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue());
@@ -46,13 +47,14 @@ public class PerformanceDataAirInterface181010Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
* @param airConfiguration configuration for additional parameter
*/
- public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, AirInterfaceHistoricalPerformanceTypeG pmRecord,
- AirInterfaceConfiguration airConfiguration) {
+ public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp,
+ AirInterfaceHistoricalPerformanceTypeG pmRecord, AirInterfaceConfiguration airConfiguration) {
this(nodeId, lp, pmRecord);
this.setRadioSignalId(airConfiguration.getRadioSignalId());
@@ -106,14 +108,16 @@ public class PerformanceDataAirInterface181010Builder extends PmdataEntityBuilde
/**
* Move data to generic type
+ *
* @param nodeId of node
* @param lp to get data from
- * @param pmRecord data itself
+ * @param pmRecord data itself
*/
- public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp, ContainerHistoricalPerformanceTypeG pmRecord) {
+ public PerformanceDataAirInterface181010Builder(NodeId nodeId, Lp lp,
+ ContainerHistoricalPerformanceTypeG pmRecord) {
this(nodeId, lp, (OtnHistoryDataG) pmRecord);
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData pmr = pmRecord
- .getPerformanceData();
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData pmr =
+ pmRecord.getPerformanceData();
if (pmr != null) {
PerformanceDataBuilder bPerformanceData = new PerformanceDataBuilder();
bPerformanceData.setTimePeriod(pmr.getTimePeriod());
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java
index 3d7ff88c7..b4900b599 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/DeviceManagerOnfImpl.java
@@ -23,7 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkEleme
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DeviceManagerOnfImpl implements AutoCloseable {
+public class DeviceManagerOnfImpl implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerOnfImpl.class);
private static final String APPLICATIONNAME = "DeviceManagerOnf";
@@ -49,8 +49,10 @@ public class DeviceManagerOnfImpl implements AutoCloseable {
LOG.info("Session Initiated start {}", APPLICATIONNAME);
- configuration = new DeviceManagerOnfConfiguration(netconfNetworkElementService.getServiceProvider().getConfigurationFileRepresentation());
- resOnf = netconfNetworkElementService.registerNetworkElementFactory(new ONFCoreNetworkElementFactory(configuration));
+ configuration = new DeviceManagerOnfConfiguration(
+ netconfNetworkElementService.getServiceProvider().getConfigurationFileRepresentation());
+ resOnf = netconfNetworkElementService
+ .registerNetworkElementFactory(new ONFCoreNetworkElementFactory(configuration));
netconfNetworkElementService.writeToEventLog(APPLICATIONNAME, "startup", "done");
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java
index 3d2e04e87..bcfc3e0e4 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/ONFCoreNetworkElementFactory.java
@@ -34,9 +34,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Create a Network Element representation according to the capability
- * information. The capabilities are more than an ODL-QName. After the ? other
- * terms than "revision" are provided.
+ * Create a Network Element representation according to the capability information. The capabilities are more than an
+ * ODL-QName. After the ? other terms than "revision" are provided.
*
*/
public class ONFCoreNetworkElementFactory implements NetworkElementFactory {
@@ -70,7 +69,8 @@ public class ONFCoreNetworkElementFactory implements NetworkElementFactory {
}
if (onfMicrowaveModel != null) {
- return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, serviceProvider, configuration, onfMicrowaveModel));
+ return Optional.of(new ONFCoreNetworkElement12Microwave(acessor, serviceProvider, configuration,
+ onfMicrowaveModel));
} else {
return Optional.of(new ONFCoreNetworkElement12Basic(acessor, serviceProvider, configuration));
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java
index 0b405d002..698a39ab6 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Base.java
@@ -57,378 +57,379 @@ import org.slf4j.LoggerFactory;
*/
public abstract class ONFCoreNetworkElement12Base extends ONFCoreNetworkElementBase implements NetworkElementCoreData {
- private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class);
-
- protected static final @NonNull List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>();
-
- protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
- .builder(NetworkElement.class).build();
-
-
- /*-----------------------------------------------------------------------------
- * Class members
- */
-
- // Non specific part. Used by all functions.
- /** interfaceList is used by PM task and should be synchronized */
- @SuppressWarnings("null")
- private final @NonNull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>());
- private Optional<NetworkElement> optionalNe;
-
- // Performance monitoring specific part
- /** Lock for the PM access specific elements that could be null */
- private final @NonNull Object pmLock = new Object();
- protected @Nullable Iterator<Lp> interfaceListIterator = null;
- /** Actual pmLp used during iteration over interfaces */
- protected @Nullable Lp pmLp = null;
-
- // Device monitoring specific part
- /** Lock for the DM access specific elements that could be null */
- protected final @NonNull Object dmLock = new Object();
-
- protected final boolean isNetworkElementCurrentProblemsSupporting12;
-
- protected final ONFCoreNetworkElement12Equipment equipment;
-
- protected final NodeId nodeId;
-
- /*---------------------------------------------------------------
- * Constructor
- */
-
- protected ONFCoreNetworkElement12Base(@NonNull NetconfAccessor acessor) {
- super(acessor);
- this.optionalNe = Optional.empty();
- this.nodeId = getAcessor().get().getNodeId();
- this.isNetworkElementCurrentProblemsSupporting12 = acessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME);
- this.equipment = new ONFCoreNetworkElement12Equipment(acessor, this, acessor.getCapabilites());
- WrapperPTPModelRev170208.initSynchronizationExtension(acessor);
- LOG.debug("support necurrent-problem-list={}", this.isNetworkElementCurrentProblemsSupporting12);
- }
-
- /*---------------------------------------------------------------
- * Getter/ Setter
- */
-
- @Override
- public Optional<NetworkElement> getOptionalNetworkElement() {
- return optionalNe;
- }
-
- List<Lp> getInterfaceList() {
- return interfaceList;
- }
-
- public Object getPmLock() {
- return pmLock;
- }
-
- /*---------------------------------------------------------------
- * Core model related function
- */
-
- /**
- * Get uuid of Optional NE.
- *
- * @return Uuid or EMPTY String if optionNE is not available
- */
- protected String getUuId() {
- return optionalNe.isPresent() ? Helper.nnGetUniversalId(optionalNe.get().getUuid()).getValue() : EMPTY;
- }
-
- /**
- * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new
- * structure. From initial state it changes also.
- */
- protected synchronized boolean readNetworkElementAndInterfaces() {
-
- LOG.debug("Update mountpoint if changed {}", getMountpoint());
-
- optionalNe = Optional.ofNullable(getGenericTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL,
- NETWORKELEMENT_IID));
- synchronized (pmLock) {
- boolean change = false;
-
- if (!optionalNe.isPresent()) {
- LOG.debug("Unable to read NE data for mountpoint {}", getMountpoint());
- if (!interfaceList.isEmpty()) {
- interfaceList.clear();
- interfaceListIterator = null;
- change = true;
- }
-
- } else {
- NetworkElement ne = optionalNe.get();
- LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountpoint(), ne.getName());
- List<Lp> actualInterfaceList = getLtpList(ne);
- if (!interfaceList.equals(actualInterfaceList)) {
- LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountpoint(),
- actualInterfaceList.size());
- interfaceList.clear();
- interfaceList.addAll(actualInterfaceList);
- interfaceListIterator = null;
- change = true;
- }
- }
- return change;
- }
- }
-
- /**
- * Get List of UUIDs for conditional packages from Networkelement<br>
- * Possible interfaces are:<br>
- * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br>
- * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br>
- * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
- * MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br>
- * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br>
- * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br>
- *
- * @param ne NetworkElement
- * @return Id List, never null.
- */
-
- private static List<Lp> getLtpList(@Nullable NetworkElement ne) {
-
- List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>());
-
- if (ne != null) {
- List<Ltp> ltpRefList = ne.getLtp();
- if (ltpRefList == null) {
- LOG.debug("DBRead NE-Interfaces: null");
- } else {
- for (Ltp ltRefListE : ltpRefList) {
- List<Lp> lpList = ltRefListE.getLp();
- if (lpList == null) {
- LOG.debug("DBRead NE-Interfaces Reference List: null");
- } else {
- for (Lp ltp : lpList) {
- res.add(ltp);
- }
- }
- }
- }
- } else {
- LOG.debug("DBRead NE: null");
- }
-
- // ---- Debug
- if (LOG.isDebugEnabled()) {
- StringBuilder strBuild = new StringBuilder();
- for (Lp ltp : res) {
- if (strBuild.length() > 0) {
- strBuild.append(", ");
- }
- strBuild.append(Helper.nnGetLayerProtocolName(ltp.getLayerProtocolName()).getValue());
- strBuild.append(':');
- strBuild.append(Helper.nnGetUniversalId(ltp.getUuid()).getValue());
- }
- LOG.debug("DBRead NE-Interfaces: {}", strBuild.toString());
- }
- // ---- Debug end
-
- return res;
- }
-
- /**
- * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB
- *
- * @return List with all problems
- */
- protected FaultData readAllCurrentProblemsOfNode() {
-
- // Step 2.3: read the existing faults and add to DB
- FaultData resultList = new FaultData();
- int idxStart; // Start index for debug messages
- UniversalId uuid;
-
- synchronized (pmLock) {
- for (Lp lp : interfaceList) {
-
- idxStart = resultList.size();
- uuid = lp.getUuid();
- FaultData.debugResultList(LOG, uuid.getValue(), resultList, idxStart);
-
- }
- }
-
- // Step 2.4: Read other problems from mountpoint
- if (isNetworkElementCurrentProblemsSupporting12) {
- idxStart = resultList.size();
- readNetworkElementCurrentProblems12(resultList);
- FaultData.debugResultList(LOG, "CurrentProblems12", resultList, idxStart);
- }
-
- return resultList;
-
- }
-
- /**
- * Reading problems for the networkElement V1.2
- * @param resultList to collect the problems
- * @return resultList with additonal problems
- */
- protected FaultData readNetworkElementCurrentProblems12(FaultData resultList) {
-
- LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountpoint());
-
- InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID =
- InstanceIdentifier.builder(
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class)
- .build();
-
- // Step 2.3: read to the config data store
- NetworkElementPac problemPac;
- NetworkElementCurrentProblems problems = null;
- try {
- problemPac = getGenericTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL,
- networkElementCurrentProblemsIID);
- if (problemPac != null) {
- problems = problemPac.getNetworkElementCurrentProblems();
- }
- if (problems == null) {
- LOG.debug("DBRead no NetworkElementCurrentProblems12");
- } else {
- for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems
- .nonnullCurrentProblemList()) {
- resultList.add(nodeId, problem.getSequenceNumber(), problem.getTimeStamp(),
- problem.getObjectReference(), problem.getProblemName(),
- WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity()));
- }
- }
- } catch (Exception e) {
- LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountpoint(),
- e.getMessage());
- }
- return resultList;
- }
-
- /*---------------------------------------------------------------
- * Device Monitor
- */
-
- @Override
- public boolean checkIfConnectionToMediatorIsOk() {
- synchronized (dmLock) {
- return optionalNe != null;
- }
- }
-
- /*
- * New implementation to interpret status with empty LTP List as notConnected => return false
- * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types
- * it needs to be activated by extension or configuration. Change to be disabled at the moment
- */
- @Override
- public boolean checkIfConnectionToNeIsOk() {
- return true;
- }
-
- /*---------------------------------------------------------------
- * Synchronization
- */
-
-
- /*---------------------------------------------------------------
- * Equipment related functions
- */
-
- @Override
- public @NonNull InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) {
- LOG.debug("request inventory information. filter: {}" + layerProtocolFilter);
- return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter));
- }
-
- @Override
- public InventoryInformationDcae getInventoryInformation() {
- return getInventoryInformation(null);
- }
-
- protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) {
- List<String> uuids = new ArrayList<>();
-
- LOG.debug("request inventory information. filter: {}" + layerProtocolFilter);
- if (optionalNe != null) {
- // uuids
- for (Lp lp : this.interfaceList) {
- if (layerProtocolFilter == null ||
- layerProtocolFilter.isEmpty() ||
- layerProtocolFilter.equals(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue())) {
- uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue());
- }
- }
- }
- LOG.debug("uuids found: {}", uuids);
- return uuids;
- }
-
-
- /*---------------------------------------------------------------
- * Performancemanagement specific interface
- */
-
- @Override
- public void resetPMIterator() {
- synchronized (pmLock) {
- interfaceListIterator = interfaceList.iterator();
- }
- LOG.debug("PM reset iterator");
- }
-
- @SuppressWarnings("null")
- @Override
- public boolean hasNext() {
- boolean res;
- synchronized (pmLock) {
- res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false;
- }
- LOG.debug("PM hasNext LTP {}", res);
- return res;
- }
-
- @SuppressWarnings("null")
- @Override
- public void next() {
- synchronized (pmLock) {
- if (interfaceListIterator == null) {
- pmLp = null;
- LOG.debug("PM next LTP null");
- } else {
- pmLp = interfaceListIterator.next();
- LOG.debug("PM next LTP {}", Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue());
- }
- }
- }
-
- @SuppressWarnings("null")
- @Override
- public String pmStatusToString() {
- StringBuilder res = new StringBuilder();
- synchronized (pmLock) {
- res.append(pmLp == null ? "no interface" : Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue());
- for (Lp lp : getInterfaceList()) {
- res.append("IF:");
- res.append(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue());
- res.append(" ");
- }
- }
- return res.toString();
- }
-
- @Override
- public void doRegisterEventListener(MountPoint mountPoint) {
- //Do nothing
- }
-
- @SuppressWarnings("unchecked")
- @Override
- public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) {
- return clazz.isInstance(this) ? Optional.of((L)this) : Optional.empty();
- }
-
- @Override
- public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() {
- return Optional.empty();
- }
+ private static final Logger LOG = LoggerFactory.getLogger(ONFCoreNetworkElement12Base.class);
+
+ protected static final @NonNull List<Extension> EMPTYLTPEXTENSIONLIST = new ArrayList<>();
+
+ protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
+ InstanceIdentifier.builder(NetworkElement.class).build();
+
+
+ /*-----------------------------------------------------------------------------
+ * Class members
+ */
+
+ // Non specific part. Used by all functions.
+ /** interfaceList is used by PM task and should be synchronized */
+ @SuppressWarnings("null")
+ private final @NonNull List<Lp> interfaceList = Collections.synchronizedList(new CopyOnWriteArrayList<>());
+ private Optional<NetworkElement> optionalNe;
+
+ // Performance monitoring specific part
+ /** Lock for the PM access specific elements that could be null */
+ private final @NonNull Object pmLock = new Object();
+ protected @Nullable Iterator<Lp> interfaceListIterator = null;
+ /** Actual pmLp used during iteration over interfaces */
+ protected @Nullable Lp pmLp = null;
+
+ // Device monitoring specific part
+ /** Lock for the DM access specific elements that could be null */
+ protected final @NonNull Object dmLock = new Object();
+
+ protected final boolean isNetworkElementCurrentProblemsSupporting12;
+
+ protected final ONFCoreNetworkElement12Equipment equipment;
+
+ protected final NodeId nodeId;
+
+ /*---------------------------------------------------------------
+ * Constructor
+ */
+
+ protected ONFCoreNetworkElement12Base(@NonNull NetconfAccessor acessor) {
+ super(acessor);
+ this.optionalNe = Optional.empty();
+ this.nodeId = getAcessor().get().getNodeId();
+ this.isNetworkElementCurrentProblemsSupporting12 =
+ acessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElementPac.QNAME);
+ this.equipment = new ONFCoreNetworkElement12Equipment(acessor, this, acessor.getCapabilites());
+ WrapperPTPModelRev170208.initSynchronizationExtension(acessor);
+ LOG.debug("support necurrent-problem-list={}", this.isNetworkElementCurrentProblemsSupporting12);
+ }
+
+ /*---------------------------------------------------------------
+ * Getter/ Setter
+ */
+
+ @Override
+ public Optional<NetworkElement> getOptionalNetworkElement() {
+ return optionalNe;
+ }
+
+ List<Lp> getInterfaceList() {
+ return interfaceList;
+ }
+
+ public Object getPmLock() {
+ return pmLock;
+ }
+
+ /*---------------------------------------------------------------
+ * Core model related function
+ */
+
+ /**
+ * Get uuid of Optional NE.
+ *
+ * @return Uuid or EMPTY String if optionNE is not available
+ */
+ protected String getUuId() {
+ return optionalNe.isPresent() ? Helper.nnGetUniversalId(optionalNe.get().getUuid()).getValue() : EMPTY;
+ }
+
+ /**
+ * Read from NetworkElement and verify LTPs have changed. If the NE has changed, update to the new structure. From
+ * initial state it changes also.
+ */
+ protected synchronized boolean readNetworkElementAndInterfaces() {
+
+ LOG.debug("Update mountpoint if changed {}", getMountpoint());
+
+ optionalNe = Optional.ofNullable(getGenericTransactionUtils().readData(getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID));
+ synchronized (pmLock) {
+ boolean change = false;
+
+ if (!optionalNe.isPresent()) {
+ LOG.debug("Unable to read NE data for mountpoint {}", getMountpoint());
+ if (!interfaceList.isEmpty()) {
+ interfaceList.clear();
+ interfaceListIterator = null;
+ change = true;
+ }
+
+ } else {
+ NetworkElement ne = optionalNe.get();
+ LOG.debug("Mountpoint '{}' NE-Name '{}'", getMountpoint(), ne.getName());
+ List<Lp> actualInterfaceList = getLtpList(ne);
+ if (!interfaceList.equals(actualInterfaceList)) {
+ LOG.debug("Mountpoint '{}' Update LTP List. Elements {}", getMountpoint(),
+ actualInterfaceList.size());
+ interfaceList.clear();
+ interfaceList.addAll(actualInterfaceList);
+ interfaceListIterator = null;
+ change = true;
+ }
+ }
+ return change;
+ }
+ }
+
+ /**
+ * Get List of UUIDs for conditional packages from Networkelement<br>
+ * Possible interfaces are:<br>
+ * MWPS, LTP(MWPS-TTP), MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface<br>
+ * ETH-CTP,LTP(Client), MW_EthernetContainer_Pac<br>
+ * MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity<br>
+ * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-HybridMwStructure<br>
+ * MWS, LTP(MWS-TTP), ,MicrowaveModel-ObjectClasses-PureEthernetStructure<br>
+ *
+ * @param ne NetworkElement
+ * @return Id List, never null.
+ */
+
+ private static List<Lp> getLtpList(@Nullable NetworkElement ne) {
+
+ List<Lp> res = Collections.synchronizedList(new ArrayList<Lp>());
+
+ if (ne != null) {
+ List<Ltp> ltpRefList = ne.getLtp();
+ if (ltpRefList == null) {
+ LOG.debug("DBRead NE-Interfaces: null");
+ } else {
+ for (Ltp ltRefListE : ltpRefList) {
+ List<Lp> lpList = ltRefListE.getLp();
+ if (lpList == null) {
+ LOG.debug("DBRead NE-Interfaces Reference List: null");
+ } else {
+ for (Lp ltp : lpList) {
+ res.add(ltp);
+ }
+ }
+ }
+ }
+ } else {
+ LOG.debug("DBRead NE: null");
+ }
+
+ // ---- Debug
+ if (LOG.isDebugEnabled()) {
+ StringBuilder strBuild = new StringBuilder();
+ for (Lp ltp : res) {
+ if (strBuild.length() > 0) {
+ strBuild.append(", ");
+ }
+ strBuild.append(Helper.nnGetLayerProtocolName(ltp.getLayerProtocolName()).getValue());
+ strBuild.append(':');
+ strBuild.append(Helper.nnGetUniversalId(ltp.getUuid()).getValue());
+ }
+ LOG.debug("DBRead NE-Interfaces: {}", strBuild.toString());
+ }
+ // ---- Debug end
+
+ return res;
+ }
+
+ /**
+ * Read current problems of AirInterfaces and EthernetContainer according to NE status into DB
+ *
+ * @return List with all problems
+ */
+ protected FaultData readAllCurrentProblemsOfNode() {
+
+ // Step 2.3: read the existing faults and add to DB
+ FaultData resultList = new FaultData();
+ int idxStart; // Start index for debug messages
+ UniversalId uuid;
+
+ synchronized (pmLock) {
+ for (Lp lp : interfaceList) {
+
+ idxStart = resultList.size();
+ uuid = lp.getUuid();
+ FaultData.debugResultList(LOG, uuid.getValue(), resultList, idxStart);
+
+ }
+ }
+
+ // Step 2.4: Read other problems from mountpoint
+ if (isNetworkElementCurrentProblemsSupporting12) {
+ idxStart = resultList.size();
+ readNetworkElementCurrentProblems12(resultList);
+ FaultData.debugResultList(LOG, "CurrentProblems12", resultList, idxStart);
+ }
+
+ return resultList;
+
+ }
+
+ /**
+ * Reading problems for the networkElement V1.2
+ *
+ * @param resultList to collect the problems
+ * @return resultList with additonal problems
+ */
+ protected FaultData readNetworkElementCurrentProblems12(FaultData resultList) {
+
+ LOG.info("DBRead Get {} NetworkElementCurrentProblems12", getMountpoint());
+
+ InstanceIdentifier<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac> networkElementCurrentProblemsIID =
+ InstanceIdentifier.builder(
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.NetworkElementPac.class)
+ .build();
+
+ // Step 2.3: read to the config data store
+ NetworkElementPac problemPac;
+ NetworkElementCurrentProblems problems = null;
+ try {
+ problemPac = getGenericTransactionUtils().readData(getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ networkElementCurrentProblemsIID);
+ if (problemPac != null) {
+ problems = problemPac.getNetworkElementCurrentProblems();
+ }
+ if (problems == null) {
+ LOG.debug("DBRead no NetworkElementCurrentProblems12");
+ } else {
+ for (org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.onf.core.model.conditional.packages.rev170402.network.element.current.problems.g.CurrentProblemList problem : problems
+ .nonnullCurrentProblemList()) {
+ resultList.add(nodeId, problem.getSequenceNumber(), problem.getTimeStamp(),
+ problem.getObjectReference(), problem.getProblemName(),
+ WrapperMicrowaveModelRev181010.mapSeverity(problem.getProblemSeverity()));
+ }
+ }
+ } catch (Exception e) {
+ LOG.warn("DBRead {} NetworkElementCurrentProblems12 not supported. Message '{}' ", getMountpoint(),
+ e.getMessage());
+ }
+ return resultList;
+ }
+
+ /*---------------------------------------------------------------
+ * Device Monitor
+ */
+
+ @Override
+ public boolean checkIfConnectionToMediatorIsOk() {
+ synchronized (dmLock) {
+ return optionalNe != null;
+ }
+ }
+
+ /*
+ * New implementation to interpret status with empty LTP List as notConnected => return false
+ * 30.10.2018 Since this behavior is very specific and implicit for specific NE Types
+ * it needs to be activated by extension or configuration. Change to be disabled at the moment
+ */
+ @Override
+ public boolean checkIfConnectionToNeIsOk() {
+ return true;
+ }
+
+ /*---------------------------------------------------------------
+ * Synchronization
+ */
+
+
+ /*---------------------------------------------------------------
+ * Equipment related functions
+ */
+
+ @Override
+ public @NonNull InventoryInformationDcae getInventoryInformation(String layerProtocolFilter) {
+ LOG.debug("request inventory information. filter: {}" + layerProtocolFilter);
+ return this.equipment.getInventoryInformation(getFilteredInterfaceUuidsAsStringList(layerProtocolFilter));
+ }
+
+ @Override
+ public InventoryInformationDcae getInventoryInformation() {
+ return getInventoryInformation(null);
+ }
+
+ protected List<String> getFilteredInterfaceUuidsAsStringList(String layerProtocolFilter) {
+ List<String> uuids = new ArrayList<>();
+
+ LOG.debug("request inventory information. filter: {}" + layerProtocolFilter);
+ if (optionalNe != null) {
+ // uuids
+ for (Lp lp : this.interfaceList) {
+ if (layerProtocolFilter == null || layerProtocolFilter.isEmpty() || layerProtocolFilter
+ .equals(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue())) {
+ uuids.add(Helper.nnGetUniversalId(lp.getUuid()).getValue());
+ }
+ }
+ }
+ LOG.debug("uuids found: {}", uuids);
+ return uuids;
+ }
+
+
+ /*---------------------------------------------------------------
+ * Performancemanagement specific interface
+ */
+
+ @Override
+ public void resetPMIterator() {
+ synchronized (pmLock) {
+ interfaceListIterator = interfaceList.iterator();
+ }
+ LOG.debug("PM reset iterator");
+ }
+
+ @SuppressWarnings("null")
+ @Override
+ public boolean hasNext() {
+ boolean res;
+ synchronized (pmLock) {
+ res = interfaceListIterator != null ? interfaceListIterator.hasNext() : false;
+ }
+ LOG.debug("PM hasNext LTP {}", res);
+ return res;
+ }
+
+ @SuppressWarnings("null")
+ @Override
+ public void next() {
+ synchronized (pmLock) {
+ if (interfaceListIterator == null) {
+ pmLp = null;
+ LOG.debug("PM next LTP null");
+ } else {
+ pmLp = interfaceListIterator.next();
+ LOG.debug("PM next LTP {}", Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue());
+ }
+ }
+ }
+
+ @SuppressWarnings("null")
+ @Override
+ public String pmStatusToString() {
+ StringBuilder res = new StringBuilder();
+ synchronized (pmLock) {
+ res.append(pmLp == null ? "no interface"
+ : Helper.nnGetLayerProtocolName(pmLp.getLayerProtocolName()).getValue());
+ for (Lp lp : getInterfaceList()) {
+ res.append("IF:");
+ res.append(Helper.nnGetLayerProtocolName(lp.getLayerProtocolName()).getValue());
+ res.append(" ");
+ }
+ }
+ return res.toString();
+ }
+
+ @Override
+ public void doRegisterEventListener(MountPoint mountPoint) {
+ //Do nothing
+ }
+
+ @SuppressWarnings("unchecked")
+ @Override
+ public <L extends NetworkElementService> Optional<L> getService(Class<L> clazz) {
+ return clazz.isInstance(this) ? Optional.of((L) this) : Optional.empty();
+ }
+
+ @Override
+ public Optional<PerformanceDataLtp> getLtpHistoricalPerformanceData() {
+ return Optional.empty();
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
index 86d28fe4e..05402f895 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Basic.java
@@ -33,13 +33,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
- * conditional packages.
+ * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
*
- * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
- * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
- * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
- * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
+ * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
+ * MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
+ * MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
* ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
* ,MicrowaveModel-ObjectClasses-PureEthernetStructure
*
@@ -71,6 +69,7 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
/**
* Basic element for netconf device with ONF Core model V1.2
+ *
* @param acessor to manage device connection
* @param serviceProvider to get devicemanager services
*/
@@ -189,7 +188,8 @@ public class ONFCoreNetworkElement12Basic extends ONFCoreNetworkElement12Base {
//eventListenerHandler.registration(mountPointNodeName, acessor.getNetconfNode());
//LOG.debug("refresh necon entry for {} with type {} not",mountPointNodeName,this.getDeviceType());
//eventListenerHandler.connectIndication(mountPointNodeName, getDeviceType());
- LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName, getDeviceType());
+ LOG.info("Starting Event listener finished. Added Netconf device:{} type:{}", mountPointNodeName,
+ getDeviceType());
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java
index ebdb8ccf1..a8384ea61 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElement12Microwave.java
@@ -47,13 +47,11 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Get information over NETCONF device according to ONF Coremodel. Read networkelement and
- * conditional packages.
+ * Get information over NETCONF device according to ONF Coremodel. Read networkelement and conditional packages.
*
- * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP),
- * MWAirInterfacePac, MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client),
- * MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD), MWAirInterfaceDiversityPac,
- * MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
+ * Get conditional packages from Networkelement Possible interfaces are: MWPS, LTP(MWPS-TTP), MWAirInterfacePac,
+ * MicrowaveModel-ObjectClasses-AirInterface ETH-CTP,LTP(Client), MW_EthernetContainer_Pac MWS, LTP(MWS-CTP-xD),
+ * MWAirInterfaceDiversityPac, MicrowaveModel-ObjectClasses-AirInterfaceDiversity MWS, LTP(MWS-TTP),
* ,MicrowaveModel-ObjectClasses-HybridMwStructure MWS, LTP(MWS-TTP),
* ,MicrowaveModel-ObjectClasses-PureEthernetStructure
*
@@ -78,16 +76,16 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas
/**
* Constructor
+ *
* @param acessor for device
* @param serviceProvider to get services
* @param onfMicrowaveModel handling ofmicrosoft model data
*/
- public ONFCoreNetworkElement12Microwave(@NonNull NetconfAccessor acessor,
- @NonNull DeviceManagerServiceProvider serviceProvider,
- DeviceManagerOnfConfiguration configuration,
- OnfMicrowaveModel onfMicrowaveModel) {
+ public ONFCoreNetworkElement12Microwave(@NonNull NetconfAccessor acessor,
+ @NonNull DeviceManagerServiceProvider serviceProvider, DeviceManagerOnfConfiguration configuration,
+ OnfMicrowaveModel onfMicrowaveModel) {
- super(acessor, serviceProvider,configuration);
+ super(acessor, serviceProvider, configuration);
this.microwaveModel = onfMicrowaveModel;
this.microwaveEventListener = serviceProvider.getFaultService();
@@ -103,12 +101,12 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas
*/
/**
- * @param acessor
- * @param serviceProvider
- * @param configuration
- * @param onfMicrowaveModel
- */
- /**
+ * @param acessor
+ * @param serviceProvider
+ * @param configuration
+ * @param onfMicrowaveModel
+ */
+ /**
* DeviceMonitor Prepare check by updating NE state and reading all interfaces.
*/
@Override
@@ -144,8 +142,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas
*
* <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
* <attribute-name>/equipment-pac/equipment-current-problems</attribute-name>
- * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value>
- * </attribute-value-changed-notification>
+ * <object-id-ref>CARD-1.1.1.0</object-id-ref> <new-value></new-value> </attribute-value-changed-notification>
* <attribute-value-changed-notification xmlns="urn:onf:params:xml:ns:yang:microwave-model">
* <attribute-name>/network-element/extension[value-name="top-level-equipment"]/value</attribute-name>
* <object-id-ref>Hybrid-Z</object-id-ref>
@@ -251,7 +248,8 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas
// Step 2.3: read the existing faults and add to DB
FaultData resultList = new FaultData();
int idxStart; // Start index for debug messages
- @NonNull UniversalId uuid;
+ @NonNull
+ UniversalId uuid;
synchronized (getPmLock()) {
for (Lp lp : getInterfaceList()) {
@@ -380,7 +378,7 @@ public class ONFCoreNetworkElement12Microwave extends ONFCoreNetworkElement12Bas
// notificationService.registerNotificationListener(microwaveEventListener);
listenerRegistrationresult =
notificationService.registerNotificationListener(microwaveModel.getNotificationListener());
- LOG.info("End registration listener for Mountpoint Result: {}",listenerRegistrationresult);
+ LOG.info("End registration listener for Mountpoint Result: {}", listenerRegistrationresult);
}
/*------------------------------------------------------------
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java
index 1b03f8acb..40a6d323b 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/ONFCoreNetworkElementBase.java
@@ -77,14 +77,14 @@ public abstract class ONFCoreNetworkElementBase implements AutoCloseable, ONFCor
public String getMountPointNodeName() {
return mountPointNodeName;
}
-
+
/**
* @return the netconfNodeDataBroker
*/
public DataBroker getNetconfNodeDataBroker() {
return netconfNodeDataBroker;
}
-
+
@Override
public void warmstart() {
int problems = removeAllCurrentProblemsOfNode();
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java
index ed6497c0f..e46383599 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/notifications/NotificationWorker.java
@@ -24,8 +24,8 @@ import java.util.concurrent.LinkedBlockingQueue;
/**
* Provide a thread that is receiving and process notifications.
- * @param <T> represents the object that is provided with a notification and
- * forwarded to the NotificationActor<T>.
+ *
+ * @param <T> represents the object that is provided with a notification and forwarded to the NotificationActor<T>.
*/
public class NotificationWorker<T> implements AutoCloseable {
@@ -39,7 +39,7 @@ public class NotificationWorker<T> implements AutoCloseable {
service = Executors.newFixedThreadPool(numWorkers);
actor = actorObject;
- for (int i=0; i < numWorkers; i++) {
+ for (int i = 0; i < numWorkers; i++) {
service.submit(new Worker<>(workQueue, actor));
}
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java
index a768da078..f9770d9fa 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/util/ONFLayerProtocolName.java
@@ -23,34 +23,36 @@ import org.slf4j.LoggerFactory;
public enum ONFLayerProtocolName {
- MWAIRINTERFACE("MWPS"), //V1.0 + V1.2
- ETHERNETCONTAINER10("ETH-CTP"), //V1.0
- ETHERNETCONTAINER12("ETC"), //V1.2 + V1.2.1.1
- ETHERNETPHYSICAL("ETY"), //V1.2
- TDMCONTAINER("TDM"), //V1.2
- STRUCTURE("MWS"), //V1.0 + V1.2
- ETHERNET("ETH"), //V1.2
+ MWAIRINTERFACE("MWPS"), //V1.0 + V1.2
+ ETHERNETCONTAINER10("ETH-CTP"), //V1.0
+ ETHERNETCONTAINER12("ETC"), //V1.2 + V1.2.1.1
+ ETHERNETPHYSICAL("ETY"), //V1.2
+ TDMCONTAINER("TDM"), //V1.2
+ STRUCTURE("MWS"), //V1.0 + V1.2
+ ETHERNET("ETH"), //V1.2
UNKNOWN("");
private static final Logger LOG = LoggerFactory.getLogger(ONFLayerProtocolName.class);
private final String myLayerProtocolName;
- ONFLayerProtocolName( String myLayerProtocolName ) {
+ ONFLayerProtocolName(String myLayerProtocolName) {
this.myLayerProtocolName = myLayerProtocolName;
}
- public boolean is( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) {
+ public boolean is(
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName) {
return myLayerProtocolName.equals(onfName.getValue());
}
- public static @NonNull ONFLayerProtocolName valueOf( org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName ) {
+ public static @NonNull ONFLayerProtocolName valueOf(
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.core.model.rev170320.LayerProtocolName onfName) {
for (ONFLayerProtocolName protocol : ONFLayerProtocolName.values()) {
if (protocol.is(onfName)) {
return protocol;
}
}
- LOG.info("Can not map {}. Use Unknown",onfName.getValue() );
+ LOG.info("Can not map {}. Use Unknown", onfName.getValue());
return UNKNOWN;
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java
index cda0f5366..20d479efa 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestExtendedEquipment.java
@@ -44,44 +44,38 @@ import org.slf4j.LoggerFactory;
public class TestExtendedEquipment {
- UniversalId id = new UniversalId("1234567");
- private static final String NODEID = "NODE1";
- private static final Logger LOG = LoggerFactory.getLogger(TestExtendedEquipment.class);
-
- @Test
- public void test() {
- final @NonNull List<ContainedHolder> holder = Arrays.asList(new ContainedHolderBuilder().setUuid(id).build());
- final @NonNull ManufacturerProperties manufacturerProps = new ManufacturerPropertiesBuilder()
- .setManufacturerIdentifier("NOK")
- .setManufacturerName("Nokia").build();
-
- final @NonNull EquipmentType eqptType = new EquipmentTypeBuilder()
- .setDescription("5G RAN Equipment")
- .setModelIdentifier("NOK-987-1T")
- .setPartTypeIdentifier("ABCDEF")
- .setTypeName("12345")
- .setVersion("5T9V4567")
- .build();
-
- final @NonNull EquipmentInstance eqptInstance = new EquipmentInstanceBuilder()
- .setAssetInstanceIdentifier("NOK1234-ABCD")
- .setManufactureDate("2020-02-11")
- .setSerialNumber("123456ABCD").build();
-
- final @NonNull ManufacturedThing manufacturedThing = new ManufacturedThingBuilder()
- .setManufacturerProperties(manufacturerProps)
- .setEquipmentType(eqptType)
- .setEquipmentInstance(eqptInstance).build();
-
- Equipment equipment = new EquipmentBuilder().setUuid(id).setContainedHolder(holder).setManufacturedThing(manufacturedThing).build();
-
- ExtendedEquipment extEqpt = new ExtendedEquipment(NODEID, "1234567890", equipment, "/var/opt", 3);
- assertEquals(extEqpt.getNodeId(), NODEID);
- assertEquals(extEqpt.getParentUuid(), "1234567890");
- assertEquals(extEqpt.getEquipment(), equipment);
- LOG.info(extEqpt.toString());
- extEqpt.getCreateInventoryInput();
-
- }
+ UniversalId id = new UniversalId("1234567");
+ private static final String NODEID = "NODE1";
+ private static final Logger LOG = LoggerFactory.getLogger(TestExtendedEquipment.class);
+
+ @Test
+ public void test() {
+ final @NonNull List<ContainedHolder> holder = Arrays.asList(new ContainedHolderBuilder().setUuid(id).build());
+ final @NonNull ManufacturerProperties manufacturerProps = new ManufacturerPropertiesBuilder()
+ .setManufacturerIdentifier("NOK").setManufacturerName("Nokia").build();
+
+ final @NonNull EquipmentType eqptType =
+ new EquipmentTypeBuilder().setDescription("5G RAN Equipment").setModelIdentifier("NOK-987-1T")
+ .setPartTypeIdentifier("ABCDEF").setTypeName("12345").setVersion("5T9V4567").build();
+
+ final @NonNull EquipmentInstance eqptInstance =
+ new EquipmentInstanceBuilder().setAssetInstanceIdentifier("NOK1234-ABCD")
+ .setManufactureDate("2020-02-11").setSerialNumber("123456ABCD").build();
+
+ final @NonNull ManufacturedThing manufacturedThing =
+ new ManufacturedThingBuilder().setManufacturerProperties(manufacturerProps).setEquipmentType(eqptType)
+ .setEquipmentInstance(eqptInstance).build();
+
+ Equipment equipment = new EquipmentBuilder().setUuid(id).setContainedHolder(holder)
+ .setManufacturedThing(manufacturedThing).build();
+
+ ExtendedEquipment extEqpt = new ExtendedEquipment(NODEID, "1234567890", equipment, "/var/opt", 3);
+ assertEquals(extEqpt.getNodeId(), NODEID);
+ assertEquals(extEqpt.getParentUuid(), "1234567890");
+ assertEquals(extEqpt.getEquipment(), equipment);
+ LOG.info(extEqpt.toString());
+ extEqpt.getCreateInventoryInput();
+
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java
index ff2969eac..403451799 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/equipment/test/TestONFCoreNetworkElement12Equipment.java
@@ -45,56 +45,59 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class TestONFCoreNetworkElement12Equipment {
- NetconfAccessor netconfAccessor;
- Capabilities capabilities;
- NetworkElementCoreData coreData;
- FaultData faultData;
- TransactionUtils transactionUtils;
- EquipmentCurrentProblems eqptCurrProblems;
- DataBroker dataBroker;
- UniversalId uid = new UniversalId("ID");
-
-
- @Before
- public void init() throws Exception {
- netconfAccessor = mock(NetconfAccessor.class);
- capabilities = mock(Capabilities.class);
- coreData = mock(NetworkElementCoreData.class);
- faultData = mock(FaultData.class);
- eqptCurrProblems = mock(EquipmentCurrentProblems.class);
- dataBroker = mock(DataBroker.class);
- transactionUtils = mock(TransactionUtils.class);
-
- final Class<EquipmentPac> clazzPac = EquipmentPac.class;
+ NetconfAccessor netconfAccessor;
+ Capabilities capabilities;
+ NetworkElementCoreData coreData;
+ FaultData faultData;
+ TransactionUtils transactionUtils;
+ EquipmentCurrentProblems eqptCurrProblems;
+ DataBroker dataBroker;
+ UniversalId uid = new UniversalId("ID");
+
+
+ @Before
+ public void init() throws Exception {
+ netconfAccessor = mock(NetconfAccessor.class);
+ capabilities = mock(Capabilities.class);
+ coreData = mock(NetworkElementCoreData.class);
+ faultData = mock(FaultData.class);
+ eqptCurrProblems = mock(EquipmentCurrentProblems.class);
+ dataBroker = mock(DataBroker.class);
+ transactionUtils = mock(TransactionUtils.class);
+
+ final Class<EquipmentPac> clazzPac = EquipmentPac.class;
final Class<EquipmentPacKey> clazzPacKey = EquipmentPacKey.class;
final Class<EquipmentCurrentProblems> clazzProblems = EquipmentCurrentProblems.class;
Constructor<EquipmentPacKey> cons = clazzPacKey.getConstructor(UniversalId.class);
- InstanceIdentifier<EquipmentCurrentProblems> interfaceIID = InstanceIdentifier
- .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
- when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
- when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
- when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
- when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems);
- }
-
- @Test
- public void test() {
- when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true);
- ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
- onfCoreEqpt.addProblemsofNode(faultData);
- onfCoreEqpt.addProblemsofNodeObject("ABCD");
- onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV"));
- onfCoreEqpt.getEquipmentAll();
- onfCoreEqpt.getEquipmentData();
- onfCoreEqpt.getEquipmentPac();
- onfCoreEqpt.readNetworkElementEquipment();
-
- }
-
- @Test
- public void test1() {
- when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false);
- ONFCoreNetworkElement12Equipment onfCoreEqpt = new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
- }
+ InstanceIdentifier<EquipmentCurrentProblems> interfaceIID =
+ InstanceIdentifier.builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
+ when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
+ when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
+ when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
+ when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, interfaceIID)).thenReturn(eqptCurrProblems);
+ }
+
+ @Test
+ public void test() {
+ when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(true);
+ ONFCoreNetworkElement12Equipment onfCoreEqpt =
+ new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
+ onfCoreEqpt.addProblemsofNode(faultData);
+ onfCoreEqpt.addProblemsofNodeObject("ABCD");
+ onfCoreEqpt.getInventoryInformation(Arrays.asList("TESTINV"));
+ onfCoreEqpt.getEquipmentAll();
+ onfCoreEqpt.getEquipmentData();
+ onfCoreEqpt.getEquipmentPac();
+ onfCoreEqpt.readNetworkElementEquipment();
+
+ }
+
+ @Test
+ public void test1() {
+ when(capabilities.isSupportingNamespaceAndRevision(WrapperEquipmentPacRev170402.QNAME)).thenReturn(false);
+ ONFCoreNetworkElement12Equipment onfCoreEqpt =
+ new ONFCoreNetworkElement12Equipment(netconfAccessor, coreData, capabilities);
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java
index cae28f4fe..337dc2644 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestHelper.java
@@ -27,21 +27,23 @@ import org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.g._874._1.model.r
public class TestHelper {
- @Test
- public void test() {
-
- assertEquals(GranularityPeriodType.Period24Hours, Helper.nnGetGranularityPeriodType(GranularityPeriodType.Period24Hours));
- assertEquals(GranularityPeriodType.Unknown, Helper.nnGetGranularityPeriodType(null));
-
- assertEquals(new LayerProtocolName("TDM"), Helper.nnGetLayerProtocolName(LayerProtocolName.getDefaultInstance("TDM")));
- assertEquals(new LayerProtocolName("default"), Helper.nnGetLayerProtocolName(null));
-
- assertEquals("TEST", Helper.nnGetString("TEST"));
- assertEquals("", Helper.nnGetString(null));
-
- assertEquals(new UniversalId("ABC"), Helper.nnGetUniversalId(new UniversalId("ABC")));
- assertEquals(new UniversalId("Default"), Helper.nnGetUniversalId(null));
-
- }
+ @Test
+ public void test() {
+
+ assertEquals(GranularityPeriodType.Period24Hours,
+ Helper.nnGetGranularityPeriodType(GranularityPeriodType.Period24Hours));
+ assertEquals(GranularityPeriodType.Unknown, Helper.nnGetGranularityPeriodType(null));
+
+ assertEquals(new LayerProtocolName("TDM"),
+ Helper.nnGetLayerProtocolName(LayerProtocolName.getDefaultInstance("TDM")));
+ assertEquals(new LayerProtocolName("default"), Helper.nnGetLayerProtocolName(null));
+
+ assertEquals("TEST", Helper.nnGetString("TEST"));
+ assertEquals("", Helper.nnGetString(null));
+
+ assertEquals(new UniversalId("ABC"), Helper.nnGetUniversalId(new UniversalId("ABC")));
+ assertEquals(new UniversalId("Default"), Helper.nnGetUniversalId(null));
+
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java
index 0140eaa59..96c3c757d 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev170324.java
@@ -82,212 +82,261 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class TestWrapperMicrowaveModelRev170324 {
- NetconfAccessor accessor;
- DeviceManagerServiceProvider serviceProvider;
- FaultData resultList;
- UniversalId uid;
- TransactionUtils transactionUtils;
- DataBroker dataBroker;
-
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
- @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems;
-
- InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
- @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
-
- @Before
- public void init() {
- accessor = mock(NetconfAccessor.class);
- serviceProvider = mock(DeviceManagerServiceProvider.class);
- resultList = mock(FaultData.class);
- transactionUtils = mock(TransactionUtils.class);
- dataBroker = mock(DataBroker.class);
-
- uid = new UniversalId("ABCD");
-
- mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceCurrentProblems.class).build();
- List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
- airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
-
- mwEthInterfaceIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerCurrentProblems.class).build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList
- = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemListBuilder()
- .setProblemName("Link Negotiation Unsuccessful")
- .setProblemSeverity(SeverityType.Critical)
- .setSequenceNumber(1)
- .setTimeStamp(null)
- .build());
- ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
-
- NodeId nNodeId = new NodeId("nSky");
- when(accessor.getNodeId()).thenReturn(nNodeId);
- when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
- when(accessor.getDataBroker()).thenReturn(dataBroker);
-
- }
-
- @Test
- public void testMWAirInterfaceWithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testMWAirInterfaceWithoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithNoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testTdmContainer12WithProblems() throws Exception {
- final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
- final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
- final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
- Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
- InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList);
-
- }
-
- @Test
- public void testMwHybridMwStructureWithProblems() throws Exception {
- final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
- final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
- InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
- final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
- final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
- InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwPureEthernetStructureWithProblems() throws Exception {
- final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
- final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
- InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testNullStructureWithProblems() throws Exception {
-
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
- wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList);
-
- }
-
- @Test
- public void testgetLtpHistoricalPerformanceData() {
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceConfiguration.class).build();
-
- AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
-
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceHistoricalPerformances.class).build();
-
- PerformanceData performanceData = new PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build());
- AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder()
- .setHistoricalPerformanceDataList(airHistPMList).build();
- when(accessor.getTransactionUtils().readData(
- accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
-
- InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerHistoricalPerformances.class).build();
-
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build());
- EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID))
- .thenReturn(ethContainerHistoricalPerformanceData);
-
- Lp lp = new LpBuilder().setUuid(uid).build();
- WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 = new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
-
- wrapperMicrowaveModelRev170324.getLtpHistoricalPerformanceData(ONFLayerProtocolName.ETHERNET, lp);
- }
+ NetconfAccessor accessor;
+ DeviceManagerServiceProvider serviceProvider;
+ FaultData resultList;
+ UniversalId uid;
+ TransactionUtils transactionUtils;
+ DataBroker dataBroker;
+
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
+ @NonNull
+ AirInterfaceCurrentProblems airInterfaceCurrentProblems;
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
+ @NonNull
+ EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
+
+ @Before
+ public void init() {
+ accessor = mock(NetconfAccessor.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ resultList = mock(FaultData.class);
+ transactionUtils = mock(TransactionUtils.class);
+ dataBroker = mock(DataBroker.class);
+
+ uid = new UniversalId("ABCD");
+
+ mwAirInterfaceIID = InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceCurrentProblems.class).build();
+ List<CurrentProblemList> currentProblemList =
+ Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
+ airInterfaceCurrentProblems =
+ new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+
+ mwEthInterfaceIID = InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerCurrentProblems.class).build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Link Negotiation Unsuccessful")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null)
+ .build());
+ ethernetContainerCurrentProblems =
+ new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
+
+ NodeId nNodeId = new NodeId("nSky");
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+ when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
+ when(accessor.getDataBroker()).thenReturn(dataBroker);
+
+ }
+
+ @Test
+ public void testMWAirInterfaceWithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testMWAirInterfaceWithoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithNoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testTdmContainer12WithProblems() throws Exception {
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.tdm.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ TdmContainerCurrentProblems tdmInterfaceCurrentProblems =
+ new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testMwHybridMwStructureWithProblems() throws Exception {
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwHybridMwStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
+
+ InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.diversity.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems =
+ new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwAirInterfaceDiversityPac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwPureEthernetStructureWithProblems() throws Exception {
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
+
+ InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwPureEthernetStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testNullStructureWithProblems() throws Exception {
+
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+ wrapperMicrowaveModelRev170324.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testgetLtpHistoricalPerformanceData() {
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceConfiguration.class).build();
+
+ AirInterfaceConfiguration airConfiguration =
+ new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
+
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ PerformanceData performanceData = new PerformanceDataBuilder().build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period15Min)
+ .setPerformanceData(performanceData).build());
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData =
+ new AirInterfaceHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(airHistPMList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
+
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID =
+ InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceData ethPerformanceData =
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.container.historical.performance.type.g.PerformanceDataBuilder()
+ .build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev170324.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period24Hours)
+ .setPerformanceData(ethPerformanceData).build());
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData =
+ new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList)
+ .build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ ethContainerIID)).thenReturn(ethContainerHistoricalPerformanceData);
+
+ Lp lp = new LpBuilder().setUuid(uid).build();
+ WrapperMicrowaveModelRev170324 wrapperMicrowaveModelRev170324 =
+ new WrapperMicrowaveModelRev170324(accessor, serviceProvider);
+
+ wrapperMicrowaveModelRev170324.getLtpHistoricalPerformanceData(ONFLayerProtocolName.ETHERNET, lp);
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java
index e4d89f28f..dec443519 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev180907.java
@@ -82,209 +82,258 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class TestWrapperMicrowaveModelRev180907 {
- NetconfAccessor accessor;
- DeviceManagerServiceProvider serviceProvider;
- FaultData resultList;
- UniversalId uid;
- TransactionUtils transactionUtils;
-
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
- @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems;
-
- InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
- @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
-
- @Before
- public void init() {
- accessor = mock(NetconfAccessor.class);
- serviceProvider = mock(DeviceManagerServiceProvider.class);
- resultList = mock(FaultData.class);
- transactionUtils = mock(TransactionUtils.class);
-
- uid = new UniversalId("ABCD");
-
- mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceCurrentProblems.class).build();
- List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
- airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
-
- mwEthInterfaceIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerCurrentProblems.class).build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList
- = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemListBuilder()
- .setProblemName("Link Negotiation Unsuccessful")
- .setProblemSeverity(SeverityType.Critical)
- .setSequenceNumber(1)
- .setTimeStamp(null)
- .build());
- ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
-
- NodeId nNodeId = new NodeId("nSky");
- when(accessor.getNodeId()).thenReturn(nNodeId);
- when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
-
- }
-
- @Test
- public void testMWAirInterfaceWithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testMWAirInterfaceWithoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithNoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testTdmContainer12WithProblems() throws Exception {
- final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
- final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
- final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
- Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
- InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList);
-
- }
-
- @Test
- public void testMwHybridMwStructureWithProblems() throws Exception {
- final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
- final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
- InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
- final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ NetconfAccessor accessor;
+ DeviceManagerServiceProvider serviceProvider;
+ FaultData resultList;
+ UniversalId uid;
+ TransactionUtils transactionUtils;
+
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
+ @NonNull
+ AirInterfaceCurrentProblems airInterfaceCurrentProblems;
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
+ @NonNull
+ EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
+
+ @Before
+ public void init() {
+ accessor = mock(NetconfAccessor.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ resultList = mock(FaultData.class);
+ transactionUtils = mock(TransactionUtils.class);
+
+ uid = new UniversalId("ABCD");
+
+ mwAirInterfaceIID = InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceCurrentProblems.class).build();
+ List<CurrentProblemList> currentProblemList =
+ Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
+ airInterfaceCurrentProblems =
+ new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+
+ mwEthInterfaceIID = InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerCurrentProblems.class).build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Link Negotiation Unsuccessful")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null)
+ .build());
+ ethernetContainerCurrentProblems =
+ new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
+
+ NodeId nNodeId = new NodeId("nSky");
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+ when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
+
+ }
+
+ @Test
+ public void testMWAirInterfaceWithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testMWAirInterfaceWithoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithNoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testTdmContainer12WithProblems() throws Exception {
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.tdm.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ TdmContainerCurrentProblems tdmInterfaceCurrentProblems =
+ new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testMwHybridMwStructureWithProblems() throws Exception {
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwHybridMwStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
+
InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
.builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwPureEthernetStructureWithProblems() throws Exception {
- final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.diversity.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems =
+ new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwAirInterfaceDiversityPac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwPureEthernetStructureWithProblems() throws Exception {
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
+
InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
.builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testNullStructureWithProblems() throws Exception {
-
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
- wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList);
-
- }
-
- @Test
- public void testgetLtpHistoricalPerformanceData() {
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceConfiguration.class).build();
-
- AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
-
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceHistoricalPerformances.class).build();
-
- PerformanceData performanceData = new PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build());
- AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder()
- .setHistoricalPerformanceDataList(airHistPMList).build();
- when(accessor.getTransactionUtils().readData(
- accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
-
- InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerHistoricalPerformances.class).build();
-
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build());
- EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID))
- .thenReturn(ethContainerHistoricalPerformanceData);
-
- Lp lp = new LpBuilder().setUuid(uid).build();;
- WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 = new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
-
- wrapperMicrowaveModelRev180907.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp);
- }
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwPureEthernetStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testNullStructureWithProblems() throws Exception {
+
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+ wrapperMicrowaveModelRev180907.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testgetLtpHistoricalPerformanceData() {
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceConfiguration.class).build();
+
+ AirInterfaceConfiguration airConfiguration =
+ new AirInterfaceConfigurationBuilder().setAirInterfaceName("TESTINTF").build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
+
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ PerformanceData performanceData = new PerformanceDataBuilder().build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period15Min)
+ .setPerformanceData(performanceData).build());
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData =
+ new AirInterfaceHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(airHistPMList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
+
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID =
+ InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceData ethPerformanceData =
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.container.historical.performance.type.g.PerformanceDataBuilder()
+ .build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev180907.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period24Hours)
+ .setPerformanceData(ethPerformanceData).build());
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData =
+ new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList)
+ .build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ ethContainerIID)).thenReturn(ethContainerHistoricalPerformanceData);
+
+ Lp lp = new LpBuilder().setUuid(uid).build();;
+ WrapperMicrowaveModelRev180907 wrapperMicrowaveModelRev180907 =
+ new WrapperMicrowaveModelRev180907(accessor, serviceProvider);
+
+ wrapperMicrowaveModelRev180907.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp);
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java
index eac003dac..94f8e6c19 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/microwave/test/TestWrapperMicrowaveModelRev181010.java
@@ -84,212 +84,260 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
@SuppressWarnings("deprecation")
public class TestWrapperMicrowaveModelRev181010 {
- NetconfAccessor accessor;
- DeviceManagerServiceProvider serviceProvider;
- FaultData resultList;
- UniversalId uid;
- TransactionUtils transactionUtils;
- DataBroker dataBroker;
-
- InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
- @NonNull AirInterfaceCurrentProblems airInterfaceCurrentProblems;
-
- InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
- @NonNull EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
-
- @Before
- public void init() {
- accessor = mock(NetconfAccessor.class);
- serviceProvider = mock(DeviceManagerServiceProvider.class);
- resultList = mock(FaultData.class);
- transactionUtils = mock(TransactionUtils.class);
- dataBroker = mock(DataBroker.class);
-
- uid = new UniversalId("ABCD");
-
- mwAirInterfaceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceCurrentProblems.class).build();
- List<CurrentProblemList> currentProblemList = Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal").setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
- airInterfaceCurrentProblems = new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
-
- mwEthInterfaceIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerCurrentProblems.class).build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList
- = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemListBuilder()
- .setProblemName("Link Negotiation Unsuccessful")
- .setProblemSeverity(SeverityType.Critical)
- .setSequenceNumber(1)
- .setTimeStamp(null)
- .build());
- ethernetContainerCurrentProblems = new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
-
- NodeId nNodeId = new NodeId("nSky");
- when(accessor.getNodeId()).thenReturn(nNodeId);
- when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
- when(accessor.getDataBroker()).thenReturn(dataBroker);
-
- }
-
- @Test
- public void testMWAirInterfaceWithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testMWAirInterfaceWithoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testEthernetContainer12WithNoProblems() {
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(null);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null, uid, resultList);
- }
-
- @Test
- public void testTdmContainer12WithProblems() throws Exception {
- final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
- final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
- final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
-
- Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
- InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- TdmContainerCurrentProblems tdmInterfaceCurrentProblems = new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid, resultList);
-
- }
-
- @Test
- public void testMwHybridMwStructureWithProblems() throws Exception {
- final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
- final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
-
- InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems = new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwHybridMwStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
- final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
- final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
-
- InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems = new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwAirInterfaceDiversityPac.class, uid, resultList);
-
- }
-
- @Test
- public void testMwPureEthernetStructureWithProblems() throws Exception {
- final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
- final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
-
- InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
- .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build();
-
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemList>
- currentProblemList = Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder().setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major).setSequenceNumber(2).setTimeStamp(null).build());
- PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems = new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, MwPureEthernetStructurePac.class, uid, resultList);
-
- }
-
- @Test
- public void testNullStructureWithProblems() throws Exception {
-
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
- wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid, resultList);
-
- }
-
- @Test
- public void testgetLtpHistoricalPerformanceData() {
- InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceConfiguration.class).build();
-
- AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().build();
- when(accessor.getTransactionUtils().readData(dataBroker,
- LogicalDatastoreType.OPERATIONAL, mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
-
- InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID = InstanceIdentifier
- .builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
- .child(AirInterfaceHistoricalPerformances.class).build();
-
- PerformanceData performanceData = new PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period15Min).setPerformanceData(performanceData).build());
- AirInterfaceHistoricalPerformances airHistoricalPerformanceData = new AirInterfaceHistoricalPerformancesBuilder()
- .setHistoricalPerformanceDataList(airHistPMList).build();
- when(accessor.getTransactionUtils().readData(
- accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
-
- InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID = InstanceIdentifier
- .builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
- .child(EthernetContainerHistoricalPerformances.class).build();
-
- org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData ethPerformanceData = new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceDataBuilder().build();
- List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
- Arrays.asList(new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder().setGranularityPeriod(GranularityPeriodType.Period24Hours).setPerformanceData(ethPerformanceData).build());
- EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData = new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList).build();
- when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL, ethContainerIID))
- .thenReturn(ethContainerHistoricalPerformanceData);
-
- Lp lp = new LpBuilder().setUuid(uid).build();
- WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 = new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
-
- wrapperMicrowaveModelRev181010.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp);
- }
+ NetconfAccessor accessor;
+ DeviceManagerServiceProvider serviceProvider;
+ FaultData resultList;
+ UniversalId uid;
+ TransactionUtils transactionUtils;
+ DataBroker dataBroker;
+
+ InstanceIdentifier<AirInterfaceCurrentProblems> mwAirInterfaceIID;
+ @NonNull
+ AirInterfaceCurrentProblems airInterfaceCurrentProblems;
+
+ InstanceIdentifier<EthernetContainerCurrentProblems> mwEthInterfaceIID;
+ @NonNull
+ EthernetContainerCurrentProblems ethernetContainerCurrentProblems;
+
+ @Before
+ public void init() {
+ accessor = mock(NetconfAccessor.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
+ resultList = mock(FaultData.class);
+ transactionUtils = mock(TransactionUtils.class);
+ dataBroker = mock(DataBroker.class);
+
+ uid = new UniversalId("ABCD");
+
+ mwAirInterfaceIID = InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceCurrentProblems.class).build();
+ List<CurrentProblemList> currentProblemList =
+ Arrays.asList(new CurrentProblemListBuilder().setProblemName("Loss of Signal")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null).build());
+ airInterfaceCurrentProblems =
+ new AirInterfaceCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+
+ mwEthInterfaceIID = InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerCurrentProblems.class).build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemList> ethCurrentProblemsList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Link Negotiation Unsuccessful")
+ .setProblemSeverity(SeverityType.Critical).setSequenceNumber(1).setTimeStamp(null)
+ .build());
+ ethernetContainerCurrentProblems =
+ new EthernetContainerCurrentProblemsBuilder().setCurrentProblemList(ethCurrentProblemsList).build();
+
+ NodeId nNodeId = new NodeId("nSky");
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+ when(accessor.getTransactionUtils()).thenReturn(transactionUtils);
+ when(accessor.getDataBroker()).thenReturn(dataBroker);
+
+ }
+
+ @Test
+ public void testMWAirInterfaceWithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(airInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testMWAirInterfaceWithoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.MWAIRINTERFACE, null, uid,
+ resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(ethernetContainerCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testEthernetContainer12WithNoProblems() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(null);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.ETHERNETCONTAINER12, null,
+ uid, resultList);
+ }
+
+ @Test
+ public void testTdmContainer12WithProblems() throws Exception {
+ final Class<MwTdmContainerPac> clazzPac = MwTdmContainerPac.class;
+ final Class<MwTdmContainerPacKey> clazzPacKey = MwTdmContainerPacKey.class;
+ final Class<TdmContainerCurrentProblems> clazzProblems = TdmContainerCurrentProblems.class;
+
+ Constructor<MwTdmContainerPacKey> cons = clazzPacKey.getConstructor(UniversalId.class); // Avoid new()
+ InstanceIdentifier<TdmContainerCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, cons.newInstance(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.tdm.container.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ TdmContainerCurrentProblems tdmInterfaceCurrentProblems =
+ new TdmContainerCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(tdmInterfaceCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.TDMCONTAINER, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testMwHybridMwStructureWithProblems() throws Exception {
+ final Class<MwHybridMwStructurePac> clazzPac = MwHybridMwStructurePac.class;
+ final Class<HybridMwStructureCurrentProblems> clazzProblems = HybridMwStructureCurrentProblems.class;
+
+ InstanceIdentifier<HybridMwStructureCurrentProblems> mwEthInterfaceIID =
+ InstanceIdentifier.builder(clazzPac, new MwHybridMwStructurePacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.hybrid.mw.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ HybridMwStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new HybridMwStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwHybridMwStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwAirInterfaceDiversityStructureWithProblems() throws Exception {
+ final Class<MwAirInterfaceDiversityPac> clazzPac = MwAirInterfaceDiversityPac.class;
+ final Class<AirInterfaceDiversityCurrentProblems> clazzProblems = AirInterfaceDiversityCurrentProblems.class;
+
+ InstanceIdentifier<AirInterfaceDiversityCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwAirInterfaceDiversityPacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.diversity.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ AirInterfaceDiversityCurrentProblems hybridMwStructureCurrentProblems =
+ new AirInterfaceDiversityCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwAirInterfaceDiversityPac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testMwPureEthernetStructureWithProblems() throws Exception {
+ final Class<MwPureEthernetStructurePac> clazzPac = MwPureEthernetStructurePac.class;
+ final Class<PureEthernetStructureCurrentProblems> clazzProblems = PureEthernetStructureCurrentProblems.class;
+
+ InstanceIdentifier<PureEthernetStructureCurrentProblems> mwEthInterfaceIID = InstanceIdentifier
+ .builder(clazzPac, new MwPureEthernetStructurePacKey(uid)).child(clazzProblems).build();
+
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemList> currentProblemList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.pure.ethernet.structure.current.problems.g.CurrentProblemListBuilder()
+ .setProblemName("Loss of Payload").setProblemSeverity(SeverityType.Major)
+ .setSequenceNumber(2).setTimeStamp(null).build());
+ PureEthernetStructureCurrentProblems hybridMwStructureCurrentProblems =
+ new PureEthernetStructureCurrentProblemsBuilder().setCurrentProblemList(currentProblemList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwEthInterfaceIID)).thenReturn(hybridMwStructureCurrentProblems);
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE,
+ MwPureEthernetStructurePac.class, uid, resultList);
+
+ }
+
+ @Test
+ public void testNullStructureWithProblems() throws Exception {
+
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+ wrapperMicrowaveModelRev181010.readTheFaultsOfMicrowaveModel(ONFLayerProtocolName.STRUCTURE, null, uid,
+ resultList);
+
+ }
+
+ @Test
+ public void testgetLtpHistoricalPerformanceData() {
+ InstanceIdentifier<AirInterfaceConfiguration> mwAirInterfaceConfigurationIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceConfiguration.class).build();
+
+ AirInterfaceConfiguration airConfiguration = new AirInterfaceConfigurationBuilder().build();
+ when(accessor.getTransactionUtils().readData(dataBroker, LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceConfigurationIID)).thenReturn(airConfiguration);
+
+ InstanceIdentifier<AirInterfaceHistoricalPerformances> mwAirInterfaceHistoricalPerformanceIID =
+ InstanceIdentifier.builder(MwAirInterfacePac.class, new MwAirInterfacePacKey(uid))
+ .child(AirInterfaceHistoricalPerformances.class).build();
+
+ PerformanceData performanceData = new PerformanceDataBuilder().build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataList> airHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.air._interface.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period15Min)
+ .setPerformanceData(performanceData).build());
+ AirInterfaceHistoricalPerformances airHistoricalPerformanceData =
+ new AirInterfaceHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(airHistPMList).build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ mwAirInterfaceHistoricalPerformanceIID)).thenReturn(airHistoricalPerformanceData);
+
+ InstanceIdentifier<EthernetContainerHistoricalPerformances> ethContainerIID =
+ InstanceIdentifier.builder(MwEthernetContainerPac.class, new MwEthernetContainerPacKey(uid))
+ .child(EthernetContainerHistoricalPerformances.class).build();
+
+ org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceData ethPerformanceData =
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.container.historical.performance.type.g.PerformanceDataBuilder()
+ .build();
+ List<org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataList> ethHistPMList =
+ Arrays.asList(
+ new org.opendaylight.yang.gen.v1.urn.onf.params.xml.ns.yang.microwave.model.rev181010.ethernet.container.historical.performances.g.HistoricalPerformanceDataListBuilder()
+ .setGranularityPeriod(GranularityPeriodType.Period24Hours)
+ .setPerformanceData(ethPerformanceData).build());
+ EthernetContainerHistoricalPerformances ethContainerHistoricalPerformanceData =
+ new EthernetContainerHistoricalPerformancesBuilder().setHistoricalPerformanceDataList(ethHistPMList)
+ .build();
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ ethContainerIID)).thenReturn(ethContainerHistoricalPerformanceData);
+
+ Lp lp = new LpBuilder().setUuid(uid).build();
+ WrapperMicrowaveModelRev181010 wrapperMicrowaveModelRev181010 =
+ new WrapperMicrowaveModelRev181010(accessor, serviceProvider);
+
+ wrapperMicrowaveModelRev181010.getLtpHistoricalPerformanceData(ONFLayerProtocolName.MWAIRINTERFACE, lp);
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java
index bf9337291..42f7de1d6 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ifpac/test/TestWrapperPTPModelRev170208.java
@@ -47,47 +47,47 @@ import static org.mockito.Mockito.*;
public class TestWrapperPTPModelRev170208 {
- private static final String NODEID = "node1";
- NetconfAccessor netconfAccessor;
- Capabilities capabilities;
- TransactionUtils transactionUtils;
- DataBroker dataBroker;
-
- @Before
- public void init() {
- netconfAccessor = mock(NetconfAccessor.class);
- capabilities = mock(Capabilities.class);
- dataBroker = mock(DataBroker.class);
- transactionUtils = mock(TransactionUtils.class);
-
- when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
- when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
- when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
- when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
-
- PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(10).build();
- List<PortDsList> portDsList = Arrays.asList(new PortDsListBuilder().setPortIdentity(portIdentity).build());
- InstanceList instanceList = new InstanceListBuilder().setPortDsList(portDsList).build();
- InstanceIdentifier<InstanceList> PTPINSTANCES_IID = InstanceIdentifier
- .builder(InstanceList.class, new InstanceListKey(1)).build();
- when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
- PTPINSTANCES_IID)).thenReturn(instanceList);
- }
-
- @Test
- public void test() {
-
- when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
-
- WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
- }
-
- @Test
- public void test1() {
-
- when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
-
- WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
- }
+ private static final String NODEID = "node1";
+ NetconfAccessor netconfAccessor;
+ Capabilities capabilities;
+ TransactionUtils transactionUtils;
+ DataBroker dataBroker;
+
+ @Before
+ public void init() {
+ netconfAccessor = mock(NetconfAccessor.class);
+ capabilities = mock(Capabilities.class);
+ dataBroker = mock(DataBroker.class);
+ transactionUtils = mock(TransactionUtils.class);
+
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
+ when(netconfAccessor.getCapabilites()).thenReturn(capabilities);
+ when(netconfAccessor.getTransactionUtils()).thenReturn(transactionUtils);
+ when(netconfAccessor.getDataBroker()).thenReturn(dataBroker);
+
+ PortIdentity portIdentity = new PortIdentityBuilder().setPortNumber(10).build();
+ List<PortDsList> portDsList = Arrays.asList(new PortDsListBuilder().setPortIdentity(portIdentity).build());
+ InstanceList instanceList = new InstanceListBuilder().setPortDsList(portDsList).build();
+ InstanceIdentifier<InstanceList> PTPINSTANCES_IID =
+ InstanceIdentifier.builder(InstanceList.class, new InstanceListKey(1)).build();
+ when(netconfAccessor.getTransactionUtils().readData(netconfAccessor.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, PTPINSTANCES_IID)).thenReturn(instanceList);
+ }
+
+ @Test
+ public void test() {
+
+ when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(false);
+
+ WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
+ }
+
+ @Test
+ public void test1() {
+
+ when(capabilities.isSupportingNamespaceAndRevision(InstanceList.QNAME)).thenReturn(true);
+
+ WrapperPTPModelRev170208.initSynchronizationExtension(netconfAccessor);
+ }
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java
index 93e65c0b9..909a67edc 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/impl/test/TestONFCoreNetworkElementFactory.java
@@ -83,9 +83,12 @@ public class TestONFCoreNetworkElementFactory {
when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
+ .thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
+ .thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
+ .thenReturn(false);
ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
assertTrue(factory.create(accessor, serviceProvider).isPresent());
}
@@ -93,9 +96,12 @@ public class TestONFCoreNetworkElementFactory {
@Test
public void testCreateMWModelRev180907() throws Exception {
when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
+ .thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
+ .thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
+ .thenReturn(false);
ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
assertTrue(factory.create(accessor, serviceProvider).isPresent());
}
@@ -103,9 +109,12 @@ public class TestONFCoreNetworkElementFactory {
@Test
public void testCreateMWModelRev181010() throws Exception {
when(accessor.getCapabilites().isSupportingNamespaceAndRevision(NetworkElement.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME)).thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev170324.QNAME))
+ .thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev180907.QNAME))
+ .thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespaceAndRevision(WrapperMicrowaveModelRev181010.QNAME))
+ .thenReturn(true);
ONFCoreNetworkElementFactory factory = new ONFCoreNetworkElementFactory(configuration);
assertTrue(factory.create(accessor, serviceProvider).isPresent());
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java
index ba295f6ce..242014fc0 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Basic.java
@@ -68,8 +68,8 @@ public class TestONFCoreNetworkElement12Basic {
EquipmentService equipmentService;
DeviceManagerOnfConfiguration configuration;
- protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
- .builder(NetworkElement.class).build();
+ protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
+ InstanceIdentifier.builder(NetworkElement.class).build();
@Before
public void init() {
@@ -179,8 +179,8 @@ public class TestONFCoreNetworkElement12Basic {
when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
NETWORKELEMENT_IID)).thenReturn(optionalNe);
- ONFCoreNetworkElement12Basic onfCoreNetworkElement12Basic = new ONFCoreNetworkElement12Basic(accessor,
- serviceProvider,configuration);
+ ONFCoreNetworkElement12Basic onfCoreNetworkElement12Basic =
+ new ONFCoreNetworkElement12Basic(accessor, serviceProvider, configuration);
onfCoreNetworkElement12Basic.prepareCheck();
/*
@@ -222,73 +222,72 @@ public class TestONFCoreNetworkElement12Basic {
@Test
- public void test1()
- {
- when (accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null);
+ public void test1() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ NETWORKELEMENT_IID)).thenReturn(null);
ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
- new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration,
- onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck();
-
- EventlogEntity eventlogEntity = new EventlogEntity() {
-
- @Override
- public @Nullable String getId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable DateAndTime getTimestamp() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getObjectId() {
- // TODO Auto-generated method stub
- return "ABCD";
- }
-
- @Override
- public @Nullable String getNodeId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable Integer getCounter() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable SourceType getSourceType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getNewValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getAttributeName() {
- // TODO Auto-generated method stub
- return "/equipment-pac/equipment-current-problems";
- }
-
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- // TODO Auto-generated method stub
- return null;
- }
- };
-
- onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
+ new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
+ onfCoreNetworkElement12MW.prepareCheck();
+
+ EventlogEntity eventlogEntity = new EventlogEntity() {
+
+ @Override
+ public @Nullable String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable DateAndTime getTimestamp() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getObjectId() {
+ // TODO Auto-generated method stub
+ return "ABCD";
+ }
+
+ @Override
+ public @Nullable String getNodeId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Integer getCounter() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable SourceType getSourceType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getNewValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getAttributeName() {
+ // TODO Auto-generated method stub
+ return "/equipment-pac/equipment-current-problems";
+ }
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+
+ onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
}
diff --git a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java
index a5462d6f1..dcef80916 100644
--- a/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java
+++ b/sdnr/wt/devicemanager-onf/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/onf/ne/test/TestONFCoreNetworkElement12Microwave.java
@@ -67,8 +67,8 @@ public class TestONFCoreNetworkElement12Microwave {
EquipmentService equipmentService;
DeviceManagerOnfConfiguration configuration;
- protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID = InstanceIdentifier
- .builder(NetworkElement.class).build();
+ protected static final InstanceIdentifier<NetworkElement> NETWORKELEMENT_IID =
+ InstanceIdentifier.builder(NetworkElement.class).build();
@Before
public void init() {
@@ -178,8 +178,8 @@ public class TestONFCoreNetworkElement12Microwave {
when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
NETWORKELEMENT_IID)).thenReturn(optionalNe);
- ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW = new ONFCoreNetworkElement12Microwave(accessor,
- serviceProvider, configuration, onfMicrowaveModel);
+ ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
+ new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
onfCoreNetworkElement12MW.prepareCheck();
EventlogEntity eventlogEntity = new EventlogEntity() {
@@ -245,73 +245,72 @@ public class TestONFCoreNetworkElement12Microwave {
@Test
- public void test1()
- {
- when (accessor.getTransactionUtils().readData(accessor.getDataBroker(),
- LogicalDatastoreType.OPERATIONAL, NETWORKELEMENT_IID)).thenReturn(null);
+ public void test1() {
+ when(accessor.getTransactionUtils().readData(accessor.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
+ NETWORKELEMENT_IID)).thenReturn(null);
ONFCoreNetworkElement12Microwave onfCoreNetworkElement12MW =
- new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration,
- onfMicrowaveModel); onfCoreNetworkElement12MW.prepareCheck();
-
- EventlogEntity eventlogEntity = new EventlogEntity() {
-
- @Override
- public @Nullable String getId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable DateAndTime getTimestamp() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getObjectId() {
- // TODO Auto-generated method stub
- return "ABCD";
- }
-
- @Override
- public @Nullable String getNodeId() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable Integer getCounter() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable SourceType getSourceType() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getNewValue() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable String getAttributeName() {
- // TODO Auto-generated method stub
- return "/equipment-pac/equipment-current-problems";
- }
-
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- // TODO Auto-generated method stub
- return null;
- }
- };
-
- onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
+ new ONFCoreNetworkElement12Microwave(accessor, serviceProvider, configuration, onfMicrowaveModel);
+ onfCoreNetworkElement12MW.prepareCheck();
+
+ EventlogEntity eventlogEntity = new EventlogEntity() {
+
+ @Override
+ public @Nullable String getId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable DateAndTime getTimestamp() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getObjectId() {
+ // TODO Auto-generated method stub
+ return "ABCD";
+ }
+
+ @Override
+ public @Nullable String getNodeId() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Integer getCounter() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable SourceType getSourceType() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getNewValue() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable String getAttributeName() {
+ // TODO Auto-generated method stub
+ return "/equipment-pac/equipment-current-problems";
+ }
+
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+ };
+
+ onfCoreNetworkElement12MW.notificationActor(eventlogEntity);
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/DeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/DeviceManagerORanImpl.java
index 50a6a75ef..8d9a215e2 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/DeviceManagerORanImpl.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/DeviceManagerORanImpl.java
@@ -23,7 +23,7 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkEleme
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class DeviceManagerORanImpl implements AutoCloseable {
+public class DeviceManagerORanImpl implements AutoCloseable {
private static final Logger LOG = LoggerFactory.getLogger(DeviceManagerORanImpl.class);
private static final String APPLICATION_NAME = "DeviceManagerORan";
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/NtsNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/NtsNetworkElement.java
index 8f4d0909f..15f906d6c 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/NtsNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/NtsNetworkElement.java
@@ -44,14 +44,13 @@ public class NtsNetworkElement implements NetworkElement {
private final DataProvider databaseService;
NtsNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) {
- LOG.info("Create {}",NtsNetworkElement.class.getSimpleName());
+ LOG.info("Create {}", NtsNetworkElement.class.getSimpleName());
this.netconfAccessor = netconfAccess;
this.databaseService = databaseService;
}
@Override
- public void deregister() {
- }
+ public void deregister() {}
@Override
public NodeId getNodeId() {
@@ -64,12 +63,10 @@ public class NtsNetworkElement implements NetworkElement {
}
@Override
- public void warmstart() {
- }
+ public void warmstart() {}
@Override
- public void register() {
- }
+ public void register() {}
@Override
public NetworkElementDeviceType getDeviceType() {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java
index e0c133e13..43bfeedaa 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanChangeNotificationListener.java
@@ -36,7 +36,7 @@ import org.slf4j.LoggerFactory;
/**
* Listener for change notifications
*/
-public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener {
+public class ORanChangeNotificationListener implements IetfNetconfNotificationsListener {
private static final Logger log = LoggerFactory.getLogger(ORanChangeNotificationListener.class);
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
index 83e840184..8b8a9bdb4 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElement.java
@@ -53,7 +53,7 @@ public class ORanNetworkElement implements NetworkElement {
private @NonNull final ORanFaultNotificationListener oRanFaultListener;
ORanNetworkElement(NetconfAccessor netconfAccess, DataProvider databaseService) {
- log.info("Create {}",ORanNetworkElement.class.getSimpleName());
+ log.info("Create {}", ORanNetworkElement.class.getSimpleName());
this.netconfAccessor = netconfAccess;
this.databaseService = databaseService;
@@ -73,7 +73,8 @@ public class ORanNetworkElement implements NetworkElement {
List<Component> componentList = hardware.getComponent();
if (componentList != null) {
for (Component component : componentList) {
- databaseService.writeInventory( oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component));
+ databaseService
+ .writeInventory(oRanMapper.getInternalEquipment(netconfAccessor.getNodeId(), component));
}
}
}
@@ -91,11 +92,10 @@ public class ORanNetworkElement implements NetworkElement {
log.info("DBRead Get equipment for class {} from mountpoint {} for uuid {}", clazzPac.getSimpleName(),
accessData.getNodeId().getValue());
- InstanceIdentifier<Hardware> hardwareIID =
- InstanceIdentifier.builder(clazzPac).build();
+ InstanceIdentifier<Hardware> hardwareIID = InstanceIdentifier.builder(clazzPac).build();
- Hardware res = accessData.getTransactionUtils().readData(accessData.getDataBroker(), LogicalDatastoreType.OPERATIONAL,
- hardwareIID);
+ Hardware res = accessData.getTransactionUtils().readData(accessData.getDataBroker(),
+ LogicalDatastoreType.OPERATIONAL, hardwareIID);
return res;
}
@@ -114,7 +114,7 @@ public class ORanNetworkElement implements NetworkElement {
}
if (oRanFaultListenerRegistrationResult != null) {
this.oRanFaultListenerRegistrationResult.close();
- };
+ } ;
}
@@ -129,8 +129,7 @@ public class ORanNetworkElement implements NetworkElement {
}
@Override
- public void warmstart() {
- }
+ public void warmstart() {}
@Override
public Optional<NetconfAccessor> getAcessor() {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElementFactory.java
index cf93ba74a..3a557ccbe 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanNetworkElementFactory.java
@@ -35,10 +35,10 @@ public class ORanNetworkElementFactory implements NetworkElementFactory {
@Override
public Optional<NetworkElement> create(NetconfAccessor acessor, DeviceManagerServiceProvider serviceProvider) {
if (acessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)) {
- log.info("Create device {} ",ORanNetworkElement.class.getName());
+ log.info("Create device {} ", ORanNetworkElement.class.getName());
return Optional.of(new ORanNetworkElement(acessor, serviceProvider.getDataProvider()));
} else if (acessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)) {
- log.info("Create device {} ",NtsNetworkElement.class.getName());
+ log.info("Create device {} ", NtsNetworkElement.class.getName());
return Optional.of(new NtsNetworkElement(acessor, serviceProvider.getDataProvider()));
} else {
return Optional.empty();
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
index a2997c0e5..f21645669 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/impl/ORanToInternalDataModel.java
@@ -1,4 +1,4 @@
-/**
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java
index 7e8327a09..48d8e802a 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/OperatorStateBuilder.java
@@ -1,14 +1,15 @@
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911;
+
import java.lang.String;
import java.lang.UnsupportedOperationException;
/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
+ * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
+ * uint16), or (string - uint32).
*
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
+ * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
+ * finished by the user. This class is generated only once to prevent loss of user code.
*
*/
public class OperatorStateBuilder {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java
index 7c4a63d2b..fb2e5d59d 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceBuilder.java
@@ -1,14 +1,15 @@
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911;
+
import java.lang.String;
import java.lang.UnsupportedOperationException;
/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
+ * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
+ * uint16), or (string - uint32).
*
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
+ * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
+ * finished by the user. This class is generated only once to prevent loss of user code.
*
*/
public class ResourceBuilder {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java
index 282a6a26d..2f4b5931f 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/ResourceMatchBuilder.java
@@ -1,14 +1,15 @@
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911;
+
import java.lang.String;
import java.lang.UnsupportedOperationException;
/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
+ * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
+ * uint16), or (string - uint32).
*
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
+ * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
+ * finished by the user. This class is generated only once to prevent loss of user code.
*
*/
public class ResourceMatchBuilder {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java
index 81391922d..49e50e004 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/SeverityWithClearBuilder.java
@@ -1,14 +1,15 @@
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911;
+
import java.lang.String;
import java.lang.UnsupportedOperationException;
/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
+ * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
+ * uint16), or (string - uint32).
*
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
+ * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
+ * finished by the user. This class is generated only once to prevent loss of user code.
*
*/
public class SeverityWithClearBuilder {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java
index 9f10ae87f..c2a500986 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/main/java/org/opendaylight/yang/gen/v1/urn/ietf/params/xml/ns/yang/ietf/alarms/rev190911/alarms/ControlMaxAlarmStatusChangesBuilder.java
@@ -1,14 +1,15 @@
package org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.ietf.alarms.rev190911.alarms;
+
import java.lang.String;
import java.lang.UnsupportedOperationException;
/**
- * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string representation.
- * In some cases it is very difficult to automate it since there can be unions such as (uint32 - uint16), or (string - uint32).
+ * The purpose of generated class in src/main/java for Union types is to create new instances of unions from a string
+ * representation. In some cases it is very difficult to automate it since there can be unions such as (uint32 -
+ * uint16), or (string - uint32).
*
- * The reason behind putting it under src/main/java is:
- * This class is generated in form of a stub and needs to be finished by the user. This class is generated only once to prevent
- * loss of user code.
+ * The reason behind putting it under src/main/java is: This class is generated in form of a stub and needs to be
+ * finished by the user. This class is generated only once to prevent loss of user code.
*
*/
public class ControlMaxAlarmStatusChangesBuilder {
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java
index 1b5ed9b86..7d7eef57f 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestDeviceManagerORanImpl.java
@@ -1,3 +1,20 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. 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. 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.
+ * ============LICENSE_END==========================================================================
+ */
package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
import java.io.File;
@@ -6,65 +23,59 @@ import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.DeviceManagerORanImpl;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanNetworkElementFactory;
-import org.onap.ccsdk.features.sdnr.wt.devicemanager.service.NetconfNetworkElementService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
-
public class TestDeviceManagerORanImpl {
- private static Path KARAF_ETC = Paths.get("etc");
- private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerORanImpl.class);
- DeviceManagerORanImpl devMgrOran;
-
- @Before
- public void init() throws InterruptedException, IOException {
- /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
+ private static Path KARAF_ETC = Paths.get("etc");
+ private static final Logger LOG = LoggerFactory.getLogger(TestDeviceManagerORanImpl.class);
+ DeviceManagerORanImpl devMgrOran;
+
+ @Before
+ public void init() throws InterruptedException, IOException {
+ /*System.out.println("Logger: " + LOG.getClass().getName() + " " + LOG.getName());
Path etc = KARAF_ETC;
- delete(etc);
-
+ delete(etc);
+
System.out.println("Create empty:" + etc.toString());
Files.createDirectories(etc);*/
- }
-
- @Test
- public void test() throws Exception {
- devMgrOran = new DeviceManagerORanImpl();
- /*DeviceManagerImpl devMgr = new DeviceManagerImpl();
-
- try {
- devMgr.init();
- devMgrOran.setNetconfNetworkElementService(devMgr);
- devMgrOran.init();
- } catch (Exception e) {
- // TODO Auto-generated catch block
- e.printStackTrace();
- }*/
- /*
- * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init();
- * NetconfNetworkElementService netConfNetworkElementService =
- * mock(NetconfNetworkElementService.class); devMgrOran =
- * mock(DeviceManagerORanImpl.class);
- * when(netConfNetworkElementService.registerNetworkElementFactory(new
- * ORanNetworkElementFactory())).thenReturn(null);
- */
-
-
- }
-
- @After
- public void cleanUp() throws Exception {
- devMgrOran.close();
- }
-
- private static void delete(Path etc) throws IOException {
+ }
+
+ @Test
+ public void test() throws Exception {
+ devMgrOran = new DeviceManagerORanImpl();
+ /*DeviceManagerImpl devMgr = new DeviceManagerImpl();
+
+ try {
+ devMgr.init();
+ devMgrOran.setNetconfNetworkElementService(devMgr);
+ devMgrOran.init();
+ } catch (Exception e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ }*/
+ /*
+ * devMgrOran.setNetconfNetworkElementService(null); devMgrOran.init();
+ * NetconfNetworkElementService netConfNetworkElementService =
+ * mock(NetconfNetworkElementService.class); devMgrOran =
+ * mock(DeviceManagerORanImpl.class);
+ * when(netConfNetworkElementService.registerNetworkElementFactory(new
+ * ORanNetworkElementFactory())).thenReturn(null);
+ */
+
+
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+ devMgrOran.close();
+ }
+
+ private static void delete(Path etc) throws IOException {
if (Files.exists(etc)) {
System.out.println("Found, removing:" + etc.toString());
delete(etc.toFile());
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java
index caa4e6463..c8a000bde 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestHardwareClass.java
@@ -1,3 +1,20 @@
+/*
+ * ============LICENSE_START========================================================================
+ * ONAP : ccsdk feature sdnr wt
+ * =================================================================================================
+ * Copyright (C) 2020 highstreet technologies GmbH Intellectual Property. 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. 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.
+ * ============LICENSE_END==========================================================================
+ */
package org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test;
import org.opendaylight.yang.gen.v1.urn.ietf.params.xml.ns.yang.iana.hardware.rev180313.HardwareClass;
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java
index a7cd28d3e..7709298e0 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanChangeNotificationListener.java
@@ -41,47 +41,47 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier.PathArgument;
public class TestORanChangeNotificationListener {
- private static final String NODEID = "node1";
+ private static final String NODEID = "node1";
- @Test
- public void test() {
+ @Test
+ public void test() {
- NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
- DataProvider databaseService = mock(DataProvider.class);
- ORanChangeNotificationListener notifListener = new ORanChangeNotificationListener(netconfAccessor,
- databaseService);
- when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
- Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() {
+ NetconfAccessor netconfAccessor = mock(NetconfAccessor.class);
+ DataProvider databaseService = mock(DataProvider.class);
+ ORanChangeNotificationListener notifListener =
+ new ORanChangeNotificationListener(netconfAccessor, databaseService);
+ when(netconfAccessor.getNodeId()).thenReturn(new NodeId(NODEID));
+ Iterable<? extends PathArgument> pathArguments = Arrays.asList(new PathArgument() {
- @Override
- public int compareTo(PathArgument arg0) {
- return 0;
- }
+ @Override
+ public int compareTo(PathArgument arg0) {
+ return 0;
+ }
- @Override
- public Class<? extends DataObject> getType() {
- return DataObject.class;
- }
- });
- InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments);
+ @Override
+ public Class<? extends DataObject> getType() {
+ return DataObject.class;
+ }
+ });
+ InstanceIdentifier<?> target = InstanceIdentifier.create(pathArguments);
- notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create,target));
- EventlogEntity event = new EventlogBuilder().setNodeId(NODEID)
- .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build();
- verify(databaseService).writeEventLog(event);
+ notifListener.onNetconfConfigChange(createNotification(EditOperationType.Create, target));
+ EventlogEntity event = new EventlogBuilder().setNodeId(NODEID)
+ .setNewValue(String.valueOf(EditOperationType.Create)).setObjectId(target.toString()).build();
+ verify(databaseService).writeEventLog(event);
- }
+ }
- /**
- * @param type
- * @return
- */
- private static NetconfConfigChange createNotification(EditOperationType type,InstanceIdentifier<?> target) {
- NetconfConfigChange change = mock(NetconfConfigChange.class);
-
- @SuppressWarnings("null")
- final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build());
- when(change.nonnullEdit()).thenReturn(edits);
- return change;
- }
+ /**
+ * @param type
+ * @return
+ */
+ private static NetconfConfigChange createNotification(EditOperationType type, InstanceIdentifier<?> target) {
+ NetconfConfigChange change = mock(NetconfConfigChange.class);
+
+ @SuppressWarnings("null")
+ final @NonNull List<Edit> edits = Arrays.asList(new EditBuilder().setOperation(type).setTarget(target).build());
+ when(change.nonnullEdit()).thenReturn(edits);
+ return change;
+ }
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java
index e67ec5430..d486f6735 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanFaultNotificationListener.java
@@ -22,9 +22,9 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.impl.ORanFaultNotifica
public class TestORanFaultNotificationListener {
- @Test
- public void test() {
- ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener();
- faultListener.onAlarmNotif(null);
- }
+ @Test
+ public void test() {
+ ORanFaultNotificationListener faultListener = new ORanFaultNotificationListener();
+ faultListener.onAlarmNotif(null);
+ }
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java
index 98589159a..675499aed 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElement.java
@@ -56,8 +56,8 @@ public class TestORanNetworkElement {
NodeId nNodeId = new NodeId("nSky");
when(accessor.getCapabilites()).thenReturn(capabilities);
- when (accessor.getNodeId()).thenReturn(nNodeId);
- when (accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
+ when(accessor.getNodeId()).thenReturn(nNodeId);
+ when(accessor.getTransactionUtils()).thenReturn(new TransactionUtilsMock());
DataProvider dataProvider = mock(DataProvider.class);
when(serviceProvider.getDataProvider()).thenReturn(dataProvider);
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
index f972f8e58..2614e4dd7 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanNetworkElementFactory.java
@@ -36,50 +36,50 @@ import org.opendaylight.yangtools.yang.common.QName;
public class TestORanNetworkElementFactory {
- static NetconfAccessor accessor;
- static DeviceManagerServiceProvider serviceProvider;
- static Capabilities capabilities;
- QName qCapability;
+ static NetconfAccessor accessor;
+ static DeviceManagerServiceProvider serviceProvider;
+ static Capabilities capabilities;
+ QName qCapability;
- @BeforeClass
- public static void init() throws InterruptedException, IOException {
- capabilities = mock(Capabilities.class);
- accessor = mock(NetconfAccessorMock.class);
- serviceProvider = mock(DeviceManagerServiceProvider.class);
-
- when(accessor.getCapabilites()).thenReturn(capabilities);
- when(serviceProvider.getDataProvider()).thenReturn(null);
+ @BeforeClass
+ public static void init() throws InterruptedException, IOException {
+ capabilities = mock(Capabilities.class);
+ accessor = mock(NetconfAccessorMock.class);
+ serviceProvider = mock(DeviceManagerServiceProvider.class);
-
- }
+ when(accessor.getCapabilites()).thenReturn(capabilities);
+ when(serviceProvider.getDataProvider()).thenReturn(null);
- @Test
- public void testCreateORANHWComponent() throws Exception {
- when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
- when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
- ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
- assertTrue((factory.create(accessor, serviceProvider)).isPresent());
- }
- @Test
- public void testCreateSimulator() throws Exception {
- when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
- ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
- assertTrue(factory.create(accessor, serviceProvider).isPresent());
- }
-
- @Test
- public void testCreateNone() throws Exception {
- when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
- when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
- ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
- assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
- }
-
- @After
- public void cleanUp() throws Exception {
+ }
- }
+ @Test
+ public void testCreateORANHWComponent() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(true);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue((factory.create(accessor, serviceProvider)).isPresent());
+ }
+
+ @Test
+ public void testCreateSimulator() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(true);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue(factory.create(accessor, serviceProvider).isPresent());
+ }
+
+ @Test
+ public void testCreateNone() throws Exception {
+ when(accessor.getCapabilites().isSupportingNamespace(ORANHWCOMPONENT.QNAME)).thenReturn(false);
+ when(accessor.getCapabilites().isSupportingNamespace(SimulatorStatus.QNAME)).thenReturn(false);
+ ORanNetworkElementFactory factory = new ORanNetworkElementFactory();
+ assertTrue(!(factory.create(accessor, serviceProvider).isPresent()));
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
index c6411523f..e5efb1b40 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/TestORanToInternalDataModel.java
@@ -41,46 +41,46 @@ import org.onap.ccsdk.features.sdnr.wt.devicemanager.oran.test.TestHardwareClass
public class TestORanToInternalDataModel {
- NodeId nodeId;
- Component component;
+ NodeId nodeId;
+ Component component;
- @SuppressWarnings("unchecked")
- @Before
- public void init() throws InterruptedException, IOException {
- nodeId = mock(NodeId.class);
- component = mock(Component.class);
+ @SuppressWarnings("unchecked")
+ @Before
+ public void init() throws InterruptedException, IOException {
+ nodeId = mock(NodeId.class);
+ component = mock(Component.class);
- when(nodeId.getValue()).thenReturn("ORan-1000");
- when(component.getParent()).thenReturn("Shelf");
- when(component.getParentRelPos()).thenReturn(0);
- when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
+ when(nodeId.getValue()).thenReturn("ORan-1000");
+ when(component.getParent()).thenReturn("Shelf");
+ when(component.getParentRelPos()).thenReturn(0);
+ when(component.getUuid()).thenReturn(new Uuid("0Aabcdef-0abc-0cfD-0abC-0123456789AB"));
- List<String> list = new ArrayList<String>();
- list.add("Card-01A");
- list.add("Card-01B");
+ List<String> list = new ArrayList<String>();
+ list.add("Card-01A");
+ list.add("Card-01B");
- when (component.getContainsChild()).thenReturn(list);
- when (component.getName()).thenReturn("Nokia");
- when (component.getDescription()).thenReturn("ORAN Network Element NO-456");
- Class<? extends HardwareClass> hwClass = TestHardwareClass.class;
- Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass);
-
- DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z");
- when (component.getMfgDate()).thenReturn(dt);
-
- }
+ when(component.getContainsChild()).thenReturn(list);
+ when(component.getName()).thenReturn("Nokia");
+ when(component.getDescription()).thenReturn("ORAN Network Element NO-456");
+ Class<? extends HardwareClass> hwClass = TestHardwareClass.class;
+ Mockito.<Class<? extends HardwareClass>>when(component.getXmlClass()).thenReturn(hwClass);
- @Test
- public void test() throws Exception {
- ORanToInternalDataModel model = new ORanToInternalDataModel();
- model.getInternalEquipment(nodeId, component);
- assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB");
- assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z");
+ DateAndTime dt = new DateAndTime("2020-02-05T12:30:45.283Z");
+ when(component.getMfgDate()).thenReturn(dt);
- }
+ }
- @After
- public void cleanUp() throws Exception {
+ @Test
+ public void test() throws Exception {
+ ORanToInternalDataModel model = new ORanToInternalDataModel();
+ model.getInternalEquipment(nodeId, component);
+ assertEquals(component.getUuid().getValue(), "0Aabcdef-0abc-0cfD-0abC-0123456789AB");
+ assertEquals(component.getMfgDate().getValue(), "2020-02-05T12:30:45.283Z");
- }
+ }
+
+ @After
+ public void cleanUp() throws Exception {
+
+ }
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java
index c1991dc47..e31aac8fd 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/NetconfConfigChangeMock.java
@@ -29,34 +29,34 @@ import org.opendaylight.yangtools.yang.binding.DataContainer;
public class NetconfConfigChangeMock implements NetconfConfigChange {
- @Override
- public Class<? extends DataContainer> getImplementedInterface() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public <E$$ extends Augmentation<NetconfConfigChange>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable ChangedBy getChangedBy() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable Datastore getDatastore() {
- // TODO Auto-generated method stub
- return null;
- }
-
- @Override
- public @Nullable List<Edit> getEdit() {
- List<Edit> list = new ArrayList<Edit>();
- return list;
- }
+ @Override
+ public Class<? extends DataContainer> getImplementedInterface() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public <E$$ extends Augmentation<NetconfConfigChange>> @Nullable E$$ augmentation(Class<E$$> augmentationType) {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable ChangedBy getChangedBy() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable Datastore getDatastore() {
+ // TODO Auto-generated method stub
+ return null;
+ }
+
+ @Override
+ public @Nullable List<Edit> getEdit() {
+ List<Edit> list = new ArrayList<Edit>();
+ return list;
+ }
}
diff --git a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java
index 0ae9b4a77..d23227d7f 100644
--- a/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java
+++ b/sdnr/wt/devicemanager-oran/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/devicemanager/oran/test/mock/TransactionUtilsMock.java
@@ -29,19 +29,19 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
public class TransactionUtilsMock implements TransactionUtils {
- @Override
- public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
- InstanceIdentifier<T> iid) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public <T extends DataObject> @Nullable T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
+ InstanceIdentifier<T> iid) {
+ // TODO Auto-generated method stub
+ return null;
+ }
- @Override
- public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker,
- LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
- AtomicReference<String> statusIndicator) {
- // TODO Auto-generated method stub
- return null;
- }
+ @Override
+ public <T extends DataObject> @Nullable T readDataOptionalWithStatus(DataBroker dataBroker,
+ LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
+ AtomicReference<String> statusIndicator) {
+ // TODO Auto-generated method stub
+ return null;
+ }
}
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
index f91e96b79..683311e8a 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/HelpServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver;
import java.io.BufferedReader;
@@ -65,7 +65,7 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
resp.addHeader("Access-Control-Allow-Methods", "OPTIONS, HEAD, GET, POST, PUT, DELETE");
resp.addHeader("Access-Control-Allow-Headers", "X-Requested-With, Content-Type, Content-Length");
if (query != null && query.contains("meta")) {
-
+
File f = new File(HelpInfrastructureObject.KARAFHELPDIRECTORY, "meta.json");
if (f.exists()) {
LOG.debug("found local meta file");
@@ -114,19 +114,19 @@ public class HelpServlet extends HttpServlet implements AutoCloseable {
}
LOG.debug("delivering file");
OutputStream out = resp.getOutputStream();
-// if (this.isTextFile(f) && REDIRECT_LINKS) {
-// String line;
-// try (BufferedReader br = new BufferedReader(new FileReader(f))) {
-// line = br.readLine();
-// while (line != null) {
-// out.write((line + "\n").getBytes());
-// line = br.readLine();
-// }
-// out.flush();
-// out.close();
-// br.close();
-// }
-// } else
+ // if (this.isTextFile(f) && REDIRECT_LINKS) {
+ // String line;
+ // try (BufferedReader br = new BufferedReader(new FileReader(f))) {
+ // line = br.readLine();
+ // while (line != null) {
+ // out.write((line + "\n").getBytes());
+ // line = br.readLine();
+ // }
+ // out.flush();
+ // out.close();
+ // br.close();
+ // }
+ // } else
{
try (FileInputStream in = new FileInputStream(f)) {
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
index 975f8985b..ca3a40043 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/ExtactBundleResource.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.data;
import java.io.File;
@@ -29,16 +29,15 @@ import org.osgi.framework.Bundle;
* Extract subtree with resources from Opendaylight/Karaf/OSGi bundle into Karaf directory<br>
*
* Reference: Eclipsezone @see
- * <a href="https://www.eclipsezone.com/eclipse/forums/t101557.html">https://www.eclipszone.com</a>
- * <br>
+ * <a href="https://www.eclipsezone.com/eclipse/forums/t101557.html">https://www.eclipszone.com</a> <br>
* <br>
- * Example for resource and directory path from karaf log. write resource: help/FAQ/0.4.0/README.md
- * Create directories for: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Open
- * the file: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Problem: Binary,
- * JPG files => do not use buffer related functions
+ * Example for resource and directory path from karaf log. write resource: help/FAQ/0.4.0/README.md Create directories
+ * for: data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Open the file:
+ * data/cache/com.highstreet.technologies.help/help/FAQ/0.4.0/README.md Problem: Binary, JPG files => do not use buffer
+ * related functions
*
- * Hint: Verify with file manager the content of the bundle.jar file to see the location of the
- * resources. There is no need to mark them via the classpath.
+ * Hint: Verify with file manager the content of the bundle.jar file to see the location of the resources. There is no
+ * need to mark them via the classpath.
*/
public class ExtactBundleResource {
@@ -47,8 +46,7 @@ public class ExtactBundleResource {
* Extract resources from Karaf/OSGi bundle into karaf directory structure.
*
* @param bundle Karaf/OSGi bundle with resources
- * @param filePrefix prefix in karaf file system for destination e.g.
- * "data/cache/com.highstreet.technologies."
+ * @param filePrefix prefix in karaf file system for destination e.g. "data/cache/com.highstreet.technologies."
* @param ressoureRoot root name of ressources, with leading "/". e.g. "/help"
* @throws IOException In case of problems.
*/
diff --git a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
index 2c79645f1..ebf11b6af 100644
--- a/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
+++ b/sdnr/wt/helpserver/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/helpserver/data/HelpInfrastructureObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.data;
import java.io.File;
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
index 5f8558270..87d33f32f 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestExtract.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
import static org.junit.Assert.assertFalse;
@@ -62,7 +62,7 @@ public class TestExtract extends Mockito {
});
when(myBundle.getEntry(anyString())).thenAnswer(invocation -> {
Object[] args = invocation.getArguments();
- System.out.println("GetEntrye input: "+args[0]);
+ System.out.println("GetEntrye input: " + args[0]);
return new URL(testFile = (String) args[0]);
});
@@ -70,11 +70,11 @@ public class TestExtract extends Mockito {
ExtactBundleResource.copyBundleResoucesRecursively(myBundle, TMPDATAFOLDER, "help/meta.json");
- assertTrue("Test file not found: "+testFile, new File(TMPDATAFOLDER+testFile).exists());
+ assertTrue("Test file not found: " + testFile, new File(TMPDATAFOLDER + testFile).exists());
- ExtactBundleResource.deleteRecursively(new File(TMPDATAFOLDER+"file:"));
+ ExtactBundleResource.deleteRecursively(new File(TMPDATAFOLDER + "file:"));
- assertFalse("Test not deleted: "+testFile, new File(TMPDATAFOLDER+"file:").exists());
+ assertFalse("Test not deleted: " + testFile, new File(TMPDATAFOLDER + "file:").exists());
} catch (Exception e) {
e.printStackTrace();
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
index 9d63da500..3e2472822 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfObject.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -6,23 +6,21 @@
* =================================================================================================
* 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.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
-import static org.junit.Assert.*;
-
+import static org.junit.Assert.fail;
import java.io.File;
import java.io.IOException;
import java.net.URISyntaxException;
-
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -43,18 +41,20 @@ public class TestHelpInfObject {
e.printStackTrace();
}
}
+
@After
public void deinit() {
this.init();
}
+
@Test
public void test() {
- File root=new File(HelpInfrastructureObject.getHelpDirectoryBase()+"/"+ROOT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test2/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test3/abc/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test3/abc1/0.4.0/README.md", CONTENT);
- TestMyServlet.createHelpFile("/"+ROOT+"/test5/0.4.0/README.md", CONTENT);
+ File root = new File(HelpInfrastructureObject.getHelpDirectoryBase() + "/" + ROOT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test2/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test3/abc/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test3/abc1/0.4.0/README.md", CONTENT);
+ TestMyServlet.createHelpFile("/" + ROOT + "/test5/0.4.0/README.md", CONTENT);
try {
new HelpInfrastructureObject(root.toPath());
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
index dfe649a87..60add4be7 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestHelpInfrastructure.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
import static org.junit.Assert.fail;
@@ -36,7 +36,7 @@ public class TestHelpInfrastructure {
try {
path = Paths.get(url.toURI());
HelpInfrastructureObject helpInfrastuctureObject = new HelpInfrastructureObject(path);
- System.out.println("Help: "+helpInfrastuctureObject);
+ System.out.println("Help: " + helpInfrastuctureObject);
} catch (URISyntaxException e) {
fail(e.getMessage());
}
diff --git a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
index 2e4f987be..cd40e122b 100644
--- a/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
+++ b/sdnr/wt/helpserver/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/helpserver/test/TestMyServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -6,20 +6,23 @@
* =================================================================================================
* 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.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.helpserver.test;
+import static java.nio.file.StandardOpenOption.CREATE;
+import static java.nio.file.StandardOpenOption.CREATE_NEW;
+import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
+import static java.nio.file.StandardOpenOption.WRITE;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.fail;
-
import java.io.File;
import java.io.IOException;
import java.io.StringWriter;
@@ -36,27 +39,24 @@ import org.mockito.Mockito;
import org.onap.ccsdk.features.sdnr.wt.helpserver.HelpServlet;
import org.onap.ccsdk.features.sdnr.wt.helpserver.data.ExtactBundleResource;
import org.onap.ccsdk.features.sdnr.wt.helpserver.data.HelpInfrastructureObject;
-import static java.nio.file.StandardOpenOption.CREATE_NEW;
-import static java.nio.file.StandardOpenOption.WRITE;
-import static java.nio.file.StandardOpenOption.CREATE;
-import static java.nio.file.StandardOpenOption.TRUNCATE_EXISTING;
public class TestMyServlet extends Mockito {
private static final String GETHELPDIRECTORYBASE = "data";
private static final String CONTENT = "abbccdfkamaosie aksdmais";
- public static void createHelpFile(String filename,String content) {
- File file=new File(HelpInfrastructureObject.getHelpDirectoryBase() + filename);
+ public static void createHelpFile(String filename, String content) {
+ File file = new File(HelpInfrastructureObject.getHelpDirectoryBase() + filename);
File folder = file.getParentFile();
- if(!folder.exists()) {
+ if (!folder.exists()) {
folder.mkdirs();
}
try {
- if(file.exists()) {
+ if (file.exists()) {
file.delete();
}
- Files.write( file.toPath(),content.getBytes(),new OpenOption[] { WRITE, CREATE_NEW , CREATE, TRUNCATE_EXISTING});
+ Files.write(file.toPath(), content.getBytes(),
+ new OpenOption[] {WRITE, CREATE_NEW, CREATE, TRUNCATE_EXISTING});
} catch (IOException e1) {
fail(e1.getMessage());
}
@@ -70,6 +70,7 @@ public class TestMyServlet extends Mockito {
e.printStackTrace();
}
}
+
@After
public void deinit() {
this.init();
@@ -87,7 +88,7 @@ public class TestMyServlet extends Mockito {
when(request.getQueryString()).thenReturn("?meta");
StringWriter stringWriter = new StringWriter();
- ServletOutputStream out=new ServletOutputStream() {
+ ServletOutputStream out = new ServletOutputStream() {
@Override
public void write(int arg0) throws IOException {
@@ -96,11 +97,11 @@ public class TestMyServlet extends Mockito {
};
when(response.getOutputStream()).thenReturn(out);
- HelpServlet helpServlet=null;
+ HelpServlet helpServlet = null;
try {
helpServlet = new HelpServlet();
System.out.println("Server created");
- createHelpFile("/meta.json",CONTENT);
+ createHelpFile("/meta.json", CONTENT);
helpServlet.doOptions(request, response);
System.out.println("Get calling");
@@ -115,7 +116,7 @@ public class TestMyServlet extends Mockito {
String result = stringWriter.toString().trim();
System.out.println("Result: '" + result + "'");
- assertEquals(CONTENT,result);
+ assertEquals(CONTENT, result);
}
@Test
@@ -128,11 +129,11 @@ public class TestMyServlet extends Mockito {
private void testGetRequest(String fn) {
HelpServlet helpServlet = new HelpServlet();
- createHelpFile("/"+fn,CONTENT);
+ createHelpFile("/" + fn, CONTENT);
HttpServletRequest request = mock(HttpServletRequest.class);
HttpServletResponse response = mock(HttpServletResponse.class);
- when(request.getRequestURI()).thenReturn("help/"+fn);
+ when(request.getRequestURI()).thenReturn("help/" + fn);
StringWriter sw = new StringWriter();
ServletOutputStream out = new ServletOutputStream() {
@@ -156,6 +157,6 @@ public class TestMyServlet extends Mockito {
} catch (Exception e) {
}
- assertEquals("compare content for "+fn,CONTENT,sw.toString().trim());
+ assertEquals("compare content for " + fn, CONTENT, sw.toString().trim());
}
}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
index ba80d305f..50176f4cf 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/Capabilities.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
/**
* Convert capabilities of netconfnode into internal format. Boron and Carbon are providing
* different versions
@@ -40,8 +40,8 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
- * Wrapper class for capabilites for Boron and later releases. Uses generics because yang model was
- * changed from Boron to later version. Interface class:
+ * Wrapper class for capabilites for Boron and later releases. Uses generics because yang model was changed from Boron
+ * to later version. Interface class:
* org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev150114.netconf.node.connection.status.available.capabilities.AvailableCapability
*/
public class Capabilities {
@@ -61,7 +61,7 @@ public class Capabilities {
if (nnode != null) {
AvailableCapabilities availableCapabilites = nnode.getAvailableCapabilities();
if (availableCapabilites != null) {
- capabilities.constructor(availableCapabilites.getAvailableCapability());
+ capabilities.constructor(availableCapabilites.getAvailableCapability());
} else {
LOG.debug("empty capabilites");
}
@@ -78,7 +78,7 @@ public class Capabilities {
if (nnode != null) {
UnavailableCapabilities availableCapabilites = nnode.getUnavailableCapabilities();
if (availableCapabilites != null) {
- capabilities.constructor(availableCapabilites.getUnavailableCapability());
+ capabilities.constructor(availableCapabilites.getUnavailableCapability());
} else {
LOG.debug("empty capabilites");
}
@@ -102,7 +102,7 @@ public class Capabilities {
Method methodGetCapability;
for (Object capability : pcapabilities) {
- if (capability instanceof String) { // ODL Boron specific
+ if (capability instanceof String) { // ODL Boron specific
this.capabilities.add((String) capability);
} else { // Carbon specific part .. handled via generics
try {
@@ -122,6 +122,7 @@ public class Capabilities {
/**
* Get Capabilites
+ *
* @return List<String> with capabilites
*/
public List<String> getCapabilities() {
@@ -130,6 +131,7 @@ public class Capabilities {
/**
* Verify if the namespace is supported
+ *
* @param qCapability from model
* @return true if namespace is supported
*/
@@ -146,7 +148,7 @@ public class Capabilities {
*
* @param qCapability capability from the model
* @return true if supporting the model AND revision<br>
- * false if revision not available or both not found.
+ * false if revision not available or both not found.
*/
public boolean isSupportingNamespaceAndRevision(QName qCapability) {
@@ -176,6 +178,7 @@ public class Capabilities {
/**
* Provide revision as String from QName, considering older formats.
+ *
* @param qCapability that specifies the revision
* @return String with revisiondate or null
*/
@@ -204,12 +207,13 @@ public class Capabilities {
/**
* Get revision of first entry of related capability
+ *
* @param qCapability that specifies the namespace
* @return String with date or
*/
public String getRevisionForNamespace(QName qCapability) {
String namespace = qCapability.getNamespace().toString();
- for (String capability : capabilities) {
+ for (String capability : capabilities) {
if (capability.contains(namespace)) {
return QName.create(capability).getRevision().get().toString();
}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
index 3ca851184..1161681e6 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfAccessor.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
import com.google.common.util.concurrent.ListenableFuture;
@@ -29,7 +29,7 @@ import org.opendaylight.yangtools.yang.binding.NotificationListener;
import org.opendaylight.yangtools.yang.common.RpcResult;
/**
- * Interface handling netconf connection.
+ * Interface handling netconf connection.
*/
public interface NetconfAccessor {
@@ -69,8 +69,8 @@ public interface NetconfAccessor {
/**
* Register netconf notification listener for related mountpoint
*
- * @param <T> specific child class of NotificationListener
- * @param listener listener to be called
+ * @param <T> specific child class of NotificationListener
+ * @param listener listener to be called
* @return handler to manager registration
*/
<T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(
@@ -78,6 +78,7 @@ public interface NetconfAccessor {
/**
* Register notifications stream for the connection.
+ *
* @param streamName that should be "NETCONF" as default.
* @return progress indication
*/
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java
index cebed4c8a..e29bb79e9 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeConnectListener.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
@@ -25,28 +25,28 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
/**
- * Indicate if device is connected or not.
- * A NetconfNode (Mountpoint) is providing the status.
- * If this is Master and connected, this function is calles.
+ * Indicate if device is connected or not. A NetconfNode (Mountpoint) is providing the status. If this is Master and
+ * connected, this function is calles.
*/
public interface NetconfNodeConnectListener extends EventListener, AutoCloseable {
/**
* Called if device state changes to "connected" for a netconf master node.
+ *
* @param acessor containing <br>
- * - nNodeId name of mount point<br>
- * - netconfNode with related information<br>
- * - mountPoint of the node<br>
- * -netconfNodeDataBroker to access connected netconf device
+ * - nNodeId name of mount point<br>
+ * - netconfNode with related information<br>
+ * - mountPoint of the node<br>
+ * -netconfNodeDataBroker to access connected netconf device
*/
- public void onEnterConnected(@NonNull NetconfAccessor acessor );
+ public void onEnterConnected(@NonNull NetconfAccessor acessor);
+
/**
- * Notify of device state change to "not connected" mount point supervision for
- * master mountpoint HINT: This callback could be called multiple times also the
- * onEnterConnected state was not called.
+ * Notify of device state change to "not connected" mount point supervision for master mountpoint HINT: This
+ * callback could be called multiple times also the onEnterConnected state was not called.
*
- * @param nNodeId name of mount point
+ * @param nNodeId name of mount point
* @param optionalNetconfNode with new status or if removed not present
*/
public void onLeaveConnected(@NonNull NodeId nNodeId, @NonNull Optional<NetconfNode> optionalNetconfNode);
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java
index 253af0598..fdbcf9595 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateListener.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
@@ -24,30 +24,32 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.netconf.node.topology.rev15
import org.opendaylight.yang.gen.v1.urn.tbd.params.xml.ns.yang.network.topology.rev131021.NodeId;
/**
- * Indicate all state changes of NetconfNode (Mountpoint). Cleans up and
- * summarizes the
+ * Indicate all state changes of NetconfNode (Mountpoint). Cleans up and summarizes the
*/
public interface NetconfNodeStateListener extends EventListener {
- /**
- * New NetconfNode has been created
- * @param nNodeId of Node
- * @param netconfNode object
- */
-
- void onCreated(NodeId nNodeId, NetconfNode netconfNode);
-
- /**
- * New NetconfNode has been created
- * @param nNodeId of node
- * @param netconfNode object after change
- */
- void onStateChange(NodeId nNodeId, NetconfNode netconfNode);
-
- /**
- * NetconfNode has been removed
- * @param nNodeId of related node
- */
- void onRemoved(NodeId nNodeId);
+ /**
+ * New NetconfNode has been created
+ *
+ * @param nNodeId of Node
+ * @param netconfNode object
+ */
+
+ void onCreated(NodeId nNodeId, NetconfNode netconfNode);
+
+ /**
+ * New NetconfNode has been created
+ *
+ * @param nNodeId of node
+ * @param netconfNode object after change
+ */
+ void onStateChange(NodeId nNodeId, NetconfNode netconfNode);
+
+ /**
+ * NetconfNode has been removed
+ *
+ * @param nNodeId of related node
+ */
+ void onRemoved(NodeId nNodeId);
}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java
index 0105c36e8..4e82b3d25 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/NetconfNodeStateService.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
@@ -26,23 +26,32 @@ public interface NetconfNodeStateService extends Registration {
/**
* Register for indication that Master NetconNode is entering or leaving Connected state.
+ *
* @param netconfNodeConnectListener
* @return managing object for listener
*/
- @NonNull <L extends NetconfNodeConnectListener> ListenerRegistration<L> registerNetconfNodeConnectListener(@NonNull L netconfNodeConnectListener);
+ @NonNull
+ <L extends NetconfNodeConnectListener> ListenerRegistration<L> registerNetconfNodeConnectListener(
+ @NonNull L netconfNodeConnectListener);
/**
* Register for all NetconfNode specific state changes
+ *
* @param netconfNodeStateListener
* @return managing object for listener
*/
- @NonNull <L extends NetconfNodeStateListener> ListenerRegistration<L> registerNetconfNodeStateListener(@NonNull L netconfNodeStateListener);
+ @NonNull
+ <L extends NetconfNodeStateListener> ListenerRegistration<L> registerNetconfNodeStateListener(
+ @NonNull L netconfNodeStateListener);
/**
* Register for Ves/DmaaP provided messages
+ *
* @param netconfNodeStateListener
* @return managing object for listener
*/
- @NonNull <L extends VesNotificationListener> ListenerRegistration<L> registerVesNotifications(@NonNull L netconfNodeStateListener);
+ @NonNull
+ <L extends VesNotificationListener> ListenerRegistration<L> registerVesNotifications(
+ @NonNull L netconfNodeStateListener);
}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java
index da8da5c7f..752e3c6b9 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/TransactionUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
import java.util.concurrent.atomic.AtomicBoolean;
@@ -31,32 +31,32 @@ import org.opendaylight.yangtools.yang.binding.InstanceIdentifier;
*/
public interface TransactionUtils {
- /**
- * Deliver the data back or null. Warning
- *
- * @param <T> SubType of the DataObject to be handled
- * @param dataBroker for accessing data
- * @param dataStoreType to address datastore
- * @param iid id to access data
- * @return null or object
- */
- @Nullable
- <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
- InstanceIdentifier<T> iid);
+ /**
+ * Deliver the data back or null. Warning
+ *
+ * @param <T> SubType of the DataObject to be handled
+ * @param dataBroker for accessing data
+ * @param dataStoreType to address datastore
+ * @param iid id to access data
+ * @return null or object
+ */
+ @Nullable
+ <T extends DataObject> T readData(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
+ InstanceIdentifier<T> iid);
- /**
- * Deliver the data back or null
- *
- * @param <T> SubType of the DataObject to be handled
- * @param dataBroker for accessing data
- * @param dataStoreType to address datastore
- * @param iid id to access data
- * @param noErrorIndication (Output) true if data could be read and are available and is not null
- * @param statusIndicator (Output) String with status indications during the read.
- * @return null or object
- */
- @Nullable
- <T extends DataObject> T readDataOptionalWithStatus(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
- InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, AtomicReference<String> statusIndicator);
+ /**
+ * Deliver the data back or null
+ *
+ * @param <T> SubType of the DataObject to be handled
+ * @param dataBroker for accessing data
+ * @param dataStoreType to address datastore
+ * @param iid id to access data
+ * @param noErrorIndication (Output) true if data could be read and are available and is not null
+ * @param statusIndicator (Output) String with status indications during the read.
+ * @return null or object
+ */
+ @Nullable
+ <T extends DataObject> T readDataOptionalWithStatus(DataBroker dataBroker, LogicalDatastoreType dataStoreType,
+ InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication, AtomicReference<String> statusIndicator);
-} \ No newline at end of file
+}
diff --git a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java
index e7d2481b8..8be6b85cc 100644
--- a/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java
+++ b/sdnr/wt/netconfnode-state-service/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/VesNotificationListener.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice;
@@ -23,21 +23,22 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfn
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfnode.state.rev191011.FaultNotification;
/**
- * Indicate if device is connected or not.
- * A NetconfNode (Mountpoint) is providing the status.
- * If this is Master and connected, this function is calles.
+ * Indicate if device is connected or not. A NetconfNode (Mountpoint) is providing the status. If this is Master and
+ * connected, this function is calles.
*/
public interface VesNotificationListener extends EventListener, AutoCloseable {
/**
* Called in case of fault notification
+ *
* @param faultNotification to handle
*/
public void onNotification(FaultNotification faultNotification);
/**
* Called in case of attributeChange notification
+ *
* @param attributeChangeNotification to handle
*/
public void onNotification(AttributeChangeNotification attributeChangeNotification);
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java
index 6a811ea59..755224027 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/GenericTransactionUtils.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl;
import com.google.common.base.Preconditions;
@@ -58,7 +58,8 @@ public final class GenericTransactionUtils implements TransactionUtils {
AtomicBoolean noErrorIndication = new AtomicBoolean();
AtomicReference<String> statusText = new AtomicReference<>();
- @Nullable T obj = readDataOptionalWithStatus(dataBroker, dataStoreType, iid, noErrorIndication, statusText);
+ @Nullable
+ T obj = readDataOptionalWithStatus(dataBroker, dataStoreType, iid, noErrorIndication, statusText);
if (!noErrorIndication.get()) {
LOG.warn("Read transaction for identifier " + iid + " failed with status " + statusText.get());
@@ -84,7 +85,8 @@ public final class GenericTransactionUtils implements TransactionUtils {
LogicalDatastoreType dataStoreType, InstanceIdentifier<T> iid, AtomicBoolean noErrorIndication,
AtomicReference<String> statusIndicator) {
- @Nullable T data = null;
+ @Nullable
+ T data = null;
noErrorIndication.set(false);
statusIndicator.set("Preconditions");
@@ -109,7 +111,8 @@ public final class GenericTransactionUtils implements TransactionUtils {
statusIndicator.set("Create Read Transaction");
ReadTransaction readTransaction = dataBroker.newReadOnlyTransaction();
try {
- @NonNull FluentFuture<Optional<T>> od = readTransaction.read(dataStoreType, iid);
+ @NonNull
+ FluentFuture<Optional<T>> od = readTransaction.read(dataStoreType, iid);
statusIndicator.set("Read done");
if (od != null) {
statusIndicator.set("Unwrap checkFuture done");
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java
index 654b9d7d9..433b34e49 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfAccessorImpl.java
@@ -58,7 +58,8 @@ public class NetconfAccessorImpl implements NetconfAccessor {
/**
* Contains all data to access and manage netconf device
- * @param nodeId of managed netconf node
+ *
+ * @param nodeId of managed netconf node
* @param netconfNode information
* @param dataBroker to access node
* @param mountpoint of netconfNode
@@ -78,7 +79,7 @@ public class NetconfAccessorImpl implements NetconfAccessor {
}
/**
- * @param nodeId with uuid of managed netconf node
+ * @param nodeId with uuid of managed netconf node
* @param dataBroker to access node
*/
public NetconfAccessorImpl(String nodeId, NetconfNode netconfNode, DataBroker dataBroker, MountPoint mountpoint,
@@ -95,31 +96,36 @@ public class NetconfAccessorImpl implements NetconfAccessor {
public DataBroker getDataBroker() {
return dataBroker;
}
+
@Override
public MountPoint getMountpoint() {
return mountpoint;
}
+
@Override
public TransactionUtils getTransactionUtils() {
return transactionUtils;
}
+
@Override
public NetconfNode getNetconfNode() {
return netconfNode;
}
+
@Override
public Capabilities getCapabilites() {
return capabilities;
}
@Override
- public @NonNull <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(@NonNull T listener) {
+ public @NonNull <T extends NotificationListener> ListenerRegistration<NotificationListener> doRegisterNotificationListener(
+ @NonNull T listener) {
log.info("Begin register listener for Mountpoint {}", mountpoint.getIdentifier().toString());
- final Optional<NotificationService> optionalNotificationService = mountpoint
- .getService(NotificationService.class);
+ final Optional<NotificationService> optionalNotificationService =
+ mountpoint.getService(NotificationService.class);
final NotificationService notificationService = optionalNotificationService.get();
- final ListenerRegistration<NotificationListener> ranListenerRegistration = notificationService
- .registerNotificationListener(listener);
+ final ListenerRegistration<NotificationListener> ranListenerRegistration =
+ notificationService.registerNotificationListener(listener);
log.info("End registration listener for Mountpoint {} Listener: {} Result: {}",
mountpoint.getIdentifier().toString(), optionalNotificationService, ranListenerRegistration);
return ranListenerRegistration;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
index adced6b33..c190346c4 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/NetconfNodeStateServiceImpl.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl;
import java.util.Collection;
@@ -144,7 +144,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
this.listenerL1 = null;
this.listenerL2 = null;
- this.initializationSuccessful= false;
+ this.initializationSuccessful = false;
this.netconfNodeConnectListenerList = new CopyOnWriteArrayList<>();
this.netconfNodeStateListenerList = new CopyOnWriteArrayList<>();
this.vesNotificationListenerList = new CopyOnWriteArrayList<>();
@@ -165,9 +165,11 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
public void setMountPointService(MountPointService mountPointService) {
this.mountPointService = mountPointService;
}
+
public void setClusterSingletonService(ClusterSingletonServiceProvider clusterSingletonService) {
this.clusterSingletonServiceProvider = clusterSingletonService;
}
+
public void setEntityDataProvider(IEntityDataProvider iEntityDataProvider) {
this.iEntityDataProvider = iEntityDataProvider;
}
@@ -187,8 +189,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
this.clusterName = akkaConfig == null ? "" : akkaConfig.getClusterConfig().getClusterSeedNodeName("abc");
// Provide status information
- ClusterConfig cc = akkaConfig==null?null:akkaConfig.getClusterConfig();
- this.iEntityDataProvider.setStatus(StatusKey.CLUSTER_SIZE,cc==null?"1":String.format("%d",cc.getClusterSize()));
+ ClusterConfig cc = akkaConfig == null ? null : akkaConfig.getClusterConfig();
+ this.iEntityDataProvider.setStatus(StatusKey.CLUSTER_SIZE,
+ cc == null ? "1" : String.format("%d", cc.getClusterSize()));
// RPC Service for specific services
this.rpcApiService.setStatusCallback(this);
@@ -206,6 +209,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
LOG.info("Session Initiated end. Initialization done {}", initializationSuccessful);
}
+
/** Blueprint destroy-method method */
public void destroy() {
close();
@@ -213,6 +217,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
/**
* Getter
+ *
* @return NetconfnodeStateServiceRpcApiImpl
*/
public NetconfnodeStateServiceRpcApiImpl getNetconfnodeStateServiceRpcApiImpl() {
@@ -227,7 +232,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public <L extends NetconfNodeConnectListener> @NonNull ListenerRegistration<L> registerNetconfNodeConnectListener(
final @NonNull L netconfNodeConnectListener) {
- LOG.info("Register connect listener {}",netconfNodeConnectListener.getClass().getName());
+ LOG.info("Register connect listener {}", netconfNodeConnectListener.getClass().getName());
netconfNodeConnectListenerList.add(netconfNodeConnectListener);
return new ListenerRegistration<L>() {
@@ -238,7 +243,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public void close() {
- LOG.info("Remove connect listener {}",netconfNodeConnectListener);
+ LOG.info("Remove connect listener {}", netconfNodeConnectListener);
netconfNodeConnectListenerList.remove(netconfNodeConnectListener);
}
};
@@ -247,7 +252,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public <L extends NetconfNodeStateListener> @NonNull ListenerRegistration<L> registerNetconfNodeStateListener(
@NonNull L netconfNodeStateListener) {
- LOG.info("Register state listener {}",netconfNodeStateListener.getClass().getName());
+ LOG.info("Register state listener {}", netconfNodeStateListener.getClass().getName());
netconfNodeStateListenerList.add(netconfNodeStateListener);
return new ListenerRegistration<L>() {
@@ -258,7 +263,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public void close() {
- LOG.info("Remove state listener {}",netconfNodeStateListener);
+ LOG.info("Remove state listener {}", netconfNodeStateListener);
netconfNodeStateListenerList.remove(netconfNodeStateListener);
}
};
@@ -267,7 +272,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public <L extends VesNotificationListener> @NonNull ListenerRegistration<L> registerVesNotifications(
@NonNull L vesNotificationListener) {
- LOG.info("Register Ves notification listener {}",vesNotificationListener.getClass().getName());
+ LOG.info("Register Ves notification listener {}", vesNotificationListener.getClass().getName());
vesNotificationListenerList.add(vesNotificationListener);
return new ListenerRegistration<L>() {
@@ -278,7 +283,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
@Override
public void close() {
- LOG.info("Remove Ves notification listener {}",vesNotificationListener);
+ LOG.info("Remove Ves notification listener {}", vesNotificationListener);
vesNotificationListenerList.remove(vesNotificationListener);
}
};
@@ -311,6 +316,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
/**
* Indication if init() of this bundle successfully done.
+ *
* @return true if init() was successful. False if not done or not successful.
*/
public boolean isInitializationSuccessful() {
@@ -322,8 +328,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
*/
/**
- * For each mounted device a mountpoint is created and this listener is called.
- * Mountpoint was created or existing. Managed device is now fully connected to node/mountpoint.
+ * For each mounted device a mountpoint is created and this listener is called. Mountpoint was created or existing.
+ * Managed device is now fully connected to node/mountpoint.
+ *
* @param nNodeId id of the mountpoint
* @param netconfNode mountpoint contents
*/
@@ -349,8 +356,8 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
LOG.info("isNetconfNodeMaster indication {} for mountpoint {}", isNetconfNodeMaster, mountPointNodeName);
if (isNetconfNodeMaster) {
- InstanceIdentifier<Node> instanceIdentifier = NETCONF_TOPO_IID.child(Node.class,
- new NodeKey(new NodeId(mountPointNodeName)));
+ InstanceIdentifier<Node> instanceIdentifier =
+ NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountPointNodeName)));
Optional<MountPoint> optionalMountPoint = null;
int timeout = 10000;
@@ -399,6 +406,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
/**
* Leave the connected status to a non connected or removed status for master mountpoint
+ *
* @param action that occurred
* @param nNodeId id of the mountpoint
* @param netconfNode mountpoint contents or not available on remove
@@ -407,8 +415,8 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
String mountPointNodeName = nNodeId.getValue();
LOG.info("netconfNode id {}", mountPointNodeName);
- InstanceIdentifier<Node> instanceIdentifier = NETCONF_TOPO_IID.child(Node.class,
- new NodeKey(new NodeId(mountPointNodeName)));
+ InstanceIdentifier<Node> instanceIdentifier =
+ NETCONF_TOPO_IID.child(Node.class, new NodeKey(new NodeId(mountPointNodeName)));
Optional<MountPoint> optionalMountPoint = mountPointService.getMountPoint(instanceIdentifier);
if (optionalMountPoint.isPresent()) {
Optional<DataBroker> optionalNetconfNodeDatabroker = optionalMountPoint.get().getService(DataBroker.class);
@@ -436,15 +444,14 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
final DataObjectModification<Node> root = change.getRootNode();
//if (LOG.isTraceEnabled()) {
- LOG.info /*trace*/("Handle this modificationType:{} path:{} root:{}", root.getModificationType(),
- change.getRootPath(), root);
+ LOG.info /*trace*/("Handle this modificationType:{} path:{} root:{}", root.getModificationType(),
+ change.getRootPath(), root);
//}
// Catch potential nullpointer exceptions ..
try {
ModificationType modificationTyp = root.getModificationType();
- Node node = modificationTyp == ModificationType.DELETE ? root.getDataBefore()
- : root.getDataAfter();
+ Node node = modificationTyp == ModificationType.DELETE ? root.getDataBefore() : root.getDataAfter();
NodeId nodeId = node != null ? node.getNodeId() : null;
if (nodeId != null) {
if (nodeId.equals(CONTROLLER)) {
@@ -453,70 +460,70 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
} else {
if (modificationTyp != null) {
switch (modificationTyp) {
- case SUBTREE_MODIFIED: // Create or modify sub level node
- case WRITE: // Create or modify top level node
- // Treat an overwrite as an update
- // leaveconnected state.before = connected; state.after != connected
- // enterConnected state.after == connected
- // => Here create or update by checking root.getDataBefore() != null
-
- boolean connectedBefore, connectedAfter, created=false;
- NetconfNode nNodeAfter = getNetconfNode(root.getDataAfter());
- connectedAfter = isConnected(nNodeAfter);
- if (root.getDataBefore() != null) {
- // It is an update
- NetconfNode nodeBefore = getNetconfNode(root.getDataBefore());
- connectedBefore = isConnected(nodeBefore);
- } else {
- // It is a create
- connectedBefore = false;
- created = true;
- }
-
- LOG.info(
- "L1 NETCONF Node change with id:{} ConnectedBefore:{} connectedAfter {}:cluster status:{} akkaIsCluster:{}",
- nodeId, connectedBefore, connectedAfter,
- getClusteredConnectionStatus(nNodeAfter), isCluster);
-
- if(created) {
- netconfNodeStateListenerList.forEach(item -> {
- try {
- item.onCreated(nodeId, nNodeAfter);
- } catch (Exception e) {
- LOG.info("Exception during onCreated listener call", e);
- }
- });
- }
- if (!connectedBefore && connectedAfter) {
- enterConnectedState(nodeId, nNodeAfter);
- } else {
- LOG.debug("State change {} {}", connectedBefore, connectedAfter);
- if (connectedBefore && !connectedAfter) {
- leaveConnectedState(nodeId, Optional.of(nNodeAfter));
+ case SUBTREE_MODIFIED: // Create or modify sub level node
+ case WRITE: // Create or modify top level node
+ // Treat an overwrite as an update
+ // leaveconnected state.before = connected; state.after != connected
+ // enterConnected state.after == connected
+ // => Here create or update by checking root.getDataBefore() != null
+
+ boolean connectedBefore, connectedAfter, created = false;
+ NetconfNode nNodeAfter = getNetconfNode(root.getDataAfter());
+ connectedAfter = isConnected(nNodeAfter);
+ if (root.getDataBefore() != null) {
+ // It is an update
+ NetconfNode nodeBefore = getNetconfNode(root.getDataBefore());
+ connectedBefore = isConnected(nodeBefore);
+ } else {
+ // It is a create
+ connectedBefore = false;
+ created = true;
+ }
+
+ LOG.info(
+ "L1 NETCONF Node change with id:{} ConnectedBefore:{} connectedAfter {}:cluster status:{} akkaIsCluster:{}",
+ nodeId, connectedBefore, connectedAfter,
+ getClusteredConnectionStatus(nNodeAfter), isCluster);
+
+ if (created) {
+ netconfNodeStateListenerList.forEach(item -> {
+ try {
+ item.onCreated(nodeId, nNodeAfter);
+ } catch (Exception e) {
+ LOG.info("Exception during onCreated listener call", e);
+ }
+ });
+ }
+ if (!connectedBefore && connectedAfter) {
+ enterConnectedState(nodeId, nNodeAfter);
+ } else {
+ LOG.debug("State change {} {}", connectedBefore, connectedAfter);
+ if (connectedBefore && !connectedAfter) {
+ leaveConnectedState(nodeId, Optional.of(nNodeAfter));
+ }
+ netconfNodeStateListenerList.forEach(item -> {
+ try {
+ item.onStateChange(nodeId, nNodeAfter);
+ } catch (Exception e) {
+ LOG.info("Exception during onStateChange listener call", e);
+ }
+ });
}
+ // doProcessing(update ? Action.UPDATE : Action.CREATE, nodeId, root);
+ break;
+ case DELETE:
+ // Node removed
+ // leaveconnected state.before = connected;
+ leaveConnectedState(nodeId, Optional.empty());
netconfNodeStateListenerList.forEach(item -> {
try {
- item.onStateChange(nodeId, nNodeAfter);
+ item.onRemoved(nodeId);
} catch (Exception e) {
- LOG.info("Exception during onStateChange listener call", e);
+ LOG.info("Exception during onRemoved listener call", e);
}
});
- }
- // doProcessing(update ? Action.UPDATE : Action.CREATE, nodeId, root);
- break;
- case DELETE:
- // Node removed
- // leaveconnected state.before = connected;
- leaveConnectedState(nodeId, Optional.empty());
- netconfNodeStateListenerList.forEach(item -> {
- try {
- item.onRemoved(nodeId);
- } catch (Exception e) {
- LOG.info("Exception during onRemoved listener call", e);
- }
- });
- // doProcessing(Action.REMOVE, nodeId, root);
- break;
+ // doProcessing(Action.REMOVE, nodeId, root);
+ break;
}
}
}
@@ -530,14 +537,13 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
// ---- subclasses for listeners
/**
- * Clustered listener function to select the right node from
- * DataObjectModification. Called at all nodes.
+ * Clustered listener function to select the right node from DataObjectModification. Called at all nodes.
*/
private class L1 implements ClusteredDataTreeChangeListener<Node> {
@Override
public void onDataTreeChanged(@NonNull Collection<DataTreeModification<Node>> changes) {
LOG.info("L1 TreeChange enter changes:{}", changes.size());
- new Thread( () -> onDataTreeChangedHandler(changes)).start();
+ new Thread(() -> onDataTreeChangedHandler(changes)).start();
LOG.info("L1 TreeChange leave");
}
}
@@ -557,7 +563,7 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
/* --- private helpers --- */
private static @Nullable NetconfNode getNetconfNode(Node node) {
- return node != null ? node.augmentation(NetconfNode.class) : null;
+ return node != null ? node.augmentation(NetconfNode.class) : null;
}
private static boolean isConnected(NetconfNode nNode) {
@@ -603,7 +609,9 @@ public class NetconfNodeStateServiceImpl implements NetconfNodeStateService, Rpc
LOG.debug("check if me is responsible for node");
ClusteredConnectionStatus ccs = nNode.getClusteredConnectionStatus();
@SuppressWarnings("null")
- @NonNull String masterNodeName = ccs == null || ccs.getNetconfMasterNode() == null ? "null" : ccs.getNetconfMasterNode();
+ @NonNull
+ String masterNodeName =
+ ccs == null || ccs.getNetconfMasterNode() == null ? "null" : ccs.getNetconfMasterNode();
LOG.debug("sdnMasterNode=" + masterNodeName + " and sdnMyNode=" + this.clusterName);
if (!masterNodeName.equals(this.clusterName)) {
LOG.debug("netconf change but me is not master for this node");
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java
index d0ea0eb69..64b0edbd6 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/AkkaConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka;
import java.io.File;
@@ -77,10 +77,11 @@ public class AkkaConfig {
public boolean isSingleNode() {
return !this.isCluster();
}
- public static AkkaConfig parse(String content) throws Exception {
+
+ public static AkkaConfig parse(String content) throws Exception {
Config cfg = ConfigFactory.parseString(content);
AkkaConfig c = new AkkaConfig();
- c.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
+ c.cluserConfig = new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
return c;
}
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java
index 7f8d6cc78..47d3ec3b7 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka;
import java.util.ArrayList;
@@ -35,20 +35,20 @@ public class ClusterConfig {
private final ClusterRoleInfoCollection roles;
private ClusterNodeInfo ismeInfo;
- public static ClusterConfig defaultSingleNodeConfig()
- {
- ClusterConfig cfg=new ClusterConfig();
- cfg.ismeInfo=ClusterNodeInfo.defaultSingleNodeInfo();
+ public static ClusterConfig defaultSingleNodeConfig() {
+ ClusterConfig cfg = new ClusterConfig();
+ cfg.ismeInfo = ClusterNodeInfo.defaultSingleNodeInfo();
cfg.seedNodes.add(cfg.ismeInfo);
cfg.roles.add(ClusterRoleInfo.defaultSingleNodeRole());
return cfg;
}
- public ClusterConfig()
- {
+
+ public ClusterConfig() {
this.seedNodes = new ArrayList<>();
this.roles = new ClusterRoleInfoCollection();
}
+
public ClusterConfig(Config o) throws Exception {
{
this.seedNodes = new ArrayList<>();
@@ -87,9 +87,9 @@ public class ClusterConfig {
public String getHostName(String defaultValue) {
if (getRoleMemberIndex() > 0 && getRoleMemberIndex() <= seedNodes.size()) {
- return this.seedNodes.get(getRoleMemberIndex()-1).getRemoteAddress();
+ return this.seedNodes.get(getRoleMemberIndex() - 1).getRemoteAddress();
} else {
- LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}",getRoleMember(), defaultValue);
+ LOG.warn("Seednode not available for roleMemberIndex {}. Using default {}", getRoleMember(), defaultValue);
return defaultValue;
}
}
@@ -97,33 +97,37 @@ public class ClusterConfig {
public String getDBClusterName(String defaultValue) {
String r = null;
if (this.seedNodes != null && this.seedNodes.size() > 0) {
- r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(), this.seedNodes.get(0).getPort());
+ r = String.format("cluster-%s.%d", this.seedNodes.get(0).getRemoteAddress(),
+ this.seedNodes.get(0).getPort());
}
if (r == null || r.isEmpty()) {
r = defaultValue;
}
return r;
}
+
public String getClusterSeedNodeName() {
return this.getClusterSeedNodeName("");
}
+
public String getClusterSeedNodeName(String defaultValue) {
- int idx=this.getRoleMemberIndex()-1;
- String r=null;
- if(this.seedNodes!=null && idx>=0 && this.seedNodes.size()>0 && this.seedNodes.size()>idx)
- {
- r=this.seedNodes.get(idx).getSeedNodeName();
+ int idx = this.getRoleMemberIndex() - 1;
+ String r = null;
+ if (this.seedNodes != null && idx >= 0 && this.seedNodes.size() > 0 && this.seedNodes.size() > idx) {
+ r = this.seedNodes.get(idx).getSeedNodeName();
}
if (r == null || r.isEmpty()) {
r = defaultValue;
}
return r;
}
+
public int getRoleMemberIndex() {
- ClusterRoleInfo role=this.roles.get("member");
- return role!=null?role.getIndex():0;
+ ClusterRoleInfo role = this.roles.get("member");
+ return role != null ? role.getIndex() : 0;
}
+
public ClusterRoleInfo getRoleMember() {
return this.roles.get("member");
}
@@ -133,9 +137,9 @@ public class ClusterConfig {
return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + ", ismeInfo=" + ismeInfo + "]";
}
- public int getClusterSize() {
- return this.seedNodes == null ? 0 : this.seedNodes.size();
- }
+ public int getClusterSize() {
+ return this.seedNodes == null ? 0 : this.seedNodes.size();
+ }
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
index ef161ad12..b27a7bd5c 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlAkka/ClusterNodeInfo.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,13 +14,13 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlAkka;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
-public class ClusterNodeInfo {
+public class ClusterNodeInfo {
private final String protocol;
private final String clusterName;
private final String remoteAdr;
@@ -28,7 +28,7 @@ public class ClusterNodeInfo {
private final String seedNodeName;
public static ClusterNodeInfo defaultSingleNodeInfo() {
- return new ClusterNodeInfo("akka.tcp","opendaylight-cluster-data","127.0.0.1",2550);
+ return new ClusterNodeInfo("akka.tcp", "opendaylight-cluster-data", "127.0.0.1", 2550);
}
public ClusterNodeInfo(String s) throws Exception {
@@ -46,11 +46,11 @@ public class ClusterNodeInfo {
}
public ClusterNodeInfo(String protocol, String clustername, String remoteadr, int port) {
- this.protocol=protocol;
- this.clusterName=clustername;
- this.remoteAdr=remoteadr;
- this.port=port;
- this.seedNodeName=this.protocol+"://"+this.clusterName+"@"+this.remoteAdr+":"+this.port;
+ this.protocol = protocol;
+ this.clusterName = clustername;
+ this.remoteAdr = remoteadr;
+ this.port = port;
+ this.seedNodeName = this.protocol + "://" + this.clusterName + "@" + this.remoteAdr + ":" + this.port;
}
public String getProtocol() {
@@ -64,6 +64,7 @@ public class ClusterNodeInfo {
public String getRemoteAddress() {
return remoteAdr;
}
+
public String getSeedNodeName() {
return seedNodeName;
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
index 994ef548b..8f4446bb4 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfo.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo;
import java.util.regex.Matcher;
@@ -29,24 +29,25 @@ public class ClusterRoleInfo {
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
if (!matcher.find()) {
- throw new Exception("unexpected role format:"+s);
+ throw new Exception("unexpected role format:" + s);
}
this.Role = matcher.group(1);
this.Index = Integer.parseInt(matcher.group(2));
}
private ClusterRoleInfo(String role, int idx) {
- this.Role=role;
- this.Index=idx;
+ this.Role = role;
+ this.Index = idx;
}
public static ClusterRoleInfo defaultSingleNodeRole() {
- return new ClusterRoleInfo("member",1);
+ return new ClusterRoleInfo("member", 1);
}
public String getRole() {
return Role;
}
+
public int getIndex() {
return Index;
}
@@ -84,6 +85,7 @@ public class ClusterRoleInfo {
}
return true;
}
+
@Override
public String toString() {
return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]";
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java
index 478ed8394..e50ac9daa 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/ClusterRoleInfoCollection.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo;
import java.util.ArrayList;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java
index c25f3264b..5091e5219 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/conf/odlGeo/GeoConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.conf.odlGeo;
import java.io.File;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java
index 9215887ff..896f010d8 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/NetconfnodeStateServiceRpcApiImpl.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.rpc;
import org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.VesNotificationListener;
@@ -113,9 +113,11 @@ public class NetconfnodeStateServiceRpcApiImpl implements NetconfnodeStateServic
PushAttributeChangeNotificationInput input) {
RpcResultBuilder<PushAttributeChangeNotificationOutput> result;
try {
- AttributeChangeNotificationBuilder attributeChangeNotificationBuilder = new AttributeChangeNotificationBuilder();
+ AttributeChangeNotificationBuilder attributeChangeNotificationBuilder =
+ new AttributeChangeNotificationBuilder();
attributeChangeNotificationBuilder.fieldsFrom(input);
- vesNotificationListenerList.forEach(item -> item.onNotification(attributeChangeNotificationBuilder.build()));
+ vesNotificationListenerList
+ .forEach(item -> item.onNotification(attributeChangeNotificationBuilder.build()));
result = RpcResultBuilder.success();
} catch (Exception e) {
result = RpcResultBuilder.failed();
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java
index 1434cf41a..b33c1473d 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/impl/rpc/RpcApigetStateCallback.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.impl.rpc;
@@ -23,5 +23,5 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.netconfn
public interface RpcApigetStateCallback {
- GetStatusOutputBuilder getStatus(GetStatusInput input);
+ GetStatusOutputBuilder getStatus(GetStatusInput input);
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java
index dd317c781..a420b5e91 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestAkkaConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
import static org.junit.Assert.fail;
@@ -108,7 +108,7 @@ public class TestAkkaConfig {
String failMessage = "failed: " + e.getMessage();
System.out.println(failMessage);
fail(failMessage);
- }
+ }
}
@Test
@@ -123,7 +123,7 @@ public class TestAkkaConfig {
System.out.println("testing clusternode config1");
System.out.println("===========================");
cfg = AkkaConfig.load(file.getAbsolutePath());
- System.out.println("succeeded: "+cfg.hashCode());
+ System.out.println("succeeded: " + cfg.hashCode());
System.out.println(cfg.toString());
System.out.println(String.format("found %d cluster nodes", cfg.getClusterConfig().getSeedNodes().size()));
for (ClusterNodeInfo n : cfg.getClusterConfig().getSeedNodes()) {
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java
index 915c88d50..327a87d2b 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestGeoConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java
index 5427c0339..eb07a48f1 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/TestNetconfNodeStateService.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START======================================================= ONAP : ccsdk
* feature sdnr wt ================================================================================
* Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
@@ -12,7 +12,7 @@
* 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. ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test;
import static org.mockito.Mockito.mock;
@@ -149,8 +149,7 @@ public class TestNetconfNodeStateService {
System.out.println("Test2: Register state listener");
NetconfNodeStateListener nSL = mock(NetconfNodeStateListener.class);
- ListenerRegistration<NetconfNodeStateListener> res =
- netconfStateService.registerNetconfNodeStateListener(nSL);
+ ListenerRegistration<NetconfNodeStateListener> res = netconfStateService.registerNetconfNodeStateListener(nSL);
assertNotNull("Result should be null", res);
res.getInstance();
res.close();
@@ -163,7 +162,7 @@ public class TestNetconfNodeStateService {
NetconfNodeConnectListener nCL = mock(NetconfNodeConnectListener.class);
ListenerRegistration<NetconfNodeConnectListener> res =
- netconfStateService.registerNetconfNodeConnectListener(nCL);
+ netconfStateService.registerNetconfNodeConnectListener(nCL);
assertNotNull("Result should be null", res);
res.getInstance();
res.close();
@@ -212,7 +211,7 @@ public class TestNetconfNodeStateService {
//verify that it was called one time and nodeId is the expected
ArgumentCaptor<NetconfAccessor> varArgs = ArgumentCaptor.forClass(NetconfAccessor.class);
verify(nCL).onEnterConnected(varArgs.capture());
- System.out.println("Accessor "+varArgs.getValue().getNodeId());
+ System.out.println("Accessor " + varArgs.getValue().getNodeId());
assertEquals(nodeIdString, varArgs.getValue().getNodeId().getValue());
}
@@ -252,7 +251,7 @@ public class TestNetconfNodeStateService {
ListenableFuture<RpcResult<GetStatusOutput>> statusOutput = api.getStatus(statusInput.build());
RpcResult<GetStatusOutput> res = statusOutput.get();
GetStatusOutput output = res.getResult();
- System.out.println("Output "+output);
+ System.out.println("Output " + output);
}
@@ -269,15 +268,16 @@ public class TestNetconfNodeStateService {
FaultNotification fault = faultBuilder.build();
PushFaultNotificationInputBuilder statusInput = new PushFaultNotificationInputBuilder();
statusInput.fieldsFrom(fault);
- ListenableFuture<RpcResult<PushFaultNotificationOutput>> rpcOutput = api.pushFaultNotification(statusInput.build());
+ ListenableFuture<RpcResult<PushFaultNotificationOutput>> rpcOutput =
+ api.pushFaultNotification(statusInput.build());
RpcResult<PushFaultNotificationOutput> res = rpcOutput.get();
PushFaultNotificationOutput output = res.getResult();
//verify that it was called one time
- verify(vNL,times(1)).onNotification(fault);
+ verify(vNL, times(1)).onNotification(fault);
registration.close();
- System.out.println("Output "+output);
+ System.out.println("Output " + output);
}
@Test
@@ -293,15 +293,16 @@ public class TestNetconfNodeStateService {
AttributeChangeNotification change = changeBuilder.build();
PushAttributeChangeNotificationInputBuilder statusInput = new PushAttributeChangeNotificationInputBuilder();
statusInput.fieldsFrom(change);
- ListenableFuture<RpcResult<PushAttributeChangeNotificationOutput>> rpcOutput = api.pushAttributeChangeNotification(statusInput.build());
+ ListenableFuture<RpcResult<PushAttributeChangeNotificationOutput>> rpcOutput =
+ api.pushAttributeChangeNotification(statusInput.build());
RpcResult<PushAttributeChangeNotificationOutput> res = rpcOutput.get();
PushAttributeChangeNotificationOutput output = res.getResult();
//verify that it was called one time
- verify(vNL,times(1)).onNotification(change);
+ verify(vNL, times(1)).onNotification(change);
registration.close();
- System.out.println("Output "+output);
+ System.out.println("Output " + output);
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java
index 86340c052..cc502b4aa 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/ClusterSingletonServiceProviderMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
@@ -24,14 +24,14 @@ import org.opendaylight.mdsal.singleton.common.api.ClusterSingletonServiceRegist
public class ClusterSingletonServiceProviderMock implements ClusterSingletonServiceProvider {
- @Override
- public void close() throws Exception {
+ @Override
+ public void close() throws Exception {
- }
+ }
- @Override
- public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service) {
- return null;
- }
+ @Override
+ public ClusterSingletonServiceRegistration registerClusterSingletonService(ClusterSingletonService service) {
+ return null;
+ }
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java
index 48401c881..ebcf5fb40 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerMountpointMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
import org.eclipse.jdt.annotation.NonNull;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java
index 90ab8608c..7db577cc8 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/DataBrokerNetconfMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
import java.util.Collection;
@@ -64,7 +64,7 @@ public class DataBrokerNetconfMock implements DataBroker {
@Override
public <T extends DataObject, L extends DataTreeChangeListener<T>> @NonNull ListenerRegistration<L> registerDataTreeChangeListener(
@NonNull DataTreeIdentifier<T> treeId, @NonNull L pListener) {
- System.out.println("Register "+pListener.getClass().getName());
+ System.out.println("Register " + pListener.getClass().getName());
if (pListener instanceof ClusteredDataTreeChangeListener) {
System.out.println("Clustered listener");
this.listenerClustered = (ClusteredDataTreeChangeListener<Node>) pListener;
@@ -80,8 +80,7 @@ public class DataBrokerNetconfMock implements DataBroker {
}
@Override
- public void close() {
- }
+ public void close() {}
};
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java
index e5bff451d..77d5e5e38 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
@@ -57,12 +57,13 @@ public class MountPointMock implements MountPoint {
@Override
public <T extends BindingService> Optional<T> getService(Class<T> service) {
- System.out.println("Requested mountpoint service: "+service.getSimpleName()+" databrokerAbsent state: "+databrokerAbsent);
+ System.out.println("Requested mountpoint service: " + service.getSimpleName() + " databrokerAbsent state: "
+ + databrokerAbsent);
Optional<? extends BindingService> res;
if (service.isInstance(dataBroker)) {
System.out.println("Delivering databroker");
- res = databrokerAbsent ? Optional.empty() : Optional.of(dataBroker);
+ res = databrokerAbsent ? Optional.empty() : Optional.of(dataBroker);
} else if (service.isInstance(rpcConsumerRegistry)) {
System.out.println("Delivering RpcConsumerRegistryMock");
res = Optional.of(rpcConsumerRegistry);
@@ -76,7 +77,7 @@ public class MountPointMock implements MountPoint {
return (Optional<T>) res;
}
- public void setDatabrokerAbsent( boolean state) {
+ public void setDatabrokerAbsent(boolean state) {
this.databrokerAbsent = state;
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java
index 127019633..996549e3d 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/MountPointServiceMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
import java.util.Optional;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java
index 0564c56a3..2b3e00f5c 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/NotificationPublishServiceMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
import com.google.common.util.concurrent.ListenableFuture;
@@ -32,14 +32,13 @@ public class NotificationPublishServiceMock implements NotificationPublishServic
return null;
}
- @Override
+ @Override
public ListenableFuture<?> offerNotification(Notification notification, int timeout, TimeUnit unit)
throws InterruptedException {
return null;
}
@Override
- public void putNotification(Notification notification) throws InterruptedException {
- }
+ public void putNotification(Notification notification) throws InterruptedException {}
}
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java
index 7e48ff2e5..8eea79abc 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcConsumerRegistryMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt sdnr-wt-devicemanager-provider
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
diff --git a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java
index fbcb21db9..f2f6c0e68 100644
--- a/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java
+++ b/sdnr/wt/netconfnode-state-service/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/netconfnodestateservice/test/mock/RpcProviderRegistryMock.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START=======================================================
* ONAP : ccsdk feature sdnr wt
* ================================================================================
@@ -17,7 +17,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.netconfnodestateservice.test.mock;
import java.util.Set;
diff --git a/sdnr/wt/odlux/apps/apiDemo/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/apiDemo/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/apiDemo/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/apiDemo/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index e2ffb596b..884759a32 100644
--- a/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/apiDemo/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/configurationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/configurationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/configurationApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/configurationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/configurationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index edf68e096..fee4a97c1 100644
--- a/sdnr/wt/odlux/apps/configurationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/configurationApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/connectApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/connectApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/connectApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/connectApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index edf68e096..fee4a97c1 100644
--- a/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/connectApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/demoApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/demoApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/demoApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/demoApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index edf68e096..fee4a97c1 100644
--- a/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/demoApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/eventLogApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/eventLogApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/eventLogApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/eventLogApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/eventLogApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/eventLogApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index e2ffb596b..884759a32 100644
--- a/sdnr/wt/odlux/apps/eventLogApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/eventLogApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/faultApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/faultApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/faultApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/faultApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index edf68e096..fee4a97c1 100644
--- a/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/faultApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/apps/helpApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/helpApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/helpApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/helpApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index d0fbe63c0..c319bb189 100644
--- a/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/helpApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/apps/inventoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/inventoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/inventoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/inventoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index d0fbe63c0..c319bb189 100644
--- a/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/inventoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index d0fbe63c0..c319bb189 100644
--- a/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/maintenanceApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/apps/mediatorApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/mediatorApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/mediatorApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/mediatorApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index d0fbe63c0..c319bb189 100644
--- a/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/mediatorApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/apps/minimumApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/minimumApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/minimumApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/minimumApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index d0fbe63c0..c319bb189 100644
--- a/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/minimumApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java b/sdnr/wt/odlux/apps/performanceHistoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
index 1e882fc69..43b072c4b 100644
--- a/sdnr/wt/odlux/apps/performanceHistoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
+++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src2/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/MyOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles;
import org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles.OdluxBundle;
diff --git a/sdnr/wt/odlux/apps/performanceHistoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java b/sdnr/wt/odlux/apps/performanceHistoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
index edf68e096..fee4a97c1 100644
--- a/sdnr/wt/odlux/apps/performanceHistoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
+++ b/sdnr/wt/odlux/apps/performanceHistoryApp/src2/test/java/org/onap/ccsdk/features/sdnr/wt/odlux/bundles/test/TestBundleRes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.bundles.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
index 4b58aac44..f6d0b55bf 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/ClassLoaderUtilExt.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
import java.io.IOException;
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/IndexOdlBundle.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/IndexOdlBundle.java
index d193edb04..39c73ef85 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/IndexOdlBundle.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/IndexOdlBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
public interface IndexOdlBundle {
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
index 4e2332b4e..e1e300a0d 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
import org.slf4j.Logger;
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
index ce003c664..455c83296 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleLoader.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
public interface OdluxBundleLoader {
diff --git a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
index d7ac3e9c4..f9a842556 100644
--- a/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
+++ b/sdnr/wt/odlux/core/model/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/model/bundles/OdluxBundleResourceAccess.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux.model.bundles;
import java.util.List;
diff --git a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexOdluxBundle.java b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexOdluxBundle.java
index 73d61a7b3..75497e08c 100644
--- a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexOdluxBundle.java
+++ b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexOdluxBundle.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux;
import java.io.BufferedReader;
diff --git a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
index d6d466ab9..db709b17d 100644
--- a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
+++ b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/IndexServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux;
import java.io.File;
diff --git a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/OdluxBundleLoaderImpl.java b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/OdluxBundleLoaderImpl.java
index 205c96129..d3ab96947 100644
--- a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/OdluxBundleLoaderImpl.java
+++ b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/OdluxBundleLoaderImpl.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux;
import java.util.ArrayList;
diff --git a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/ResFilesServlet.java b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/ResFilesServlet.java
index fe00662aa..321924e52 100644
--- a/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/ResFilesServlet.java
+++ b/sdnr/wt/odlux/core/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/odlux/ResFilesServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.odlux;
import java.io.IOException;
diff --git a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestBundleLoaderImpl.java b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestBundleLoaderImpl.java
index bebbffdcf..c973d530b 100644
--- a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestBundleLoaderImpl.java
+++ b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestBundleLoaderImpl.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.odlux.test;
import static org.junit.Assert.assertEquals;
diff --git a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestLoadResources.java b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestLoadResources.java
index 3c9ad4308..d9cd920de 100644
--- a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestLoadResources.java
+++ b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestLoadResources.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.odlux.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestRedirect.java b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestRedirect.java
index 78d5eb8fe..bbf542441 100644
--- a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestRedirect.java
+++ b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestRedirect.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.odlux.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestResFileServlet.java b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestResFileServlet.java
index 217735c40..0490c80d5 100644
--- a/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestResFileServlet.java
+++ b/sdnr/wt/odlux/core/provider/src/test/java/org/onap/ccsdk/features/sdnr/odlux/test/TestResFileServlet.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.odlux.test;
import static org.junit.Assert.*;
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/Blueprint.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/Blueprint.java
index bd84043a2..7deefa940 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/Blueprint.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/Blueprint.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2;
import org.opendaylight.mdsal.binding.api.RpcProviderService;
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManager.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManager.java
index ea06ffcd3..1c4d924cb 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManager.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManager.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2;
import com.google.common.util.concurrent.ListenableFuture;
@@ -37,9 +37,9 @@ import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocke
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventOutput;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketEventOutputBuilder;
import org.opendaylight.yang.gen.v1.urn.opendaylight.params.xml.ns.yang.websocketmanager.rev150105.WebsocketmanagerService;
+import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
-import org.opendaylight.yangtools.yang.common.RpcError.ErrorType;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -54,9 +54,9 @@ public class WebSocketManager extends WebSocketServlet implements Websocketmanag
private final AkkaConfig akkaConfig;
/**
* timeout for websocket with no messages in ms
- */
+ */
//private static final long IDLE_TIMEOUT = 5 * 60 * 1000L;
- private static final long IDLE_TIMEOUT =0L;
+ private static final long IDLE_TIMEOUT = 0L;
private final ArrayList<URI> clusterNodeClients = new ArrayList<>();
@@ -142,12 +142,12 @@ public class WebSocketManager extends WebSocketServlet implements Websocketmanag
/**********************************************************
* Private functions
- */
+ */
@Override
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
if (req.getHeader("Upgrade") != null) {
- /* Accept upgrade request */
+ /* Accept upgrade request */
resp.setStatus(101);
resp.setHeader("Upgrade", "XYZP");
resp.setHeader("Connection", "Upgrade");
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerProvider.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerProvider.java
index 881ee1a82..7e82b5e0f 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerProvider.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerProvider.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2;
import com.google.common.util.concurrent.ListenableFuture;
@@ -107,8 +107,8 @@ public class WebSocketManagerProvider extends Blueprint implements Websocketmana
@Override
public ListenableFuture<RpcResult<WebsocketEventOutput>> websocketEvent(WebsocketEventInput input) {
if (wsServlet != null) {
- return wsServlet.websocketEvent(input);
- } else {
+ return wsServlet.websocketEvent(input);
+ } else {
RpcResultBuilder<WebsocketEventOutput> result = RpcResultBuilder.failed();
return result.withError(ErrorType.APPLICATION, "Not intialized").buildFuture();
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerSocket.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerSocket.java
index 0fd2cae4e..70810a7ac 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerSocket.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/WebSocketManagerSocket.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2;
import java.util.ArrayList;
@@ -50,15 +50,15 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
/**
* list of all sessionids
- */
+ */
private static final List<String> sessionIds = new ArrayList<>();
/**
* map of sessionid <=> UserScopes
- */
+ */
private static final HashMap<String, UserScopes> userScopesList = new HashMap<>();
/**
* map of class.hashCode <=> class
- */
+ */
private static final HashMap<String, WebSocketManagerSocket> clientList = new HashMap<>();
private final String myUniqueSessionId;
@@ -88,7 +88,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
@Override
public void onWebSocketText(String message) {
- LOG.info("{} has sent {}",this.getRemoteAdr(), message);
+ LOG.info("{} has sent {}", this.getRemoteAdr(), message);
if (!this.manageClientRequest(message)) {
this.manageClientRequest2(message);
}
@@ -130,10 +130,9 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
/**
*
- * @param request is a json object
- * {"data":"scopes","scopes":["scope1","scope2",...]}
+ * @param request is a json object {"data":"scopes","scopes":["scope1","scope2",...]}
* @return if handled
- */
+ */
private boolean manageClientRequest(String request) {
boolean ret = false;
try {
@@ -160,7 +159,7 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
/*
* broadcast message to all your clients
- */
+ */
private void manageClientRequest2(String request) {
try {
JSONObject o = new JSONObject(request);
@@ -180,7 +179,8 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
LOG.warn("problem sending message: " + e.getMessage());
}
}
- public String getSessionId() {
+
+ public String getSessionId() {
return this.myUniqueSessionId;
}
@@ -209,12 +209,12 @@ public class WebSocketManagerSocket extends WebSocketAdapter {
}
}
}
+
public static void broadCast(String nodeName, String eventType, String xmlEvent) {
- if(clientList.size()>0) {
+ if (clientList.size() > 0) {
Set<Entry<String, WebSocketManagerSocket>> e = clientList.entrySet();
WebSocketManagerSocket s = e.iterator().next().getValue();
- if(s!=null)
- {
+ if (s != null) {
s.sendToAll(nodeName, eventType, xmlEvent);
}
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/AkkaConfig.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/AkkaConfig.java
index 4381595a7..93a941d20 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/AkkaConfig.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/AkkaConfig.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -6,17 +6,19 @@
* =================================================================================================
* 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.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.utils;
+import com.typesafe.config.Config;
+import com.typesafe.config.ConfigFactory;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
@@ -26,42 +28,40 @@ import org.onap.ccsdk.features.sdnr.wt.websocketmanager2.WebSocketManager;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.typesafe.config.Config;
-import com.typesafe.config.ConfigFactory;
-
-public class AkkaConfig{
+public class AkkaConfig {
private static final Logger LOG = LoggerFactory.getLogger(WebSocketManager.class.getName());
- public static class ClusterNodeInfo
- {
+ public static class ClusterNodeInfo {
@Override
public String toString() {
return "ClusterNodeInfo [protocol=" + protocol + ", clusterName=" + clusterName + ", remoteAdr=" + remoteAdr
+ ", port=" + port + "]";
}
+
private final String protocol;
private final String clusterName;
private final String remoteAdr;
private final int port;
- public String getRemoteAddress() {return this.remoteAdr;}
- public ClusterNodeInfo(String s) throws Exception
- {
- final String regex ="([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
+ public String getRemoteAddress() {
+ return this.remoteAdr;
+ }
+
+ public ClusterNodeInfo(String s) throws Exception {
+ final String regex = "([a-z.]*):\\/\\/([a-zA-Z0-9-]*)@([a-zA-Z0-9.-]*):([0-9]*)";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
- if(!matcher.find()) {
+ if (!matcher.find()) {
throw new Exception("invalid seedNode format");
}
- this.protocol=matcher.group(1);
- this.clusterName=matcher.group(2);
- this.remoteAdr=matcher.group(3);
- this.port=Integer.parseInt(matcher.group(4));
+ this.protocol = matcher.group(1);
+ this.clusterName = matcher.group(2);
+ this.remoteAdr = matcher.group(3);
+ this.port = Integer.parseInt(matcher.group(4));
}
}
- public static class ClusterRoleInfo
- {
+ public static class ClusterRoleInfo {
@Override
public String toString() {
return "ClusterRoleInfo [Role=" + Role + ", Index=" + Index + "]";
@@ -69,58 +69,61 @@ public class AkkaConfig{
private final String Role;
private final int Index;
+
public ClusterRoleInfo(String s) throws Exception {
final String regex = "([a-z]*)-([0-9]*)";
final Pattern pattern = Pattern.compile(regex);
final Matcher matcher = pattern.matcher(s);
- if(!matcher.find()) {
+ if (!matcher.find()) {
throw new Exception("invalid role format");
}
- this.Role=matcher.group(1);
- this.Index=Integer.parseInt(matcher.group(2));
+ this.Role = matcher.group(1);
+ this.Index = Integer.parseInt(matcher.group(2));
}
}
- public static class ClusterConfig
- {
+ public static class ClusterConfig {
@Override
public String toString() {
return "ClusterConfig [seedNodes=" + seedNodes + ", roles=" + roles + "]";
}
+
private final List<ClusterNodeInfo> seedNodes;
private final List<ClusterRoleInfo> roles;
private final ClusterNodeInfo ismeInfo;
+
public ClusterConfig(Config o) throws Exception {
{
- this.seedNodes = new ArrayList<>();
- List<String> a= o.getStringList("seed-nodes");
- for(int i=0;i<a.size();i++)
- {
- ClusterNodeInfo info=new ClusterNodeInfo(a.get(i));
- this.seedNodes.add(info);
- }
- this.roles=new ArrayList<>();
- a=o.getStringList("roles");
- for(int i=0;i<a.size();i++)
- {
- ClusterRoleInfo s=new ClusterRoleInfo(a.get(i));
- this.roles.add(s);
- }
- int idx=this.roles.get(0).Index-1;
- if(idx>=0 && idx<this.seedNodes.size()) {
- this.ismeInfo=this.seedNodes.get(idx);
- } else {
- this.ismeInfo=null;
+ this.seedNodes = new ArrayList<>();
+ List<String> a = o.getStringList("seed-nodes");
+ for (int i = 0; i < a.size(); i++) {
+ ClusterNodeInfo info = new ClusterNodeInfo(a.get(i));
+ this.seedNodes.add(info);
+ }
+ this.roles = new ArrayList<>();
+ a = o.getStringList("roles");
+ for (int i = 0; i < a.size(); i++) {
+ ClusterRoleInfo s = new ClusterRoleInfo(a.get(i));
+ this.roles.add(s);
+ }
+ int idx = this.roles.get(0).Index - 1;
+ if (idx >= 0 && idx < this.seedNodes.size()) {
+ this.ismeInfo = this.seedNodes.get(idx);
+ } else {
+ this.ismeInfo = null;
+ }
}
+
}
- }
public boolean isCluster() {
- return this.seedNodes!=null?this.seedNodes.size()>1:false;
+ return this.seedNodes != null ? this.seedNodes.size() > 1 : false;
}
+
public boolean isMe(ClusterNodeInfo i) {
- return this.ismeInfo!=null?this.ismeInfo.equals(i):false;
+ return this.ismeInfo != null ? this.ismeInfo.equals(i) : false;
}
+
public List<ClusterNodeInfo> getSeedNodes() {
return this.seedNodes;
}
@@ -131,13 +134,17 @@ public class AkkaConfig{
private final String resourceFilename;
private final String fileContent;
private ClusterConfig cluserConfig;
- public ClusterConfig getClusterConfig() {return this.cluserConfig;}
- private AkkaConfig(File file,boolean isResource) {
- this.file=isResource?null:file;
- this.fileContent=null;
- this.resourceFilename=isResource?file.getName():null;
+ public ClusterConfig getClusterConfig() {
+ return this.cluserConfig;
}
+
+ private AkkaConfig(File file, boolean isResource) {
+ this.file = isResource ? null : file;
+ this.fileContent = null;
+ this.resourceFilename = isResource ? file.getName() : null;
+ }
+
private AkkaConfig(String fileContent) {
this.file = null;
this.fileContent = fileContent;
@@ -151,47 +158,45 @@ public class AkkaConfig{
}
private void loadFromFile() throws Exception {
- Config cfg=null;
- if(this.file!=null) {
- cfg=ConfigFactory.parseFile(this.file);
- } else if(this.fileContent!=null) {
- cfg=ConfigFactory.parseString(this.fileContent);
- } else if(this.resourceFilename!=null) {
- cfg=ConfigFactory.parseResources(this.getClass(), this.resourceFilename);
+ Config cfg = null;
+ if (this.file != null) {
+ cfg = ConfigFactory.parseFile(this.file);
+ } else if (this.fileContent != null) {
+ cfg = ConfigFactory.parseString(this.fileContent);
+ } else if (this.resourceFilename != null) {
+ cfg = ConfigFactory.parseResources(this.getClass(), this.resourceFilename);
}
- if(cfg!=null) {
- this.cluserConfig=new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
- } else
- {
+ if (cfg != null) {
+ this.cluserConfig =
+ new ClusterConfig(cfg.getConfig("odl-cluster-data").getConfig("akka").getConfig("cluster"));
+ } else {
LOG.warn("unable to parse config file");
- this.cluserConfig=null;
+ this.cluserConfig = null;
}
}
- public boolean isCluster()
- {
- return this.cluserConfig!=null?this.cluserConfig.isCluster():false;
+ public boolean isCluster() {
+ return this.cluserConfig != null ? this.cluserConfig.isCluster() : false;
}
- public static AkkaConfig load() throws Exception
- {
+
+ public static AkkaConfig load() throws Exception {
return load(DEFAULT_FILENAME);
}
- public static AkkaConfig load(String filename) throws Exception
- {
- return load(filename,false);
+ public static AkkaConfig load(String filename) throws Exception {
+ return load(filename, false);
}
- public static AkkaConfig load(String filename,boolean isResource) throws Exception
- {
- AkkaConfig cfg=new AkkaConfig(new File(filename),isResource);
+
+ public static AkkaConfig load(String filename, boolean isResource) throws Exception {
+ AkkaConfig cfg = new AkkaConfig(new File(filename), isResource);
cfg.loadFromFile();
return cfg;
}
- public static AkkaConfig loadContent(String content) throws Exception
- {
- AkkaConfig cfg=new AkkaConfig(content);
+
+ public static AkkaConfig loadContent(String content) throws Exception {
+ AkkaConfig cfg = new AkkaConfig(content);
cfg.loadFromFile();
return cfg;
@@ -199,8 +204,4 @@ public class AkkaConfig{
-
-
-
-
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/UserScopes.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/UserScopes.java
index 5dd503c73..c7772d8cb 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/UserScopes.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/utils/UserScopes.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,33 +14,33 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.utils;
import org.json.JSONArray;
public class UserScopes {
- private JSONArray scopes;
+ private JSONArray scopes;
- /**
- *
- * @param jsonArray array of Strings
- */
- public void setScopes(JSONArray jsonArray) {
- this.scopes = jsonArray;
- }
+ /**
+ *
+ * @param jsonArray array of Strings
+ */
+ public void setScopes(JSONArray jsonArray) {
+ this.scopes = jsonArray;
+ }
- public boolean hasScope(String scope) {
- if (this.scopes == null)
- return false;
- for (int i = 0, l = this.scopes.length(); i < l; i++) {
- if (this.scopes.get(i).toString().equals(scope)) {
- return true;
- }
- }
+ public boolean hasScope(String scope) {
+ if (this.scopes == null)
+ return false;
+ for (int i = 0, l = this.scopes.length(); i < l; i++) {
+ if (this.scopes.get(i).toString().equals(scope)) {
+ return true;
+ }
+ }
- return false;
- }
+ return false;
+ }
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/websocket/SyncWebSocketClient.java b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/websocket/SyncWebSocketClient.java
index fb2384ee5..6512e7171 100644
--- a/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/websocket/SyncWebSocketClient.java
+++ b/sdnr/wt/websocketmanager2/provider/src/main/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/websocket/SyncWebSocketClient.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.websocket;
import java.net.URI;
@@ -29,87 +29,93 @@ import org.slf4j.LoggerFactory;
public class SyncWebSocketClient extends WebSocketClient {
- public interface WebsocketEventHandler{
- void onMessageReceived(String message);
- void onOpen(ServerHandshake arg0);
- void onClose(int arg0, String arg1, boolean arg2);
- void onError(Exception e);
- }
-
- private static final Logger LOG = LoggerFactory.getLogger(SyncWebSocketClient.class.getName());
- private String messageToSend;
- private final List<WebsocketEventHandler> handlers;
- public SyncWebSocketClient(URI serverUri) {
- super(serverUri);
- this.handlers = new ArrayList<WebsocketEventHandler>();
- }
-
- public SyncWebSocketClient(String uri) throws URISyntaxException {
- this(new URI(uri));
- }
- public void addEventHandler(WebsocketEventHandler h) {
- this.handlers.add(h);
- }
- public void removeEventHandler(WebsocketEventHandler h) {
- this.handlers.remove(h);
- }
-
- @Override
- public void onClose(int arg0, String arg1, boolean arg2) {
- LOG.debug("socket closed: {} {} {}", arg0, arg1, arg2);
- for(WebsocketEventHandler h:this.handlers) {
- h.onClose(arg0,arg1,arg2);
- }
- }
-
- @Override
- public void onError(Exception arg0) {
- LOG.warn("error on socket: {}", arg0.getMessage());
- for(WebsocketEventHandler h:this.handlers) {
- h.onError(arg0);
- }
- }
-
- @Override
- public void onMessage(String arg0) {
- LOG.debug("received message: {}", arg0);
- for(WebsocketEventHandler h:this.handlers) {
- h.onMessageReceived(arg0);
- }
- }
-
- @Override
- public void onOpen(ServerHandshake arg0) {
- LOG.debug("socket opened");
- if (this.messageToSend != null) {
- LOG.debug("try to send: " + this.messageToSend);
- this.send(this.messageToSend);
- this.messageToSend = null;
- }
- for(WebsocketEventHandler h:this.handlers) {
- h.onOpen(arg0);
- }
- }
-
- public void openAndSendAsync(String message) {
- this.messageToSend = message;
- this.connect();
- }
-
- public void openAndSendAndCloseSync(String message) {
- try {
- this.connectBlocking();
- } catch (InterruptedException e) {
- LOG.warn("problem connecting:" + e.getMessage());
- Thread.currentThread().interrupt();
- }
- this.send(message);
- try {
- this.closeBlocking();
- } catch (InterruptedException e) {
- LOG.warn("problem disconnecting:" + e.getMessage());
+ public interface WebsocketEventHandler {
+ void onMessageReceived(String message);
+
+ void onOpen(ServerHandshake arg0);
+
+ void onClose(int arg0, String arg1, boolean arg2);
+
+ void onError(Exception e);
+ }
+
+ private static final Logger LOG = LoggerFactory.getLogger(SyncWebSocketClient.class.getName());
+ private String messageToSend;
+ private final List<WebsocketEventHandler> handlers;
+
+ public SyncWebSocketClient(URI serverUri) {
+ super(serverUri);
+ this.handlers = new ArrayList<WebsocketEventHandler>();
+ }
+
+ public SyncWebSocketClient(String uri) throws URISyntaxException {
+ this(new URI(uri));
+ }
+
+ public void addEventHandler(WebsocketEventHandler h) {
+ this.handlers.add(h);
+ }
+
+ public void removeEventHandler(WebsocketEventHandler h) {
+ this.handlers.remove(h);
+ }
+
+ @Override
+ public void onClose(int arg0, String arg1, boolean arg2) {
+ LOG.debug("socket closed: {} {} {}", arg0, arg1, arg2);
+ for (WebsocketEventHandler h : this.handlers) {
+ h.onClose(arg0, arg1, arg2);
+ }
+ }
+
+ @Override
+ public void onError(Exception arg0) {
+ LOG.warn("error on socket: {}", arg0.getMessage());
+ for (WebsocketEventHandler h : this.handlers) {
+ h.onError(arg0);
+ }
+ }
+
+ @Override
+ public void onMessage(String arg0) {
+ LOG.debug("received message: {}", arg0);
+ for (WebsocketEventHandler h : this.handlers) {
+ h.onMessageReceived(arg0);
+ }
+ }
+
+ @Override
+ public void onOpen(ServerHandshake arg0) {
+ LOG.debug("socket opened");
+ if (this.messageToSend != null) {
+ LOG.debug("try to send: " + this.messageToSend);
+ this.send(this.messageToSend);
+ this.messageToSend = null;
+ }
+ for (WebsocketEventHandler h : this.handlers) {
+ h.onOpen(arg0);
+ }
+ }
+
+ public void openAndSendAsync(String message) {
+ this.messageToSend = message;
+ this.connect();
+ }
+
+ public void openAndSendAndCloseSync(String message) {
+ try {
+ this.connectBlocking();
+ } catch (InterruptedException e) {
+ LOG.warn("problem connecting:" + e.getMessage());
+ Thread.currentThread().interrupt();
+ }
+ this.send(message);
+ try {
+ this.closeBlocking();
+ } catch (InterruptedException e) {
+ LOG.warn("problem disconnecting:" + e.getMessage());
Thread.currentThread().interrupt();
- }
- }
+ }
+ }
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/AkkaConfigTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/AkkaConfigTest.java
index 2460ca42f..486aaaccc 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/AkkaConfigTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/AkkaConfigTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.*;
@@ -34,7 +34,7 @@ public class AkkaConfigTest {
@Test
public void test() throws URISyntaxException, IOException {
- AkkaConfig config=null;
+ AkkaConfig config = null;
try {
//config = AkkaConfig.load("akka-singlenode.cfg", true);
config = AkkaConfig.loadContent(loadResourceContentAsString("akka-singlenode.cfg"));
@@ -42,25 +42,26 @@ public class AkkaConfigTest {
e.printStackTrace();
fail("error loading singlenode config");
}
- assertEquals("no singlenode config detected",false,config.isCluster());
- assertEquals("more than one node detected",1,config.getClusterConfig().getSeedNodes().size());
+ assertEquals("no singlenode config detected", false, config.isCluster());
+ assertEquals("more than one node detected", 1, config.getClusterConfig().getSeedNodes().size());
try {
config = AkkaConfig.loadContent(loadResourceContentAsString("akka-cluster.cfg"));
} catch (Exception e) {
fail("error loading cluster config");
}
- assertEquals("no cluster config detected",true,config.isCluster());
- assertTrue("only one node detected",config.getClusterConfig().getSeedNodes().size()>1);
+ assertEquals("no cluster config detected", true, config.isCluster());
+ assertTrue("only one node detected", config.getClusterConfig().getSeedNodes().size() > 1);
}
- public static String loadResourceContentAsString(String resourceName) throws URISyntaxException, FileNotFoundException, IOException {
+ public static String loadResourceContentAsString(String resourceName)
+ throws URISyntaxException, FileNotFoundException, IOException {
StringBuilder sb = new StringBuilder();
ClassLoader classLoader = AkkaConfigTest.class.getClassLoader();
File file = Paths.get(classLoader.getResource(resourceName).toURI()).toFile();
- try(BufferedReader br = new BufferedReader(new FileReader(file))) {
+ try (BufferedReader br = new BufferedReader(new FileReader(file))) {
String line = br.readLine();
while (line != null) {
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/UserScopeTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/UserScopeTest.java
index 52eedb994..3f04ac09d 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/UserScopeTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/UserScopeTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.*;
@@ -25,15 +25,15 @@ import org.onap.ccsdk.features.sdnr.wt.websocketmanager2.utils.UserScopes;
public class UserScopeTest {
- private static final String SCOPE1 ="scope1";
- private static final String SCOPE2 ="scope2";
- private static final String SCOPE3 ="scope3";
- private static final String SCOPE4 ="scope4";
+ private static final String SCOPE1 = "scope1";
+ private static final String SCOPE2 = "scope2";
+ private static final String SCOPE3 = "scope3";
+ private static final String SCOPE4 = "scope4";
@Test
public void test() {
UserScopes scopes1 = new UserScopes();
- JSONArray json1=new JSONArray();
+ JSONArray json1 = new JSONArray();
json1.put(SCOPE1);
json1.put(SCOPE2);
json1.put(SCOPE3);
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsockerProviderTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsockerProviderTest.java
index 57d79602b..d6f0bcf4c 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsockerProviderTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsockerProviderTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.*;
@@ -28,7 +28,7 @@ public class WebsockerProviderTest extends Mockito {
@Test
public void test() {
- RpcProviderService rpcProviderServiceMock = mock(RpcProviderService.class);
+ RpcProviderService rpcProviderServiceMock = mock(RpcProviderService.class);
HttpService httpService = mock(HttpService.class);
try (WebSocketManagerProvider provider = new WebSocketManagerProvider();) {
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketClientTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketClientTest.java
index f56e1a686..df68ff3a2 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketClientTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketClientTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.*;
@@ -41,7 +41,7 @@ public class WebsocketClientTest extends Mockito {
client.close();
} catch (Exception e) {
e.printStackTrace();
- fail("Exception "+e.getMessage());
+ fail("Exception " + e.getMessage());
}
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketMessageTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketMessageTest.java
index f769dd40d..0e4db163a 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketMessageTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketMessageTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.assertTrue;
@@ -30,7 +30,8 @@ public class WebsocketMessageTest {
private static final String MSG1 = "{\"data\":\"scopes\",\"scopes\":[\"scope1\"]}";
private static final String MSG2 = "{}";
- private static final String MSG3 = "{\""+WebSocketManagerSocket.KEY_NODENAME+":\"xy\","+WebSocketManagerSocket.KEY_EVENTTYPE+":\"zu\"}";
+ private static final String MSG3 = "{\"" + WebSocketManagerSocket.KEY_NODENAME + ":\"xy\","
+ + WebSocketManagerSocket.KEY_EVENTTYPE + ":\"zu\"}";
private static final String MSG4 = "{ Not correct messga}";
@Test
@@ -58,8 +59,8 @@ public class WebsocketMessageTest {
private String expected;
- public MyWebSocketManagerSocket() {
- }
+ public MyWebSocketManagerSocket() {}
+
void setExpected(String expected) {
this.expected = expected;
}
@@ -67,7 +68,7 @@ public class WebsocketMessageTest {
@Override
public void send(String msg) {
System.out.println(msg);
- assertTrue("Expected '"+expected+"' answer '"+msg+"'", msg.contains(expected));
+ assertTrue("Expected '" + expected + "' answer '" + msg + "'", msg.contains(expected));
}
}
diff --git a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketServerConnectTest.java b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketServerConnectTest.java
index e59c343f2..c9a96f5f3 100644
--- a/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketServerConnectTest.java
+++ b/sdnr/wt/websocketmanager2/provider/src/test/java/org/onap/ccsdk/features/sdnr/wt/websocketmanager2/test/WebsocketServerConnectTest.java
@@ -1,4 +1,4 @@
-/*******************************************************************************
+/*
* ============LICENSE_START========================================================================
* ONAP : ccsdk feature sdnr wt
* =================================================================================================
@@ -14,7 +14,7 @@
* or implied. See the License for the specific language governing permissions and limitations under
* the License.
* ============LICENSE_END==========================================================================
- ******************************************************************************/
+ */
package org.onap.ccsdk.features.sdnr.wt.websocketmanager2.test;
import static org.junit.Assert.assertEquals;