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

Enrich YangParserTestUtils with String literal YANG methods

XMLWordPrintable

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

      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()).

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

              Created:
              Updated:
              Resolved: