*/
package org.opendaylight.yangtools.yang.parser.spi.meta;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class ModelProcessingPhaseTest {
+class ModelProcessingPhaseTest {
@Test
- public void testSequencing() {
+ void testSequencing() {
assertNull(ModelProcessingPhase.INIT.getPreviousPhase());
assertEquals(ModelProcessingPhase.INIT, ModelProcessingPhase.SOURCE_PRE_LINKAGE.getPreviousPhase());
assertEquals(ModelProcessingPhase.SOURCE_PRE_LINKAGE, ModelProcessingPhase.SOURCE_LINKAGE.getPreviousPhase());
*/
package org.opendaylight.yangtools.yang.parser.spi.meta;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
-public class NamespaceTest {
+class NamespaceTest {
@Test
- public void testNamespaces() {
+ void testNamespaces() {
// Touch behaviors
// FIXME: add more checks/split this up when behaviours are testable
assertNotNull(StatementDefinitions.BEHAVIOUR);
*/
package org.opendaylight.yangtools.yang.parser.spi.source;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
-public class ExplicitStatementTest {
+class ExplicitStatementTest {
@Test
- public void testStatementSource() {
+ void testStatementSource() {
assertEquals(StatementOrigin.DECLARATION, ExplicitStatement.inFile("foo").statementOrigin());
}
@Test
- public void testToString() {
+ void testToString() {
assertEquals("foo", ExplicitStatement.inFile("foo").toString());
assertEquals("<UNKNOWN>:5:10", ExplicitStatement.atPosition(5, 10).toString());
assertEquals("foo:5:10", ExplicitStatement.atPosition("foo", 5, 10).toString());
*/
package org.opendaylight.yangtools.yang.parser.spi.source;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.yangtools.yang.model.api.meta.StatementOrigin;
-public class ImplicitStatementTest {
+@ExtendWith(MockitoExtension.class)
+class ImplicitStatementTest {
+ @Mock
+ private StatementSourceReference ref;
+
@Test
- public void testForwarding() {
- final StatementSourceReference ref = mock(StatementSourceReference.class);
- final ImplicitSubstatement stmt = ImplicitSubstatement.of(ref);
+ void testForwarding() {
+ final var stmt = ImplicitSubstatement.of(ref);
assertEquals(StatementOrigin.CONTEXT, stmt.statementOrigin());
doReturn("ref").when(ref).toString();
*/
package org.opendaylight.yangtools.yang.parser.spi.source;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.mock;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.Mock;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.model.api.meta.StatementDefinition;
import org.opendaylight.yangtools.yang.parser.spi.meta.StatementSupport;
-public class QNameToStatementDefinitionMapTest {
+@ExtendWith(MockitoExtension.class)
+class QNameToStatementDefinitionMapTest {
private static final QName QNAME = QName.create("", "a");
private final QNameToStatementDefinitionMap map = new QNameToStatementDefinitionMap();
- private final StatementSupport<?, ?, ?> support = mock(StatementSupport.class);
- private final StatementDefinition definition = mock(StatementDefinition.class);
- @Before
- public void before() {
- doReturn(definition).when(support).definition();
- }
+ @Mock
+ private StatementSupport<?, ?, ?> support;
+ @Mock
+ private StatementDefinition definition;
@Test
- public void testPutNullNull() {
+ void testPutNullNull() {
assertThrows(NullPointerException.class, () -> map.put(null, null));
}
@Test
- public void testPutNullSome() {
+ void testPutNullSome() {
assertThrows(NullPointerException.class, () -> map.put(null, support));
}
@Test
- public void testPutSomeNull() {
+ void testPutSomeNull() {
assertThrows(NullPointerException.class, () -> map.put(QName.create("", "a"), null));
}
@Test
- public void testPut() {
+ void testPut() {
+ doReturn(definition).when(support).definition();
+
map.put(QNAME, support);
assertSame(definition, map.get(QNAME));
assertSame(support, map.getSupport(QNAME));
*/
package org.opendaylight.yangtools.yang.parser.spi.source;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
+import static org.junit.jupiter.api.Assertions.assertThrows;
import static org.mockito.Mockito.doReturn;
import java.util.Optional;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class SourceExceptionTest {
+@ExtendWith(MockitoExtension.class)
+class SourceExceptionTest {
@Mock
- public StatementSourceReference mock;
-
- @Before
- public void before() {
- doReturn("mock").when(mock).toString();
- }
+ private StatementSourceReference mock;
@Test
- public void testThrowIfFalse() {
+ void testThrowIfFalse() {
SourceException.throwIf(false, mock, "");
}
@Test
- public void testThrowIfTrueMockNull() {
+ void testThrowIfTrueMockNull() {
assertThrows(NullPointerException.class, () -> SourceException.throwIf(true, mock, null));
}
@Test
- public void testThrowIfTrueMockEmpty() {
+ void testThrowIfTrueMockEmpty() {
+ doReturn("mock").when(mock).toString();
+
assertThrows(SourceException.class, () -> SourceException.throwIf(true, mock, ""));
}
@Test
- public void testThrowIfNullNullMockNull() {
+ void testThrowIfNullNullMockNull() {
assertThrows(NullPointerException.class, () -> SourceException.throwIfNull(null, mock, null));
}
@Test
- public void testThrowIfNullNullMockEmpty() {
+ void testThrowIfNullNullMockEmpty() {
+ doReturn("mock").when(mock).toString();
+
assertThrows(SourceException.class, () -> SourceException.throwIfNull(null, mock, ""));
}
@Test
- public void testThrowIfNullMock() {
+ void testThrowIfNullMock() {
assertSame(mock, SourceException.throwIfNull(mock, mock, ""));
}
@Test
- public void testUnwrapPresent() {
+ void testUnwrapPresent() {
assertEquals("test", SourceException.unwrap(Optional.of("test"), mock, ""));
}
@Test
- public void testUnwrapAbsent() {
+ void testUnwrapAbsent() {
+ doReturn("mock").when(mock).toString();
+
assertThrows(SourceException.class, () -> SourceException.unwrap(Optional.empty(), mock, ""));
}
}