2 * ============LICENSE_START=======================================================
4 * ================================================================================
5 * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6 * ================================================================================
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
18 * ============LICENSE_END=========================================================
21 package org.openecomp.mso.requestsdb;
25 import java.util.HashMap;
28 public class MockRequestsDatabase {
30 private Map<String, InfraActiveRequests> activeRequests;
32 public MockRequestsDatabase() {
33 activeRequests = new HashMap<>();
36 public void addRecord(InfraActiveRequests record) {
37 String serviceType = record.getServiceType();
38 String serviceInstanceId = record.getServiceInstanceId();
39 String key = serviceType + "::" + serviceInstanceId;
40 activeRequests.put(key, record);
43 public void deleteRecord(String serviceType, String serviceInstanceId) {
44 String key = serviceType + "::" + serviceInstanceId;
45 activeRequests.remove(key);
48 public InfraActiveRequests getRecord(String serviceType, String serviceInstanceId) {
49 String key = serviceType + "::" + serviceInstanceId;
50 InfraActiveRequests record = activeRequests.get(key);
54 public InfraActiveRequests checkDuplicate(String serviceType, String serviceInstanceId) {
55 return getRecord(serviceType, serviceInstanceId);
58 public InfraActiveRequests checkRetry(String serviceType, String serviceInstanceId) {
59 InfraActiveRequests record = getRecord(serviceType, serviceInstanceId);
60 InfraActiveRequests returnRecord = null;
62 String requestAction = record.getRequestAction();
63 if (!"GetLayer3ServiceDetailsRequest".equals(requestAction)) {
64 String status = record.getRequestStatus();
65 if ("COMPLETED".equals(status)) {
66 returnRecord = record;