948613e33a04a352427d28d050d99f5a2706353c
[yangtools.git] / yang / yang-model-util / src / test / java / org / opendaylight / yangtools / yang / model / util / LengthConstraintImplTest.java
1 /*
2  * Copyright (c) 2016 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.yangtools.yang.model.util;
10
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
13
14 import com.google.common.base.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
17
18 public class LengthConstraintImplTest {
19
20     @Test
21     public void testLengthConstraint() {
22         LengthConstraint lengthConstraint = new LengthConstraintImpl(3, 5, Optional.of("test description"),
23                 Optional.of("test reference"));
24         LengthConstraint lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("test description"),
25                 Optional.of("test reference"));
26         assertTrue(lengthConstraint.equals(lengthConstraint2));
27
28         assertFalse(lengthConstraint.equals(null));
29         assertFalse(lengthConstraint.equals(new Object()));
30
31         lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("another test description"),
32                 Optional.of("test reference"));
33         assertFalse(lengthConstraint.equals(lengthConstraint2));
34
35         lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("test description"),
36                 Optional.of("another test reference"));
37         assertFalse(lengthConstraint.equals(lengthConstraint2));
38
39         lengthConstraint = new LengthConstraintImpl(3, 5, Optional.of("test description"),
40                 Optional.of("test reference"), "error app-tag", "error message");
41         lengthConstraint2 = new LengthConstraintImpl(2, 5, Optional.of("test description"),
42                 Optional.of("test reference"), "error app-tag", "error message");
43         assertFalse(lengthConstraint.equals(lengthConstraint2));
44
45         lengthConstraint2 = new LengthConstraintImpl(3, 6, Optional.of("test description"),
46                 Optional.of("test reference"), "error app-tag", "error message");
47         assertFalse(lengthConstraint.equals(lengthConstraint2));
48
49         lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("test description"),
50                 Optional.of("test reference"), "another error app-tag", "error message");
51         assertFalse(lengthConstraint.equals(lengthConstraint2));
52
53         lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("test description"),
54                 Optional.of("test reference"), "error app-tag", "another error message");
55         assertFalse(lengthConstraint.equals(lengthConstraint2));
56     }
57 }