blob: db438b50bfa90a3e306bee9c5b756e0d8d9fdfa1 [file] [log] [blame]
Daniele Moro8d630f12021-06-15 20:53:22 +02001/*
2 * Copyright 2021-present Open Networking Foundation
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package org.onosproject.pipelines.fabric.impl.behaviour.upf;
18
19import com.google.common.collect.Maps;
20import org.onosproject.net.pi.model.PiActionProfileId;
21import org.onosproject.net.pi.model.PiActionProfileModel;
22import org.onosproject.net.pi.model.PiCounterId;
23import org.onosproject.net.pi.model.PiCounterModel;
24import org.onosproject.net.pi.model.PiMeterId;
25import org.onosproject.net.pi.model.PiMeterModel;
26import org.onosproject.net.pi.model.PiPacketOperationModel;
27import org.onosproject.net.pi.model.PiPacketOperationType;
28import org.onosproject.net.pi.model.PiPipelineModel;
29import org.onosproject.net.pi.model.PiRegisterId;
30import org.onosproject.net.pi.model.PiRegisterModel;
31import org.onosproject.net.pi.model.PiTableId;
32import org.onosproject.net.pi.model.PiTableModel;
33
34import java.util.Collection;
35import java.util.List;
36import java.util.Map;
37import java.util.Optional;
38
39
40public class MockPiPipelineModel implements PiPipelineModel {
41
42 private final Map<PiTableId, PiTableModel> tableMap = Maps.newHashMap();
43
44 private final List<PiCounterModel> counters;
45
46 public MockPiPipelineModel(Collection<PiTableModel> tables, Collection<PiCounterModel> counters) {
47 tables.forEach(tableModel -> tableMap.put(tableModel.id(), tableModel));
48 this.counters = List.copyOf(counters);
49 }
50
51 @Override
52 public Optional<PiTableModel> table(PiTableId tableId) {
53 return Optional.ofNullable(tableMap.getOrDefault(tableId, null));
54 }
55
56 @Override
57 public Collection<PiTableModel> tables() {
58 return tableMap.values();
59 }
60
61 @Override
62 public Optional<PiCounterModel> counter(PiCounterId counterId) {
63 return Optional.empty();
64 }
65
66 @Override
67 public Collection<PiCounterModel> counters() {
68 return counters;
69 }
70
71 @Override
72 public Optional<PiMeterModel> meter(PiMeterId meterId) {
73 return Optional.empty();
74 }
75
76 @Override
77 public Collection<PiMeterModel> meters() {
78 return null;
79 }
80
81 @Override
82 public Optional<PiRegisterModel> register(PiRegisterId registerId) {
83 return Optional.empty();
84 }
85
86 @Override
87 public Collection<PiRegisterModel> registers() {
88 return null;
89 }
90
91 @Override
92 public Optional<PiActionProfileModel> actionProfiles(PiActionProfileId actionProfileId) {
93 return Optional.empty();
94 }
95
96 @Override
97 public Collection<PiActionProfileModel> actionProfiles() {
98 return null;
99 }
100
101 @Override
102 public Optional<PiPacketOperationModel> packetOperationModel(PiPacketOperationType type) {
103 return Optional.empty();
104 }
105
106
107}