### Question:
UpdateDatasetCommand extends BaseDatasetCommand { @Override public int run() throws IOException { if (datasets == null || datasets.size() != 1) { throw new IllegalArgumentException( "Exactly one dataset name must be specified."); } String dataset = datasets.remove(0); Dataset<GenericRecord> currentDataset = load(dataset).getDataset(); DatasetDescriptor.Builder descriptorBuilder = new DatasetDescriptor .Builder(currentDataset.getDescriptor()); if (avroSchemaFile != null) { descriptorBuilder.schemaUri(qualifiedURI(avroSchemaFile)); } if (partitionStrategyFile != null) { descriptorBuilder.partitionStrategyUri( qualifiedURI(partitionStrategyFile)); } if (properties != null) { for (String propValue : properties) { Iterator<String> parts = PROP_VALUE_SEP.split(propValue).iterator(); descriptorBuilder.property( Iterators.getNext(parts, null), Iterators.getNext(parts, null)); } } DatasetDescriptor descriptor = descriptorBuilder.build(); if (isDatasetOrViewUri(dataset)) { Datasets.<GenericData.Record, Dataset<GenericData.Record>> update(dataset, descriptor, GenericData.Record.class); } else { getDatasetRepository().update(namespace, dataset, descriptor); } console.debug("Updated {}", dataset); return 0; } UpdateDatasetCommand(Logger console); @Override int run(); @Override List<String> getExamples();  }### Answer:
@Test public void testBasicUse() throws Exception { command.datasets = Lists.newArrayList("users"); command.run(); verify(repo).load("default", "users"); verify(ds).getDescriptor(); verify(repo).update(eq("default"), eq("users"), argThat(TestUtil.matches(original))); verify(console).debug(contains("Updated"), eq("users")); }
@Test public void testUpdateSchema() throws Exception { File avroSchemaFile = new File("target/schema_update.avsc"); new FileWriter(avroSchemaFile).append(schema2).close(); command.datasets = Lists.newArrayList("users"); command.avroSchemaFile = avroSchemaFile.toString(); command.run(); DatasetDescriptor updated = new DatasetDescriptor.Builder(original) .schemaLiteral(schema2) .build(); verify(repo).load("default", "users"); verify(ds).getDescriptor(); verify(repo).update(eq("default"), eq("users"), argThat(TestUtil.matches(updated))); verify(console).debug(contains("Updated"), eq("users")); }
@Test public void testAddProperty() throws Exception { command.datasets = Lists.newArrayList("users"); command.properties = Lists.newArrayList( "new.property=1234", "prop=with=equals" ); command.run(); DatasetDescriptor updated = new DatasetDescriptor.Builder(original) .property("new.property", "1234") .property("prop", "with=equals") .build(); verify(repo).load("default", "users"); verify(ds).getDescriptor(); verify(repo).update(eq("default"), eq("users"), argThat(TestUtil.matches(updated))); verify(console).debug(contains("Updated"), eq("users")); }
@Test public void testZeroDatasets() throws Exception { command.datasets = Lists.newArrayList(); TestHelpers.assertThrows("Should require one dataset", IllegalArgumentException.class, new Callable<Void>() { @Override public Void call() throws IOException { command.run(); return null; } }); verifyZeroInteractions(console); }
@Test public void testMultipleDatasets() throws Exception { command.datasets = Lists.newArrayList("users", "moreusers"); TestHelpers.assertThrows("Should reject multiple datasets", IllegalArgumentException.class, new Callable<Void>() { @Override public Void call() throws IOException { command.run(); return null; } }); verifyZeroInteractions(console); }
@Test public void testNonExistentAvroSchemaFile() throws Exception { command.avroSchemaFile = "nonexistent.avsc"; command.datasets = Lists.newArrayList("users"); TestHelpers.assertThrows("Should fail on missing schema", FileNotFoundException.class, new Callable() { @Override public Void call() throws Exception { command.run(); return null; } }); verifyZeroInteractions(console); }