Migrate yang-repo-spi to JUnit5
[yangtools.git] / yang / yang-repo-spi / src / test / java / org / opendaylight / yangtools / yang / model / repo / spi / RefcountedRegistrationTest.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 package org.opendaylight.yangtools.yang.model.repo.spi;
9
10 import static org.junit.jupiter.api.Assertions.assertFalse;
11 import static org.junit.jupiter.api.Assertions.assertTrue;
12 import static org.mockito.Mockito.doNothing;
13
14 import org.junit.jupiter.api.Test;
15 import org.junit.jupiter.api.extension.ExtendWith;
16 import org.mockito.Mock;
17 import org.mockito.junit.jupiter.MockitoExtension;
18
19 @ExtendWith(MockitoExtension.class)
20 class RefcountedRegistrationTest {
21     @Mock
22     private SchemaSourceRegistration<?> reg;
23
24     @Test
25     void refcountDecTrue() {
26         final var ref = new RefcountedRegistration(reg);
27         doNothing().when(reg).close();
28         assertTrue(ref.decRef());
29     }
30
31     @Test
32     void refcountIncDecFalse() {
33         final var ref = new RefcountedRegistration(reg);
34         ref.incRef();
35         assertFalse(ref.decRef());
36     }
37
38     @Test
39     void refcountIncDecTrue() {
40         final var ref = new RefcountedRegistration(reg);
41         ref.incRef();
42         assertFalse(ref.decRef());
43         doNothing().when(reg).close();
44         assertTrue(ref.decRef());
45     }
46 }