Skip to content
Open
Show file tree
Hide file tree
Changes from all 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 @@ -197,8 +197,10 @@ protected void validateLiteSubTopic(ProxyContext ctx, String group, Set<Subscrip
if (CollectionUtils.isEmpty(subList)) {
return;
}
// check bindTopic for sub list
validateLiteBindTopic(ctx, group, subList.iterator().next().getTopic());
// check bindTopic for every subscription in the sub list
for (SubscriptionData subscriptionData : subList) {
validateLiteBindTopic(ctx, group, subscriptionData.getTopic());
}
}

protected void validateLiteBindTopic(ProxyContext ctx, String group, String bindTopic) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,27 @@ public void testValidateLiteSubTopic_validSubList_noException() {
});
}

@Test
public void testValidateLiteSubTopic_mismatchedSecondTopic_throwsException() {
String group = "group";
String bindTopic = "topic1";
SubscriptionData matching = new SubscriptionData();
matching.setTopic(bindTopic);
SubscriptionData mismatching = new SubscriptionData();
mismatching.setTopic("topic2");
Set<SubscriptionData> subList = new HashSet<>();
subList.add(matching);
subList.add(mismatching);

when(groupConfig.getLiteBindTopic()).thenReturn(bindTopic);
when(messagingProcessor.getSubscriptionGroupConfig(ctx, group)).thenReturn(groupConfig);

GrpcProxyException exception = assertThrows(GrpcProxyException.class, () -> {
clientProcessor.validateLiteSubTopic(ctx, group, subList);
});
assertTrue(exception.getMessage().contains("expected to bind topic"));
}

@Test
public void testValidateLiteBindTopic_matchingTopics_noException() {
String group = "group";
Expand Down