Skip to content

Commit

Permalink
Fixing DownloadSchemaRegistryMojoTest tests
Browse files Browse the repository at this point in the history
  • Loading branch information
danielpetisme committed Dec 8, 2020
1 parent e8f89f8 commit 968b050
Showing 1 changed file with 22 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;

Expand All @@ -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<File> files = new ArrayList<>();
List<File> filesToDownload = new ArrayList<>();
List<File> filesNotToDownload = new ArrayList<>();
this.mojo.subjectPatterns.clear();

for (int i = 0; i < 100; i++) {
Expand All @@ -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));
}
}

}

0 comments on commit 968b050

Please sign in to comment.