assertEquals(ErrorTags.RESOURCE_DENIED_TRANSPORT, error.getErrorTag());
}
+ /**
+ * Positive test of getting <code>SchemaExportContext</code> behind mount point for module without revision.
+ * Expected module name, prefix and namespace are verified.
+ */
+ @Test
+ void toSchemaExportContextFromIdentifierNullRevisionTest() {
+ mockMountPoint();
+
+ final var content = assertYang(MOUNT_POINT_IDENT, "module-without-revision", null);
+
+ assertEquals("""
+ module module-without-revision {
+ namespace module:without:revision;
+ prefix mwr;
+ }
+ """, content);
+ }
+
private void mockMountPoint() {
doReturn(Optional.of(new FixedDOMSchemaService(MODEL_CONTEXT_ON_MOUNT_POINT))).when(mountPoint)
.getService(DOMSchemaService.class);
}
/**
- * Negative test of module revision validation when there is no revision. Test fails catching
- * <code>RestconfDocumentedException</code> and checking for correct error type, error tag and error status code.
+ * Positive test of getting <code>SchemaExportContext</code> for module without revision.
+ * Expected module name, prefix and namespace are verified.
*/
@Test
- void validateAndGetRevisionNotSuppliedTest() {
- final var error = assertError(ar -> restconf.modulesYangGET("module", null, ar));
- assertEquals("Source module not found", error.getErrorMessage());
- assertEquals(ErrorType.APPLICATION, error.getErrorType());
- assertEquals(ErrorTag.DATA_MISSING, error.getErrorTag());
+ void validateAndGetModuleWithoutRevisionTest() {
+ final var content = assertYang(null, "module-without-revision", null);
+
+ assertEquals("""
+ module module-without-revision {
+ namespace module:without:revision;
+ prefix mwr;
+ }
+ """, content);
}
/**
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 java.util.List;
import org.junit.Before;
}
/**
- * Try to get schema with identifier which does not contain revision catching
- * <code>RestconfDocumentedException</code>. Error type, error tag and error status code are compared to expected
- * values.
+ * Try to get schema with identifier which does not contain revision catching and check if the correct module
+ * was found.
*/
@Test
- public void getSchemaWithoutRevisionTest() {
- final var error = assertError(ar -> restconf.modulesYinGET("module", null, ar));
- assertEquals("Source module not found", error.getErrorMessage());
- assertEquals(ErrorType.APPLICATION, error.getErrorType());
- assertEquals(ErrorTag.DATA_MISSING, error.getErrorTag());
+ public void getSchemaWithoutRevisionTest() throws IOException {
+ doReturn(Futures.immediateFuture(yangSource)).when(sourceProvider)
+ .getYangTexttSource(new SourceIdentifier("module-without-revision", (Revision) null));
+ doReturn(yangReader).when(yangSource).openStream();
+ assertSame(yangReader, assertEntity(Reader.class, 200,
+ ar -> restconf.modulesYangGET("module-without-revision", null, ar)));
}
}