2 * Copyright (c) 2016 Ericsson India Global Services Pvt Ltd. and others. All rights reserved.
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
8 package org.opendaylight.netvirt.cloudservicechain.matchers;
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;
17 public class FlowMatcher extends ArgumentMatcher<Flow> {
21 public FlowMatcher(Flow expectedFlow) {
22 this.expectedFlow = expectedFlow;
25 public boolean sameMatch(Match match1, Match match2) {
26 // TODO: implement this
30 public boolean sameInstructions(Instructions instructions1, Instructions instructions2) {
31 // TODO: implement this
36 public boolean matches(Object actualFlow) {
37 if (! (actualFlow instanceof Flow)) {
40 Flow flow = (Flow) actualFlow;
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());