blob: 7067132f7b90a36ccea7952127b7fd74293feb79 [file] [log] [blame]
Jian Lif53d0b22016-02-12 18:01:25 -08001/*
Brian O'Connor5ab426f2016-04-09 01:19:45 -07002 * Copyright 2016-present Open Networking Laboratory
Jian Lif53d0b22016-02-12 18:01:25 -08003 *
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 */
16package org.onosproject.cpman.impl.message;
17
18import org.junit.Test;
19import org.onosproject.cpman.ControlMessage;
20import org.onosproject.cpman.ControlMetricType;
21
22import static org.hamcrest.Matchers.is;
23import static org.junit.Assert.assertThat;
24import static org.onosproject.cpman.impl.ControlMessageMetricMapper.lookupControlMessageType;
25import static org.onosproject.cpman.impl.ControlMessageMetricMapper.lookupControlMetricType;
26
27/**
28 * Unit test for control message metric mapper.
29 */
30public final class ControlMessageMetricMapperTest {
31
32 /**
33 * Tests whether control message metric mapper returns right control metric type.
34 */
35 @Test
36 public void testLookupControlMetricType() {
37 assertThat(lookupControlMetricType(ControlMessage.Type.INBOUND_PACKET),
38 is(ControlMetricType.INBOUND_PACKET));
39
40 assertThat(lookupControlMetricType(ControlMessage.Type.OUTBOUND_PACKET),
41 is(ControlMetricType.OUTBOUND_PACKET));
42
43 assertThat(lookupControlMetricType(ControlMessage.Type.FLOW_MOD_PACKET),
44 is(ControlMetricType.FLOW_MOD_PACKET));
45
46 assertThat(lookupControlMetricType(ControlMessage.Type.FLOW_REMOVED_PACKET),
47 is(ControlMetricType.FLOW_REMOVED_PACKET));
48
49 assertThat(lookupControlMetricType(ControlMessage.Type.REQUEST_PACKET),
50 is(ControlMetricType.REQUEST_PACKET));
51
52 assertThat(lookupControlMetricType(ControlMessage.Type.REPLY_PACKET),
53 is(ControlMetricType.REPLY_PACKET));
54 }
55
56 /**
57 * Tests whether control message metric mapper returns right control message type.
58 */
59 @Test
60 public void testLookupControlMessageType() {
61 assertThat(lookupControlMessageType(ControlMetricType.INBOUND_PACKET),
62 is(ControlMessage.Type.INBOUND_PACKET));
63
64 assertThat(lookupControlMessageType(ControlMetricType.OUTBOUND_PACKET),
65 is(ControlMessage.Type.OUTBOUND_PACKET));
66
67 assertThat(lookupControlMessageType(ControlMetricType.FLOW_MOD_PACKET),
68 is(ControlMessage.Type.FLOW_MOD_PACKET));
69
70 assertThat(lookupControlMessageType(ControlMetricType.FLOW_REMOVED_PACKET),
71 is(ControlMessage.Type.FLOW_REMOVED_PACKET));
72
73 assertThat(lookupControlMessageType(ControlMetricType.REQUEST_PACKET),
74 is(ControlMessage.Type.REQUEST_PACKET));
75
76 assertThat(lookupControlMessageType(ControlMetricType.REPLY_PACKET),
77 is(ControlMessage.Type.REPLY_PACKET));
78 }
79}