Update Tomas's name
[netconf.git] / protocol / netconf-server / src / test / java / org / opendaylight / netconf / server / api / operations / 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 package org.opendaylight.netconf.server.api.operations;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13
14 import org.junit.Test;
15
16 public class HandlingPriorityTest {
17     @Test
18     public void testHandlingPriority() throws Exception {
19         assertEquals(0,
20             HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY));
21         assertEquals(-1, HandlingPriority.CANNOT_HANDLE.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY));
22         assertEquals(1, HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.CANNOT_HANDLE));
23
24         assertEquals(-1,
25             HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_MAX_PRIORITY));
26         assertEquals(1,
27             HandlingPriority.HANDLE_WITH_MAX_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY));
28         assertEquals(0, HandlingPriority.getHandlingPriority(Integer.MIN_VALUE)
29             .compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY));
30
31         HandlingPriority prio = HandlingPriority.getHandlingPriority(10);
32         assertTrue(prio.increasePriority(1).compareTo(HandlingPriority.getHandlingPriority(11)) == 0);
33
34         assertFalse(HandlingPriority.CANNOT_HANDLE.getPriority().isPresent());
35         assertFalse(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.equals(new Object()));
36         assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY,
37             HandlingPriority.getHandlingPriority(Integer.MAX_VALUE));
38         assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.hashCode(),
39             HandlingPriority.getHandlingPriority(Integer.MAX_VALUE).hashCode());
40     }
41 }