Skip to content

[Improvement] Ensure that converting a string to a namespace validates all input #7516

@justinmclean

Description

@justinmclean

What would you like to be improved?

Add these tests to TestNamespace causes test failures:

  @Test
  public void testFromString() {
    Assertions.assertEquals(Namespace.empty(), Namespace.fromString(""));
    Assertions.assertEquals(Namespace.of("a", "b"), Namespace.fromString("a.b"));
    Assertions.assertEquals(Namespace.of("a"), Namespace.fromString("a"));
  }

  @Test
  public void testFromStringInvalidArgs() {
    Assertions.assertThrows(IllegalArgumentException.class, () -> Namespace.fromString(null));
    Assertions.assertThrows(IllegalArgumentException.class, () -> Namespace.fromString(".a"));
    Assertions.assertThrows(IllegalArgumentException.class, () -> Namespace.fromString("a."));
    Assertions.assertThrows(IllegalArgumentException.class, () -> Namespace.fromString("a..b"));
  }

How should we improve?

Fix fromString in Namespace.java so that the tests pass.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions