diff --git a/maven-plugin/src/test/java/io/confluent/kafka/schemaregistry/maven/DownloadSchemaRegistryMojoTest.java b/maven-plugin/src/test/java/io/confluent/kafka/schemaregistry/maven/DownloadSchemaRegistryMojoTest.java index 7952757c7b2..29b4694e76f 100644 --- a/maven-plugin/src/test/java/io/confluent/kafka/schemaregistry/maven/DownloadSchemaRegistryMojoTest.java +++ b/maven-plugin/src/test/java/io/confluent/kafka/schemaregistry/maven/DownloadSchemaRegistryMojoTest.java @@ -19,6 +19,9 @@ import io.confluent.kafka.schemaregistry.client.MockSchemaRegistryClient; import io.confluent.kafka.schemaregistry.client.rest.exceptions.RestClientException; import org.apache.avro.Schema; +import org.apache.maven.plugin.MojoExecutionException; +import org.apache.maven.plugin.MojoFailureException; +import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -28,6 +31,8 @@ import java.util.Arrays; import java.util.List; +import static org.hamcrest.CoreMatchers.is; + public class DownloadSchemaRegistryMojoTest extends SchemaRegistryTest { DownloadSchemaRegistryMojo mojo; @@ -38,10 +43,11 @@ public void createMojo() { } @Test - public void specificSubjects() throws IOException, RestClientException { - int version = 1; + public void specificSubjects() throws IOException, RestClientException, MojoFailureException, MojoExecutionException { + this.mojo.outputDirectory = this.tempDirectory; - List files = new ArrayList<>(); + List filesToDownload = new ArrayList<>(); + List filesNotToDownload = new ArrayList<>(); this.mojo.subjectPatterns.clear(); for (int i = 0; i < 100; i++) { @@ -55,12 +61,22 @@ public void specificSubjects() throws IOException, RestClientException { File valueSchemaFile = new File(this.tempDirectory, valueSubject + ".avsc"); if (i % 10 == 0) { - String subjectPattern = String.format("^TestSubject%03d-(Key|Value)$", i); - files.add(keySchemaFile); - files.add(valueSchemaFile); + String subjectPattern = String.format("^TestSubject%03d-(key|value)$", i); + filesToDownload.add(keySchemaFile); + filesToDownload.add(valueSchemaFile); this.mojo.subjectPatterns.add(subjectPattern); + } else { + filesNotToDownload.add(keySchemaFile); + filesNotToDownload.add(valueSchemaFile); } } + this.mojo.execute(); + for (File file: filesToDownload) { + Assert.assertThat(file.exists(), is(true)); + } + for (File file: filesNotToDownload) { + Assert.assertThat(file.exists(), is(false)); + } } }