### Question:
EntityId { public static <T extends EntityId> T fromString(String string) { return fromString(string, null); } protected  EntityId(EntityType entity); static void ensureValidId(String propertyName, String name); static void ensureValidArtifactId(String propertyName, String name); static boolean isValidId(String name); static boolean isValidArtifactId(String name); static void ensureValidDatasetId(String propertyName, String datasetId); static boolean isValidDatasetId(String datasetId); static void ensureValidNamespace(String namespace); static boolean isValidNamespace(String namespace); static boolean isValidVersionId(String datasetId); abstract Iterable<String> toIdParts(); abstract String getEntityName(); MetadataEntity toMetadataEntity(); static T fromMetadataEntity(MetadataEntity metadataEntity); static T getSelfOrParentEntityId(MetadataEntity metadataEntity); final EntityType getEntityType(); static T fromString(String string); @Override final String toString(); @Override boolean equals(Object o); @Override int hashCode(); Iterable<EntityId> getHierarchy(); static final String IDSTRING_TYPE_SEPARATOR; static final String IDSTRING_PART_SEPARATOR; static final Pattern IDSTRING_PART_SEPARATOR_PATTERN; }### Answer:
@Test public void testDatasetName() { DatasetId.fromString("dataset:foo.Zo123_-$$_-"); DatasetId dataset = DatasetId.fromString("dataset:foo.app.meta"); Assert.assertEquals("foo", dataset.getNamespace()); Assert.assertEquals("app.meta", dataset.getDataset()); dataset = DatasetId.fromString("dataset:foo.app.meta.second"); Assert.assertEquals("app.meta.second", dataset.getDataset()); try { DatasetId.fromString("dataset:i have a space in my name"); Assert.fail("Dataset Id with space in its name was created successfully while it should have failed."); } catch (IllegalArgumentException e) { } try { DatasetId.fromString("dataset:.should.have.a.namespace.name"); Assert.fail("Dataset Id without namespace in its name was created successfully while it should have failed."); } catch (IllegalArgumentException e) { } try { DatasetId.fromString("dataset:foo"); Assert.fail("Dataset Id creation should fail without dataset name"); } catch (IllegalArgumentException e) { Assert.assertEquals("Missing field: dataset", e.getCause().getMessage()); } }
@Test public void testMissingApplicationName() { try { ApplicationId.fromString("application:ns1"); Assert.fail(); } catch (IllegalArgumentException e) { Assert.assertEquals("Missing field: application", e.getCause().getMessage()); } }