Migrate restconf/restconf-nb tests to JUnit5 00/111700/12
authorMatej Sramcik <matej.sramcik@pantheon.tech>
Wed, 15 May 2024 11:52:38 +0000 (13:52 +0200)
committerRobert Varga <nite@hq.sk>
Mon, 10 Jun 2024 08:46:19 +0000 (08:46 +0000)
Migrate tests in arestconf/restconf-nb from JUnit4 to JUnit5.

JIRA: NETCONF-1310
Change-Id: Ib54819fa14b8673390d9986cd9669600f0b2985f
Signed-off-by: Matej Sramcik <matej.sramcik@pantheon.tech>
22 files changed:
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/jaxrs/RestconfDataPostTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/jaxrs/RestconfOperationsPostTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/jaxrs/RestconfSchemaServiceMountTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/jaxrs/RestconfSchemaServiceTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/AbstractOperationInputBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/AbstractPatchBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/JsonPatchBodyMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/JsonPatchBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/XmlPatchBodyMountPointTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/databind/XmlPatchBodyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/legacy/RestconfDocumentedExceptionMapperTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/AbstractFieldsTranslatorTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/AbstractRestconfStrategyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/MdsalFieldsParamTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/MdsalRestconfStrategyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/NetconfFieldsParamTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/rests/transactions/NetconfRestconfStrategyTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/nb/rfc8040/streams/DataTreeChangeStreamTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/api/ParamsTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/api/ServerExceptionTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/spi/NormalizedNodeWriterParametersTest.java
restconf/restconf-nb/src/test/java/org/opendaylight/restconf/server/spi/YangPatchStatusBodyTest.java

index bb8f4a42dc6ff8d9f0be35f336ec1fb730c88e7b..4ad69bc8fe7dfef34391236e686973b8dd3de53c 100644 (file)
@@ -7,13 +7,12 @@
  */
 package org.opendaylight.restconf.nb.jaxrs;
 
-import static org.junit.Assert.assertThrows;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
 import static org.mockito.Mockito.doNothing;
 import static org.mockito.Mockito.doReturn;
-import static org.mockito.Mockito.lenient;
 import static org.mockito.Mockito.times;
 import static org.mockito.Mockito.verify;
 import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediateFalseFluentFuture;
@@ -58,7 +57,6 @@ class RestconfDataPostTest extends AbstractRestconfTest {
 
     @BeforeEach
     void beforeEach() {
-        lenient().doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
         doReturn(tx).when(dataBroker).newReadWriteTransaction();
     }
 
@@ -69,6 +67,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
         doNothing().when(tx).put(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID,
             ImmutableNodes.newContainerBuilder().withNodeIdentifier(new NodeIdentifier(JUKEBOX_QNAME)).build());
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox"),
             assertResponse(201, ar -> restconf.postDataJSON(stringInputStream("""
@@ -79,12 +78,13 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostMapEntryData() {
+    void testPostMapEntryData() {
         doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
         final var node = PLAYLIST_IID.node(BAND_ENTRY.name());
         doReturn(immediateFalseFluentFuture()).when(tx).exists(LogicalDatastoreType.CONFIGURATION, node);
         doNothing().when(tx).put(LogicalDatastoreType.CONFIGURATION, node, BAND_ENTRY);
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox/playlist=name%20of%20band"),
             assertResponse(201, ar -> restconf.postDataJSON(JUKEBOX_API_PATH, stringInputStream("""
@@ -97,7 +97,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostExistingData() {
+    void testPostExistingData() {
         doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
         doReturn(immediateTrueFluentFuture())
             .when(tx).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
@@ -116,7 +116,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostExistingListsDataErrorPath() {
+    void testPostExistingListsDataErrorPath() {
         doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
         final var node = PLAYLIST_IID.node(BAND_ENTRY.name());
         doReturn(immediateTrueFluentFuture()).when(tx).exists(LogicalDatastoreType.CONFIGURATION, node);
@@ -139,7 +139,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostDataWithInsertLast() {
+    void testPostDataWithInsertLast() {
         // Mocking the query parameters to include 'insert=last'
         final var queryParams = new MultivaluedHashMap<String, String>();
         queryParams.put(INSERT, List.of("last"));
@@ -151,6 +151,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
         doNothing().when(tx).put(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class),
             any(NormalizedNode.class));
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox/playlist=0/song=3"),
             assertResponse(201, ar -> restconf.postDataJSON(
@@ -166,7 +167,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostDataWithInsertFirst() {
+    void testPostDataWithInsertFirst() {
         // Mocking the query parameters to include 'insert=first'
         final var queryParams = new MultivaluedHashMap<String, String>();
         queryParams.put(INSERT, List.of("first"));
@@ -182,6 +183,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
         doNothing().when(tx).put(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class),
                 any(NormalizedNode.class));
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox/playlist=0/song=3"),
             assertResponse(201, ar -> restconf.postDataJSON(
@@ -197,7 +199,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostDataWithInsertBefore() {
+    void testPostDataWithInsertBefore() {
         // Mocking the query parameters to include 'insert=before' and 'point=example-jukebox:jukebox/playlist=0/song=2'
         final var queryParams = new MultivaluedHashMap<String, String>();
         queryParams.put(INSERT, List.of("before"));
@@ -212,6 +214,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
             .read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox/playlist=0/song=3"),
             assertResponse(201, ar -> restconf.postDataJSON(
@@ -229,7 +232,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
     }
 
     @Test
-    public void testPostDataWithInsertAfter() {
+    void testPostDataWithInsertAfter() {
         // Mocking the query parameters to include 'insert=after' and 'point=example-jukebox:jukebox/playlist=0/song=1'
         final var queryParams = new MultivaluedHashMap<String, String>();
         queryParams.put(INSERT, List.of("after"));
@@ -243,6 +246,7 @@ class RestconfDataPostTest extends AbstractRestconfTest {
             .read(eq(LogicalDatastoreType.CONFIGURATION), any(YangInstanceIdentifier.class));
 
         doReturn(UriBuilder.fromUri(BASE_URI)).when(uriInfo).getBaseUriBuilder();
+        doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
 
         assertEquals(URI.create("http://localhost:8181/rests/data/example-jukebox:jukebox/playlist=0/song=3"),
             assertResponse(201, ar -> restconf.postDataJSON(
index c3e9dfc8d5daf4a05b7ab16c04e28bfbf250a822..5608301930d5d1cc8055faa60f585a4d6863820f 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.restconf.nb.jaxrs;
 
-import static org.junit.Assert.assertNull;
 import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.ArgumentMatchers.eq;
index d5b69425312164145f408c941a29e0f966444740..237b5263551c6323dba7af4e7d6cafdb70ff7921 100644 (file)
@@ -7,17 +7,17 @@
  */
 package org.opendaylight.restconf.nb.jaxrs;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.opendaylight.restconf.nb.jaxrs.AbstractRestconfTest.assertEntity;
 import static org.opendaylight.restconf.nb.jaxrs.AbstractRestconfTest.assertError;
 
 import com.google.common.io.CharStreams;
 import java.io.Reader;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+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;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMRpcService;
@@ -41,8 +41,8 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 /**
  * Unit tests for {@code RestconfSchemaService}.
  */
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class RestconfSchemaServiceMountTest {
+@ExtendWith(MockitoExtension.class)
+class RestconfSchemaServiceMountTest {
     private static final ApiPath MOUNT_POINT = AbstractRestconfTest.apiPath("mount-point-1:cont/yang-ext:mount");
     private static final ApiPath NULL_MOUNT_POINT = AbstractRestconfTest.apiPath("mount-point-2:cont/yang-ext:mount");
     private static final ApiPath NOT_EXISTING_MOUNT_POINT =
@@ -70,8 +70,8 @@ public class RestconfSchemaServiceMountTest {
     // service under test
     private JaxRsRestconf restconf;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() {
         final var mountPointService = new DOMMountPointServiceImpl();
         // create and register mount points
         mountPointService
@@ -94,7 +94,7 @@ public class RestconfSchemaServiceMountTest {
      * Get schema with identifier of existing module behind mount point and check if correct module was found.
      */
     @Test
-    public void getSchemaMountPointTest() throws Exception {
+    void getSchemaMountPointTest() throws Exception {
         final var reader = assertEntity(Reader.class, 200,
             ar -> restconf.modulesYangGET(MOUNT_POINT, "module1-behind-mount-point", "2014-02-03", ar));
         assertEquals("""
@@ -112,7 +112,7 @@ public class RestconfSchemaServiceMountTest {
      * <code>SchemaExportContext</code> with not-existing module behind mount point should result in error.
      */
     @Test
-    public void getSchemaForNotExistingModuleMountPointTest() {
+    void getSchemaForNotExistingModuleMountPointTest() {
         final var error = assertError(ar -> restconf.modulesYangGET(MOUNT_POINT, "not-existing", "2016-01-01", ar));
         assertEquals("Source not-existing@2016-01-01 not found", error.getErrorMessage());
         assertEquals(ErrorTag.DATA_MISSING, error.getErrorTag());
@@ -124,7 +124,7 @@ public class RestconfSchemaServiceMountTest {
      * <code>NULL_MOUNT_POINT</code>. Test is expected to fail with <code>NullPointerException</code>.
      */
     @Test
-    public void getSchemaNullSchemaContextBehindMountPointTest() {
+    void getSchemaNullSchemaContextBehindMountPointTest() {
         // make test - call service on mount point with null schema context
         // NULL_MOUNT_POINT contains null schema context
         final var error = assertError(
@@ -140,7 +140,7 @@ public class RestconfSchemaServiceMountTest {
      * values.
      */
     @Test
-    public void getSchemaWithEmptyIdentifierMountPointTest() {
+    void getSchemaWithEmptyIdentifierMountPointTest() {
         final var error = assertError(ar -> restconf.modulesYangGET(MOUNT_POINT, "", null, ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -153,7 +153,7 @@ public class RestconfSchemaServiceMountTest {
      * values.
      */
     @Test
-    public void getSchemaWithNotParsableIdentifierMountPointTest() {
+    void getSchemaWithNotParsableIdentifierMountPointTest() {
         final var error = assertError(ar -> restconf.modulesYangGET(MOUNT_POINT, "01_module", "2016-01-01", ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -169,7 +169,7 @@ public class RestconfSchemaServiceMountTest {
      * Not valid identifier contains only revision without module name.
      */
     @Test
-    public void getSchemaWrongIdentifierMountPointTest() {
+    void getSchemaWrongIdentifierMountPointTest() {
         final var error = assertError(ar -> restconf.modulesYangGET(MOUNT_POINT, "2014-01-01", null, ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -182,7 +182,7 @@ public class RestconfSchemaServiceMountTest {
      * values.
      */
     @Test
-    public void getSchemaWithoutRevisionMountPointTest() {
+    void getSchemaWithoutRevisionMountPointTest() {
         final var error = assertError(ar -> restconf.modulesYangGET(MOUNT_POINT, "module", null, ar));
         assertEquals("Source module not found", error.getErrorMessage());
         assertEquals(ErrorType.APPLICATION, error.getErrorType());
@@ -194,7 +194,7 @@ public class RestconfSchemaServiceMountTest {
      * <code>IllegalArgumentException</code> exception is expected.
      */
     @Test
-    public void getSchemaContextWithNotExistingMountPointTest() {
+    void getSchemaContextWithNotExistingMountPointTest() {
         final var error = assertError(
             ar -> restconf.modulesYangGET(NOT_EXISTING_MOUNT_POINT, "module1-behind-mount-point", "2014-02-03", ar));
         assertEquals("Failed to lookup for module with name 'mount-point-3'.", error.getErrorMessage());
index 6d63f581b8762cf670a41cf18dedec9f5a3b9da0..a25a418996933de0bd5343ac1e33481f13d43fdb 100644 (file)
@@ -7,8 +7,8 @@
  */
 package org.opendaylight.restconf.nb.jaxrs;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertSame;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertSame;
 import static org.mockito.Mockito.doReturn;
 import static org.opendaylight.restconf.nb.jaxrs.AbstractRestconfTest.assertEntity;
 import static org.opendaylight.restconf.nb.jaxrs.AbstractRestconfTest.assertError;
@@ -16,11 +16,11 @@ import static org.opendaylight.restconf.nb.jaxrs.AbstractRestconfTest.assertErro
 import com.google.common.util.concurrent.Futures;
 import java.io.IOException;
 import java.io.Reader;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+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;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
@@ -42,8 +42,8 @@ import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 /**
  * Unit tests for {@code RestconfSchemaService}.
  */
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class RestconfSchemaServiceTest {
+@ExtendWith(MockitoExtension.class)
+class RestconfSchemaServiceTest {
     // schema context with modules
     private static final EffectiveModelContext MODEL_CONTEXT =
         YangParserTestUtils.parseYangResourceDirectory("/modules");
@@ -66,8 +66,8 @@ public class RestconfSchemaServiceTest {
     // service under test
     private JaxRsRestconf restconf;
 
-    @Before
-    public void setup() throws Exception {
+    @BeforeEach
+    void setup() {
         restconf = new JaxRsRestconf(
             new MdsalRestconfServer(new MdsalDatabindProvider(
                 new FixedDOMSchemaService(() -> MODEL_CONTEXT, sourceProvider)), dataBroker, rpcService, actionService,
@@ -79,7 +79,7 @@ public class RestconfSchemaServiceTest {
      * Get schema with identifier of existing module and check if correct module was found.
      */
     @Test
-    public void getSchemaTest() throws Exception {
+    void getSchemaTest() throws Exception {
         doReturn(Futures.immediateFuture(yangSource)).when(sourceProvider)
             .getYangTexttSource(new SourceIdentifier("module1", Revision.of("2014-01-01")));
         doReturn(yangReader).when(yangSource).openStream();
@@ -93,7 +93,7 @@ public class RestconfSchemaServiceTest {
      * not-existing module should result in error.
      */
     @Test
-    public void getSchemaForNotExistingModuleTest() {
+    void getSchemaForNotExistingModuleTest() {
         final var error = assertError(ar -> restconf.modulesYinGET("not-existing", "2016-01-01", ar));
         assertEquals("Source not-existing@2016-01-01 not found", error.getErrorMessage());
         assertEquals(ErrorTag.DATA_MISSING, error.getErrorTag());
@@ -105,7 +105,7 @@ public class RestconfSchemaServiceTest {
      * type, error tag and error status code are compared to expected values.
      */
     @Test
-    public void getSchemaWithEmptyIdentifierTest() {
+    void getSchemaWithEmptyIdentifierTest() {
         final var error = assertError(ar -> restconf.modulesYangGET("", null, ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -117,7 +117,7 @@ public class RestconfSchemaServiceTest {
      * error tag and error status code are compared to expected values.
      */
     @Test
-    public void getSchemaWithNotParsableIdentifierTest() {
+    void getSchemaWithNotParsableIdentifierTest() {
         final var error = assertError(ar -> restconf.modulesYangGET("01_module", "2016-01-01", ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -132,7 +132,7 @@ public class RestconfSchemaServiceTest {
      * Not valid identifier contains only revision without module name.
      */
     @Test
-    public void getSchemaWrongIdentifierTest() {
+    void getSchemaWrongIdentifierTest() {
         final var error = assertError(ar -> restconf.modulesYangGET("2014-01-01", null, ar));
         assertEquals("Identifier must start with character from set 'a-zA-Z_", error.getErrorMessage());
         assertEquals(ErrorType.PROTOCOL, error.getErrorType());
@@ -144,7 +144,7 @@ public class RestconfSchemaServiceTest {
      * was found.
      */
     @Test
-    public void getSchemaWithoutRevisionTest() throws IOException {
+    void getSchemaWithoutRevisionTest() throws IOException {
         doReturn(Futures.immediateFuture(yangSource)).when(sourceProvider)
             .getYangTexttSource(new SourceIdentifier("module-without-revision", (Revision) null));
         doReturn(yangReader).when(yangSource).openStream();
index 41ce7a3049ab71c55bd47a97c0a5e54a50a50f06..27fe61dc4e990a388460c3be27e37b9ba58ba082 100644 (file)
@@ -7,11 +7,11 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertInstanceOf;
 
-import org.junit.BeforeClass;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest;
 import org.opendaylight.restconf.server.api.DatabindContext;
 import org.opendaylight.restconf.server.api.DatabindPath.Action;
@@ -32,8 +32,8 @@ abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifier
 
     private static Action RESET_PATH;
 
-    @BeforeClass
-    public static final void setupInference() {
+    @BeforeAll
+    static final void setupInference() {
         final var stack = SchemaInferenceStack.ofDataTreePath(IID_SCHEMA, CONT_QNAME, CONT1_QNAME);
         final var action = assertInstanceOf(ActionEffectiveStatement.class, stack.enterSchemaTree(RESET_QNAME));
 
@@ -42,7 +42,7 @@ abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifier
     }
 
     @Test
-    public final void moduleSubContainerDataPostActionTest() throws Exception {
+    final void moduleSubContainerDataPostActionTest() throws Exception {
         final var body = moduleSubContainerDataPostActionBody();
 
         assertEquals(ImmutableNodes.newContainerBuilder()
@@ -54,7 +54,7 @@ abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifier
     abstract OperationInputBody moduleSubContainerDataPostActionBody();
 
     @Test
-    public final void testEmpty() throws Exception {
+    final void testEmpty() throws Exception {
         final var body = testEmptyBody();
         assertEquals(ImmutableNodes.newContainerBuilder().withNodeIdentifier(INPUT_NID).build(),
             body.toContainerNode(RESET_PATH));
@@ -63,7 +63,7 @@ abstract class AbstractOperationInputBodyTest extends AbstractInstanceIdentifier
     abstract OperationInputBody testEmptyBody();
 
     @Test
-    public final void testRpcModuleInput() throws Exception {
+    final void testRpcModuleInput() throws Exception {
         final var rpcTest = QName.create("invoke:rpc:module", "2013-12-03", "rpc-test");
         final var modelContext = YangParserTestUtils.parseYangResourceDirectory("/invoke-rpc");
         final var stack = SchemaInferenceStack.of(modelContext);
index d9eea3e190b2826f3dd54bca055fb959f7ea1000..949b1deea10fa37681547dc97af094d1b6cc0067 100644 (file)
@@ -8,30 +8,21 @@
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
 import static java.util.Objects.requireNonNull;
-import static org.junit.Assert.assertNotNull;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.Mockito.doReturn;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
 
 import com.google.common.collect.ImmutableMap;
 import java.io.IOException;
 import java.io.InputStream;
 import java.text.ParseException;
-import java.util.Optional;
 import java.util.function.Function;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.extension.ExtendWith;
 import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
-import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
 import org.opendaylight.mdsal.dom.api.DOMMountPointService;
-import org.opendaylight.mdsal.dom.api.DOMRpcService;
-import org.opendaylight.mdsal.dom.api.DOMSchemaService;
-import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
-import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
 import org.opendaylight.restconf.api.ApiPath;
 import org.opendaylight.restconf.common.patch.PatchContext;
 import org.opendaylight.restconf.nb.rfc8040.AbstractInstanceIdentifierTest;
@@ -40,14 +31,13 @@ import org.opendaylight.restconf.nb.rfc8040.rests.transactions.RestconfStrategy.
 import org.opendaylight.restconf.server.api.PatchBody;
 import org.opendaylight.restconf.server.api.ServerException;
 import org.opendaylight.restconf.server.spi.DefaultResourceContext;
-import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 
-@RunWith(MockitoJUnitRunner.Silent.class)
+@ExtendWith(MockitoExtension.class)
 abstract class AbstractPatchBodyTest extends AbstractInstanceIdentifierTest {
     private final Function<InputStream, PatchBody> bodyConstructor;
 
     @Mock
-    private DOMDataBroker dataBroker;
+    DOMDataBroker dataBroker;
     @Mock
     DOMMountPointService mountPointService;
     @Mock
@@ -57,18 +47,6 @@ abstract class AbstractPatchBodyTest extends AbstractInstanceIdentifierTest {
         this.bodyConstructor = requireNonNull(bodyConstructor);
     }
 
-    @Before
-    public final void before() {
-        doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
-        doReturn(Optional.of(new FixedDOMSchemaService(IID_SCHEMA))).when(mountPoint)
-            .getService(DOMSchemaService.class);
-        doReturn(Optional.of(dataBroker)).when(mountPoint).getService(DOMDataBroker.class);
-        doReturn(Optional.empty()).when(mountPoint).getService(DOMActionService.class);
-        doReturn(Optional.empty()).when(mountPoint).getService(DOMRpcService.class);
-        doReturn(Optional.empty()).when(mountPoint).getService(DOMMountPointService.class);
-        doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
-    }
-
     @NonNull String mountPrefix() {
         return "";
     }
index 0a3c4d468e389bf14f55e06484086c3357918669..1d0e2628520309d18f5c56f29a2b226bfa731c9c 100644 (file)
@@ -7,9 +7,35 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.Optional;
+import org.junit.jupiter.api.BeforeEach;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
+import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+class JsonPatchBodyMountPointTest extends JsonPatchBodyTest {
+
+    @BeforeEach
+    final void before() {
+        doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
+        doReturn(Optional.of(new FixedDOMSchemaService(IID_SCHEMA))).when(mountPoint)
+            .getService(DOMSchemaService.class);
+        doReturn(Optional.of(dataBroker)).when(mountPoint).getService(DOMDataBroker.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMActionService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMRpcService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMMountPointService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
+    }
 
-public class JsonPatchBodyMountPointTest extends JsonPatchBodyTest {
     @Override
     String mountPrefix() {
         return "instance-identifier-module:cont/yang-ext:mount";
index 82bf5942e36db2d8441ea682e2b1473ee35121db..a8aa61ccb7765fda92fd46762fddb3c89dbe2fb3 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.server.api.JsonPatchBody;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -18,13 +18,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
-public class JsonPatchBodyTest extends AbstractPatchBodyTest {
-    public JsonPatchBodyTest() {
+class JsonPatchBodyTest extends AbstractPatchBodyTest {
+    JsonPatchBodyTest() {
         super(JsonPatchBody::new);
     }
 
     @Test
-    public final void modulePatchDataTest() throws Exception {
+    final void modulePatchDataTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -65,7 +65,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of successful Patch consisting of create and delete Patch operations.
      */
     @Test
-    public final void modulePatchCreateAndDeleteTest() throws Exception {
+    final void modulePatchCreateAndDeleteTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -105,7 +105,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * {@link RestconfDocumentedException} with error code 400.
      */
     @Test
-    public final void modulePatchValueMissingNegativeTest() throws Exception {
+    final void modulePatchValueMissingNegativeTest() {
         final var ex = assertThrows(RestconfDocumentedException.class,
             () -> parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
                 {
@@ -130,7 +130,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * {@link RestconfDocumentedException} with error code 400.
      */
     @Test
-    public final void modulePatchValueNotSupportedNegativeTest() throws Exception {
+    final void modulePatchValueNotSupportedNegativeTest() {
         final var ex = assertThrows(RestconfDocumentedException.class,
             () -> parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
                 {
@@ -161,7 +161,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
      */
     @Test
-    public final void modulePatchCompleteTargetInURITest() throws Exception {
+    final void modulePatchCompleteTargetInURITest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -212,7 +212,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch merge operation on list. Test consists of two edit operations - replace and merge.
      */
     @Test
-    public final void modulePatchMergeOperationOnListTest() throws Exception {
+    final void modulePatchMergeOperationOnListTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -252,7 +252,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch merge operation on container. Test consists of two edit operations - create and merge.
      */
     @Test
-    public final void modulePatchMergeOperationOnContainerTest() throws Exception {
+    final void modulePatchMergeOperationOnContainerTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -303,7 +303,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test reading simple leaf value.
      */
     @Test
-    public final void modulePatchSimpleLeafValueTest() throws Exception {
+    final void modulePatchSimpleLeafValueTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -329,7 +329,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the top-level container with empty URI for data root.
      */
     @Test
-    public final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+    final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "", """
             {
               "ietf-yang-patch:yang-patch" : {
@@ -359,7 +359,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the top-level container with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
+    final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             {
               "ietf-yang-patch:yang-patch": {
@@ -404,7 +404,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the second-level list with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
+    final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
             """
             {
@@ -446,7 +446,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the top augmented element.
      */
     @Test
-    public final void modulePatchTargetTopLevelAugmentedContainerTest() throws Exception {
+    final void modulePatchTargetTopLevelAugmentedContainerTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             {
                 "ietf-yang-patch:yang-patch": {
@@ -477,7 +477,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the system map node element.
      */
     @Test
-    public final void modulePatchTargetMapNodeTest() throws Exception {
+    final void modulePatchTargetMapNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             {
                 "ietf-yang-patch:yang-patch": {
@@ -513,7 +513,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the leaf set node element.
      */
     @Test
-    public final void modulePatchTargetLeafSetNodeTest() throws Exception {
+    final void modulePatchTargetLeafSetNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             {
                 "ietf-yang-patch:yang-patch": {
@@ -542,7 +542,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the unkeyed list node element.
      */
     @Test
-    public final void modulePatchTargetUnkeyedListNodeTest() throws Exception {
+    final void modulePatchTargetUnkeyedListNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             {
                 "ietf-yang-patch:yang-patch": {
@@ -578,7 +578,7 @@ public class JsonPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the case node element.
      */
     @Test
-    public final void modulePatchTargetCaseNodeTest() throws Exception {
+    final void modulePatchTargetCaseNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             {
                 "ietf-yang-patch:yang-patch": {
index a0aa7f1e13dbaa03703a62f1720cbc2e7cf6b074..37e386db842d43d6c448acd5984e227420a7d634 100644 (file)
@@ -7,9 +7,35 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.doReturn;
+
+import java.util.Optional;
+import org.junit.jupiter.api.BeforeEach;
+import org.opendaylight.mdsal.dom.api.DOMActionService;
+import org.opendaylight.mdsal.dom.api.DOMDataBroker;
 import org.opendaylight.mdsal.dom.api.DOMMountPoint;
+import org.opendaylight.mdsal.dom.api.DOMMountPointService;
+import org.opendaylight.mdsal.dom.api.DOMRpcService;
+import org.opendaylight.mdsal.dom.api.DOMSchemaService;
+import org.opendaylight.mdsal.dom.spi.FixedDOMSchemaService;
+import org.opendaylight.netconf.dom.api.NetconfDataTreeService;
+import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
+
+class XmlPatchBodyMountPointTest extends XmlPatchBodyTest {
+
+    @BeforeEach
+    final void before() {
+        doReturn(Optional.of(mountPoint)).when(mountPointService).getMountPoint(any(YangInstanceIdentifier.class));
+        doReturn(Optional.of(new FixedDOMSchemaService(IID_SCHEMA))).when(mountPoint)
+            .getService(DOMSchemaService.class);
+        doReturn(Optional.of(dataBroker)).when(mountPoint).getService(DOMDataBroker.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMActionService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMRpcService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(DOMMountPointService.class);
+        doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
+    }
 
-public class XmlPatchBodyMountPointTest extends XmlPatchBodyTest {
     @Override
     String mountPrefix() {
         return "instance-identifier-module:cont/yang-ext:mount";
index e3bb0673d74c3e5029da4672f5025bfcb9c851ab..24e8f33b7b94c41a569f306527798fc0547e085c 100644 (file)
@@ -7,10 +7,10 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.databind;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.server.api.XmlPatchBody;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
@@ -18,13 +18,13 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdent
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier.NodeIdentifierWithPredicates;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 
-public class XmlPatchBodyTest extends AbstractPatchBodyTest {
-    public XmlPatchBodyTest() {
+class XmlPatchBodyTest extends AbstractPatchBodyTest {
+    XmlPatchBodyTest() {
         super(XmlPatchBody::new);
     }
 
     @Test
-    public final void moduleDataTest() throws Exception {
+    final void moduleDataTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -60,7 +60,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test trying to use Patch create operation which requires value without value. Error code 400 should be returned.
      */
     @Test
-    public final void moduleDataValueMissingNegativeTest() throws Exception {
+    final void moduleDataValueMissingNegativeTest() {
         final var ex = assertThrows(RestconfDocumentedException.class,
             () -> parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
                 <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
@@ -80,7 +80,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * returned.
      */
     @Test
-    public final void moduleDataNotValueNotSupportedNegativeTest() throws Exception {
+    final void moduleDataNotValueNotSupportedNegativeTest() {
         final var ex = assertThrows(RestconfDocumentedException.class,
             () -> parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
                 <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
@@ -106,7 +106,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch with absolute target path.
      */
     @Test
-    public final void moduleDataAbsoluteTargetPathTest() throws Exception {
+    final void moduleDataAbsoluteTargetPathTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -142,7 +142,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test using Patch when target is completely specified in request URI and thus target leaf contains only '/' sign.
      */
     @Test
-    public final void modulePatchCompleteTargetInURITest() throws Exception {
+    final void modulePatchCompleteTargetInURITest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -187,7 +187,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch merge operation on list. Test consists of two edit operations - replace and merge.
      */
     @Test
-    public final void moduleDataMergeOperationOnListTest() throws Exception {
+    final void moduleDataMergeOperationOnListTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>Test merge operation</patch-id>
@@ -223,7 +223,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch merge operation on container. Test consists of two edit operations - create and merge.
      */
     @Test
-    public final void moduleDataMergeOperationOnContainerTest() throws Exception {
+    final void moduleDataMergeOperationOnContainerTest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>Test merge operation</patch-id>
@@ -268,7 +268,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the top-level container with empty URI for data root.
      */
     @Test
-    public final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
+    final void modulePatchTargetTopLevelContainerWithEmptyURITest() throws Exception {
         checkPatchContext(parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -292,7 +292,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the top-level container with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
+    final void modulePatchTargetTopLevelContainerWithFullPathURITest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -331,7 +331,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the second-level list with the full path in the URI and "/" in 'target'.
      */
     @Test
-    public final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
+    final void modulePatchTargetSecondLevelListWithFullPathURITest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=my-leaf-set",
             """
                 <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
@@ -366,7 +366,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the top augmented element.
      */
     @Test
-    public final void moduleTargetTopLevelAugmentedContainerTest() throws Exception {
+    final void moduleTargetTopLevelAugmentedContainerTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
@@ -393,7 +393,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the top system map node element.
      */
     @Test
-    public final void moduleTargetMapNodeTest() throws Exception {
+    final void moduleTargetMapNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>map-patch</patch-id>
@@ -425,7 +425,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of YANG Patch on the leaf set node element.
      */
     @Test
-    public final void modulePatchTargetLeafSetNodeTest() throws Exception {
+    final void modulePatchTargetLeafSetNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>set-patch</patch-id>
@@ -450,7 +450,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the top unkeyed list element.
      */
     @Test
-    public final void moduleTargetUnkeyedListNodeTest() throws Exception {
+    final void moduleTargetUnkeyedListNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>list-patch</patch-id>
@@ -482,7 +482,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test of Yang Patch on the top case node element.
      */
     @Test
-    public final void moduleTargetCaseNodeTest() throws Exception {
+    final void moduleTargetCaseNodeTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>choice-patch</patch-id>
@@ -509,7 +509,7 @@ public class XmlPatchBodyTest extends AbstractPatchBodyTest {
      * Test reading simple leaf value.
      */
     @Test
-    public final void modulePatchSimpleLeafValueTest() throws Exception {
+    final void modulePatchSimpleLeafValueTest() throws Exception {
         final var returnValue = parse(mountPrefix(), "instance-identifier-patch-module:patch-cont/my-list1=leaf1", """
             <yang-patch xmlns="urn:ietf:params:xml:ns:yang:ietf-yang-patch">
                 <patch-id>test-patch</patch-id>
index f534a9cb2b218ec294cf6be537b355ddfc4491f1..f79c6d4c02605d99a6f39ed1a24837bea787010b 100644 (file)
@@ -7,13 +7,14 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.legacy;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assume.assumeTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assumptions.assumeTrue;
+import static org.junit.jupiter.params.provider.Arguments.arguments;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 
-import java.util.Arrays;
 import java.util.List;
+import java.util.stream.Stream;
 import javax.ws.rs.core.HttpHeaders;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.core.Response;
@@ -21,12 +22,10 @@ import javax.ws.rs.core.Response.Status;
 import org.json.JSONException;
 import org.json.JSONObject;
 import org.json.XML;
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.junit.runners.Parameterized;
-import org.junit.runners.Parameterized.Parameter;
-import org.junit.runners.Parameterized.Parameters;
+import org.junit.jupiter.api.BeforeAll;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.common.errors.RestconfError;
 import org.opendaylight.restconf.nb.jaxrs.JaxRsMediaTypes;
@@ -40,15 +39,14 @@ import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.skyscreamer.jsonassert.JSONAssert;
 
-@RunWith(Parameterized.class)
-public class RestconfDocumentedExceptionMapperTest {
+class RestconfDocumentedExceptionMapperTest {
     private static final QNameModule MONITORING_MODULE_INFO =
         QNameModule.ofRevision("instance:identifier:patch:module", "2015-11-21");
 
     private static RestconfDocumentedExceptionMapper exceptionMapper;
 
-    @BeforeClass
-    public static void setupExceptionMapper() {
+    @BeforeAll
+    static void setupExceptionMapper() {
         final var schemaContext = YangParserTestUtils.parseYangResources(
                 RestconfDocumentedExceptionMapperTest.class, "/restconf/impl/ietf-restconf@2017-01-26.yang",
                 "/instanceidentifier/yang/instance-identifier-patch-module.yang");
@@ -63,8 +61,7 @@ public class RestconfDocumentedExceptionMapperTest {
      *
      * @return Testing data for parametrized test.
      */
-    @Parameters(name = "{index}: {0}: {1}")
-    public static Iterable<Object[]> data() {
+    static Stream<Arguments> data() {
         final RestconfDocumentedException sampleComplexError =
             new RestconfDocumentedException("general message", new IllegalStateException("cause"), List.of(
                 new RestconfError(ErrorType.APPLICATION, ErrorTag.BAD_ATTRIBUTE, "message 1", "app tag #1"),
@@ -79,15 +76,15 @@ public class RestconfDocumentedExceptionMapperTest {
                     .node(QName.create(MONITORING_MODULE_INFO, "my-leaf12"))
                     .build())));
 
-        return Arrays.asList(new Object[][] {
-            {
+        return Stream.of(
+            arguments(
                 "Mapping of the exception with one error entry but null status code. This status code should"
-                        + "be derived from single error entry; JSON output",
+                    + " be derived from single error entry; JSON output",
                 new RestconfDocumentedException("Sample error message"),
                 mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(JaxRsMediaTypes.APPLICATION_YANG_PATCH_JSON)),
                 Response.status(Status.INTERNAL_SERVER_ERROR)
-                        .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON)
-                        .entity("""
+                    .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON)
+                    .entity("""
                             {
                               "errors": {
                                 "error": [
@@ -99,18 +96,18 @@ public class RestconfDocumentedExceptionMapperTest {
                                 ]
                               }
                             }""")
-                        .build()
-            },
-            {
+                    .build()
+            ),
+            arguments(
                 "Mapping of the exception with two error entries but null status code. This status code should"
-                        + "be derived from the first error entry that is specified; XML output",
+                    + "be derived from the first error entry that is specified; XML output",
                 new RestconfDocumentedException("general message", new IllegalStateException("cause"), List.of(
-                                new RestconfError(ErrorType.APPLICATION, ErrorTag.BAD_ATTRIBUTE, "message 1"),
-                                new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "message 2"))),
+                    new RestconfError(ErrorType.APPLICATION, ErrorTag.BAD_ATTRIBUTE, "message 1"),
+                    new RestconfError(ErrorType.APPLICATION, ErrorTag.OPERATION_FAILED, "message 2"))),
                 mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(JaxRsMediaTypes.APPLICATION_YANG_PATCH_XML)),
                 Response.status(Status.BAD_REQUEST)
-                        .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)
-                        .entity("""
+                    .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)
+                    .entity("""
                             <errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
                               <error>
                                 <error-message>message 1</error-message>
@@ -123,16 +120,15 @@ public class RestconfDocumentedExceptionMapperTest {
                                 <error-type>application</error-type>
                               </error>
                             </errors>""")
-                        .build()
-            },
-            {
-                "Mapping of the exception with three entries and optional entries set: error app tag (the first error),"
-                        + " error info (the second error), and error path (the last error); JSON output",
+                    .build()
+            ),
+            arguments("Mapping of the exception with three entries and optional entries set: error app tag"
+                    + " (the first error), error info (the second error), and error path (the last error); JSON output",
                 sampleComplexError, mockHttpHeaders(MediaType.APPLICATION_JSON_TYPE, List.of(
-                        MediaType.APPLICATION_JSON_TYPE)),
+                    MediaType.APPLICATION_JSON_TYPE)),
                 Response.status(Status.BAD_REQUEST)
-                        .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON)
-                        .entity("""
+                    .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON)
+                    .entity("""
                             {
                               "errors": {
                                 "error": [
@@ -161,16 +157,14 @@ public class RestconfDocumentedExceptionMapperTest {
                                 ]
                               }
                             }""")
-                        .build()
-            },
-            {
-                "Mapping of the exception with three entries and optional entries set: error app tag (the first error),"
-                        + " error info (the second error), and error path (the last error); XML output",
+                    .build()),
+            arguments("Mapping of the exception with three entries and optional entries set: error app tag"
+                    + " (the first error), error info (the second error), and error path (the last error); XML output",
                 sampleComplexError, mockHttpHeaders(JaxRsMediaTypes.APPLICATION_YANG_PATCH_JSON,
-                        List.of(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)),
+                    List.of(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)),
                 Response.status(Status.BAD_REQUEST)
-                        .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)
-                        .entity("""
+                    .type(JaxRsMediaTypes.APPLICATION_YANG_DATA_XML)
+                    .entity("""
                             <errors xmlns="urn:ietf:params:xml:ns:yang:ietf-restconf">
                               <error>
                                 <error-type>application</error-type>
@@ -194,29 +188,24 @@ public class RestconfDocumentedExceptionMapperTest {
                                 <error-info>my error info</error-info>
                               </error>
                             </errors>""")
-                        .build()
-            }
-        });
+                    .build()
+            )
+         );
     }
 
-    @Parameter
-    public String testDescription;
-    @Parameter(1)
-    public RestconfDocumentedException thrownException;
-    @Parameter(2)
-    public HttpHeaders httpHeaders;
-    @Parameter(3)
-    public Response expectedResponse;
-
-    @Test
-    public void testMappingOfExceptionToResponse() throws JSONException {
+    @ParameterizedTest
+    @MethodSource("data")
+    void testMappingOfExceptionToResponse(String testDescription, RestconfDocumentedException thrownException,
+        HttpHeaders httpHeaders, Response expectedResponse) throws JSONException {
         exceptionMapper.setHttpHeaders(httpHeaders);
         final Response response = exceptionMapper.toResponse(thrownException);
         compareResponseWithExpectation(expectedResponse, response);
     }
 
-    @Test
-    public void testFormattingJson() throws JSONException {
+    @ParameterizedTest
+    @MethodSource("data")
+    void testFormattingJson(String testDescription, RestconfDocumentedException thrownException,
+        HttpHeaders httpHeaders, Response expectedResponse) throws JSONException {
         assumeTrue(expectedResponse.getMediaType().equals(JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON));
 
         exceptionMapper.setHttpHeaders(httpHeaders);
@@ -235,8 +224,8 @@ public class RestconfDocumentedExceptionMapperTest {
             throws JSONException {
         final String errorMessage = String.format("Actual response %s doesn't equal to expected response %s",
                 actualResponse, expectedResponse);
-        assertEquals(errorMessage, expectedResponse.getStatus(), actualResponse.getStatus());
-        assertEquals(errorMessage, expectedResponse.getMediaType(), actualResponse.getMediaType());
+        assertEquals(expectedResponse.getStatus(), actualResponse.getStatus(), errorMessage);
+        assertEquals(expectedResponse.getMediaType(), actualResponse.getMediaType(), errorMessage);
         if (JaxRsMediaTypes.APPLICATION_YANG_DATA_JSON.equals(expectedResponse.getMediaType())) {
             JSONAssert.assertEquals(expectedResponse.getEntity().toString(),
                     actualResponse.getEntity().toString(), true);
index efea6856bf052d4060768bb0baf76cbce0f11016..f69cdf7fe3695758405d5b39df7b4109f0d60161 100644 (file)
@@ -14,8 +14,8 @@ import static org.junit.jupiter.api.Assertions.assertThrows;
 import java.text.ParseException;
 import java.util.List;
 import org.eclipse.jdt.annotation.NonNull;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.api.query.FieldsParam;
 import org.opendaylight.restconf.common.errors.RestconfDocumentedException;
 import org.opendaylight.restconf.nb.rfc8040.AbstractJukeboxTest;
@@ -28,7 +28,7 @@ import org.opendaylight.yangtools.yang.data.util.DataSchemaContextTree;
 import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 
-public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTest {
+abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTest {
     private static final QNameModule Q_NAME_MODULE_TEST_SERVICES =
         QNameModule.ofRevision("tests:test-services", "2019-03-25");
     private static final QNameModule Q_NAME_MODULE_AUGMENTED_JUKEBOX =
@@ -102,8 +102,8 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     // container foo
     protected static final QName EPSILON_Q_NAME = QName.create(Q_NAME_MODULE_FOO, "epsilon");
 
-    @Before
-    public void setUp() {
+    @BeforeEach
+    void setUp() {
         jukeboxSchemaNode = DataSchemaContextTree.from(JUKEBOX_SCHEMA).getRoot().childByQName(JUKEBOX_QNAME);
         assertNotNull(jukeboxSchemaNode);
         testServices = DataSchemaContextTree.from(TEST_SERVICES_SCHEMA).getRoot().childByQName(TEST_DATA_Q_NAME);
@@ -119,7 +119,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter containing only one child selected.
      */
     @Test
-    public void testSimplePath() {
+    void testSimplePath() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode, assertFields("library"));
         assertNotNull(result);
         assertSimplePath(result);
@@ -131,7 +131,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter containing two child nodes selected.
      */
     @Test
-    public void testDoublePath() {
+    void testDoublePath() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode, assertFields("library;player"));
         assertNotNull(result);
         assertDoublePath(result);
@@ -143,7 +143,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter containing sub-children selected delimited by slash.
      */
     @Test
-    public void testSubPath() {
+    void testSubPath() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode,
             assertFields("library/artist/album/name"));
         assertNotNull(result);
@@ -156,7 +156,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter containing sub-children selected delimited by parenthesis.
      */
     @Test
-    public void testChildrenPath() {
+    void testChildrenPath() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode,
             assertFields("library(artist(album(name)))"));
         assertNotNull(result);
@@ -169,7 +169,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter when augmentation with different namespace is used.
      */
     @Test
-    public void testNamespace() {
+    void testNamespace() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode,
             assertFields("augmented-jukebox:augmented-library"));
         assertNotNull(result);
@@ -183,7 +183,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * direct children of parent node - multiple children which are constructed using '/'.
      */
     @Test
-    public void testMultipleChildren1() {
+    void testMultipleChildren1() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices,
             assertFields("services(type-of-service;instance/instance-name;instance/provider)"));
         assertNotNull(result);
@@ -197,7 +197,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * direct children of parent node - one of children nodes is typed using brackets, other is constructed using '/'.
      */
     @Test
-    public void testMultipleChildren2() {
+    void testMultipleChildren2() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices,
             assertFields("services(type-of-service;instance(instance-name;provider))"));
         assertNotNull(result);
@@ -211,7 +211,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * direct children of parent node - multiple children with different parent nodes.
      */
     @Test
-    public void testMultipleChildren3() {
+    void testMultipleChildren3() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices,
             assertFields("services(instance/instance-name;type-of-service;next-data/next-service)"));
         assertNotNull(result);
@@ -221,7 +221,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertMultipleChildren3(@NonNull List<T> result);
 
     @Test
-    public void testMultipleChildren4() {
+    void testMultipleChildren4() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices,
                 assertFields("services(type-of-service;instance(instance-name;provider);next-data(next-service))"));
         assertNotNull(result);
@@ -231,7 +231,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertMultipleChildren4(@NonNull List<T> result);
 
     @Test
-    public void testMultipleChildren5() {
+    void testMultipleChildren5() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices,
                 assertFields("services(type-of-service;instance(instance-name;provider);next-data/next-service)"));
         assertNotNull(result);
@@ -241,7 +241,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertMultipleChildren5(@NonNull List<T> result);
 
     @Test
-    public void testAugmentedChild() {
+    void testAugmentedChild() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode,
             assertFields("player/augmented-jukebox:speed"));
         assertNotNull(result);
@@ -251,7 +251,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertAugmentedChild(@NonNull List<T> result);
 
     @Test
-    public void testListFieldUnderList() {
+    void testListFieldUnderList() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices, assertFields("services/instance"));
         assertNotNull(result);
         assertListFieldUnderList(result);
@@ -260,14 +260,14 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertListFieldUnderList(@NonNull List<T> result);
 
     @Test
-    public void testLeafList() {
+    void testLeafList() {
         final var result = translateFields(TEST_SERVICES_SCHEMA, testServices, assertFields("protocols"));
         assertNotNull(result);
         assertLeafList(result);
     }
 
     @Test
-    public void testKeyedList() {
+    void testKeyedList() {
         final var result = translateFields(JUKEBOX_SCHEMA, jukeboxSchemaNode, assertFields("library/artist(name)"));
         assertNotNull(result);
         assertKeyedList(result);
@@ -278,7 +278,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertLeafList(@NonNull List<T> result);
 
     @Test
-    public void testDuplicateNodes1() {
+    void testDuplicateNodes1() {
         final var result = translateFields(FOO_SCHEMA, foo,
             assertFields("bar(alpha;beta/gamma);baz(alpha;beta/gamma)"));
         assertNotNull(result);
@@ -288,7 +288,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
     protected abstract void assertDuplicateNodes1(List<T> result);
 
     @Test
-    public void testDuplicateNodes2() {
+    void testDuplicateNodes2() {
         final var result = translateFields(FOO_SCHEMA, foo,
             assertFields("bar(alpha;beta/delta);baz(alpha;beta/epsilon)"));
         assertNotNull(result);
@@ -301,7 +301,7 @@ public abstract class AbstractFieldsTranslatorTest<T> extends AbstractJukeboxTes
      * Test parse fields parameter when not existing child node selected.
      */
     @Test
-    public void testMissingChildSchema() throws ParseException {
+    void testMissingChildSchema() throws ParseException {
         final FieldsParam input = FieldsParam.parse("library(not-existing)");
 
         final RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
index 17209541fca35e4c484e062b15c7cb3d1325f0bb..0d9bf4e4eff5a042a9443a496cd564c651bc6227 100644 (file)
@@ -8,14 +8,14 @@
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
 import static org.hamcrest.CoreMatchers.containsString;
-import static org.hamcrest.CoreMatchers.instanceOf;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertInstanceOf;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
 
 import com.google.common.collect.ImmutableList;
 import com.google.common.util.concurrent.Futures;
@@ -24,8 +24,8 @@ import java.util.concurrent.ExecutionException;
 import javax.ws.rs.core.UriInfo;
 import org.eclipse.jdt.annotation.NonNull;
 import org.eclipse.jdt.annotation.Nullable;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
 import org.mockito.Mock;
 import org.opendaylight.restconf.api.ApiPath;
 import org.opendaylight.restconf.api.QueryParameters;
@@ -221,8 +221,8 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
 
     private DatabindContext mockDatabind;
 
-    @Before
-    public void initMockDatabind() {
+    @BeforeEach
+    void initMockDatabind() {
         mockDatabind = DatabindContext.ofModel(mockSchemaContext);
     }
 
@@ -240,7 +240,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
      * Test of successful DELETE operation.
      */
     @Test
-    public final void testDeleteData() throws Exception {
+    final void testDeleteData() throws Exception {
         final var future = testDeleteDataStrategy().dataDELETE(REQUEST, ApiPath.empty());
         assertNotNull(Futures.getDone(future));
     }
@@ -251,10 +251,10 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
      * Negative test for DELETE operation when data to delete does not exist. Error DATA_MISSING is expected.
      */
     @Test
-    public final void testNegativeDeleteData() {
+    final void testNegativeDeleteData() {
         final var future = testNegativeDeleteDataStrategy().dataDELETE(REQUEST, ApiPath.empty());
         final var ex = assertThrows(ExecutionException.class, () -> Futures.getDone(future)).getCause();
-        assertThat(ex, instanceOf(RestconfDocumentedException.class));
+        assertInstanceOf(RestconfDocumentedException.class, ex);
         final var errors = ((RestconfDocumentedException) ex).getErrors();
         assertEquals(1, errors.size());
         final var error = errors.get(0);
@@ -265,14 +265,14 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testNegativeDeleteDataStrategy();
 
     @Test
-    public final void testPostContainerData() {
+    final void testPostContainerData() {
         testPostContainerDataStrategy().postData(JUKEBOX_IID, EMPTY_JUKEBOX, null);
     }
 
     abstract @NonNull RestconfStrategy testPostContainerDataStrategy();
 
     @Test
-    public final void testPostListData() {
+    final void testPostListData() {
         testPostListDataStrategy(BAND_ENTRY, PLAYLIST_IID.node(BAND_ENTRY.name())).postData(PLAYLIST_IID, PLAYLIST,
             null);
     }
@@ -280,11 +280,11 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testPostListDataStrategy(MapEntryNode entryNode, YangInstanceIdentifier node);
 
     @Test
-    public final void testPostDataFail() {
+    final void testPostDataFail() {
         final var domException = new DOMException((short) 414, "Post request failed");
         final var future = testPostDataFailStrategy(domException).postData(JUKEBOX_IID, EMPTY_JUKEBOX, null);
         final var cause = assertThrows(ExecutionException.class, () -> Futures.getDone(future)).getCause();
-        assertThat(cause, instanceOf(RestconfDocumentedException.class));
+        assertInstanceOf(RestconfDocumentedException.class, cause);
         final var errors = ((RestconfDocumentedException) cause).getErrors();
         assertEquals(1, errors.size());
         assertThat(errors.get(0).getErrorInfo(), containsString(domException.getMessage()));
@@ -293,28 +293,28 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testPostDataFailStrategy(DOMException domException);
 
     @Test
-    public final void testPatchContainerData() {
+    final void testPatchContainerData() {
         testPatchContainerDataStrategy().merge(JUKEBOX_IID, EMPTY_JUKEBOX).getOrThrow();
     }
 
     abstract @NonNull RestconfStrategy testPatchContainerDataStrategy();
 
     @Test
-    public final void testPatchLeafData() {
+    final void testPatchLeafData() {
         testPatchLeafDataStrategy().merge(GAP_IID, GAP_LEAF).getOrThrow();
     }
 
     abstract @NonNull RestconfStrategy testPatchLeafDataStrategy();
 
     @Test
-    public final void testPatchListData() {
+    final void testPatchListData() {
         testPatchListDataStrategy().merge(JUKEBOX_IID, JUKEBOX_WITH_PLAYLIST).getOrThrow();
     }
 
     abstract @NonNull RestconfStrategy testPatchListDataStrategy();
 
     @Test
-    public final void testPatchDataReplaceMergeAndRemove() {
+    final void testPatchDataReplaceMergeAndRemove() {
         final var buildArtistList = ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(ARTIST_QNAME))
             .withChild(ImmutableNodes.newMapEntryBuilder()
@@ -334,7 +334,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testPatchDataReplaceMergeAndRemoveStrategy();
 
     @Test
-    public final void testPatchDataCreateAndDelete() {
+    final void testPatchDataCreateAndDelete() {
         patch(new PatchContext("patchCD", List.of(
             new PatchEntity("edit1", Operation.Create, PLAYER_IID, EMPTY_JUKEBOX),
             new PatchEntity("edit2", Operation.Delete, CREATE_AND_DELETE_TARGET))),
@@ -344,7 +344,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testPatchDataCreateAndDeleteStrategy();
 
     @Test
-    public final void testPatchMergePutContainer() {
+    final void testPatchMergePutContainer() {
         patch(new PatchContext("patchM", List.of(new PatchEntity("edit1", Operation.Merge, PLAYER_IID, EMPTY_JUKEBOX))),
             testPatchMergePutContainerStrategy(), false);
     }
@@ -352,7 +352,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy testPatchMergePutContainerStrategy();
 
     @Test
-    public final void testDeleteNonexistentData() {
+    final void testDeleteNonexistentData() {
         final var status = deleteNonexistentDataTestStrategy().patchData(
             new PatchContext("patchD", List.of(new PatchEntity("edit", Operation.Delete, CREATE_AND_DELETE_TARGET))))
             .getOrThrow().status();
@@ -370,35 +370,35 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract void assertTestDeleteNonexistentData(@NonNull PatchStatusContext status, @NonNull PatchStatusEntity edit);
 
     @Test
-    public final void readDataConfigTest() {
+    final void readDataConfigTest() {
         assertEquals(DATA_3, readData(ContentParam.CONFIG, PATH, readDataConfigTestStrategy()));
     }
 
     abstract @NonNull RestconfStrategy readDataConfigTestStrategy();
 
     @Test
-    public final void readAllHavingOnlyConfigTest() {
+    final void readAllHavingOnlyConfigTest() {
         assertEquals(DATA_3, readData(ContentParam.ALL, PATH, readAllHavingOnlyConfigTestStrategy()));
     }
 
     abstract @NonNull RestconfStrategy readAllHavingOnlyConfigTestStrategy();
 
     @Test
-    public final void readAllHavingOnlyNonConfigTest() {
+    final void readAllHavingOnlyNonConfigTest() {
         assertEquals(DATA_2, readData(ContentParam.ALL, PATH_2, readAllHavingOnlyNonConfigTestStrategy()));
     }
 
     abstract @NonNull RestconfStrategy readAllHavingOnlyNonConfigTestStrategy();
 
     @Test
-    public final void readDataNonConfigTest() {
+    final void readDataNonConfigTest() {
         assertEquals(DATA_2, readData(ContentParam.NONCONFIG, PATH_2, readDataNonConfigTestStrategy()));
     }
 
     abstract @NonNull RestconfStrategy readDataNonConfigTestStrategy();
 
     @Test
-    public final void readContainerDataAllTest() {
+    final void readContainerDataAllTest() {
         assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(NODE_IDENTIFIER)
             .withChild(CONTENT_LEAF)
@@ -409,7 +409,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readContainerDataAllTestStrategy();
 
     @Test
-    public final void readContainerDataConfigNoValueOfContentTest() {
+    final void readContainerDataConfigNoValueOfContentTest() {
         assertEquals(ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(NODE_IDENTIFIER)
             .withChild(CONTENT_LEAF)
@@ -420,7 +420,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readContainerDataConfigNoValueOfContentTestStrategy();
 
     @Test
-    public final void readListDataAllTest() {
+    final void readListDataAllTest() {
         assertEquals(ImmutableNodes.newSystemMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(QName.create("ns", "2016-02-28", "list")))
             .withChild(CHECK_DATA)
@@ -430,7 +430,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readListDataAllTestStrategy();
 
     @Test
-    public final void readOrderedListDataAllTest() {
+    final void readOrderedListDataAllTest() {
         assertEquals(ImmutableNodes.newUserMapBuilder()
             .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
             .withChild(CHECK_DATA)
@@ -440,7 +440,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readOrderedListDataAllTestStrategy();
 
     @Test
-    public void readUnkeyedListDataAllTest() {
+    void readUnkeyedListDataAllTest() {
         assertEquals(ImmutableNodes.newUnkeyedListBuilder()
             .withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
             .withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
@@ -454,7 +454,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readUnkeyedListDataAllTestStrategy();
 
     @Test
-    public final void readLeafListDataAllTest() {
+    final void readLeafListDataAllTest() {
         assertEquals(ImmutableNodes.<String>newSystemLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
             .withValue(ImmutableList.<LeafSetEntryNode<String>>builder()
@@ -467,7 +467,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readLeafListDataAllTestStrategy();
 
     @Test
-    public final void readOrderedLeafListDataAllTest() {
+    final void readOrderedLeafListDataAllTest() {
         assertEquals(ImmutableNodes.<String>newUserLeafSetBuilder()
             .withNodeIdentifier(new NodeIdentifier(LEAF_LIST_QNAME))
             .withValue(ImmutableList.<LeafSetEntryNode<String>>builder()
@@ -480,7 +480,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
     abstract @NonNull RestconfStrategy readOrderedLeafListDataAllTestStrategy();
 
     @Test
-    public void readDataWrongPathOrNoContentTest() {
+    void readDataWrongPathOrNoContentTest() {
         assertNull(readData(ContentParam.CONFIG, PATH_2, readDataWrongPathOrNoContentTestStrategy()));
     }
 
@@ -502,7 +502,7 @@ abstract class AbstractRestconfStrategyTest extends AbstractJukeboxTest {
         final var patchStatusContext = strategy.patchData(patchContext).getOrThrow().status();
         for (var entity : patchStatusContext.editCollection()) {
             if (failed) {
-                assertTrue("Edit " + entity.getEditId() + " failed", entity.isOk());
+                assertTrue(entity.isOk(), "Edit " + entity.getEditId() + " failed");
             } else {
                 assertTrue(entity.isOk());
             }
index c92dd3671d9c1734f7281cb910b061d5d534b0ec..755f41b39203a38e5d5510a4732edf52083714db 100644 (file)
@@ -8,12 +8,12 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
 import java.util.Set;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.restconf.api.query.FieldsParam;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.util.DataSchemaContext;
@@ -22,8 +22,8 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 /**
  * Unit test for {@link MdsalFieldsParam}.
  */
-@RunWith(MockitoJUnitRunner.class)
-public class MdsalFieldsParamTest extends AbstractFieldsTranslatorTest<Set<QName>> {
+@ExtendWith(MockitoExtension.class)
+class MdsalFieldsParamTest extends AbstractFieldsTranslatorTest<Set<QName>> {
     @Override
     protected List<Set<QName>> translateFields(final EffectiveModelContext modelContext,
             final DataSchemaContext startNode, final FieldsParam fields) {
index 41ea0e1a13ee553a6dfb115c06983c5710b0013f..68fd83a9effb267e6c3098a8c328fded4b3e40e6 100644 (file)
@@ -25,11 +25,10 @@ import static org.opendaylight.yangtools.util.concurrent.FluentFutures.immediate
 import com.google.common.collect.ImmutableMap;
 import java.util.Optional;
 import org.eclipse.jdt.annotation.NonNull;
-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;
 import org.opendaylight.mdsal.common.api.CommitInfo;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.dom.api.DOMActionService;
@@ -61,8 +60,8 @@ import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.opendaylight.yangtools.yang.test.util.YangParserTestUtils;
 import org.w3c.dom.DOMException;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTest {
+@ExtendWith(MockitoExtension.class)
+final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTest {
     private static final DatabindContext MODULES_DATABIND = DatabindContext.ofModel(
         YangParserTestUtils.parseYangResourceDirectory("/modules"));
 
@@ -83,12 +82,6 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     @Mock
     private NetconfDataTreeService netconfService;
 
-    @Before
-    public void before() {
-        doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
-        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
-    }
-
     @Override
     RestconfStrategy newStrategy(final DatabindContext databind) {
         return new MdsalRestconfStrategy(databind, dataBroker, ImmutableMap.of(), rpcService, null, null,
@@ -102,6 +95,8 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     @Override
     RestconfStrategy testDeleteDataStrategy() {
         // assert that data to delete exists
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
+        doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
         when(readWrite.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of()))
             .thenReturn(immediateTrueFluentFuture());
         return jukeboxStrategy();
@@ -110,6 +105,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     @Override
     RestconfStrategy testNegativeDeleteDataStrategy() {
         // assert that data to delete does NOT exist
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         when(readWrite.exists(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of()))
             .thenReturn(immediateFalseFluentFuture());
         return jukeboxStrategy();
@@ -117,6 +113,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
     @Override
     RestconfStrategy testPostListDataStrategy(final MapEntryNode entryNode, final YangInstanceIdentifier node) {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, node);
         doNothing().when(readWrite).put(LogicalDatastoreType.CONFIGURATION, node, entryNode);
         doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
@@ -125,6 +122,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
     @Override
     RestconfStrategy testPostDataFailStrategy(final DOMException domException) {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
         doReturn(immediateFailedFluentFuture(domException)).when(readWrite).commit();
         doNothing().when(readWrite).put(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, EMPTY_JUKEBOX);
@@ -132,7 +130,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void testPutContainerData() {
+    void testPutContainerData() {
         doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(read).when(dataBroker).newReadOnlyTransaction();
         doReturn(immediateFalseFluentFuture()).when(read).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
@@ -145,7 +143,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void testPutLeafData() {
+    void testPutLeafData() {
         doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(read).when(dataBroker).newReadOnlyTransaction();
         doReturn(immediateFalseFluentFuture()).when(read).exists(LogicalDatastoreType.CONFIGURATION, GAP_IID);
@@ -159,7 +157,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
 
     @Test
-    public void testPutListData() {
+    void testPutListData() {
         doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(read).when(dataBroker).newReadOnlyTransaction();
         doReturn(immediateFalseFluentFuture())
@@ -174,6 +172,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
     @Override
     RestconfStrategy testPostContainerDataStrategy() {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
         doNothing().when(readWrite).put(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, EMPTY_JUKEBOX);
         doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
@@ -203,11 +202,15 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
     @Override
     RestconfStrategy testPatchDataReplaceMergeAndRemoveStrategy() {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
+        doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy testPatchDataCreateAndDeleteStrategy() {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
+        doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
         doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION, PLAYER_IID);
         doReturn(immediateTrueFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION,
             CREATE_AND_DELETE_TARGET);
@@ -216,11 +219,14 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
 
     @Override
     RestconfStrategy testPatchMergePutContainerStrategy() {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
+        doReturn(CommitInfo.emptyFluentFuture()).when(readWrite).commit();
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy deleteNonexistentDataTestStrategy() {
+        doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
         doReturn(immediateFalseFluentFuture()).when(readWrite).exists(LogicalDatastoreType.CONFIGURATION,
             CREATE_AND_DELETE_TARGET);
         return jukeboxStrategy();
@@ -351,7 +357,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void readLeafWithDefaultParameters() {
+    void readLeafWithDefaultParameters() {
         final var data = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
             .withChild(ImmutableNodes.leafNode(QName.create(BASE, "exampleLeaf"), "i am leaf"))
@@ -367,7 +373,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void readContainerWithDefaultParameters() {
+    void readContainerWithDefaultParameters() {
         final var exampleList = new NodeIdentifier(QName.create(BASE, "exampleList"));
         final var data = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
@@ -397,7 +403,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void readLeafInListWithDefaultParameters() {
+    void readLeafInListWithDefaultParameters() {
         final var exampleList = new NodeIdentifier(QName.create(BASE, "exampleList"));
         final var content = ImmutableNodes.newContainerBuilder()
             .withNodeIdentifier(new NodeIdentifier(CONT_QNAME))
@@ -420,13 +426,13 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void testGetRestconfStrategyLocal() throws Exception {
+    void testGetRestconfStrategyLocal() throws Exception {
         final var strategy = jukeboxStrategy();
         assertEquals(new StrategyAndTail(strategy, ApiPath.empty()), strategy.resolveStrategy(ApiPath.empty()));
     }
 
     @Test
-    public void testGetRestconfStrategyMountDataBroker() throws Exception {
+    void testGetRestconfStrategyMountDataBroker() throws Exception {
         doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
         doReturn(Optional.of(dataBroker)).when(mountPoint).getService(DOMDataBroker.class);
         doReturn(Optional.of(rpcService)).when(mountPoint).getService(DOMRpcService.class);
@@ -443,7 +449,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void testGetRestconfStrategyMountNetconfService() throws Exception {
+    void testGetRestconfStrategyMountNetconfService() throws Exception {
         doReturn(Optional.of(netconfService)).when(mountPoint).getService(NetconfDataTreeService.class);
         doReturn(Optional.of(rpcService)).when(mountPoint).getService(DOMRpcService.class);
         doReturn(Optional.of(new FixedDOMSchemaService(JUKEBOX_SCHEMA))).when(mountPoint)
@@ -459,7 +465,7 @@ public final class MdsalRestconfStrategyTest extends AbstractRestconfStrategyTes
     }
 
     @Test
-    public void testGetRestconfStrategyMountNone() throws Exception {
+    void testGetRestconfStrategyMountNone() throws Exception {
         doReturn(JUKEBOX_IID).when(mountPoint).getIdentifier();
         doReturn(Optional.empty()).when(mountPoint).getService(NetconfDataTreeService.class);
         doReturn(Optional.empty()).when(mountPoint).getService(DOMDataBroker.class);
index 34f07c6ad8bde79005be92cd6e833e9953ef5608..21b4a8f86b8ed49d2c0f289ad08e5c9b551f8874 100644 (file)
@@ -8,13 +8,13 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
 
 import java.util.List;
 import java.util.Set;
 import java.util.stream.Collectors;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.restconf.api.query.FieldsParam;
 import org.opendaylight.yangtools.yang.common.QName;
 import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
@@ -26,8 +26,8 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 /**
  * Unit test for {@link NetconfFieldsParam}.
  */
-@RunWith(MockitoJUnitRunner.class)
-public class NetconfFieldsParamTest extends AbstractFieldsTranslatorTest<YangInstanceIdentifier> {
+@ExtendWith(MockitoExtension.class)
+class NetconfFieldsParamTest extends AbstractFieldsTranslatorTest<YangInstanceIdentifier> {
     @Override
     protected List<YangInstanceIdentifier> translateFields(final EffectiveModelContext modelContext,
             final DataSchemaContext startNode, final FieldsParam fields) {
index a25cb63e862852040513692c954cc66f0ca510f1..3eda6c7c0cbc040fbfb2eebf1d4cd94c40883ac1 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.restconf.nb.rfc8040.rests.transactions;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
 import static org.mockito.ArgumentMatchers.any;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
@@ -24,11 +24,10 @@ import com.google.common.util.concurrent.Futures;
 import java.text.ParseException;
 import java.util.List;
 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;
 import org.opendaylight.mdsal.common.api.LogicalDatastoreType;
 import org.opendaylight.mdsal.common.api.TransactionCommitFailedException;
 import org.opendaylight.mdsal.dom.spi.DefaultDOMRpcResult;
@@ -58,22 +57,11 @@ import org.opendaylight.yangtools.yang.data.api.schema.MapEntryNode;
 import org.opendaylight.yangtools.yang.data.spi.node.ImmutableNodes;
 import org.w3c.dom.DOMException;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyTest {
+@ExtendWith(MockitoExtension.class)
+final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyTest {
     @Mock
     private NetconfDataTreeService netconfService;
 
-    @Before
-    public void before() {
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).discardChanges();
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).unlock();
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).lock();
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
-            .delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(),
-            any(), any());
-    }
 
     @Override
     RestconfStrategy newStrategy(final DatabindContext databind) {
@@ -82,11 +70,17 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testDeleteDataStrategy() {
+        mockLockUnlockCommit();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
+            .delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy testNegativeDeleteDataStrategy() {
+        mockLockUnlockDiscard();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
+            .delete(LogicalDatastoreType.CONFIGURATION, YangInstanceIdentifier.of());
         doReturn(Futures.immediateFailedFuture(new TransactionCommitFailedException(
             "Commit of transaction " + this + " failed", new NetconfDocumentedException("id",
                 ErrorType.RPC, ErrorTag.DATA_MISSING, ErrorSeverity.ERROR)))).when(netconfService).commit();
@@ -94,7 +88,7 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testDeleteFullList() {
+    void testDeleteFullList() {
         final var songListPath = YangInstanceIdentifier.builder().node(JUKEBOX_QNAME).node(PLAYLIST_QNAME)
             .node(NodeIdentifierWithPredicates.of(PLAYLIST_QNAME, NAME_QNAME, "playlist"))
             .node(SONG_QNAME).build();
@@ -105,7 +99,7 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
             .withNodeIdentifier(new NodeIdentifier(SONG_QNAME))
             .withChild(SONG1).withChild(SONG2).build();
         final var songKeyFields = List.of(YangInstanceIdentifier.of(SONG_INDEX_QNAME));
-
+        mockLockUnlockCommit();
         // data fetched using key field names to minimize amount of data returned
         doReturn(immediateFluentFuture(Optional.of(songListData))).when(netconfService)
             .getConfig(songListWildcardPath, songKeyFields);
@@ -124,6 +118,7 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPostContainerDataStrategy() {
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).lock();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .create(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, EMPTY_JUKEBOX, Optional.empty());
@@ -132,6 +127,7 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPostListDataStrategy(final MapEntryNode entryNode, final YangInstanceIdentifier node) {
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).lock();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             // FIXME: exact match
             .merge(any(), any(), any(), any());
@@ -143,16 +139,16 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPostDataFailStrategy(final DOMException domException) {
+        mockLockUnlockDiscard();
         doReturn(immediateFailedFluentFuture(domException)).when(netconfService)
             // FIXME: exact match
             .create(any(), any(), any(), any());
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).discardChanges();
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).unlock();
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy testPatchContainerDataStrategy() {
+        mockLockUnlockCommit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(),any(),
             any());
         return jukeboxStrategy();
@@ -160,24 +156,24 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPatchLeafDataStrategy() {
+        mockLockUnlockCommit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .merge(any(), any(), any(), any());
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy testPatchListDataStrategy() {
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
+        mockLockUnlockCommit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .merge(any(), any(),any(),any());
         return jukeboxStrategy();
     }
 
     @Test
-    public void testPutCreateContainerData() {
+    void testPutCreateContainerData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(JUKEBOX_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, EMPTY_JUKEBOX, Optional.empty());
 
@@ -189,10 +185,10 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testPutReplaceContainerData() {
+    void testPutReplaceContainerData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.of(mock(ContainerNode.class)))).when(netconfService)
             .getConfig(JUKEBOX_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, EMPTY_JUKEBOX, Optional.empty());
 
@@ -203,9 +199,9 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testPutCreateLeafData() {
+    void testPutCreateLeafData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(GAP_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, GAP_IID, GAP_LEAF, Optional.empty());
 
@@ -215,10 +211,10 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testPutReplaceLeafData() {
+    void testPutReplaceLeafData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.of(mock(ContainerNode.class)))).when(netconfService)
             .getConfig(GAP_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, GAP_IID, GAP_LEAF, Optional.empty());
 
@@ -228,9 +224,9 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testPutCreateListData() {
+    void testPutCreateListData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(JUKEBOX_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, JUKEBOX_WITH_BANDS, Optional.empty());
 
@@ -247,9 +243,11 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
      * @throws ParseException if ApiPath string cannot be parsed
      */
     @Test
-    public void testPutDataWithInsertAfterLast() throws ParseException {
+    void testPutDataWithInsertAfterLast() throws ParseException {
         // Spy of jukeboxStrategy will be used later to count how many items was inserted
         final var spyStrategy = spy(jukeboxStrategy());
+        mockLockUnlockDiscard();
+
         final var spyTx = spy(jukeboxStrategy().prepareWriteExecution());
         doReturn(spyTx).when(spyStrategy).prepareWriteExecution();
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(any());
@@ -285,9 +283,11 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
      * @throws ParseException if ApiPath string cannot be parsed
      */
     @Test
-    public void testPostDataWithInsertAfterLast() throws ParseException {
+    void testPostDataWithInsertAfterLast() throws ParseException {
         // Spy of jukeboxStrategy will be used later to count how many items was inserted
         final var spyStrategy = spy(jukeboxStrategy());
+        mockLockUnlockDiscard();
+
         final var spyTx = spy(jukeboxStrategy().prepareWriteExecution());
         doReturn(spyTx).when(spyStrategy).prepareWriteExecution();
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(any());
@@ -316,10 +316,10 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
     }
 
     @Test
-    public void testPutReplaceListData() {
+    void testPutReplaceListData() {
+        mockLockUnlockCommit();
         doReturn(immediateFluentFuture(Optional.of(mock(ContainerNode.class)))).when(netconfService)
             .getConfig(JUKEBOX_IID);
-        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .replace(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID, JUKEBOX_WITH_BANDS, Optional.empty());
 
@@ -331,6 +331,9 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPatchDataReplaceMergeAndRemoveStrategy() {
+        mockLockUnlockCommit();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(),
+            any(), any());
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .remove(LogicalDatastoreType.CONFIGURATION, ARTIST_IID);
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
@@ -341,6 +344,7 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPatchDataCreateAndDeleteStrategy() {
+        mockLockUnlockCommit();
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
             .create(LogicalDatastoreType.CONFIGURATION, PLAYER_IID, EMPTY_JUKEBOX, Optional.empty());
         doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService)
@@ -350,11 +354,15 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
 
     @Override
     RestconfStrategy testPatchMergePutContainerStrategy() {
+        mockLockUnlockCommit();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).merge(any(), any(),
+            any(), any());
         return jukeboxStrategy();
     }
 
     @Override
     RestconfStrategy deleteNonexistentDataTestStrategy() {
+        mockLockUnlockDiscard();
         doReturn(Futures.immediateFailedFuture(
             new TransactionCommitFailedException("Commit of transaction " + this + " failed",
                 new NetconfDocumentedException("id", ErrorType.RPC, ErrorTag.DATA_MISSING, ErrorSeverity.ERROR))))
@@ -460,4 +468,20 @@ public final class NetconfRestconfStrategyTest extends AbstractRestconfStrategyT
         doReturn(immediateFluentFuture(Optional.empty())).when(netconfService).getConfig(PATH_2);
         return mockStrategy();
     }
+
+    private void mockLockUnlock()  {
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).unlock();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).lock();
+    }
+
+    private void mockLockUnlockCommit()  {
+        mockLockUnlock();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).commit();
+    }
+
+    private void mockLockUnlockDiscard()  {
+        mockLockUnlock();
+        doReturn(Futures.immediateFuture(new DefaultDOMRpcResult())).when(netconfService).discardChanges();
+    }
+
 }
index 3303fedbeae8fe1d642063293fd33807c6ff7b0c..dc5798d2b7d46b0510a8480d0897f4bdb3d9511e 100644 (file)
@@ -10,7 +10,7 @@ package org.opendaylight.restconf.nb.rfc8040.streams;
 import static org.hamcrest.CoreMatchers.allOf;
 import static org.hamcrest.CoreMatchers.containsString;
 import static org.hamcrest.MatcherAssert.assertThat;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.fail;
 
 import com.google.common.util.concurrent.Uninterruptibles;
 import java.io.IOException;
index 307391281348f4240d1f2b7d8561793fd56bdfd9..f1663254e549e3f9a634a2e0ea18f85152d19151 100644 (file)
@@ -7,19 +7,19 @@
  */
 package org.opendaylight.restconf.server.api;
 
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertThrows;
 import static org.mockito.Mockito.doReturn;
 import static org.mockito.Mockito.mock;
 import static org.mockito.Mockito.withSettings;
 
 import java.util.Set;
 import java.util.function.Function;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
 import org.opendaylight.restconf.api.QueryParameters;
 import org.opendaylight.restconf.api.query.ContentParam;
 import org.opendaylight.restconf.api.query.DepthParam;
@@ -35,13 +35,13 @@ import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
 import org.opendaylight.yangtools.yang.model.api.LeafSchemaNode;
 import org.opendaylight.yangtools.yang.model.api.stmt.ContainerEffectiveStatement;
 
-@RunWith(MockitoJUnitRunner.StrictStubs.class)
-public class ParamsTest {
+@ExtendWith(MockitoExtension.class)
+class ParamsTest {
     /**
      * Test when not allowed parameter type is used.
      */
     @Test
-    public void checkParametersTypesNegativeTest() {
+    void checkParametersTypesNegativeTest() {
         final var mockDatabind = DatabindContext.ofModel(mock(EffectiveModelContext.class));
 
         assertInvalidIAE(EventStreamGetParams::of);
@@ -58,7 +58,7 @@ public class ParamsTest {
      * Test of parsing default parameters from URI request.
      */
     @Test
-    public void parseUriParametersDefaultTest() {
+    void parseUriParametersDefaultTest() {
         // no parameters, default values should be used
         final var params = assertParams(DataGetParams::of, QueryParameters.of());
         assertEquals(ContentParam.ALL, params.content());
@@ -67,7 +67,7 @@ public class ParamsTest {
     }
 
     @Test
-    public void testInvalidValueReadDataParams() {
+    void testInvalidValueReadDataParams() {
         assertParamsThrows(
             "Invalid content value: Value can be 'all', 'config' or 'nonconfig', not 'odl-invalid-value'",
             DataGetParams::of, ContentParam.uriName, "odl-invalid-value");
@@ -91,7 +91,7 @@ public class ParamsTest {
      * Testing parsing of with-defaults parameter which value matches 'report-all-tagged' setting.
      */
     @Test
-    public void parseUriParametersWithDefaultAndTaggedTest() {
+    void parseUriParametersWithDefaultAndTaggedTest() {
         final var params = assertParams(DataGetParams::of, WithDefaultsParam.uriName,
             "report-all-tagged");
         assertEquals(WithDefaultsParam.REPORT_ALL_TAGGED, params.withDefaults());
@@ -101,7 +101,7 @@ public class ParamsTest {
      * Testing parsing of with-defaults parameter which value matches 'report-all' setting.
      */
     @Test
-    public void parseUriParametersWithDefaultAndReportAllTest() {
+    void parseUriParametersWithDefaultAndReportAllTest() {
         final var params = assertParams(DataGetParams::of, WithDefaultsParam.uriName,
             "report-all");
         assertEquals(WithDefaultsParam.REPORT_ALL, params.withDefaults());
@@ -112,7 +112,7 @@ public class ParamsTest {
      * - non-reporting setting.
      */
     @Test
-    public void parseUriParametersWithDefaultAndNonTaggedTest() {
+    void parseUriParametersWithDefaultAndNonTaggedTest() {
         final var params = assertParams(DataGetParams::of, WithDefaultsParam.uriName,
             "explicit");
         assertEquals(WithDefaultsParam.EXPLICIT, params.withDefaults());
@@ -122,7 +122,7 @@ public class ParamsTest {
      * Test of parsing user defined parameters from URI request.
      */
     @Test
-    public void parseUriParametersUserDefinedTest() {
+    void parseUriParametersUserDefinedTest() {
         final QName containerChild = QName.create("ns", "container-child");
 
         final var params = assertParams(DataGetParams::of, QueryParameters.of(
index fe3b6eedf96accbd31ea28e1d6a7f7082a484b83..e9bdb5e2bcb5710f6b584230133d3fabf656326e 100644 (file)
@@ -7,9 +7,9 @@
  */
 package org.opendaylight.restconf.server.api;
 
-import static org.junit.Assert.assertSame;
 import static org.junit.jupiter.api.Assertions.assertEquals;
 import static org.junit.jupiter.api.Assertions.assertNull;
+import static org.junit.jupiter.api.Assertions.assertSame;
 
 import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.api.ErrorMessage;
index 9e7be362c7e5a670cef4c208f7d0a1de87c32e55..c0702ab31d68ac8e4b91aa429e89f23682baae59 100644 (file)
@@ -12,7 +12,7 @@ import static org.mockito.Mockito.times;
 
 import java.util.List;
 import java.util.Set;
-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;
index 61ece25aaa848ef728bc319914f7e88d8c23b60a..d5a1aa91308413ad594870489fcf95dea7d1aecc 100644 (file)
@@ -7,9 +7,8 @@
  */
 package org.opendaylight.restconf.server.spi;
 
-import java.io.IOException;
 import java.util.List;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
 import org.opendaylight.restconf.nb.rfc8040.AbstractJukeboxTest;
 import org.opendaylight.restconf.server.api.PatchStatusContext;
 import org.opendaylight.restconf.server.api.PatchStatusEntity;
@@ -17,7 +16,7 @@ import org.opendaylight.restconf.server.api.ServerError;
 import org.opendaylight.yangtools.yang.common.ErrorTag;
 import org.opendaylight.yangtools.yang.common.ErrorType;
 
-public class YangPatchStatusBodyTest extends AbstractJukeboxTest {
+class YangPatchStatusBodyTest extends AbstractJukeboxTest {
     private final ServerError error = new ServerError(ErrorType.PROTOCOL, new ErrorTag("data-exists"),
         "Data already exists");
     private final PatchStatusEntity statusEntity = new PatchStatusEntity("patch1", true, null);
@@ -27,7 +26,7 @@ public class YangPatchStatusBodyTest extends AbstractJukeboxTest {
      * Test if per-operation status is omitted if global error is present.
      */
     @Test
-    public void testOutputWithGlobalError() throws IOException {
+    void testOutputWithGlobalError() {
         final var body = new YangPatchStatusBody(new PatchStatusContext("patch", List.of(statusEntity), false,
             List.of(error)));
 
@@ -61,7 +60,7 @@ public class YangPatchStatusBodyTest extends AbstractJukeboxTest {
      * Test if per-operation status is present if there is no global error present.
      */
     @Test
-    public void testOutputWithoutGlobalError() throws IOException {
+    void testOutputWithoutGlobalError() {
         final var body = new YangPatchStatusBody(new PatchStatusContext("patch", List.of(statusEntityError), false,
             null));