Remove RevisionSourceIdentifier
[yangtools.git] / yang / yang-repo-spi / src / test / java / org / opendaylight / yangtools / yang / model / repo / spi / PotentialSchemaSourceTest.java
1 /*
2  * Copyright (c) 2018 Pantheon Technologies, s.r.o. 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.yangtools.yang.model.repo.spi;
9
10 import static org.junit.Assert.assertEquals;
11 import static org.junit.Assert.assertFalse;
12 import static org.junit.Assert.assertSame;
13 import static org.junit.Assert.assertThrows;
14 import static org.junit.Assert.assertTrue;
15
16 import org.junit.Before;
17 import org.junit.Test;
18 import org.junit.runner.RunWith;
19 import org.mockito.junit.MockitoJUnitRunner;
20 import org.opendaylight.yangtools.yang.model.repo.api.SchemaSourceRepresentation;
21 import org.opendaylight.yangtools.yang.model.repo.api.SourceIdentifier;
22
23 @RunWith(MockitoJUnitRunner.StrictStubs.class)
24 public class PotentialSchemaSourceTest {
25     private interface TestSchemaSourceRepresentation extends SchemaSourceRepresentation {
26
27     }
28
29     public final SourceIdentifier sourceIdentifier = new SourceIdentifier("foo");
30     @SuppressWarnings("exports")
31     public PotentialSchemaSource<TestSchemaSourceRepresentation> source;
32     @SuppressWarnings("exports")
33     public PotentialSchemaSource<TestSchemaSourceRepresentation> same;
34
35     @Before
36     public void before() {
37         source = PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class,
38             PotentialSchemaSource.Costs.LOCAL_IO.getValue());
39         same = PotentialSchemaSource.create(source.getSourceIdentifier(), source.getRepresentation(),
40             source.getCost());
41     }
42
43     @Test
44     public void testNegativeCost() {
45         assertThrows(IllegalArgumentException.class,
46             () -> PotentialSchemaSource.create(sourceIdentifier, TestSchemaSourceRepresentation.class, -1));
47     }
48
49     @Test
50     public void testMethods() {
51         assertEquals(PotentialSchemaSource.Costs.LOCAL_IO.getValue(), source.getCost());
52         assertSame(sourceIdentifier, source.getSourceIdentifier());
53         assertSame(TestSchemaSourceRepresentation.class, source.getRepresentation());
54         assertEquals(same.hashCode(), source.hashCode());
55         assertFalse(source.equals(null));
56         assertTrue(source.equals(source));
57         assertTrue(source.equals(same));
58     }
59
60     @Test
61     public void testIntern() {
62         assertSame(source, source.cachedReference());
63         assertSame(source, same.cachedReference());
64     }
65 }