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
8 package org.opendaylight.yangtools.yang.model.repo.spi;
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;
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;
19 @ExtendWith(MockitoExtension.class)
20 class RefcountedRegistrationTest {
22 private SchemaSourceRegistration<?> reg;
25 void refcountDecTrue() {
26 final var ref = new RefcountedRegistration(reg);
27 doNothing().when(reg).close();
28 assertTrue(ref.decRef());
32 void refcountIncDecFalse() {
33 final var ref = new RefcountedRegistration(reg);
35 assertFalse(ref.decRef());
39 void refcountIncDecTrue() {
40 final var ref = new RefcountedRegistration(reg);
42 assertFalse(ref.decRef());
43 doNothing().when(reg).close();
44 assertTrue(ref.decRef());