2 * Copyright (c) 2015 Cisco Systems, Inc. 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
9 package org.opendaylight.controller.netconf.mapping.api;
11 import static org.junit.Assert.assertEquals;
12 import static org.junit.Assert.assertFalse;
13 import static org.junit.Assert.assertTrue;
15 import org.junit.Test;
17 public class HandlingPriorityTest {
19 @Test public void testHandlingPriority() throws Exception {
21 HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY)
23 assertTrue(HandlingPriority.CANNOT_HANDLE.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == -1);
24 assertTrue(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.CANNOT_HANDLE) == 1);
27 HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_MAX_PRIORITY) == -1);
29 HandlingPriority.HANDLE_WITH_MAX_PRIORITY.compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == 1);
30 assertTrue(HandlingPriority.getHandlingPriority(Integer.MIN_VALUE)
31 .compareTo(HandlingPriority.HANDLE_WITH_DEFAULT_PRIORITY) == 0);
33 HandlingPriority prio = HandlingPriority.getHandlingPriority(10);
34 assertTrue(prio.increasePriority(1).compareTo(HandlingPriority.getHandlingPriority(11)) == 0);
36 assertFalse(HandlingPriority.CANNOT_HANDLE.getPriority().isPresent());
37 assertFalse(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.equals(new Object()));
38 assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY,
39 HandlingPriority.getHandlingPriority(Integer.MAX_VALUE));
40 assertEquals(HandlingPriority.HANDLE_WITH_MAX_PRIORITY.hashCode(),
41 HandlingPriority.getHandlingPriority(Integer.MAX_VALUE).hashCode());