3ad043cd181076cc08e9b95564d2a8e0aa2d1f35
[mdsal.git] / common / mdsal-common-api / src / test / java / org / opendaylight / mdsal / common / api / clustering / EntityOwnershipChangeStateTest.java
1 /*
2  * Copyright (c) 2015 Brocade Communications 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.mdsal.common.api.clustering;
9
10 import static org.junit.Assert.assertEquals;
11 import org.junit.Test;
12
13 /**
14  * Unit tests for EntityOwnershipChangeState.
15  *
16  * @author Thomas Pantelis
17  */
18 public class EntityOwnershipChangeStateTest {
19
20     @Test
21     public void testFromWithValid() {
22         assertEquals("from(false, true, true)", EntityOwnershipChangeState.LOCAL_OWNERSHIP_GRANTED,
23                 EntityOwnershipChangeState.from(false, true, true));
24         assertEquals("from(true, false, true)", EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NEW_OWNER,
25                 EntityOwnershipChangeState.from(true, false, true));
26         assertEquals("from(true, false, false)", EntityOwnershipChangeState.LOCAL_OWNERSHIP_LOST_NO_OWNER,
27                 EntityOwnershipChangeState.from(true, false, false));
28         assertEquals("from(false, false, true)", EntityOwnershipChangeState.REMOTE_OWNERSHIP_CHANGED,
29                 EntityOwnershipChangeState.from(false, false, true));
30         assertEquals("from(false, false, false)", EntityOwnershipChangeState.REMOTE_OWNERSHIP_LOST_NO_OWNER,
31                 EntityOwnershipChangeState.from(false, false, false));
32     }
33
34     @Test(expected=IllegalArgumentException.class)
35     public void testFromWithInvalidFalseTrueFalse() {
36         EntityOwnershipChangeState.from(false, true, false);
37     }
38
39     @Test(expected=IllegalArgumentException.class)
40     public void testFromWithInvalidTrueTrueFalse() {
41         EntityOwnershipChangeState.from(true, true, false);
42     }
43
44     @Test(expected=IllegalArgumentException.class)
45     public void testFromWithInvalidTrueTrueTrue() {
46         EntityOwnershipChangeState.from(true, true, true);
47     }
48 }