Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Throw exception for invalid plan name #426

Merged
merged 3 commits into from
Dec 18, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import com.fasterxml.jackson.databind.deser.std.StdDeserializer;
import com.fasterxml.jackson.databind.node.ArrayNode;
import com.purbon.kafka.topology.Configuration;
import com.purbon.kafka.topology.exceptions.TopologyParsingException;
import com.purbon.kafka.topology.exceptions.ValidationException;
import com.purbon.kafka.topology.model.PlanMap;
import com.purbon.kafka.topology.model.SubjectNameStrategy;
Expand Down Expand Up @@ -85,10 +86,10 @@ public Topic deserialize(JsonParser parser, DeserializationContext context) thro
Map<String, String> planConfigObject = plans.get(planLabel).getConfig();
planConfigObject.forEach(config::putIfAbsent);
} else {
LOGGER.warn(planLabel + " is missing in the plans definition. It will be ignored.");
throw new TopologyParsingException(
"Topic \"" + name "\" references non-existing plan \"" + planLabel + "\"");
akselh marked this conversation as resolved.
Show resolved Hide resolved
}
});

Topic topic = new Topic(name, producers, consumers, optionalDataType, config, this.config);

Optional<SubjectNameStrategy> subjectNameStrategy =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ public void testTopologyWithPlansButWithNoPlansDef() throws IOException {
TopologyObjectBuilder.build(descriptorFile);
}

@Test(expected = TopologyParsingException.class)
public void testTopologyWithInvalidPlan() throws IOException {
String descriptorFile = TestUtils.getResourceFilename("/descriptor-with-invalid-plan.yaml");
String plansFile = TestUtils.getResourceFilename("/plans.yaml");
TopologyObjectBuilder.build(descriptorFile, plansFile);
}

@Test(expected = TopologyParsingException.class)
public void testInvalidTopology() throws IOException {
String descriptorFile =
Expand Down
10 changes: 10 additions & 0 deletions src/test/resources/descriptor-with-invalid-plan.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
---
context: "contextOrg"
source: "source"
projects:
- name: "foo"
topics:
- name: "fooBar"
plan: "gold"
- name: "barFoo"
plan: "invalid-plan-name"