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
10 * http://www.apache.org/licenses/LICENSE-2.0
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
16 * ============LICENSE_END==========================================================================
17 ******************************************************************************/
19 package org.onap.ccsdk.features.sdnr.wt.devicemanager.test;
21 import static org.junit.Assert.assertFalse;
22 import static org.junit.Assert.assertTrue;
23 import static org.junit.Assert.fail;
25 import java.io.IOException;
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;
40 public class TestDatabaseClient {
43 private static ExtRestClient client;
46 public static void init() throws InvalidProtocolException {
48 client = ExtRestClient.createInstance("localhost",9200,Protocol.HTTP);
52 public static void deinit() {
55 } catch (IOException e) {
61 public void testIndexExists() {
63 GetIndexRequest request =new GetIndexRequest("mwtn");
65 boolean response = client.indicesExists(request);
67 } catch (IOException e) {
70 request =new GetIndexRequest("mwrn");
72 boolean response = client.indicesExists(request);
73 assertFalse(response);
74 } catch (IOException e) {
81 public void testIndexCreate() {
82 CreateIndexRequest request = new CreateIndexRequest("mwtn");
84 CreateIndexResponse response = client.createIndex(request);
85 assertTrue(response.isAcknowledged());
86 } catch (IOException e) {
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");
97 IndexResponse response = client.index(request);
99 assertTrue(response.isCreated() || response.isUpdated());
100 } catch (IOException e) {
102 fail(e.getMessage());