summaryrefslogtreecommitdiffstats
path: root/plugins/restconf-client/provider/src/test/java
diff options
context:
space:
mode:
authorDan Timoney <dtimoney@att.com>2021-04-14 14:15:41 -0400
committerDan Timoney <dtimoney@att.com>2021-04-19 17:45:33 +0000
commit43228cc2a7f06d5e1b6e398023684c80d9ed1270 (patch)
tree1128649a01f6da9e4941adfb30f1e95715aa14d9 /plugins/restconf-client/provider/src/test/java
parent19c7de1f524478ea351f4d2dcd76508455a75ba8 (diff)
Fix yangparser invocation
Fix YangParser invocation in restconf-provider to address breaking change in ODL Aluminum release. Issue-ID: SDNC-1515 Signed-off-by: Dan Timoney <dtimoney@att.com> Change-Id: I9974889bfa9bbd11077c95275c0cb8ba59b1b0bb
Diffstat (limited to 'plugins/restconf-client/provider/src/test/java')
-rw-r--r--plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfapicall/TestRestconfApiUtils.java52
-rw-r--r--plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java10
-rw-r--r--plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java6
-rw-r--r--plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java6
4 files changed, 70 insertions, 4 deletions
diff --git a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfapicall/TestRestconfApiUtils.java b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfapicall/TestRestconfApiUtils.java
new file mode 100644
index 000000000..a76bb52bf
--- /dev/null
+++ b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfapicall/TestRestconfApiUtils.java
@@ -0,0 +1,52 @@
+package org.onap.ccsdk.sli.plugins.restconfapicall;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import org.junit.Test;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.yangtools.yang.model.api.EffectiveModelContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
+
+/*-
+ * ============LICENSE_START=======================================================
+ * ONAP: CCSDK
+ * ================================================================================
+ * Copyright (C) 2021 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ * ============LICENSE_END=========================================================
+ */
+
+public class TestRestconfApiUtils {
+ @Test
+ public void testGetSchemaCtxFromDir() throws SvcLogicException {
+
+ YangParserFactory factory = new YangParserFactoryImpl();
+
+
+ // Test with valid subdirectories
+ EffectiveModelContext modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "src/test/test-yang");
+ assertNotNull(modelCtx);
+
+ // Test with directory with no yang
+ modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "src/test/java");
+ assertNotNull(modelCtx);
+
+ // Test with invalid directory
+ modelCtx = RestconfApiUtils.getSchemaCtxFromDir(factory, "no/such/directory");
+ assertNotNull(modelCtx);
+ }
+}
diff --git a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java
index aa89d67d7..64173306d 100644
--- a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java
+++ b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/restconfdiscovery/TestRestconfDiscoveryNode.java
@@ -29,6 +29,7 @@ import org.onap.ccsdk.sli.core.sli.SvcLogicContext;
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import java.io.IOException;
import java.net.URI;
@@ -104,8 +105,9 @@ public class TestRestconfDiscoveryNode {
throws SvcLogicException{
SvcLogicContext ctx = new SvcLogicContext();
Map<String, String> p = new HashMap<>();
+
RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
- new RestconfApiCallNode(new RestapiCallNode()));
+ new RestconfApiCallNode(new RestapiCallNode(), new YangParserFactoryImpl()));
rdn.establishSubscription(p, ctx);
}
@@ -115,7 +117,7 @@ public class TestRestconfDiscoveryNode {
ctx.setAttribute("restapi-result.response-code", "200");
ctx.setAttribute("response-code", "404");
RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
- new RestconfApiCallNode(new RestapiCallNode()));
+ new RestconfApiCallNode(new RestapiCallNode(), new YangParserFactoryImpl()));
assertThat(rdn.getResponseCode("restapi-result", ctx),
is("200"));
assertThat(rdn.getResponseCode(null, ctx),
@@ -131,7 +133,7 @@ public class TestRestconfDiscoveryNode {
ctx.setAttribute("ietf-subscribed-notifications:establish-subscripti" +
"on.output.identifier", "89");
RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
- new RestconfApiCallNode(new RestapiCallNode()));
+ new RestconfApiCallNode(new RestapiCallNode(), new YangParserFactoryImpl()));
assertThat(rdn.getOutputIdentifier("restapi-result", ctx),
is("89"));
}
@@ -142,7 +144,7 @@ public class TestRestconfDiscoveryNode {
"futh9ho6eofy3wjsap7wqktemlqm4bbsmnar3vrtbyrzukbv5itd6m1cftldpjarny" +
"le3sdcqq9hftc4lebz464b5ffxmlbvg9";
RestconfDiscoveryNode rdn = new RestconfDiscoveryNode(
- new RestconfApiCallNode(new RestapiCallNode()));
+ new RestconfApiCallNode(new RestapiCallNode(), new YangParserFactoryImpl()));
assertThat(rdn.getTokenId(customHttpHeaders),
is("x-ik2ps4ikvzupbx0486ft1ebzs7rt85futh9ho6eofy3wjsap7wqkt" +
diff --git a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
index aa1e50d6a..a5353fad4 100644
--- a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
+++ b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/DataFormatSerializerTest.java
@@ -33,6 +33,8 @@ import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
@@ -75,6 +77,8 @@ public class DataFormatSerializerTest {
private RestapiCallNode restApi;
+ private YangParserFactory parserFactory;
+
private DfCaptor dfCaptor;
/**
@@ -90,6 +94,7 @@ public class DataFormatSerializerTest {
p.put("responsePrefix", "response");
p.put("skipSending", "true");
restApi = new RestapiCallNode();
+ parserFactory = new YangParserFactoryImpl();
restconf = mock(RestconfApiCallNode.class);
dfCaptor = new DfCaptor();
createMethodMocks();
@@ -102,6 +107,7 @@ public class DataFormatSerializerTest {
*/
private void createMethodMocks() throws SvcLogicException {
doReturn(restApi).when(restconf).getRestapiCallNode();
+ doReturn(parserFactory).when(restconf).getParserFactory();
doCallRealMethod().when(restconf).sendRequest(
any(Map.class), any(SvcLogicContext.class));
doCallRealMethod().when(restconf).sendRequest(
diff --git a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
index 1109d426c..9abbb16b7 100644
--- a/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
+++ b/plugins/restconf-client/provider/src/test/java/org/onap/ccsdk/sli/plugins/yangserializers/dfserializer/IdentifierValidationTest.java
@@ -33,6 +33,8 @@ import org.onap.ccsdk.sli.plugins.restapicall.HttpResponse;
import org.onap.ccsdk.sli.plugins.restapicall.RestapiCallNode;
import org.onap.ccsdk.sli.plugins.restconfapicall.RestconfApiCallNode;
import org.opendaylight.restconf.common.context.InstanceIdentifierContext;
+import org.opendaylight.yangtools.yang.model.parser.api.YangParserFactory;
+import org.opendaylight.yangtools.yang.parser.impl.YangParserFactoryImpl;
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;
@@ -64,6 +66,8 @@ public class IdentifierValidationTest {
private RestapiCallNode restApi;
+ private YangParserFactory parserFactory;
+
private DfCaptor dfCaptor;
/**
@@ -79,6 +83,7 @@ public class IdentifierValidationTest {
p.put("responsePrefix", "response");
p.put("skipSending", "true");
restApi = new RestapiCallNode();
+ parserFactory = new YangParserFactoryImpl();
restconf = mock(RestconfApiCallNode.class);
dfCaptor = new DfCaptor();
createMethodMocks();
@@ -91,6 +96,7 @@ public class IdentifierValidationTest {
*/
private void createMethodMocks() throws SvcLogicException {
doReturn(restApi).when(restconf).getRestapiCallNode();
+ doReturn(parserFactory).when(restconf).getParserFactory();
doCallRealMethod().when(restconf).sendRequest(
any(Map.class), any(SvcLogicContext.class));
doCallRealMethod().when(restconf).sendRequest(