Uploaded image for project: 'yangtools'
  1. yangtools
  2. YANGTOOLS-1483

Enrich YangParserTestUtils with String literal YANG methods

    XMLWordPrintable

Details

    • New Feature
    • Status: Resolved
    • Highest
    • Resolution: Done
    • None
    • 11.0.0, 9.0.9, 10.0.9
    • parser

    Description

      A number of integration tests end up parsing a simple YANG file and make assertions on that.

      For example, MDSAL-810 ends up doing:

      final var it = DefaultBindingGenerator.generateFor(
          YangParserTestUtils.parseYangResource("/mdsal-810/root-conflict.yang")).iterator();
      

      and the input file is, literally:

      module root-conflict { // results in RootConflictData
        namespace root-conflict;
        prefix rc;
      
        container root-conflict-data; // results in RootConflictData as well
      }
      

      i.e. a bare-minimum model.

      Add YangParserTestUtils.parseYang(String... yangContent), which will create the appropriate YangTextSchemaSource (or deeper, as we should derive SourceIdentifier from the content by inspecting the IR). With that we should be able to do the above with:

      final var it = DefaultBindingGenerator.generateFor(YangParserTestUtils.parseYang("""
        module root-conflict { // results in RootConflictData
          namespace root-conflict;
          prefix rc;
      
          container root-conflict-data; // results in RootConflictData as well
        }""")).iterator();

      This means we do not need to maintain a src/test/resources file and deal with whether it is accessible across modules (as needed for for Class.getResource()).

      Attachments

        Issue Links

          No reviews matched the request. Check your Options in the drop-down menu of this sections header.

          Activity

            People

              matusmatok Matúš Matok
              rovarga Robert Varga
              Votes:
              0 Vote for this issue
              Watchers:
              7 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: