faea46180aff2439e7c7fb9b4cb5f35b9c2b1c38
[ccsdk/features.git] /
1 /*******************************************************************************
2  * ============LICENSE_START========================================================================
3  * ONAP : ccsdk feature sdnr wt
4  * =================================================================================================
5  * Copyright (C) 2019 highstreet technologies GmbH Intellectual Property. All rights reserved.
6  * =================================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
8  * in compliance with the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software distributed under the License
13  * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14  * or implied. See the License for the specific language governing permissions and limitations under
15  * the License.
16  * ============LICENSE_END==========================================================================
17  ******************************************************************************/
18
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
20
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
24
25 import java.io.IOException;
26
27 import org.junit.AfterClass;
28 import org.junit.BeforeClass;
29 import org.junit.Ignore;
30 import org.junit.Test;
31 import org.onap.ccsdk.features.sdnr.wt.common.database.ExtRestClient;
32 import org.onap.ccsdk.features.sdnr.wt.common.database.InvalidProtocolException;
33 import org.onap.ccsdk.features.sdnr.wt.common.database.config.HostInfo.Protocol;
34 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.CreateIndexRequest;
35 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.GetIndexRequest;
36 import org.onap.ccsdk.features.sdnr.wt.common.database.requests.IndexRequest;
37 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.CreateIndexResponse;
38 import org.onap.ccsdk.features.sdnr.wt.common.database.responses.IndexResponse;
39
40 public class TestDatabaseClient {
41
42
43         private static ExtRestClient client;
44
45         @BeforeClass
46         public static void init() throws InvalidProtocolException {
47
48                  client = ExtRestClient.createInstance("localhost",9200,Protocol.HTTP);
49
50         }
51         @AfterClass
52         public static void deinit() {
53                 try {
54                         client.close();
55                 } catch (IOException e) {
56                         e.printStackTrace();
57                 }
58         }
59     @Ignore
60         @Test
61         public void testIndexExists() {
62
63                  GetIndexRequest request =new GetIndexRequest("mwtn");
64                  try {
65                                 boolean response = client.indicesExists(request);
66                                 assertTrue(response);
67                         } catch (IOException e) {
68                                 fail(e.getMessage());
69                         }
70                  request =new GetIndexRequest("mwrn");
71                  try {
72                                 boolean response = client.indicesExists(request);
73                                 assertFalse(response);
74                         } catch (IOException e) {
75                                 fail(e.getMessage());
76                         }
77
78         }
79     @Ignore
80         @Test
81         public void testIndexCreate() {
82                 CreateIndexRequest request = new CreateIndexRequest("mwtn");
83                 try {
84                         CreateIndexResponse response = client.createIndex(request);
85                         assertTrue(response.isAcknowledged());
86                 } catch (IOException e) {
87                         fail(e.getMessage());
88                 }
89         }
90     @Ignore
91         @Test
92         public void testAddPmEntry() {
93                 String json="{\"node-name\":\"sim12600\",\"uuid-interface\":\"LP-MWPS-TTP-01\",\"layer-protocol-name\":\"MWPS\",\"radio-signal-id\":\"Test11\",\"time-stamp\":\"2017-07-04T00:00:00.0Z\",\"granularity-period\":\"PERIOD_24HOURS\",\"scanner-id\":\"PM_RADIO_24H_1\",\"performance-data\":{\"rx-level-avg\":-41,\"time2-states\":-1,\"time4-states-s\":9,\"time4-states\":0,\"time8-states\":0,\"time16-states-s\":-1,\"time16-states\":0,\"time32-states\":1,\"time64-states\":1,\"time128-states\":2,\"time256-states\":38319,\"time512-states\":-1,\"time512-states-l\":-1,\"time1024-states\":-1,\"time1024-states-l\":-1,\"time2048-states\":-1,\"time2048-states-l\":-1,\"time4096-states\":-1,\"time4096-states-l\":-1,\"time8192-states\":-1,\"time8192-states-l\":-1,\"snir-min\":-99,\"unavailability\":504,\"tx-level-max\":25,\"tx-level-avg\":25,\"rx-level-min\":-41,\"rx-level-max\":-41,\"ses\":2,\"tx-level-min\":20,\"snir-max\":-99,\"snir-avg\":-99,\"xpd-min\":-99,\"xpd-max\":-99,\"xpd-avg\":-99,\"rf-temp-min\":-99,\"rf-temp-max\":-99,\"rf-temp-avg\":-99,\"defect-blocks-sum\":-1,\"time-period\":86400,\"cses\":0,\"es\":5},\"suspect-interval-flag\":true}";
94                 IndexRequest request=new IndexRequest("historicalperformance24h", "historicalperformance24h","sim12600/LP-MWPS-TTP-01/2017-07-04T00:00:00.0+00:00");
95                 request.source(json);
96                 try {
97                         IndexResponse response = client.index(request);
98
99                         assertTrue(response.isCreated() || response.isUpdated());
100                 } catch (IOException e) {
101                         e.printStackTrace();
102                         fail(e.getMessage());
103                 }
104         }
105 }