Commit b3e8c348 authored by Komal Makkar's avatar Komal Makkar
Browse files

checkstyle changes

parent 467e65bc
Pipeline #28167 failed with stage
in 40 seconds
......@@ -310,7 +310,7 @@
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.version}</version>
</plugin>
<!-- <plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-checkstyle-plugin</artifactId>
<version>${checkstyle.version}</version>
......@@ -331,7 +331,7 @@
</goals>
</execution>
</executions>
</plugin>-->
</plugin>
</plugins>
</build>
......
......@@ -20,11 +20,14 @@ import lombok.Data;
import lombok.NoArgsConstructor;
import org.opengroup.osdu.core.common.partition.Property;
@NoArgsConstructor
@AllArgsConstructor
/**
* Azure event grid topic data partition variables.
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public class EventGridTopicPartitionInfoAzure {
Property TopicName;
Property TopicAccessKey;
private Property topicName;
private Property topicAccessKey;
}
......@@ -8,12 +8,15 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import org.opengroup.osdu.common.Validators;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.*;
import org.opengroup.osdu.core.common.partition.IPartitionFactory;
import org.opengroup.osdu.core.common.partition.IPartitionProvider;
import org.opengroup.osdu.core.common.partition.PartitionException;
import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.List;
/**
* Partition service client implementation.
......
......@@ -20,7 +20,11 @@ import org.opengroup.osdu.azure.util.AzureServicePrincipleTokenService;
import org.opengroup.osdu.common.Validators;
import org.opengroup.osdu.core.common.model.http.AppException;
import org.opengroup.osdu.core.common.model.http.DpsHeaders;
import org.opengroup.osdu.core.common.partition.*;
import org.opengroup.osdu.core.common.partition.IPartitionFactory;
import org.opengroup.osdu.core.common.partition.IPartitionProvider;
import org.opengroup.osdu.core.common.partition.PartitionException;
import org.opengroup.osdu.core.common.partition.PartitionInfo;
import org.opengroup.osdu.core.common.partition.Property;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
......@@ -29,6 +33,9 @@ import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;
/**
* Partition service client for Event Grid implementation.
*/
@Service
@Lazy
public class PartitionServiceEventGridClient {
......@@ -43,13 +50,15 @@ public class PartitionServiceEventGridClient {
private DpsHeaders headers;
/**
* @param partitionId
* @param topicName
* @return
* @throws AppException
* @throws PartitionException
* Get TopicInfo for a given topic.
*
* @param partitionId partitionId
* @param topicName topicName
* @return EventGridTopicPartitionInfoAzure
* @throws AppException exception from the configuration
* @throws PartitionException AppException Exception thrown by {@link IPartitionFactory}
*/
public EventGridTopicPartitionInfoAzure getEventGridTopicInPartition(final String partitionId, String topicName) throws AppException, PartitionException {
public EventGridTopicPartitionInfoAzure getEventGridTopicInPartition(final String partitionId, final String topicName) throws AppException, PartitionException {
Validators.checkNotNullAndNotEmpty(partitionId, "partitionId");
Validators.checkNotNullAndNotEmpty(topicName, "topicName");
......@@ -66,7 +75,8 @@ public class PartitionServiceEventGridClient {
*
* @param partitionId Partition Id
* @return Partition info
* @throws AppException Exception thrown by {@link IPartitionFactory}
* @throws AppException Exception thrown by {@link IPartitionFactory}
* @throws PartitionException Exception thrown by {@link IPartitionFactory}
*/
Map<String, EventGridTopicPartitionInfoAzure> getAllEventGridTopicsInPartition(final String partitionId) throws AppException, PartitionException {
Validators.checkNotNullAndNotEmpty(partitionId, "partitionId");
......@@ -91,31 +101,37 @@ public class PartitionServiceEventGridClient {
}
/**
* @param partitionId
* @return
* @throws PartitionException
* @param partitionId partitionId
* @return PartitionInfo
* @throws PartitionException Exception thrown by {@link IPartitionFactory}
*/
PartitionInfo getPartitionInfo(String partitionId) throws PartitionException {
PartitionInfo getPartitionInfo(final String partitionId) throws PartitionException {
IPartitionProvider serviceClient = getServiceClient();
return serviceClient.get(partitionId);
}
/**
* @param property
* @return
* Util to identify if property is for event grid topic.
*
* @param property property
* @return isEventGridProperty
*/
private boolean isEventGridProperty(Map.Entry<String, Property> property) {
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));
}
/**
* @param topics
* @param property
* @param stringTokenizer
* Populate the map.
*
* @param topics topics
* @param property properties
* @param stringTokenizer tokenizer util
*/
private void addEventGridAccessKey(Map<String, EventGridTopicPartitionInfoAzure> topics, Map.Entry<String, Property> property, StringTokenizer stringTokenizer) {
private void addEventGridAccessKey(final Map<String, EventGridTopicPartitionInfoAzure> topics,
final Map.Entry<String, Property> property,
final StringTokenizer stringTokenizer) {
stringTokenizer.nextToken();
String key = stringTokenizer.nextToken();
if (topics.containsKey(key)) {
......@@ -129,11 +145,15 @@ public class PartitionServiceEventGridClient {
}
/**
* @param topics
* @param property
* @param stringTokenizer
* Populate the map.
*
* @param topics topics
* @param property properties
* @param stringTokenizer tokenizer util
*/
private void addEventGridTopicName(Map<String, EventGridTopicPartitionInfoAzure> topics, Map.Entry<String, Property> property, StringTokenizer stringTokenizer) {
private void addEventGridTopicName(final Map<String, EventGridTopicPartitionInfoAzure> topics,
final Map.Entry<String, Property> property,
final StringTokenizer stringTokenizer) {
stringTokenizer.nextToken();
String key = stringTokenizer.nextToken();
if (topics.containsKey(key)) {
......
......@@ -77,8 +77,8 @@ class EventGridTopicClientFactoryImplTest {
// Setup
when(this.partitionService.getEventGridTopicInPartition(VALID_DATA_PARTIION_ID, "validtopic")).thenReturn(
EventGridTopicPartitionInfoAzure.builder()
.TopicName(Property.builder().value(VALID_TOPIC_NAME).build())
.TopicAccessKey(Property.builder().value(VALID_TOPICKEY_NAME).build()).build());
.topicName(Property.builder().value(VALID_TOPIC_NAME).build())
.topicAccessKey(Property.builder().value(VALID_TOPICKEY_NAME).build()).build());
when(this.clientCache.containsKey(any())).thenReturn(false);
......
......@@ -60,8 +60,8 @@ class EventGridTopicStoreTest {
@Test
public void should_throwException_given_invalidURI() throws PartitionException {
doReturn(EventGridTopicPartitionInfoAzure.builder()
.TopicName(Property.builder().value(INVALID_URI).build())
.TopicAccessKey(Property.builder().value("validkey").build()).build())
.topicName(Property.builder().value(INVALID_URI).build())
.topicAccessKey(Property.builder().value("validkey").build()).build())
.when(this.partitionService).getEventGridTopicInPartition(anyString(), anyString());
......@@ -76,8 +76,8 @@ class EventGridTopicStoreTest {
public void should_should_invoke_publishEvents() throws PartitionException {
doReturn(EventGridTopicPartitionInfoAzure.builder()
.TopicName(Property.builder().value(VALID_TOPIC).build())
.TopicAccessKey(Property.builder().value("validkey").build()).build())
.topicName(Property.builder().value(VALID_TOPIC).build())
.topicAccessKey(Property.builder().value("validkey").build()).build())
.when(this.partitionService).getEventGridTopicInPartition(anyString(), anyString());
when(this.eventGridTopicClientFactory.getClient(VALID_DATA_PARTIION_ID, "validTopic")).thenReturn(this.eventGridClient);
......
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