Fix netconf-connector-config groupId
[netconf.git] / netconf / netconf-mapping-api / src / main / test / java / org / opendaylight / netconf / mapping / api / HandlingPriorityTest.java
1 /*
2  * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.netconf.mapping.api;
10
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
14
15 import org.junit.Test;
16 import org.opendaylight.netconf.mapping.api.HandlingPriority;
17
18 public class HandlingPriorityTest {
19
20     @Test public void testHandlingPriority() throws Exception {
21         assertTrue(
22             HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY)
23                 == 0);
24         assertTrue(HandlingPriority.CANNOT_HANDLE.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == -1);
25         assertTrue(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.CANNOT_HANDLE) == 1);
26
27         assertTrue(
28             HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_MAX_PRIORITY) == -1);
29         assertTrue(
30             HandlingPriority.HANDLE_WITH_MAX_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == 1);
31         assertTrue(HandlingPriority.getHandlingPriority(Integer.MIN_VALUE)
32             .compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == 0);
33
34         HandlingPriority prio = HandlingPriority.getHandlingPriority(10);
35         assertTrue(prio.increasePriority(1).compareTo(HandlingPriority.getHandlingPriority(11)) == 0);
36
37         assertFalse(HandlingPriority.CANNOT_HANDLE.getPriority().isPresent());
38         assertFalse(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.equals(new Object()));
39         assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY,
40             HandlingPriority.getHandlingPriority(Integer.MAX_VALUE));
41         assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.hashCode(),
42             HandlingPriority.getHandlingPriority(Integer.MAX_VALUE).hashCode());
43     }
44 }