2 * Copyright (c) 2016 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.yangtools.yang.model.util;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertTrue;
14 import com.google.common.base.Optional;
15 import org.junit.Test;
16 import org.opendaylight.yangtools.yang.model.api.type.LengthConstraint;
18 public class LengthConstraintImplTest {
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));
28 assertFalse(lengthConstraint.equals(null));
29 assertFalse(lengthConstraint.equals(new Object()));
31 lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("another test description"),
32 Optional.of("test reference"));
33 assertFalse(lengthConstraint.equals(lengthConstraint2));
35 lengthConstraint2 = new LengthConstraintImpl(3, 5, Optional.of("test description"),
36 Optional.of("another test reference"));
37 assertFalse(lengthConstraint.equals(lengthConstraint2));
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));
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));
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));
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));