Merge "BUG-2329 Add test for anyxmls inside rpc resonse for netcfon-connector"
[controller.git] / opendaylight / hosttracker_new / implementation / src / test / java / org / opendaylight / controller / hosttracker / test / MockEntityClassifier.java
1 /*
2  * Copyright (c) 2013 Big Switch Networks, Inc.
3  *
4  * Licensed under the Eclipse Public License, Version 1.0 (the
5  * "License"); you may not use this file except in compliance with the
6  * License. You may obtain a copy of the License at
7  *
8  *      http://www.eclipse.org/legal/epl-v10.html
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
13  * implied. See the License for the specific language governing
14  * permissions and limitations under the License.
15  */
16
17 package org.opendaylight.controller.hosttracker.test;
18
19 import static org.opendaylight.controller.hosttracker.IDeviceService.DeviceField.MAC;
20 import static org.opendaylight.controller.hosttracker.IDeviceService.DeviceField.SWITCHPORT;
21 import static org.opendaylight.controller.hosttracker.IDeviceService.DeviceField.VLAN;
22
23 import java.util.EnumSet;
24
25 import org.opendaylight.controller.hosttracker.Entity;
26 import org.opendaylight.controller.hosttracker.IDeviceService;
27 import org.opendaylight.controller.hosttracker.IDeviceService.DeviceField;
28 import org.opendaylight.controller.hosttracker.IEntityClass;
29 import org.opendaylight.controller.hosttracker.internal.DefaultEntityClassifier;
30
31 /**
32  * A simple IEntityClassifier. Useful for tests that need IEntityClassifiers and
33  * IEntityClass'es with switch and/or port key fields
34  */
35 public class MockEntityClassifier extends DefaultEntityClassifier {
36     public static class TestEntityClass implements IEntityClass {
37         @Override
38         public EnumSet<DeviceField> getKeyFields() {
39             return EnumSet.of(MAC, VLAN, SWITCHPORT);
40         }
41
42         @Override
43         public String getName() {
44             return "TestEntityClass";
45         }
46     }
47
48     public static IEntityClass testEC = new MockEntityClassifier.TestEntityClass();
49
50     @Override
51     public IEntityClass classifyEntity(Entity entity) {
52         if (((Long) entity.getPort().getNode().getID()) >= 10L) {
53             return testEC;
54         }
55         return DefaultEntityClassifier.entityClass;
56     }
57
58     @Override
59     public EnumSet<IDeviceService.DeviceField> getKeyFields() {
60         return EnumSet.of(MAC, VLAN, SWITCHPORT);
61     }
62
63 }