|
13 | 13 |
|
14 | 14 | import static org.junit.Assert.assertThrows; |
15 | 15 |
|
16 | | -public class SetCompatibilityMojoTest extends SchemaRegistryTest{ |
17 | | - SetCompatibilityMojo mojo; |
18 | | - |
19 | | - @Before |
20 | | - public void createMojoAndFiles() { |
21 | | - this.mojo = new SetCompatibilityMojo(); |
22 | | - this.mojo.client(new MockSchemaRegistryClient()); |
23 | | - } |
24 | | - |
25 | | - @Test |
26 | | - public void specificSubjects() throws IOException, RestClientException, MojoExecutionException { |
27 | | - String keySubject = String.format("TestSubject-key"); |
28 | | - Schema keySchema = Schema.create(Schema.Type.STRING); |
29 | | - |
30 | | - this.mojo.client().register(keySubject, new AvroSchema(keySchema)); |
31 | | - // Compatibility not set till now and hence should throw error |
32 | | - assertThrows("Checking that compatibility hasn't been set", |
33 | | - RestClientException.class, () -> this.mojo.client().getCompatibility(keySubject)); |
34 | | - |
35 | | - // Setting compatibility & checking if it matches |
36 | | - this.mojo.compatibilityLevels.put(keySubject,"BACKWARD"); |
37 | | - this.mojo.execute(); |
38 | | - |
39 | | - assert(this.mojo.getConfig(keySubject).equals("BACKWARD")); |
40 | | - |
41 | | - //Updating to a different compatibility |
42 | | - this.mojo.compatibilityLevels.replace(keySubject, "BACKWARD", "FULL"); |
43 | | - this.mojo.execute(); |
44 | | - |
45 | | - assert(this.mojo.getConfig(keySubject).equals("FULL")); |
46 | | - |
47 | | - //Checking for Global Compatibility |
48 | | - this.mojo.compatibilityLevels.put("__GLOBAL", "BACKWARD_TRANSITIVE"); |
49 | | - this.mojo.execute(); |
50 | | - assert(this.mojo.getConfig(null).equals("BACKWARD_TRANSITIVE")); |
51 | | - |
52 | | - } |
| 16 | +public class SetCompatibilityMojoTest extends SchemaRegistryTest { |
| 17 | + SetCompatibilityMojo mojo; |
| 18 | + |
| 19 | + @Before |
| 20 | + public void createMojoAndFiles() { |
| 21 | + this.mojo = new SetCompatibilityMojo(); |
| 22 | + this.mojo.client(new MockSchemaRegistryClient()); |
| 23 | + } |
| 24 | + |
| 25 | + @Test |
| 26 | + public void specificSubjects() throws IOException, RestClientException, MojoExecutionException { |
| 27 | + String keySubject = String.format("TestSubject-key"); |
| 28 | + Schema keySchema = Schema.create(Schema.Type.STRING); |
| 29 | + |
| 30 | + this.mojo.client().register(keySubject, new AvroSchema(keySchema)); |
| 31 | + // Compatibility not set till now and hence should throw error |
| 32 | + assertThrows("Checking that compatibility hasn't been set", |
| 33 | + RestClientException.class, () -> this.mojo.client().getCompatibility(keySubject)); |
| 34 | + |
| 35 | + // Setting compatibility & checking if it matches |
| 36 | + this.mojo.compatibilityLevels.put(keySubject, "BACKWARD"); |
| 37 | + this.mojo.execute(); |
| 38 | + |
| 39 | + assert (this.mojo.getConfig(keySubject).equals("BACKWARD")); |
| 40 | + |
| 41 | + // Updating to a different compatibility |
| 42 | + this.mojo.compatibilityLevels.replace(keySubject, "BACKWARD", "FULL"); |
| 43 | + this.mojo.execute(); |
| 44 | + |
| 45 | + assert (this.mojo.getConfig(keySubject).equals("FULL")); |
| 46 | + |
| 47 | + // Checking for global compatibility |
| 48 | + this.mojo.compatibilityLevels.put("__GLOBAL", "BACKWARD_TRANSITIVE"); |
| 49 | + this.mojo.execute(); |
| 50 | + assert (this.mojo.getConfig(null).equals("BACKWARD_TRANSITIVE")); |
| 51 | + |
| 52 | + // Checking for invalid compatibility level |
| 53 | + this.mojo.compatibilityLevels.put(keySubject, "INVALID_LEVEL"); |
| 54 | + assertThrows(java.lang.IllegalArgumentException.class, () -> this.mojo.execute()); |
| 55 | + } |
53 | 56 | } |
0 commit comments