@Test public void testSchemaStdout() throws Exception { command.samplePaths = Lists.newArrayList("target/users.csv"); command.recordName = "User"; int rc = command.run(); Assert.assertEquals("Should return success code", 0, rc); verify(console).info(argThat(TestUtil.matchesSchema(schema))); verifyNoMoreInteractions(console); }
@Test public void testSchemaToFile() throws Exception { command.samplePaths = Lists.newArrayList("target/users.csv"); command.recordName = "User"; command.outputPath = "target/user.avsc"; int rc = command.run(); Assert.assertEquals("Should return success code", 0, rc); String fileContent = Files.toString(new File("target/user.avsc"), SchemaCommand.SCHEMA_CHARSET); Assert.assertTrue( "File should contain pretty printed schema", TestUtil.matchesSchema(schema).matches(fileContent)); verifyNoMoreInteractions(console); }