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>
*/
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;
@BeforeEach
void beforeEach() {
- lenient().doReturn(CommitInfo.emptyFluentFuture()).when(tx).commit();
doReturn(tx).when(dataBroker).newReadWriteTransaction();
}
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("""
}
@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("""
}
@Test
- public void testPostExistingData() {
+ void testPostExistingData() {
doReturn(new MultivaluedHashMap<>()).when(uriInfo).getQueryParameters();
doReturn(immediateTrueFluentFuture())
.when(tx).exists(LogicalDatastoreType.CONFIGURATION, JUKEBOX_IID);
}
@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);
}
@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"));
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(
}
@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"));
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(
}
@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"));
.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(
}
@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"));
.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(
*/
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;
*/
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;
/**
* 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 =
// 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
* 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("""
* <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());
* <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(
* 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());
* 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());
* 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());
* 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());
* <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());
*/
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;
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;
/**
* 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");
// 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,
* 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();
* 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());
* 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());
* 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());
* 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());
* 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();
*/
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;
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));
}
@Test
- public final void moduleSubContainerDataPostActionTest() throws Exception {
+ final void moduleSubContainerDataPostActionTest() throws Exception {
final var body = moduleSubContainerDataPostActionBody();
assertEquals(ImmutableNodes.newContainerBuilder()
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));
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);
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;
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
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 "";
}
*/
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";
*/
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;
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" : {
* 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" : {
* {@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", """
{
* {@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", """
{
* 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" : {
* 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" : {
* 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" : {
* 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" : {
* 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" : {
* 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": {
* 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",
"""
{
* 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": {
* 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": {
* 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": {
* 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": {
* 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": {
*/
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";
*/
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;
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>
* 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">
* 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">
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
* 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">
* 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>
* 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>
* 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>
* 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>
* 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>
* 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>
*/
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;
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;
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");
*
* @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"),
.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": [
]
}
}""")
- .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>
<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": [
]
}
}""")
- .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>
<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);
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);
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;
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 =
// 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);
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
* 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);
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);
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);
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);
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);
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);
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);
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);
* 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,
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;
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;
private DatabindContext mockDatabind;
- @Before
- public void initMockDatabind() {
+ @BeforeEach
+ void initMockDatabind() {
mockDatabind = DatabindContext.ofModel(mockSchemaContext);
}
* 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));
}
* 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);
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);
}
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()));
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()
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))),
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);
}
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();
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)
abstract @NonNull RestconfStrategy readContainerDataAllTestStrategy();
@Test
- public final void readContainerDataConfigNoValueOfContentTest() {
+ final void readContainerDataConfigNoValueOfContentTest() {
assertEquals(ImmutableNodes.newContainerBuilder()
.withNodeIdentifier(NODE_IDENTIFIER)
.withChild(CONTENT_LEAF)
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)
abstract @NonNull RestconfStrategy readListDataAllTestStrategy();
@Test
- public final void readOrderedListDataAllTest() {
+ final void readOrderedListDataAllTest() {
assertEquals(ImmutableNodes.newUserMapBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(CHECK_DATA)
abstract @NonNull RestconfStrategy readOrderedListDataAllTestStrategy();
@Test
- public void readUnkeyedListDataAllTest() {
+ void readUnkeyedListDataAllTest() {
assertEquals(ImmutableNodes.newUnkeyedListBuilder()
.withNodeIdentifier(new NodeIdentifier(LIST_QNAME))
.withChild(ImmutableNodes.newUnkeyedListEntryBuilder()
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()
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()
abstract @NonNull RestconfStrategy readOrderedLeafListDataAllTestStrategy();
@Test
- public void readDataWrongPathOrNoContentTest() {
+ void readDataWrongPathOrNoContentTest() {
assertNull(readData(ContentParam.CONFIG, PATH_2, readDataWrongPathOrNoContentTestStrategy()));
}
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());
}
*/
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;
/**
* 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) {
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;
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"));
@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,
@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();
@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();
@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();
@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);
}
@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);
}
@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);
@Test
- public void testPutListData() {
+ void testPutListData() {
doReturn(readWrite).when(dataBroker).newReadWriteTransaction();
doReturn(read).when(dataBroker).newReadOnlyTransaction();
doReturn(immediateFalseFluentFuture())
@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();
@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);
@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();
}
@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"))
}
@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))
}
@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))
}
@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);
}
@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)
}
@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);
*/
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;
/**
* 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) {
*/
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;
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;
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) {
@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();
}
@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();
.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);
@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());
@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());
@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();
@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());
}
@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());
}
@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());
}
@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());
}
@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());
* @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());
* @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());
}
@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());
@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)
@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)
@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))))
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();
+ }
+
}
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;
*/
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;
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);
* 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());
}
@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");
* 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());
* 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());
* - non-reporting setting.
*/
@Test
- public void parseUriParametersWithDefaultAndNonTaggedTest() {
+ void parseUriParametersWithDefaultAndNonTaggedTest() {
final var params = assertParams(DataGetParams::of, WithDefaultsParam.uriName,
"explicit");
assertEquals(WithDefaultsParam.EXPLICIT, params.withDefaults());
* 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(
*/
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;
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;
*/
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;
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);
* 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)));
* 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));