ELAN: skip remote unicast MACs
[netvirt.git] / cloud-servicechain / cloud-servicechain-impl / src / test / java / org / opendaylight / netvirt / cloudservicechain / matchers / FlowMatcher.java
1 /*
2  * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.netvirt.cloudservicechain.matchers;
9
10 import java.util.Objects;
11 import org.apache.commons.lang3.StringUtils;
12 import org.mockito.ArgumentMatcher;
13 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.inventory.rev130819.tables.table.Flow;
14 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Instructions;
15 import org.opendaylight.yang.gen.v1.urn.opendaylight.flow.types.rev131026.flow.Match;
16
17 public class FlowMatcher extends ArgumentMatcher<Flow> {
18
19     Flow expectedFlow;
20
21     public FlowMatcher(Flow expectedFlow) {
22         this.expectedFlow = expectedFlow;
23     }
24
25     public boolean sameMatch(Match match1, Match match2) {
26         // TODO: implement this
27         return true;
28     }
29
30     public boolean sameInstructions(Instructions instructions1, Instructions instructions2) {
31         // TODO: implement this
32         return true;
33     }
34
35     @Override
36     public boolean matches(Object actualFlow) {
37         if (! (actualFlow instanceof Flow)) {
38             return false;
39         }
40         Flow flow = (Flow) actualFlow;
41
42         boolean result =
43                 flow.getId() != null && flow.getId().equals(expectedFlow.getId())
44                 && Objects.equals(flow.getTableId(), expectedFlow.getTableId())
45                 && StringUtils.equals(flow.getFlowName(), expectedFlow.getFlowName())
46                 && sameInstructions(flow.getInstructions(), expectedFlow.getInstructions())
47                 && sameMatch(flow.getMatch(), expectedFlow.getMatch());
48
49         return result;
50     }
51
52 }