blob: 6280f8ef04d72f3f4b474afdcb40ba7c7900578e [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.fasterxml.jackson.databind.JsonNode;
20import com.fasterxml.jackson.databind.ObjectMapper;
21import org.onosproject.net.DeviceId;
22import org.onosproject.net.config.basics.BasicDeviceConfig;
23
24import java.io.IOException;
25import java.io.InputStream;
26
27public final class TestUpfUtils {
28
29 private static final String BASIC_CONFIG_KEY = "basic";
30
31 private TestUpfUtils() {
32 // hide constructor
33 }
34
35 public static BasicDeviceConfig getBasicConfig(DeviceId deviceId, String fileName)
36 throws IOException {
37 BasicDeviceConfig basicCfg = new BasicDeviceConfig();
38 InputStream jsonStream = TestUpfUtils.class.getResourceAsStream(fileName);
39 ObjectMapper mapper = new ObjectMapper();
40 JsonNode jsonNode = mapper.readTree(jsonStream);
41 basicCfg.init(deviceId, BASIC_CONFIG_KEY, jsonNode, mapper, config -> {
42 });
43 return basicCfg;
44 }
45}