bba8e2b94016735433b2e8862d7636f9a11eb4ab
[ccsdk/sli/adaptors.git] / resource-assignment / provider / src / test / java / jtest / org / onap / ccsdk / sli / adaptors / ra / DataSetup.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : SDN-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package jtest.org.onap.ccsdk.sli.adaptors.ra;
23
24 import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestDb;
25 import jtest.util.org.onap.ccsdk.sli.adaptors.ra.TestTable;
26
27 public class DataSetup {
28
29     private TestDb testDb;
30
31     private TestTable resource = null;
32     private TestTable allocationItem = null;
33
34     private static final String[] RESOURCE_COLUMNS = {"asset_id", "resource_name", "resource_type", "lt_used"};
35
36     private static final String[] ALLOCATION_ITEM_COLUMNS = {"resource_id", "application_id", "resource_set_id",
37             "resource_union_id", "resource_share_group_list", "lt_used", "allocation_time"};
38
39     private void initTables() {
40         if (resource == null) {
41             resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS);
42         }
43         if (allocationItem == null) {
44             allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
45         }
46     }
47
48     public void cleanup() {
49         initTables();
50         allocationItem.delete("true");
51         resource.delete("true");
52     }
53
54     public void setTestDb(TestDb testDb) {
55         this.testDb = testDb;
56     }
57 }