2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 ONAP Intellectual Property. All rights
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
12 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
22 package jtest.org.openecomp.sdnc.rm;
24 import java.util.Date;
26 import jtest.util.org.openecomp.sdnc.ra.TestDb;
27 import jtest.util.org.openecomp.sdnc.ra.TestTable;
29 public class DataSetup {
31 private TestDb testDb;
33 private TestTable resource = null;
34 private TestTable allocationItem = null;
36 private static final String[] RESOURCE_COLUMNS =
37 { "asset_id", "resource_name", "resource_type", "lt_used", "ll_label", "ll_reference_count", "rr_used" };
39 private static final String[] ALLOCATION_ITEM_COLUMNS = {
40 "resource_id", "application_id", "resource_set_id", "resource_union_id", "resource_share_group_list",
41 "lt_used", "ll_label", "rr_used", "allocation_time" };
43 private void initTables() {
45 resource = testDb.table("RESOURCE", "resource_id", RESOURCE_COLUMNS);
46 if (allocationItem == null)
47 allocationItem = testDb.table("ALLOCATION_ITEM", "allocation_item_id", ALLOCATION_ITEM_COLUMNS);
50 public void cleanup() {
51 allocationItem.delete("true");
52 resource.delete("true");
55 public void setupLimitItem(
59 String resourceUnionId,
63 Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'");
65 resource.add(assetId, resourceName, "Limit", 1, null, null, null);
66 rid = resource.getLastId();
68 allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, used, null, null, new Date());
71 public void setupRangeItem(
75 String resourceUnionId,
79 Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'");
81 resource.add(assetId, resourceName, "Range", null, null, null, used);
82 rid = resource.getLastId();
84 allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, null, used, new Date());
87 public void setupLabelItem(
91 String resourceUnionId,
95 Long rid = resource.getId("asset_id = '" + assetId + "' AND resource_name = '" + resourceName + "'");
97 resource.add(assetId, resourceName, "Label", null, label, 1, null);
98 rid = resource.getLastId();
100 allocationItem.add(rid, "SDNC", resourceSetId, resourceUnionId, null, null, label, null, new Date());
103 public void setTestDb(TestDb testDb) {
104 this.testDb = testDb;