diff --git a/src/main/java/com/purbon/kafka/topology/TopologyObjectBuilder.java b/src/main/java/com/purbon/kafka/topology/TopologyObjectBuilder.java index 4006f8acb..2fed1e437 100644 --- a/src/main/java/com/purbon/kafka/topology/TopologyObjectBuilder.java +++ b/src/main/java/com/purbon/kafka/topology/TopologyObjectBuilder.java @@ -55,6 +55,7 @@ private static List parseListOfTopologies( if (isDir) { Files.list(Paths.get(fileOrDir)) .sorted() + .filter(p -> !Files.isDirectory(p)) .map(path -> parser.deserialise(path.toFile())) .forEach(subTopology -> topologies.add(subTopology)); } else { diff --git a/src/test/java/com/purbon/kafka/topology/JulieOpsTest.java b/src/test/java/com/purbon/kafka/topology/JulieOpsTest.java index 341f33ba4..b43cfc32e 100644 --- a/src/test/java/com/purbon/kafka/topology/JulieOpsTest.java +++ b/src/test/java/com/purbon/kafka/topology/JulieOpsTest.java @@ -212,4 +212,32 @@ public void buiderRunTest() throws Exception { verify(topicManager, times(1)).apply(anyObject(), anyObject()); verify(accessControlManager, times(1)).apply(anyObject(), anyObject()); } + + @Test + public void builderRunTestAsFromDirectoryWithSchema() throws Exception { + String fileOrDirPath = TestUtils.getResourceFilename("/dir_with_subdir"); + + Configuration builderConfig = new Configuration(cliOps, props); + + JulieOps builder = + JulieOps.build( + fileOrDirPath, + builderConfig, + topologyAdminClient, + accessControlProvider, + bindingsBuilderProvider); + + builder.setTopicManager(topicManager); + builder.setAccessControlManager(accessControlManager); + + doNothing().when(topicManager).apply(anyObject(), anyObject()); + + doNothing().when(accessControlManager).apply(anyObject(), anyObject()); + + builder.run(); + builder.close(); + + verify(topicManager, times(1)).apply(anyObject(), anyObject()); + verify(accessControlManager, times(1)).apply(anyObject(), anyObject()); + } } diff --git a/src/test/java/com/purbon/kafka/topology/integration/RBACPRoviderRbacIT.java b/src/test/java/com/purbon/kafka/topology/integration/RBACPRoviderRbacIT.java index 1f7fdda82..4ca4fccaa 100644 --- a/src/test/java/com/purbon/kafka/topology/integration/RBACPRoviderRbacIT.java +++ b/src/test/java/com/purbon/kafka/topology/integration/RBACPRoviderRbacIT.java @@ -54,7 +54,6 @@ import org.mockito.Mock; import org.mockito.Mockito; import org.mockito.runners.MockitoJUnitRunner; -import org.testcontainers.shaded.com.google.common.eventbus.AllowConcurrentEvents; @RunWith(MockitoJUnitRunner.class) public class RBACPRoviderRbacIT extends MDSBaseTest { diff --git a/src/test/resources/dir_with_subdir/descriptor-with-others.yml b/src/test/resources/dir_with_subdir/descriptor-with-others.yml new file mode 100644 index 000000000..dfe16e048 --- /dev/null +++ b/src/test/resources/dir_with_subdir/descriptor-with-others.yml @@ -0,0 +1,55 @@ +--- +context: "contextOrg" +source: "source" +foo: "foo" +bar: "bar" +zet: "zet" +projects: + - name: "foo" + zookeepers: [] + consumers: + - principal: "User:App0" + - principal: "User:App1" + producers: [] + streams: + - principal: "User:App0" + topics: + read: + - "topicA" + - "topicB" + write: + - "topicC" + - "topicD" + connectors: + - principal: "User:Connect1" + topics: + read: + - "topicA" + - "topicB" + - principal: "User:Connect2" + topics: + write: + - "topicC" + - "topicD" + topics: + - name: "foo" + config: + replication.factor: "1" + num.partitions: "1" + - dataType: "avro" + name: "bar" + config: + replication.factor: "1" + num.partitions: "1" + - name: "bar" + zookeepers: [] + consumers: [] + producers: [] + streams: [] + connectors: [] + topics: + - dataType: "avro" + name: "bar" + config: + replication.factor: "1" + num.partitions: "1" \ No newline at end of file diff --git a/src/test/resources/dir_with_subdir/descriptor.yaml b/src/test/resources/dir_with_subdir/descriptor.yaml new file mode 100644 index 000000000..d320b687b --- /dev/null +++ b/src/test/resources/dir_with_subdir/descriptor.yaml @@ -0,0 +1,61 @@ +--- +context: "contextOrg" +source: "source" +projects: + - name: "foo" + zookeepers: [] + consumers: + - principal: "User:App0" + - principal: "User:App1" + producers: [] + streams: + - principal: "User:App0" + topics: + read: + - "topicA" + - "topicB" + write: + - "topicC" + - "topicD" + connectors: + - principal: "User:Connect1" + topics: + read: + - "topicA" + - "topicB" + - principal: "User:Connect2" + topics: + write: + - "topicC" + - "topicD" + topics: + - name: "foo" + config: + replication.factor: "1" + num.partitions: "1" + - dataType: "avro" + name: "bar" + config: + replication.factor: "1" + num.partitions: "1" + - name: "bar" + zookeepers: [] + consumers: [] + producers: [] + streams: [] + connectors: [] + topics: + - dataType: "avro" + name: "bar" + config: + replication.factor: "1" + num.partitions: "1" +platform: + schema_registry: + instances: + - principal: "User:SchemaRegistry01" + - principal: "User:SchemaRegistry02" + control_center: + instances: + - principal: "User:ControlCenter" + appId: "controlcenter" \ No newline at end of file diff --git a/src/test/resources/dir_with_subdir/schemas/bar-key.avsc b/src/test/resources/dir_with_subdir/schemas/bar-key.avsc new file mode 100644 index 000000000..5566b9f89 --- /dev/null +++ b/src/test/resources/dir_with_subdir/schemas/bar-key.avsc @@ -0,0 +1 @@ +{"type": "string"} diff --git a/src/test/resources/dir_with_subdir/schemas/bar-value.avsc b/src/test/resources/dir_with_subdir/schemas/bar-value.avsc new file mode 100644 index 000000000..5566b9f89 --- /dev/null +++ b/src/test/resources/dir_with_subdir/schemas/bar-value.avsc @@ -0,0 +1 @@ +{"type": "string"}