Daniele Moro | 8d630f1 | 2021-06-15 20:53:22 +0200 | [diff] [blame^] | 1 | /* |
| 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 | |
| 17 | package org.onosproject.pipelines.fabric.impl.behaviour.upf; |
| 18 | |
| 19 | import com.fasterxml.jackson.databind.JsonNode; |
| 20 | import com.fasterxml.jackson.databind.ObjectMapper; |
| 21 | import org.onosproject.net.DeviceId; |
| 22 | import org.onosproject.net.config.basics.BasicDeviceConfig; |
| 23 | |
| 24 | import java.io.IOException; |
| 25 | import java.io.InputStream; |
| 26 | |
| 27 | public 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 | } |