gaoran10 commented on a change in pull request #11986:
URL: https://github.com/apache/pulsar/pull/11986#discussion_r706854463
##########
File path:
pulsar-broker/src/test/java/org/apache/pulsar/broker/admin/PersistentTopicsTest.java
##########
@@ -389,6 +392,27 @@ public void testNonPartitionedTopics() {
0);
}
+ @Test
+ public void testGetPartitionedMetadata() {
+
+ String testLocalTopicName = "test-topic";
+
+ // 1) Auto create non-partitioned topic.
+ PartitionedTopicMetadata partitionedMetadata =
persistentTopics.getPartitionedMetadata(testTenant, testNamespace,
testLocalTopicName, true, true);
+ Assert.assertEquals(0, partitionedMetadata.partitions);
+
+ // 2. Add validate policy assert.
+ doThrow(new RestException(Response.Status.FORBIDDEN, "mock message"))
+
.when(persistentTopics).validateTopicPolicyOperation(persistentTopics.topicName,
PolicyName.PARTITION, PolicyOperation.WRITE);
+ try {
+ persistentTopics.getPartitionedMetadata(testTenant, testNamespace,
testLocalTopicName, true, true);
+ Assert.fail("Should fail validation on policy exception");
+ } catch (RestException e) {
+ Assert.assertEquals(Response.Status.FORBIDDEN.getStatusCode(),
e.getResponse().getStatus());
+ }
+
Review comment:
Could we add tests to when the param `checkAllowAutoCreation` is `false`?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]