* Util class for Restconf constants.
*/
public final class RestconfConstants {
- public static final String MOUNT = "yang-ext:mount";
public static final Splitter SLASH_SPLITTER = Splitter.on('/');
public static final String BASE_URI_PATTERN = "rests";
public static final String NOTIF = "notif";
+ // FIXME: Remove this constant. All logic relying on this constant should instead rely on YangInstanceIdentifier
+ // equivalent coming out of argument parsing. This may require keeping List<YangInstanceIdentifier> as the
+ // nested path split on yang-ext:mount. This splitting needs to be based on consulting the
+ // EffectiveModelContext and allowing it only where yang-ext:mount is actually used in models.
+ public static final String MOUNT = "yang-ext:mount";
+
private RestconfConstants() {
// Hidden on purpose
}
import org.opendaylight.restconf.nb.rfc8040.TestRestconfUtils;
import org.opendaylight.restconf.nb.rfc8040.handlers.SchemaContextHandler;
import org.opendaylight.restconf.nb.rfc8040.rests.services.api.RestconfSchemaService;
-import org.opendaylight.restconf.nb.rfc8040.utils.RestconfConstants;
import org.opendaylight.yangtools.yang.common.QName;
import org.opendaylight.yangtools.yang.common.Revision;
import org.opendaylight.yangtools.yang.data.api.YangInstanceIdentifier;
*/
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class RestconfSchemaServiceTest {
- private static final String MOUNT_POINT = "mount-point-1:cont" + "/" + RestconfConstants.MOUNT + "/";
- private static final String NULL_MOUNT_POINT = "mount-point-2:cont" + "/" + RestconfConstants.MOUNT + "/";
- private static final String NOT_EXISTING_MOUNT_POINT = "mount-point-3:cont" + "/" + RestconfConstants.MOUNT + "/";
+ private static final String MOUNT_POINT = "mount-point-1:cont/yang-ext:mount/";
+ private static final String NULL_MOUNT_POINT = "mount-point-2:cont/yang-ext:mount/";
+ private static final String NOT_EXISTING_MOUNT_POINT = "mount-point-3:cont/yang-ext:mount/";
private static final String TEST_MODULE = "module1/2014-01-01";
private static final String TEST_MODULE_BEHIND_MOUNT_POINT = "module1-behind-mount-point/2014-02-03";
@RunWith(MockitoJUnitRunner.StrictStubs.class)
public class ParserIdentifierTest {
// mount point identifier
- private static final String MOUNT_POINT_IDENT =
- "mount-point:mount-container/point-number" + "/" + RestconfConstants.MOUNT;
+ private static final String MOUNT_POINT_IDENT = "mount-point:mount-container/point-number/yang-ext:mount";
// invalid mount point identifier
- private static final String INVALID_MOUNT_POINT_IDENT =
- "mount-point:point-number" + "/" + RestconfConstants.MOUNT;
+ private static final String INVALID_MOUNT_POINT_IDENT = "mount-point:point-number/yang-ext:mount";
// test identifier + expected result
private static final String TEST_IDENT =
@Test
public void toInstanceIdentifierMissingMountPointNegativeTest() {
RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
- () -> ParserIdentifier.toInstanceIdentifier("" + "/" + RestconfConstants.MOUNT, SCHEMA_CONTEXT,
+ () -> ParserIdentifier.toInstanceIdentifier("/yang-ext:mount", SCHEMA_CONTEXT,
Optional.of(this.mountPointService)));
assertEquals("Not expected error type", RestconfError.ErrorType.PROTOCOL, ex.getErrors().get(0).getErrorType());
assertEquals("Not expected error tag", ErrorTag.RESOURCE_DENIED_TRANSPORT, ex.getErrors().get(0).getErrorTag());
@Test
public void toInstanceIdentifierMissingMountPointServiceNegativeTest() {
RestconfDocumentedException ex = assertThrows(RestconfDocumentedException.class,
- () -> ParserIdentifier.toInstanceIdentifier(RestconfConstants.MOUNT, SCHEMA_CONTEXT, Optional.empty()));
+ () -> ParserIdentifier.toInstanceIdentifier("yang-ext:mount", SCHEMA_CONTEXT, Optional.empty()));
assertEquals("Not expected error type", ErrorType.APPLICATION, ex.getErrors().get(0).getErrorType());
assertEquals("Not expected error tag", ErrorTag.OPERATION_FAILED, ex.getErrors().get(0).getErrorTag());
assertEquals("Not expected error status code", 500, ex.getErrors().get(0).getErrorTag().getStatusCode());
@Test
public void toSchemaExportContextFromIdentifierNullSchemaContextBehindMountPointNegativeTest() {
assertThrows(IllegalStateException.class, () -> ParserIdentifier.toSchemaExportContextFromIdentifier(
- SCHEMA_CONTEXT, "/" + RestconfConstants.MOUNT + "/" + TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION,
+ SCHEMA_CONTEXT, "/yang-ext:mount/" + TEST_MODULE_NAME + "/" + TEST_MODULE_REVISION,
this.mockMountPointService, sourceProvider));
}