### Question:
MetadataEntity implements Iterable<MetadataEntity.KeyValue> { public static Builder builder() { return new Builder(); } private  MetadataEntity(LinkedHashMap<String, String> details, String type);  MetadataEntity(MetadataEntity metadataEntity); static MetadataEntity ofNamespace(String namespace); static MetadataEntity ofDataset(String datasetName); static MetadataEntity ofDataset(String namespace, String datasetName); List<MetadataEntity.KeyValue> head(String splitKey); String getDescription(); String getType(); @Nullable String getValue(String key); boolean containsKey(String key); Iterable<String> getKeys(); static Builder builder(); static Builder builder(MetadataEntity metadataEntity); @Override Iterator<KeyValue> iterator(); @Override String toString(); @Override boolean equals(Object o); @Override int hashCode(); static final String NAMESPACE; static final String APPLICATION; static final String ARTIFACT; static final String VERSION; static final String DATASET; static final String TYPE; static final String PROGRAM; static final String SCHEDULE; static final String PROGRAM_RUN; }### Answer:
@Test public void testInvalidKeys() { try { MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns") .appendAsType(MetadataEntity.DATASET, "ds").append(MetadataEntity.DATASET, "soemthing"); Assert.fail(); } catch (IllegalArgumentException e) { } try { MetadataEntity.builder().append("", "ns"); Assert.fail(); } catch (IllegalArgumentException e) { } }
@Test public void testBuilder() { try { MetadataEntity.builder().build(); Assert.fail(); } catch (IllegalArgumentException e) { } MetadataEntity metadataEntity = MetadataEntity.builder().append(MetadataEntity.NAMESPACE, "ns") .appendAsType(MetadataEntity.DATASET, "myDataset").build(); assertEquals(metadataEntity.getKeys(), MetadataEntity.NAMESPACE, MetadataEntity.DATASET); assertEquals(metadataEntity.getValues(), "ns", "myDataset"); }