Open Kilda Java Documentation
TopologyUnderTest.java
Go to the documentation of this file.
1 /* Copyright 2018 Telstra Open Source
2  *
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 package org.openkilda.atdd.staging.helpers;
17 
20 
21 import lombok.Data;
22 
23 import java.util.HashMap;
24 import java.util.List;
25 import java.util.Map;
26 import java.util.stream.Collectors;
27 
28 @Data
29 public class TopologyUnderTest {
30  Map<FlowPayload, List<TopologyDefinition.Isl>> flowIsls = new HashMap<>();
31  Map<String, Object> aliasedObjects = new HashMap<>();
32 
33  public void addAlias(String alias, Object obj) {
34  aliasedObjects.put(alias, obj);
35  }
36 
37  @SuppressWarnings("unchecked")
38  public <T> T getAliasedObject(String alias) {
39  return (T) aliasedObjects.get(alias);
40  }
41 
45  @SuppressWarnings("unchecked")
46  public <T> List<T> getAliasedObjects(Class<T> clazz) {
47  return aliasedObjects.values().stream()
48  .filter(clazz::isInstance)
49  .map(sw -> (T) sw).collect(Collectors.toList());
50  }
51 }