### Question:
IdGenerator { public static BigInteger generateNamespaceId( final String namespaceName, final BigInteger parentId) { if (!namespaceName.matches("^[a-z0-9][a-z0-9-_]*$")) { throw new IllegalIdentifierException("invalid namespace name"); } final ByteBuffer parentIdBuffer = ByteBuffer.allocate(8).order(ByteOrder.LITTLE_ENDIAN).putLong(parentId.longValue()); final byte[] hash = IdGenerator.getHashInLittleEndian(parentIdBuffer.array(), namespaceName.getBytes()); return ConvertUtils.toUnsignedBigInteger(ByteBuffer.wrap(hash).getLong() | ID_GENERATOR_FLAG); } private  IdGenerator(); static BigInteger generateMosaicId(final int nonce, final byte[] publicKey); static BigInteger generateNamespaceId(
      final String namespaceName, final BigInteger parentId); static BigInteger generateNamespaceId(String namespaceName, String parentNamespaceName); static BigInteger generateNamespaceId(String namespacePath); static List<BigInteger> generateNamespacePath(String namespacePath);  }### Answer:
@Test void namespacePathSupportsMultiLevelNamespaces2() { List<BigInteger> ids = new ArrayList<BigInteger>(); ids.add(IdGenerator.generateNamespaceId("foo", BigInteger.valueOf(0))); ids.add(IdGenerator.generateNamespaceId("bar", ids.get(0))); ids.add(IdGenerator.generateNamespaceId("baz", ids.get(1))); assertEquals(ids.get(2), IdGenerator.generateNamespaceId("baz", "foo.bar")); }
@Test void namespacePathSupportsMultiLevelNamespaces2a() { List<BigInteger> ids = new ArrayList<BigInteger>(); ids.add(IdGenerator.generateNamespaceId("nem", BigInteger.valueOf(0))); ids.add(IdGenerator.generateNamespaceId("subnem", ids.get(0))); ids.add(IdGenerator.generateNamespaceId("subsubnem", ids.get(1))); assertEquals(ids.get(2), IdGenerator.generateNamespaceId("subsubnem", "nem.subnem")); }
@Test void namespacePathSupportsMultiLevelNamespaces3() { List<BigInteger> ids = new ArrayList<BigInteger>(); ids.add(IdGenerator.generateNamespaceId("foo", BigInteger.valueOf(0))); ids.add(IdGenerator.generateNamespaceId("bar", ids.get(0))); ids.add(IdGenerator.generateNamespaceId("baz", ids.get(1))); assertEquals(ids.get(2), IdGenerator.generateNamespaceId("bar.baz", "foo")); }
@Test void namespaceNameInvalid() { assertThrows( IllegalIdentifierException.class, () -> { IdGenerator.generateNamespaceId("foo.bar", BigInteger.valueOf(0)); }, "contains dot"); assertThrows( IllegalIdentifierException.class, () -> { IdGenerator.generateNamespaceId("", BigInteger.valueOf(0)); }, "having zero length"); }