Commit 85955c2c authored by Komal Makkar's avatar Komal Makkar
Browse files

minor changes

parent 4988e4ab
Pipeline #28185 failed with stage
in 16 seconds
......@@ -39,6 +39,8 @@ import java.util.StringTokenizer;
@Service
@Lazy
public class PartitionServiceEventGridClient {
private static final String ACCESS_KEY_REGEX = "^eventgrid-([a-zA-Z0-9]*)topic-accesskey$";
private static final String TOPIC_NAME_REGEX = "^eventgrid-([a-zA-Z0-9]*)topic$";
@Autowired
private IPartitionFactory partitionFactory;
......@@ -93,7 +95,7 @@ public class PartitionServiceEventGridClient {
} else if (stringTokenizer.countTokens() == 3) {
addEventGridAccessKey(topics, property, stringTokenizer);
} else {
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Invalid EventGrid Partition configuration for the partition " + partitionId, "Please refer to wiki here <>");
throw new AppException(HttpStatus.SC_INTERNAL_SERVER_ERROR, "Invalid EventGrid Partition configuration for the partition " + partitionId, "Please reconfigure the partition service");
}
}
}
......@@ -117,9 +119,7 @@ public class PartitionServiceEventGridClient {
* @return isEventGridProperty
*/
private boolean isEventGridProperty(final Map.Entry<String, Property> property) {
String accessKeyRegex = "^eventgrid-([a-zA-Z0-9]*)topic-accesskey$";
String topicNameRegex = "^eventgrid-([a-zA-Z0-9]*)topic$";
return property.getKey().matches((accessKeyRegex)) || property.getKey().matches((topicNameRegex));
return property.getKey().matches((ACCESS_KEY_REGEX)) || property.getKey().matches((TOPIC_NAME_REGEX));
}
/**
......
......@@ -92,7 +92,7 @@ public class PartitionServiceEventGridClientTest {
}
@Test
public void getTopicName() throws PartitionException {
public void should_throwWhenInvalid_getEventGridTopicInPartition() throws PartitionException {
final String eventGridTopicName1 = "testEventGridTopicName1";
final String eventGridTopicAccessKey1 = "testEventGridTopicAccessKey1";
Map<String, Property> properties = new HashMap<>();
......@@ -115,9 +115,7 @@ public class PartitionServiceEventGridClientTest {
assertEquals(eventGridTopicPartitionInfoAzure.getTopicAccessKey().getValue(), eventGridTopicAccessKey1);
// Assert negative
AppException exception = assertThrows(AppException.class, () -> {
partitionServiceClientSpy.getEventGridTopicInPartition("tenant1", "recordschangedtopic");
});
AppException exception = assertThrows(AppException.class, () -> partitionServiceClientSpy.getEventGridTopicInPartition("tenant1", "recordschangedtopic"));
assertEquals(500, exception.getError().getCode());
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment