diff --git a/.github/workflows/maven-build.yml b/.github/workflows/maven-build.yml index 282720a..af33edd 100644 --- a/.github/workflows/maven-build.yml +++ b/.github/workflows/maven-build.yml @@ -26,7 +26,7 @@ jobs: distribution: 'zulu' - name: Build with Maven - run: mvn clean -B package -DskipTests=true --file pom.xml + run: mvn clean -B package --file pom.xml check_sonar_configured: runs-on: ubuntu-latest @@ -71,4 +71,4 @@ jobs: mvn --update-snapshots verify \ org.sonarsource.scanner.maven:sonar-maven-plugin:sonar \ -Dsonar.projectKey=eclipse-ecsp_streambase -Dsonar.organization=eclipse-ecsp \ - -Dcheckstyle.skip -Dpmd.skip=true \ No newline at end of file + -Dcheckstyle.skip -Dpmd.skip=true diff --git a/pom.xml b/pom.xml index 34680ff..1524073 100644 --- a/pom.xml +++ b/pom.xml @@ -1230,4 +1230,4 @@ - \ No newline at end of file + diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/AbstractLauncher.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/AbstractLauncher.java index c6c34ea..89c14c6 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/AbstractLauncher.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/AbstractLauncher.java @@ -64,10 +64,10 @@ * wrapper over some other messaging broker. Hence, that launcher class can extend from this abstract class * and get the common functionality. * - * @param the generic type for incoming key - * @param the generic type for incoming value - * @param the generic type for outgoing key - * @param the generic type for outgoing value + * @param the generic type for incoming key + * @param the generic type for incoming value + * @param the generic type for outgoing key + * @param > the generic type for outgoing value */ public abstract class AbstractLauncher implements LauncherProvider { @@ -125,7 +125,7 @@ public final void launch(Properties props) { } /** - * Method to define how would the streams, for eg. {@link KafkaStreams} be launched. + * Method to launch the application with streaming. * * @param props the props */ diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateAgentListener.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateAgentListener.java index 1d57540..12929ad 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateAgentListener.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateAgentListener.java @@ -46,5 +46,12 @@ * {@link org.apache.kafka.streams.KafkaStreams}. */ public interface KafkaStateAgentListener { + + /** + * Callback method to handle state changes in Kafka Streams. + * + * @param newState the new state of the Kafka Streams instance + * @param oldState the previous state of the Kafka Streams instance + */ void onChange(final State newState, final State oldState); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateListener.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateListener.java index a37bad4..4dbb8cd 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateListener.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStateListener.java @@ -56,17 +56,16 @@ import java.util.Map; /** - * An implementation of {@link KafkaStateAgentListener} which takes the following actions on {@link KafkaStreams} - * state change. - *
  • - * Restart the {@link BackdoorKafkaConsumer}. - *
  • - *
  • - * If the streams have been in rebalancing state for over 10 mins then restart the KafkaStreams. - *
  • + * An implementation of {@link KafkaStreams.StateListener} and {@link HealthMonitor} that monitors + * the state of {@link KafkaStreams} and takes appropriate actions based on state changes. * + *

    Key functionalities include: + *

      + *
    • Restarting {@link BackdoorKafkaConsumer} instances when the state changes to RUNNING.
    • + *
    • Monitoring the REBALANCING state and restarting the application if it persists for too long.
    • + *
    • Notifying {@link OffsetManager} to repopulate offsets from MongoDB.
    • + *
    */ - @Component public class KafkaStateListener implements KafkaStreams.StateListener, HealthMonitor { @@ -147,18 +146,20 @@ void setBackdoorConsumers(List backdoorConsumers) { } /** - * Following actions are taken when the state of KafkaStreams changes. + * Handles state changes in the {@link KafkaStreams} instance. + * + *

    This method performs the following actions: *

      - *
    • Notify all the {@link BackdoorKafkaConsumer} that the KafkaStreams state has changed so that - * necessary action could be taken by the Kafka consumers
    • . - *
    • Keep monitoring the state of KafkaStreams and if it remains in the REBALANCING state for - * more than 10 mins, then restart the streams application.
    • - *
    • Notify the {@link OffsetManager} so that offsets could be repopulated from MongoDB. This is - * related to the manual offset management done in the stream-base library. See {@link OffsetManager} for more. + *
    • Notifies all {@link BackdoorKafkaConsumer} instances about the state change.
    • + *
    • Updates the health status based on the new state.
    • + *
    • Monitors the REBALANCING state and starts a thread to validate if it persists too long.
    • + *
    • Notifies {@link OffsetManager} to repopulate offsets when transitioning from REBALANCING to RUNNING.
    • + *
    • Invokes any registered {@link KafkaStateAgentListener} instances when + * transitioning from REBALANCING to RUNNING.
    • *
    * - * @param newState the new state - * @param oldState the old state + * @param newState the new state of the {@link KafkaStreams}. + * @param oldState the previous state of the {@link KafkaStreams}. */ @Override public void onChange(State newState, State oldState) { diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncher.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncher.java index afdc04c..4834023 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncher.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncher.java @@ -51,6 +51,7 @@ import org.apache.kafka.streams.Topology; import org.apache.kafka.streams.processor.StateStore; import org.apache.kafka.streams.processor.api.ProcessorSupplier; +import org.apache.kafka.streams.state.KeyValueStore; import org.apache.kafka.streams.state.StoreBuilder; import org.eclipse.ecsp.analytics.stream.base.KafkaStreamsProcessorContext.StoreType; import org.eclipse.ecsp.analytics.stream.base.discovery.StreamProcessorDiscoveryService; @@ -506,18 +507,10 @@ private void validateProps(Properties props) { if (props.getProperty(PropertyNames.APPLICATION_ID) == null) { throw new IllegalArgumentException(PropertyNames.APPLICATION_ID + " is mandatory"); } - // if (props.getProperty(PropertyNames.AUTO_OFFSET_RESET_CONFIG) == - // null) { - // throw new - // IllegalArgumentException(PropertyNames.AUTO_OFFSET_RESET_CONFIG + " - // is mandatory"); - // } if (props.getProperty(PropertyNames.BOOTSTRAP_SERVERS) == null) { props.put(PropertyNames.BOOTSTRAP_SERVERS, "localhost:9092"); } - if (props.get(PropertyNames.ZOOKEEPER_CONNECT) == null) { - props.put(PropertyNames.ZOOKEEPER_CONNECT, "localhost:2181/haa"); - } + props.computeIfAbsent(PropertyNames.ZOOKEEPER_CONNECT, k -> "localhost:2181/haa"); String numThreads = null; if ((numThreads = props.getProperty(PropertyNames.NUM_STREAM_THREADS)) == null) { props.put(PropertyNames.NUM_STREAM_THREADS, Constants.FOUR); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/Launcher.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/Launcher.java index d899ed5..0f67c29 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/Launcher.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/Launcher.java @@ -176,13 +176,12 @@ public static void main(String[] args) throws Exception { } /** - * Extract all the properties supplied via ".properties" file & config-map and, launch the + * Extract all the properties supplied via properties file and config-map and, launch the * streams application. * * @throws IllegalArgumentException if {@link LauncherProvider} implementation isn't available on the * classpath. */ - public void launch() throws IllegalArgumentException { Thread.setDefaultUncaughtExceptionHandler((Thread t, Throwable e) -> LOGGER.error("Uncaught exception for thread " + t.getName(), e)); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/LauncherProvider.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/LauncherProvider.java index 10403fd..9690858 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/LauncherProvider.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/LauncherProvider.java @@ -48,10 +48,21 @@ * @author ssasidharan */ public interface LauncherProvider { + + /** + * Launches the stream processing system with the provided properties. + * + * @param props the properties to configure the stream processing system + */ void launch(Properties props); + /** + * Terminates the stream processing system and releases resources. + */ void terminate(); - //WI-365808 For unit test cases + /** + * Terminates the streams with a timeout for unit test cases. + */ void terminateStreamsWithTimeout(); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/PropertyNames.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/PropertyNames.java index f6b86bf..a4424e8 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/PropertyNames.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/PropertyNames.java @@ -902,7 +902,7 @@ public static String getDefaultPropertyValue(String propertyName) { public static final String KAFKA_HEADERS_ENABLED = "kafka.headers.enabled"; /** - * RDNG 171775 & RTC 503148 Expose RocksDB metrics to Prometheus. + * RDNG 171775 and RTC 503148 Expose RocksDB metrics to Prometheus. */ public static final String ROCKSDB_METRICS_ENABLED = "rocksdb.metrics.enabled"; @@ -916,7 +916,7 @@ public static String getDefaultPropertyValue(String propertyName) { public static final String ROCKSDB_METRICS_THREAD_FREQUENCY_MS = "rocksdb.metrics.thread.frequency.ms"; /** - * RDNG 171859 & RTC 525171 Report internal cache metrics to Prometheus . + * RDNG 171859 and RTC 525171 Report internal cache metrics to Prometheus . */ public static final String INTERNAL_METRICS_ENABLED = "internal.metrics.enabled"; diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessingContext.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessingContext.java index 832fbcb..dacdfa8 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessingContext.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessingContext.java @@ -79,6 +79,12 @@ public interface StreamProcessingContext { */ public void checkpoint(); + /** + * Retrieves the state store by its name. + * + * @param name the name of the state store to retrieve + * @return the KeyValueStore associated with the given name + */ @SuppressWarnings("rawtypes") public KeyValueStore getStateStore(String name); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessor.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessor.java index e20b07a..08264c3 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessor.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessor.java @@ -83,8 +83,10 @@ public interface StreamProcessor { /** * Perform actions on a schedule dictated by wall clock time. - * One tick is roughly one second. Note that implementations of this method - * should use the StreamsProcessorContext.forwardDirectly() instead of the forward() methods. + * This method is called periodically, with one tick representing roughly one second. + * Implementations should use StreamsProcessorContext.forwardDirectly() instead of forward() methods. + * + * @param ticks The number of ticks since the processor started. */ default void punctuateWc(long ticks) { } @@ -110,6 +112,12 @@ default String[] sources() { */ void configChanged(Properties props); + /** + * Creates a state store for the processor. + * The state store is used to persist key-value pairs for processing. + * + * @return A new instance of `HarmanPersistentKVStore`. + */ @SuppressWarnings("rawtypes") HarmanPersistentKVStore createStateStore(); @@ -144,6 +152,9 @@ default void initConfig(Properties props) { * property or master data needs to be read as and when * needed. * + * @param key The key of the data to update. + * @param value The value of the data to update. + * @param streamName The name of the stream associated with the update. */ default void updateSharedData(Object key, Object value, String streamName) { } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilter.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilter.java index 70245c9..d79776b 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilter.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilter.java @@ -49,9 +49,10 @@ public interface StreamProcessorFilter { /** - * returns if current stream processor is enabled or not. + * Determines whether the current stream processor should be included in the processor chain. * - * @return boolean + * @param props the properties to evaluate for inclusion + * @return {@code true} if the processor should be included, {@code false} otherwise */ boolean includeInProcessorChain(Properties props); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/TickListener.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/TickListener.java index f8c9d3f..cfafa76 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/TickListener.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/TickListener.java @@ -45,5 +45,11 @@ * @author ssasidharan */ public interface TickListener { + + /** + * Invoked when a tick event occurs. + * + * @param seconds the number of seconds since the last tick + */ void tick(long seconds); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContext.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContext.java index 366cf95..48b6b11 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContext.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContext.java @@ -54,9 +54,12 @@ public class StreamBaseSpringContext implements ApplicationContextAware { private static ApplicationContext context; /** - * Returns the Spring managed bean instance of the given class type if it exists. Returns null otherwise. + * Retrieves a Spring-managed bean of the specified class type. * - * @param beanClass beanClass + * @param the type of the bean to retrieve + * @param beanClass the class type of the bean to retrieve + * @return the Spring-managed bean instance of the specified type + * @throws BeansException if the bean could not be created or retrieved */ public static T getBean(Class beanClass) { return context.getBean(beanClass); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/CacheBackedInMemoryBatchCompleteCallBack.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/CacheBackedInMemoryBatchCompleteCallBack.java index 66ab73c..5e231fa 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/CacheBackedInMemoryBatchCompleteCallBack.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/CacheBackedInMemoryBatchCompleteCallBack.java @@ -47,6 +47,11 @@ **/ public interface CacheBackedInMemoryBatchCompleteCallBack { + /** + * Callback method invoked after the completion of processing a batch of records in the in-memory cache. + * + * @param processedRecords A list of objects representing the records that were processed in the batch. + */ public void batchCompleted(List processedRecords); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/SinkNode.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/SinkNode.java index 1808efc..9c4c184 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/SinkNode.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/SinkNode.java @@ -47,6 +47,11 @@ */ public interface SinkNode { + /** + * Initialize the sink node with the given properties. + * + * @param prop the properties to initialize the sink node + */ public void init(Properties prop); /** diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/ConnectionException.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/ConnectionException.java index 6c15efe..bcf6ae6 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/ConnectionException.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/ConnectionException.java @@ -44,8 +44,13 @@ */ public class ConnectionException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 943434134L; + /** + * Constructs a new ConnectionException with the specified detail message. + * + * @param msg the detail message explaining the reason for the exception + */ public ConnectionException(String msg) { super(msg); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNode.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNode.java index 05aa928..cd57873 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNode.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNode.java @@ -104,14 +104,13 @@ public void put(byte[] key, byte[] messageInBytes, String kafkaTopic, String pri try { logger.debug("Sending message to kafka. Topic: {}, Message: {}, key: {}", kafkaTopic, keyString); java.util.concurrent.Future f = producer - .send(new ProducerRecord(kafkaTopic, key, messageInBytes), new Callback() { - public void onCompletion(RecordMetadata metadata, Exception e) { - if (e != null) { - logger.error("Exception occurred in " - + "KafkaProducerByPartition callback for key : {}", keyString, e); + .send(new ProducerRecord(kafkaTopic, key, messageInBytes), + (metadata, exception) -> { + if (exception != null) { + logger.error("Exception occurred in KafkaProducerByPartition callback " + + "for key : {}", keyString, exception); } - } - }); + }); testIsSync(f, keyString); } catch (Exception e) { logger.error("Unable to send messages on Kafka for key : {} ", keyString, e); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/discovery/PropBasedDiscoveryServiceImpl.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/discovery/PropBasedDiscoveryServiceImpl.java index 5eeb423..6574dbf 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/discovery/PropBasedDiscoveryServiceImpl.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/discovery/PropBasedDiscoveryServiceImpl.java @@ -52,7 +52,7 @@ /** * The purpose of this class is to chain the mandatory pre and post processors along with the service processors. * The pre and post processor classes are pluggable via the following configs exposed by the stream-base - * library: {@link PropertyNames#PRE_PROCESSORS} & {@link PropertyNames#POST_PROCESSORS}. + * library: {@link PropertyNames#PRE_PROCESSORS} and {@link PropertyNames#POST_PROCESSORS}. * *

    * In between pre and post processors, service integrating the stream-base library can provide its own diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/BackdoorKafkaConsumerException.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/BackdoorKafkaConsumerException.java index d077509..27cd2a8 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/BackdoorKafkaConsumerException.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/BackdoorKafkaConsumerException.java @@ -39,9 +39,9 @@ package org.eclipse.ecsp.analytics.stream.base.exception; - /** - * Custom runtime exception for errors in {@link BackdoorKafkaConsumer}. + * Custom runtime exception for errors in + * {@link org.eclipse.ecsp.analytics.stream.base.kafka.internal.BackdoorKafkaConsumer}. */ public class BackdoorKafkaConsumerException extends RuntimeException { diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/InvalidSourceTopicException.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/InvalidSourceTopicException.java index 1833f29..7409076 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/InvalidSourceTopicException.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/InvalidSourceTopicException.java @@ -40,7 +40,7 @@ package org.eclipse.ecsp.analytics.stream.base.exception; /** - * Custom exception for invalid source topic name coming from the {@link StreamProcessingContext} instance. + * Custom exception for invalid source topic name. */ public class InvalidSourceTopicException extends RuntimeException { diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/MaxRetriesFailedException.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/MaxRetriesFailedException.java index 2b1ddf0..d6ddd69 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/MaxRetriesFailedException.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/exception/MaxRetriesFailedException.java @@ -41,7 +41,6 @@ /** * Custom exception for retries exhausted if a function doesn't return successfully. - * Check usage in {@link RetryUtils} */ public class MaxRetriesFailedException extends RuntimeException { diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsHealthMonitor.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsHealthMonitor.java index 2b37942..910a0b3 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsHealthMonitor.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsHealthMonitor.java @@ -105,7 +105,7 @@ public class KafkaTopicsHealthMonitor implements HealthMonitor { private KafkaSslConfig kafkaSslConfig; /** The props. */ - private Properties props = new Properties(); + private Properties properties = new Properties(); /** The topic config. */ private Map topicConfig; @@ -126,11 +126,11 @@ public class KafkaTopicsHealthMonitor implements HealthMonitor { public void init() { PROPS.put(PropertyNames.BOOTSTRAP_SERVERS, bootstrapServer); PROPS.put(ConsumerConfig.CONNECTIONS_MAX_IDLE_MS_CONFIG, connectionsMaxIdleMs); - kafkaSslConfig.setSslPropsIfEnabled(props); + kafkaSslConfig.setSslPropsIfEnabled(properties); logger.debug("Admin client config for topics health monitor {}", PROPS); topicConfig = getTopicsConfig(); topics = topicConfig.keySet(); - logger.info("Creating admin client with properties : {}", props); + logger.info("Creating admin client with properties : {}", properties); admin = AdminClient.create(PROPS); logger.info("admin client created - {}", admin.getClass()); logger.info("Get topic descriptions for topics {}", topics); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClient.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClient.java index f27d530..830e56c 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClient.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClient.java @@ -177,8 +177,8 @@ public JsonNode invokeJsonResource(String httpUrl, Map keyValue) */ public Map invokeJsonResource(HttpReqMethod method, String httpUrl, Map headers, Map parameters, int retryCount, long retryInterval) { - if ((!(HttpReqMethod.GET.equals(method) | HttpReqMethod.PUT - .equals(method) | HttpReqMethod.POST.equals(method)))) { + if ((!(HttpReqMethod.GET.equals(method) || HttpReqMethod.PUT + .equals(method) || HttpReqMethod.POST.equals(method)))) { throw new IllegalArgumentException("Accepts only 'GET', 'PUT', 'POST' method."); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdGenerator.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdGenerator.java index 755e6bf..b0afe93 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdGenerator.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdGenerator.java @@ -43,5 +43,12 @@ * Interface for generating the IDs for the events coming into stream-base library. */ public interface MessageIdGenerator { + + /** + * Generates a unique message ID for the given service name. + * + * @param serviceName the name of the service for which the message ID is generated + * @return a unique message ID as a String + */ public String generateUniqueMsgId(String serviceName); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdPartGenerator.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdPartGenerator.java index c666cf8..ee7bb8b 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdPartGenerator.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/idgen/MessageIdPartGenerator.java @@ -43,5 +43,12 @@ * interface {@link MessageIdPartGenerator}. */ public interface MessageIdPartGenerator { + + /** + * Generates a part of the message ID based on the provided service name. + * + * @param serviceName the name of the service for which the ID part is generated + * @return a string representing the generated ID part + */ public String generateIdPart(String serviceName); } diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/CumulativeLogger.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/CumulativeLogger.java index c70867f..8c5b86d 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/CumulativeLogger.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/CumulativeLogger.java @@ -73,7 +73,7 @@ public final class CumulativeLogger { private static class CumulativeLoggerHolder { /** The Constant C_LOGGER. */ - private static final CumulativeLogger C_LOGGER = new CumulativeLogger(logEveryXMinute); + private static final CumulativeLogger C_LOGGER = new CumulativeLogger(); /** * Instantiates a new cumulative logger holder. @@ -87,7 +87,7 @@ private CumulativeLoggerHolder() { * * @param logEveryXminute the log every xminute */ - private CumulativeLogger(int logEveryXminute) { + private CumulativeLogger() { ScheduledExecutorService ses = Executors.newSingleThreadScheduledExecutor( runnable -> { Thread t = Executors.defaultThreadFactory().newThread(runnable); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/HarmanRocksDBMetricsExporter.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/HarmanRocksDBMetricsExporter.java index 5155dee..62d7bb0 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/HarmanRocksDBMetricsExporter.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/metrics/reporter/HarmanRocksDBMetricsExporter.java @@ -137,12 +137,9 @@ private void prefix() { } /** - * This method fetches each metric name one by one in - * {@link HarmanRocksDBMetricsExporter#rocksDBMetricsList} and gets its value from + * This method fetches each metric name one by one and gets its value from * the RocksDB's instance that's been initialized and opened in {@code HarmanRocksDBStore} - * The value fetched above is then set to the corresponding Prometheus guage by the same name as in - * {@link HarmanRocksDBMetricsExporter#rocksDBMetricsList}. - * + * The value fetched above is then set to the corresponding Prometheus guage by the same name. */ @Scheduled(fixedDelayString = "${" + PropertyNames.ROCKSDB_METRICS_THREAD_FREQUENCY_MS + "}", initialDelayString = "${" + PropertyNames.ROCKSDB_METRICS_THREAD_INITIAL_DELAY_MS + "}") diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/CachedSortedMapStateStore.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/CachedSortedMapStateStore.java index 6ebfb32..d7b018a 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/CachedSortedMapStateStore.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/CachedSortedMapStateStore.java @@ -57,6 +57,8 @@ public class CachedSortedMapStateStore, V extends /** The task id. */ //This taskId has been added here to pass it down to CacheBypass from syncWithMapCacheMethod private String taskId; + + private final String AND_MUTATION_ID = "and mutationId {}"; /** * Sets the cache. @@ -115,7 +117,7 @@ public void put(K key, V value, String cacheType) { @Override public void put(K key, V value, Optional mutationId, String cacheType) { logger.debug("Invoking put of CacheBackedGenericInMemoryDAOImpl with key {} and value {} " - + "and mutationId {}", key, value, mutationId); + + AND_MUTATION_ID, key, value, mutationId); putToCache(key, value, mutationId); super.put(key, value); cacheGuage.set(super.approximateNumEntries(), cacheType, svc, nodeName, taskId); @@ -133,7 +135,7 @@ public void put(K key, V value, Optional mutationId, String cacheTyp @Override public V putIfAbsent(K key, V value, Optional mutationId, String cacheType) { logger.debug("Invoking put of CacheBackedGenericInMemoryDAOImpl with key {} and value {} " - + "and mutationId {}", key, value, mutationId); + + AND_MUTATION_ID, key, value, mutationId); V oldValue = super.putIfAbsent(key, value); cacheGuage.set(super.approximateNumEntries(), cacheType, svc, nodeName, taskId); @@ -152,8 +154,8 @@ public V putIfAbsent(K key, V value, Optional mutationId, String cac */ @Override public void delete(K key, Optional mutationId, String cacheType) { - logger.debug("Invoking delete of CacheBackedGenericInMemoryDAOImpl with key {} and " - + "mutationId", key, mutationId); + logger.debug("Invoking delete of CacheBackedGenericInMemoryDAOImpl with key {} " + + AND_MUTATION_ID, key, mutationId); super.delete(key); cacheGuage.set(super.approximateNumEntries(), cacheType, svc, nodeName, taskId); deleteFromCache(key, mutationId); @@ -243,7 +245,7 @@ private void putToCache(K key, V value, Optional mutationId) { public void putToMap(String mapKey, K mapEntryKey, V mapEntryValue, Optional mutationId, String cacheType) { logger.debug("Invoking put to map of CachedMapStateStore with key {} and value {} " - + "and mutationId {}", mapEntryKey, mapEntryValue, mutationId); + + AND_MUTATION_ID, mapEntryKey, mapEntryValue, mutationId); putToMapCache(mapKey, mapEntryKey, mapEntryValue, mutationId); super.put(mapEntryKey, mapEntryValue); cacheGuage.set(super.approximateNumEntries(), cacheType, svc, nodeName, taskId); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/GenericMapStateStore.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/GenericMapStateStore.java index fba53b9..cc6d05b 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/GenericMapStateStore.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/stores/GenericMapStateStore.java @@ -66,9 +66,6 @@ public class GenericMapStateStore extends GenericMapStateStoreBase extends GenericMapStateStoreBase * The value type - * @see org.apache.kafka.streams.state.Stores#create(String) + * @see org.apache.kafka.streams.state.Stores */ public class HarmanRocksDBStore implements KeyValueStore, BatchWritingStore { @@ -175,7 +175,7 @@ public class HarmanRocksDBStore implements KeyValueStore, BatchWriti private final String parentDir; /** The open iterators. */ - private final Set openIterators = new HashSet<>(); + private final Set> openIterators = new HashSet<>(); /** The key serde. */ private final Serde keySerde; @@ -505,8 +505,6 @@ private void putInternal(byte[] rawKey, byte[] rawValue) { try { db.delete(writeOptions, rawKey); } catch (RocksDBException e) { - LOG.error("Error while removing key " - + serdes.keyFrom(rawKey) + " from store " + this.name, e); throw new ProcessorStateException("Error while removing key " + serdes.keyFrom(rawKey) + FROM_STORE + this.name, e); } @@ -514,8 +512,6 @@ private void putInternal(byte[] rawKey, byte[] rawValue) { try { db.put(writeOptions, rawKey, rawValue); } catch (RocksDBException e) { - LOG.error("Error while executing put key " + serdes.keyFrom(rawKey) - + " and value " + serdes.keyFrom(rawValue) + " from store " + this.name, e); throw new ProcessorStateException("Error while executing put key " + serdes.keyFrom(rawKey) + " and value " + serdes.keyFrom(rawValue) + FROM_STORE + this.name, e); } @@ -756,8 +752,8 @@ private void maybeSetUpStatistics(final Map configs) { */ public void prepareBatchForRestore(final Collection> records, final WriteBatch batch) throws RocksDBException { - for (final KeyValue record : records) { - addToBatch(record.key, record.value, batch); + for (final KeyValue kvRecord : records) { + addToBatch(kvRecord.key, kvRecord.value, batch); } } @@ -782,13 +778,13 @@ public void addToBatch(final byte[] key, /** * Adds the to batch. * - * @param record the record + * @param kvRecord the record * @param batch the batch * @throws RocksDBException the rocks DB exception */ @Override - public void addToBatch(KeyValue record, WriteBatch batch) throws RocksDBException { - addToBatch(record.key, record.value, batch); + public void addToBatch(KeyValue kvRecord, WriteBatch batch) throws RocksDBException { + addToBatch(kvRecord.key, kvRecord.value, batch); } /** diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/ConnectionStatusRetriever.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/ConnectionStatusRetriever.java index 129457f..06bf01c 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/ConnectionStatusRetriever.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/ConnectionStatusRetriever.java @@ -6,7 +6,7 @@ * CR-4570 DMA should expose an interface for services to retrieve connection * status from an API. * Services can implement this interface and plug-in its implementation configuration to - * provide their own logic to call the API & fetch device connection status. + * provide their own logic to call the API and fetch device connection status. * * @author HBadshah */ diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaTestUtils.java b/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaTestUtils.java index d8612ec..360d28f 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaTestUtils.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaTestUtils.java @@ -62,7 +62,6 @@ import java.util.Properties; import java.util.concurrent.ExecutionException; import java.util.concurrent.Future; -import java.util.concurrent.TimeoutException; /** @@ -319,7 +318,7 @@ public static void sendMessages(String topic, Properties producerProps, String.. Collection> kvs = new ArrayList<>(); for (int i = 1; i <= strings.length; i++) { if (i % Constants.TWO == 0) { - kvs.add(new KeyValue(strings[i - Constants.TWO], strings[i - 1])); + kvs.add(new KeyValue(strings[i - Constants.TWO], strings[i - 1])); } } KafkaTestUtils.produceKeyValuesSynchronously(topic, kvs, producerProps); diff --git a/src/main/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtil.java b/src/main/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtil.java index a5fb8ee..5ca77b3 100644 --- a/src/main/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtil.java +++ b/src/main/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtil.java @@ -55,7 +55,11 @@ /** - * Utility class for {@link org.eclipse.ecsp.vehicleprofile.domain.VehicleProfile} API. + * Utility class for interacting with the Vehicle Profile API. + *

    + * This class provides methods to invoke the Vehicle Profile API to fetch vehicle information + * based on a given device ID. It also handles logging, response parsing, and error handling. + *

    */ @Component @Scope("prototype") diff --git a/src/main/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandler.java b/src/main/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandler.java index 4f27c0c..f849199 100644 --- a/src/main/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandler.java +++ b/src/main/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandler.java @@ -343,7 +343,7 @@ private boolean isDeviceActive(IgniteKey key, DeviceMessage entity) { * * 1. No data exists for this VIN in in-memory map. * - * 2. If multiple devices are associated with a VIN & data exists for + * 2. If multiple devices are associated with a VIN and data exists for * this VIN in in-memory but not for this targetDeviceId. * * Eg. Suppose vehicleId = vin123 and devices associated are d1 and d2. @@ -356,7 +356,8 @@ private boolean isDeviceActive(IgniteKey key, DeviceMessage entity) { * * vin123 = {d1=ACTIVE,d2=INACTIVE} * - * Check {@link DefaultDeviceConnectionStatusRetriever#getConnectionStatusData + * Check {@link + * org.eclipse.ecsp.analytics.stream.base.utils.DefaultDeviceConnectionStatusRetriever#getConnectionStatusData * (String, String, String)} for more on how it fetches data from * the third party API. *

    diff --git a/src/test/java/org/apache/kafka/test/TestUtils.java b/src/test/java/org/apache/kafka/test/TestUtils.java index 023819d..94d402b 100644 --- a/src/test/java/org/apache/kafka/test/TestUtils.java +++ b/src/test/java/org/apache/kafka/test/TestUtils.java @@ -235,7 +235,7 @@ public void run() { try { Utils.delete(file); } catch (IOException e) { - LOGGER.error("Error while deleting the file - " + file.getAbsolutePath()); + LOGGER.error("Error while deleting the file {}", file.getAbsolutePath()); } } }); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/CacheMapStateStoreTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/CacheMapStateStoreTest.java index 44e1f5a..4c04a31 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/CacheMapStateStoreTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/CacheMapStateStoreTest.java @@ -106,8 +106,6 @@ public class CacheMapStateStoreTest { @Before public void setup() { MockitoAnnotations.initMocks(this); - //cache = Mockito.mock(IgniteCacheRedisImpl.class); - igniteEvent = new IgniteEventImpl(); igniteEvent.setEventId("test"); stringKey = new StringKey(key); @@ -272,7 +270,6 @@ public void testPutToMapIfAbsentPersistanceFalse() { @Test public void testPutToMapIfAbsentValuePresent() { CachedMapStateStore storeMock = Mockito.mock(CachedMapStateStore.class); - IgniteCache cacheMock = Mockito.mock(IgniteCache.class); storeMock.setPersistInIgniteCache(true); Mockito.when(storeMock.putIfAbsent(stringKey, igniteEvent)).thenReturn(igniteEvent); storeMock.putToMapIfAbsent("prefix", stringKey, igniteEvent, Optional.empty(), "dummy_cache"); @@ -388,7 +385,6 @@ public void testdeleteFromMap() { pairs.put(stringKey.convertToString(), igniteEvent); Mockito.when(cache.getMapOfEntities(Mockito.any(GetMapOfEntitiesRequest.class))).thenReturn(pairs); store.deleteFromMap("prefix", stringKey, Optional.empty(), "dummy_cache"); - ArgumentCaptor argument = ArgumentCaptor.forClass(GetMapOfEntitiesRequest.class); IgniteEventImpl actual = store.get(stringKey); Assert.assertNull(actual); } @@ -399,7 +395,6 @@ public void testdeleteFromMap() { @Test public void testputIfAbsent() { CachedMapStateStore storeMock = Mockito.mock(CachedMapStateStore.class); - IgniteCache cacheMock = Mockito.mock(IgniteCache.class); storeMock.putIfAbsent(null, null); Mockito.when(storeMock.putIfAbsent(stringKey, igniteEvent)).thenReturn(igniteEvent); storeMock.putToMapIfAbsent("prefix", stringKey, igniteEvent, Optional.empty(), "dummy_cache"); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/CachedSortedMapStateStoreTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/CachedSortedMapStateStoreTest.java index 303ca80..89f9c1d 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/CachedSortedMapStateStoreTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/CachedSortedMapStateStoreTest.java @@ -123,8 +123,8 @@ public void setup() { public void testSetTaskId() { store.setTaskId(null); store.setTaskId(taskId); - String taskId = (String) ReflectionTestUtils.getField(store, "taskId"); - Assert.assertEquals(this.taskId, taskId); + String testTaskId = (String) ReflectionTestUtils.getField(store, "taskId"); + Assert.assertEquals(taskId, testTaskId); } /** @@ -136,9 +136,9 @@ public void testSyncWithRedis() { String regex = prefix + "*"; Map map = new HashMap(); map.put("123", igniteEvent); - IgniteCache cache = Mockito.mock(IgniteCacheRedisImpl.class); - Mockito.when(cache.getKeyValuePairsForRegex(regex, Optional.of(false))).thenReturn(map); - store.setCache(cache); + IgniteCache igniteCache = Mockito.mock(IgniteCacheRedisImpl.class); + Mockito.when(igniteCache.getKeyValuePairsForRegex(regex, Optional.of(false))).thenReturn(map); + store.setCache(igniteCache); store.syncWithcache(regex, new RetryBucketKey()); Assert.assertEquals(igniteEvent, store.get(key)); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/DataUsageMetricsTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/DataUsageMetricsTest.java index fa478c7..ea8853e 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/DataUsageMetricsTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/DataUsageMetricsTest.java @@ -161,17 +161,15 @@ public void testDataUsageConsumptionMetricForNormalEvent() throws Exception { .toBlob(new IgniteStringKey("dummyId")), transformer.toBlob(event)); List messages = KafkaTestUtils.readMessages(dataUsageTestTopicName, consumerProps, 1); - for (int i = 0; i < messages.size(); i++) { - IgniteEvent igniteEvent = transformer.fromBlob(messages.get(i)[1].getBytes(), + for (int k = 0; k < messages.size(); k++) { + IgniteEvent igniteEvent = transformer.fromBlob(messages.get(k)[1].getBytes(), Optional.ofNullable(null)); DataUsageEventDataV1_0 testDataUsageEventData = (DataUsageEventDataV1_0) igniteEvent.getEventData(); Assert.assertEquals((double) transformer.toBlob(event).length / Constants.BYTE_1024, testDataUsageEventData.getPayLoadSize(), 0.0); } - shutDownApplication(); - } /** @@ -245,7 +243,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -253,7 +251,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -263,7 +261,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -309,7 +307,7 @@ public static final class StreamPostProcessor implements StreamProcessor kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -359,7 +357,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -369,7 +367,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncherTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncherTest.java index 67e7ada..d17a131 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncherTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsLauncherTest.java @@ -603,6 +603,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -610,6 +611,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -629,6 +631,7 @@ public String[] sinks() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -765,7 +768,6 @@ public String name() { @Override public void process(Record kafkaRecord) { objectStore.put(new String(kafkaRecord.key()), new String(kafkaRecord.value())); - String value = String.valueOf(objectStore.get(new String(kafkaRecord.key()))); spc.forward(new Record<>(new String(kafkaRecord.key()), new String(kafkaRecord.value()), System.currentTimeMillis())); } @@ -789,6 +791,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -798,6 +801,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -887,6 +891,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -894,6 +899,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -903,6 +909,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -943,9 +950,6 @@ public String[] sinks() { @Component public static final class IgniteCacheTestProcessor implements StreamProcessor { - /** The spc. */ - private StreamProcessingContext spc; - /** The config. */ private Properties config; @@ -971,7 +975,6 @@ public Properties getConfig() { public void init(StreamProcessingContext spc) { Assert.assertNotNull(config); Assert.assertFalse(config.isEmpty()); - this.spc = spc; } /** @@ -1002,6 +1005,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -1009,6 +1013,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -1018,6 +1023,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -1125,6 +1131,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -1132,6 +1139,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -1141,6 +1149,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -1267,6 +1276,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -1276,6 +1286,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtExceptionTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtExceptionTest.java index 0bd1e0f..f45821d 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtExceptionTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtExceptionTest.java @@ -231,9 +231,8 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } - } /** @@ -283,7 +282,7 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } } } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtReplaceThreadTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtReplaceThreadTest.java index e482929..05b0b5e 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtReplaceThreadTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtReplaceThreadTest.java @@ -49,8 +49,6 @@ import org.apache.kafka.streams.Topology; import org.apache.kafka.streams.processor.Processor; import org.apache.kafka.streams.processor.ProcessorContext; -import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.PropertyNames; import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; import org.eclipse.ecsp.analytics.stream.base.discovery.PropBasedDiscoveryServiceImpl; import org.eclipse.ecsp.analytics.stream.base.utils.KafkaStreamsApplicationTestBase; @@ -220,7 +218,7 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } } @@ -272,7 +270,7 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } } } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtShutdownTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtShutdownTest.java index 7b19184..5b4f92a 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtShutdownTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/KafkaStreamsMaxUncaughtShutdownTest.java @@ -49,8 +49,6 @@ import org.apache.kafka.streams.Topology; import org.apache.kafka.streams.processor.Processor; import org.apache.kafka.streams.processor.ProcessorContext; -import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.PropertyNames; import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; import org.eclipse.ecsp.analytics.stream.base.discovery.PropBasedDiscoveryServiceImpl; import org.eclipse.ecsp.analytics.stream.base.utils.KafkaStreamsApplicationTestBase; @@ -224,7 +222,7 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } } @@ -276,7 +274,7 @@ public void process(byte[] key, byte[] value) { */ @Override public void close() { - + // Nothing to do. } } } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/ProcessorChainingTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/ProcessorChainingTest.java index 61f416a..9c1bc23 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/ProcessorChainingTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/ProcessorChainingTest.java @@ -185,7 +185,7 @@ public static final class StreamPostProcessor implements StreamProcessor kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -238,7 +238,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -249,7 +249,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } @@ -288,7 +288,7 @@ public static final class StreamPreProcessor implements StreamProcessor kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -340,7 +340,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -351,7 +351,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } @@ -435,7 +435,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -444,7 +444,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -455,7 +455,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } @@ -539,7 +539,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -548,7 +548,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -559,7 +559,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/PrometheusMetricsTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/PrometheusMetricsTest.java index cb75d13..58a32ee 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/PrometheusMetricsTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/PrometheusMetricsTest.java @@ -82,9 +82,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Properties; -import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; -import java.util.concurrent.TimeoutException; import static org.junit.Assert.assertNotNull; @@ -423,10 +421,6 @@ public void testServiceConsumptionMetric() throws Exception { KafkaTestUtils.sendMessages(inTopicName, producerProps, KEY_SER.toBlob(new IgniteStringKey("dummy_id")), transformer.toBlob(event2)); - - List messages = KafkaTestUtils.getMessages(outTopicName, - consumerProps, Constants.THREE, Constants.THREAD_SLEEP_TIME_5000); - String metricsGet = sendGET("http://localhost:" + prometheusExportPort); String liveThreadMetric = metricsGet.substring(metricsGet.indexOf("service_data_consumption_count{svc=")); liveThreadMetric = liveThreadMetric.substring(0, liveThreadMetric.indexOf("service_data_consumption_sum{svc=")); @@ -477,7 +471,7 @@ public static final class StreamPostProcessor implements StreamProcessor kafkaRecord) { */ @Override public void punctuate(long timestamp) { - - + // Nothing to do. } /** @@ -531,8 +524,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - - + // Nothing to do. } /** @@ -542,8 +534,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - - + // Nothing to do. } /** @@ -581,7 +572,7 @@ public static final class StreamPreProcessor implements StreamProcessor kafkaRecord) { */ @Override public void punctuate(long timestamp) { - - + // Nothing to do. } /** @@ -633,8 +623,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - - + // Nothing to do. } /** @@ -644,8 +633,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - - + // Nothing to do. } /** @@ -728,8 +716,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - - + // Nothing to do. } /** @@ -737,8 +724,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - - + // Nothing to do. } /** @@ -748,8 +734,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - - + // Nothing to do. } /** @@ -832,8 +817,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - - + // Nothing to do. } /** @@ -841,8 +825,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - - + // Nothing to do. } /** @@ -852,8 +835,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilterTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilterTest.java index 3f2d59d..e68f1e4 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilterTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/StreamProcessorFilterTest.java @@ -43,11 +43,6 @@ import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.processor.api.Record; -import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.PropertyNames; -import org.eclipse.ecsp.analytics.stream.base.StreamProcessingContext; -import org.eclipse.ecsp.analytics.stream.base.StreamProcessor; -import org.eclipse.ecsp.analytics.stream.base.StreamProcessorFilter; import org.eclipse.ecsp.analytics.stream.base.discovery.PropBasedDiscoveryServiceImpl; import org.eclipse.ecsp.analytics.stream.base.stores.HarmanPersistentKVStore; import org.eclipse.ecsp.analytics.stream.base.utils.Constants; @@ -66,8 +61,6 @@ import java.util.List; import java.util.Properties; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import static org.junit.Assert.assertEquals; @@ -169,7 +162,7 @@ public static final class StreamPreProcessorEnabled implements * Instantiates a new stream pre processor enabled. */ public StreamPreProcessorEnabled() { - + // Nothing to do. } /** @@ -211,7 +204,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -219,7 +212,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -229,7 +222,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -287,7 +280,7 @@ public static final class StreamPostProcessorEnabled implements * Instantiates a new stream post processor enabled. */ public StreamPostProcessorEnabled() { - + // Nothing to do. } /** @@ -330,7 +323,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -338,7 +331,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -348,7 +341,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -396,7 +389,7 @@ public static final class StreamPreProcessorDisabled * Instantiates a new stream pre processor disabled. */ public StreamPreProcessorDisabled() { - + // Nothing to do. } /** @@ -446,7 +439,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -456,7 +449,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -557,7 +550,7 @@ public void process(Record kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -565,7 +558,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -575,7 +568,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/TestKryo.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/TestKryo.java index e96b194..8e4ca2e 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/TestKryo.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/TestKryo.java @@ -70,10 +70,6 @@ public static void main(String[] args) { Kryo k = new Kryo(); k.setDefaultSerializer(CompatibleFieldSerializer.class); k.setCopyReferences(false); - // Output output = new Output(1024, -1); - // kryo.writeClassAndObject(output, data); - // return output.toBytes(); - Name n = null; ByteArrayOutputStream baos = new ByteArrayOutputStream(1 * Constants.BYTE_1024 * Constants.BYTE_1024); Output output = new Output(baos); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContextTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContextTest.java index d17140c..1e5acb9 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContextTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/context/StreamBaseSpringContextTest.java @@ -40,7 +40,6 @@ package org.eclipse.ecsp.analytics.stream.base.context; import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.context.StreamBaseSpringContext; import org.eclipse.ecsp.analytics.stream.base.metrics.reporter.HarmanRocksDBMetricsExporter; import org.eclipse.ecsp.analytics.stream.base.utils.KafkaStreamsApplicationTestBase; import org.junit.Assert; diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNodeTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNodeTest.java index dc353c5..ad1aaec 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNodeTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/KafkaSinkNodeTest.java @@ -74,7 +74,6 @@ @ContextConfiguration(classes = Launcher.class) @EnableRuleMigrationSupport @TestPropertySource("/integration-test-application.properties") -/*@org.junit.experimental.categories.Category(NightlyBuildTestCase.class)*/ public class KafkaSinkNodeTest extends KafkaStreamsApplicationTestBase { /** The Constant SOURCE_TOPIC_NAME. */ @@ -141,12 +140,10 @@ public void testPut() throws TimeoutException, InterruptedException { boolean flag = false; for (String[] keyMessage : allMessages) { - if (keyMessage.length == Constants.TWO) { - if (MESSAGE_KEY.equals(keyMessage[0]) + if (keyMessage.length == Constants.TWO && MESSAGE_KEY.equals(keyMessage[0]) && PAYLOAD.equals(keyMessage[1])) { - flag = true; - break; - } + flag = true; + break; } } assertTrue("Dint get message which is sent", flag); @@ -168,8 +165,8 @@ public void testInitWithSSLEnabled() { properties.put(PropertyNames.KAFKA_SSL_CLIENT_AUTH, sslClientAuth); properties.put(PropertyNames.KAFKA_SSL_ENABLE, true); kafkaSinkNode.init(properties); - assertEquals("SSL", properties.getProperty(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG), - "Expected protocol set to SSL"); + assertEquals("Expected protocol set to SSL", "SSL", + properties.getProperty(CommonClientConfigs.SECURITY_PROTOCOL_CONFIG)); } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/MongoSinkNodeTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/MongoSinkNodeTest.java index 7c6ffa5..9b3add8 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/MongoSinkNodeTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/dao/impl/MongoSinkNodeTest.java @@ -51,9 +51,6 @@ import org.springframework.test.context.TestPropertySource; import java.util.Properties; -import java.util.concurrent.TimeoutException; - - /** * Test class to verify the functionalities of KafkaSinkNodeTest class. @@ -87,7 +84,6 @@ public void setup() throws Exception { properties.setProperty(PropertyNames.MONGO_CLIENT_MAX_WAIT_TIME_MS, "30000"); properties.setProperty(PropertyNames.MONGO_CLIENT_CONNECTION_TIMEOUT_MS, "20000"); properties.setProperty(PropertyNames.MONGO_CLIENT_SOCKET_TIMEOUT_MS, "60000"); - ConnectionException exp = new ConnectionException("Exception in connection"); } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsMonitorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsMonitorTest.java index 9892526..4942de3 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsMonitorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/healthcheck/KafkaTopicsMonitorTest.java @@ -64,7 +64,6 @@ import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import org.springframework.test.util.ReflectionTestUtils; -import java.io.IOException; import java.util.Collections; import java.util.HashMap; import java.util.HashSet; @@ -72,12 +71,9 @@ import java.util.Properties; import java.util.Set; import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; import static org.junit.jupiter.api.Assertions.assertEquals; - - /** * UT class {@link KafkaTopicsMonitorTest}. */ @@ -136,9 +132,8 @@ public void setup() throws Exception { topics.add(topic); ReflectionTestUtils.setField(kafaTopicsMonitor, "topics", topics); - Map topicConfig = new HashMap<>(); KafkaTopicsHealthMonitor monitor = ctx.getBean(KafkaTopicsHealthMonitor.class); - topicConfig = ReflectionTestUtils.invokeMethod(monitor, "getTopicsConfig", new Object[0]); + Map topicConfig = ReflectionTestUtils.invokeMethod(monitor, "getTopicsConfig", new Object[0]); ReflectionTestUtils.setField(kafaTopicsMonitor, "topicConfig", topicConfig); } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClientTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClientTest.java index 900660a..9153548 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClientTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/http/HttpClientTest.java @@ -189,8 +189,6 @@ public void testHttpClientGET() { */ @Test public void testHttpClientGETWithRetries() { - MockResponse mockResponse = new MockResponse(); - Map headers = new HashMap<>(); headers.put("sessionId", "Session1234"); headers.put("clientRequestId", "Request1234"); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/EmbeddedKafka.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/EmbeddedKafka.java index 666f92c..a61971d 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/EmbeddedKafka.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/EmbeddedKafka.java @@ -124,25 +124,23 @@ public EmbeddedKafka(final Properties config) throws IOException { * @return the properties */ private Properties effectiveConfigFrom(final Properties initialConfig) { - final Properties effectiveConfig = new Properties(); - effectiveConfig.put(KafkaConfig$.MODULE$.BrokerIdProp(), 0); - effectiveConfig.put(KafkaConfig.ListenersProp(), "PLAINTEXT://127.0.0.1:9092"); - effectiveConfig.put(KafkaConfig$.MODULE$.NumPartitionsProp(), 1); - effectiveConfig.put(KafkaConfig$.MODULE$.AutoCreateTopicsEnableProp(), true); - effectiveConfig.put(KafkaConfig$.MODULE$.MessageMaxBytesProp(), Constants.INT_1000000); - effectiveConfig.put(KafkaConfig$.MODULE$.ControlledShutdownEnableProp(), true); + final Properties effectiveConfigProps = new Properties(); + effectiveConfigProps.put(KafkaConfig$.MODULE$.BrokerIdProp(), 0); + effectiveConfigProps.put(KafkaConfig.ListenersProp(), "PLAINTEXT://127.0.0.1:9092"); + effectiveConfigProps.put(KafkaConfig$.MODULE$.NumPartitionsProp(), 1); + effectiveConfigProps.put(KafkaConfig$.MODULE$.AutoCreateTopicsEnableProp(), true); + effectiveConfigProps.put(KafkaConfig$.MODULE$.MessageMaxBytesProp(), Constants.INT_1000000); + effectiveConfigProps.put(KafkaConfig$.MODULE$.ControlledShutdownEnableProp(), true); - effectiveConfig.putAll(initialConfig); - effectiveConfig.setProperty(KafkaConfig$.MODULE$.LogDirProp(), logDir.getAbsolutePath()); + effectiveConfigProps.putAll(initialConfig); + effectiveConfigProps.setProperty(KafkaConfig$.MODULE$.LogDirProp(), logDir.getAbsolutePath()); //effectiveConfig.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, effectiveConfig) - effectiveConfig.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); - effectiveConfig.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); - //effectiveConfig.put(PropertyNames.NUM_STREAM_THREADS, "1"); - //effectiveConfig.put(PropertyNames.REPLICATION_FACTOR, "1"); - effectiveConfig.put(StreamsConfig.STATE_DIR_CONFIG, "/tmp/kafka-streams"); + effectiveConfigProps.put(StreamsConfig.DEFAULT_KEY_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); + effectiveConfigProps.put(StreamsConfig.DEFAULT_VALUE_SERDE_CLASS_CONFIG, Serdes.String().getClass().getName()); + effectiveConfigProps.put(StreamsConfig.STATE_DIR_CONFIG, "/tmp/kafka-streams"); - return effectiveConfig; + return effectiveConfigProps; } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/SingleNodeKafkaCluster.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/SingleNodeKafkaCluster.java index 20ad921..ff4fba6 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/SingleNodeKafkaCluster.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/SingleNodeKafkaCluster.java @@ -67,18 +67,6 @@ public class SingleNodeKafkaCluster extends ExternalResource { /** The Constant LOG. */ private static final Logger LOG = LoggerFactory.getLogger(SingleNodeKafkaCluster.class); - /** The Constant KAFKA_SCHEMAS_TOPIC. */ - private static final String KAFKA_SCHEMAS_TOPIC = "_schemas"; - - /** The Constant KAFKASTORE_OPERATION_TIMEOUT_MS. */ - private static final String KAFKASTORE_OPERATION_TIMEOUT_MS = "60000"; - - /** The Constant KAFKASTORE_DEBUG. */ - private static final String KAFKASTORE_DEBUG = "true"; - - /** The Constant KAFKASTORE_INIT_TIMEOUT. */ - private static final String KAFKASTORE_INIT_TIMEOUT = "90000"; - /** The kafka broker port. */ private static int kafkaBrokerPort = 1234; // pick a random port @@ -320,69 +308,4 @@ public void deleteTopicsAndWait(final long timeoutMs, final String... topics) th public boolean isRunning() { return running; } - - /** - * The Class TopicsDeletedCondition. - */ - private final class TopicsDeletedCondition implements TestCondition { - - /** The deleted topics. */ - final Set deletedTopics = new HashSet<>(); - - /** - * Instantiates a new topics deleted condition. - * - * @param topics the topics - */ - private TopicsDeletedCondition(final String... topics) { - Collections.addAll(deletedTopics, topics); - } - - /** - * Condition met. - * - * @return true, if successful - */ - @Override - public boolean conditionMet() { - final Set allTopicsFromZk = new HashSet<>( - CollectionConverters.SetHasAsJava(broker.kafkaServer() - .zkClient().getAllTopicsInCluster(false)).asJava()); - - final Set allTopicsFromBrokerCache = new HashSet<>( - CollectionConverters.SeqHasAsJava(broker.kafkaServer() - .metadataCache().getAllTopics().toSeq()).asJava()); - - return !allTopicsFromZk.removeAll(deletedTopics) && !allTopicsFromBrokerCache.removeAll(deletedTopics); - } - } - - /** - * The Class TopicCreatedCondition. - */ - private final class TopicCreatedCondition implements TestCondition { - - /** The created topic. */ - final String createdTopic; - - /** - * Instantiates a new topic created condition. - * - * @param topic the topic - */ - private TopicCreatedCondition(final String topic) { - createdTopic = topic; - } - - /** - * Condition met. - * - * @return true, if successful - */ - @Override - public boolean conditionMet() { - return broker.kafkaServer().zkClient().getAllTopicsInCluster(false).contains(createdTopic) - && broker.kafkaServer().metadataCache().contains(createdTopic); - } - } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackDoorKafkaConsumerTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackDoorKafkaConsumerTest.java index e7e5917..7cf7969 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackDoorKafkaConsumerTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackDoorKafkaConsumerTest.java @@ -148,19 +148,19 @@ public void testIgniteKeyTransformerImplMissing() { */ @Test(expected = RuntimeException.class) public void testGroupIdMissing() { - DeviceStatusBackDoorKafkaConsumer consumer = new DeviceStatusBackDoorKafkaConsumer(); - consumer.setIgniteKeyTransformerImpl("org.eclipse.ecsp.transform.IgniteKeyTransformerStringImpl"); - consumer.setKafkaBootstrapServers("localhost:9092"); + DeviceStatusBackDoorKafkaConsumer deviecStatusConsumer = new DeviceStatusBackDoorKafkaConsumer(); + deviecStatusConsumer.setIgniteKeyTransformerImpl("org.eclipse.ecsp.transform.IgniteKeyTransformerStringImpl"); + deviecStatusConsumer.setKafkaBootstrapServers("localhost:9092"); - consumer.initializeProperties(); + deviecStatusConsumer.initializeProperties(); TestCallBack callBack = new TestCallBack(); - consumer.addCallback(callBack, 0); - consumer.setDeviceStatusTopicName(deviceConnStatusTopic); - consumer.setDmaConsumerPoll(TestConstants.THREAD_SLEEP_TIME_10); - consumer.setDmaAutoOffsetReset("latest"); - consumer.setServiceName("TestService"); - consumer.startBackDoorKafkaConsumer(); + deviecStatusConsumer.addCallback(callBack, 0); + deviecStatusConsumer.setDeviceStatusTopicName(deviceConnStatusTopic); + deviecStatusConsumer.setDmaConsumerPoll(TestConstants.THREAD_SLEEP_TIME_10); + deviecStatusConsumer.setDmaAutoOffsetReset("latest"); + deviecStatusConsumer.setServiceName("TestService"); + deviecStatusConsumer.startBackDoorKafkaConsumer(); } /** @@ -168,19 +168,19 @@ public void testGroupIdMissing() { */ @Test(expected = RuntimeException.class) public void testTopicMissing() { - DeviceStatusBackDoorKafkaConsumer consumer = new DeviceStatusBackDoorKafkaConsumer(); - consumer.setIgniteKeyTransformerImpl("org.eclipse.ecsp.transform.IgniteKeyTransformerStringImpl"); - consumer.setKafkaBootstrapServers("localhost:9092"); + DeviceStatusBackDoorKafkaConsumer deviceStatusConsumer = new DeviceStatusBackDoorKafkaConsumer(); + deviceStatusConsumer.setIgniteKeyTransformerImpl("org.eclipse.ecsp.transform.IgniteKeyTransformerStringImpl"); + deviceStatusConsumer.setKafkaBootstrapServers("localhost:9092"); - consumer.initializeProperties(); + deviceStatusConsumer.initializeProperties(); TestCallBack callBack = new TestCallBack(); - consumer.addCallback(callBack, 0); - consumer.setDmaConsumerGroupId((i + "testBackDoorGroupId")); - consumer.setDmaConsumerPoll(TestConstants.THREAD_SLEEP_TIME_10); - consumer.setDmaAutoOffsetReset("latest"); - consumer.setServiceName("TestService"); - consumer.startBackDoorKafkaConsumer(); + deviceStatusConsumer.addCallback(callBack, 0); + deviceStatusConsumer.setDmaConsumerGroupId((i + "testBackDoorGroupId")); + deviceStatusConsumer.setDmaConsumerPoll(TestConstants.THREAD_SLEEP_TIME_10); + deviceStatusConsumer.setDmaAutoOffsetReset("latest"); + deviceStatusConsumer.setServiceName("TestService"); + deviceStatusConsumer.startBackDoorKafkaConsumer(); } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackdoorKafkaTopicOffsetDAOMongoImplTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackdoorKafkaTopicOffsetDAOMongoImplTest.java index 1adc9a5..1e937e1 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackdoorKafkaTopicOffsetDAOMongoImplTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/kafka/internal/BackdoorKafkaTopicOffsetDAOMongoImplTest.java @@ -68,9 +68,6 @@ public class BackdoorKafkaTopicOffsetDAOMongoImplTest extends KafkaStreamsApplic /** The kafka topic. */ private String kafkaTopic = "kafkaTopic"; - /** The service. */ - private String service = "service"; - /** The partition. */ private int partition = 1; diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/KafkaStreamsOffsetManagementDAOMongoImplTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/KafkaStreamsOffsetManagementDAOMongoImplTest.java index 4404483..110eb85 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/KafkaStreamsOffsetManagementDAOMongoImplTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/KafkaStreamsOffsetManagementDAOMongoImplTest.java @@ -41,8 +41,6 @@ import org.eclipse.ecsp.analytics.stream.base.Launcher; import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; -import org.eclipse.ecsp.analytics.stream.base.offset.KafkaStreamsOffsetManagementDAOMongoImpl; -import org.eclipse.ecsp.analytics.stream.base.offset.KafkaStreamsTopicOffset; import org.eclipse.ecsp.analytics.stream.base.utils.Constants; import org.eclipse.ecsp.analytics.stream.base.utils.KafkaStreamsApplicationTestBase; import org.junit.Assert; diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerIntegrationTest.java index 1a19842..0270f96 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerIntegrationTest.java @@ -210,7 +210,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -218,6 +218,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -227,6 +228,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerTest.java index 430e797..266ee18 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/offset/OffsetManagerTest.java @@ -40,9 +40,6 @@ package org.eclipse.ecsp.analytics.stream.base.offset; import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; -import org.eclipse.ecsp.analytics.stream.base.offset.KafkaStreamsOffsetManagementDAOMongoImpl; -import org.eclipse.ecsp.analytics.stream.base.offset.KafkaStreamsTopicOffset; -import org.eclipse.ecsp.analytics.stream.base.offset.OffsetManager; import org.eclipse.ecsp.analytics.stream.base.utils.Constants; import org.junit.Assert; import org.junit.Before; @@ -221,10 +218,10 @@ public void testInitializeRefrenceMap() { */ @Test public void testGetKey() { - String topic = "topic"; - int partition = Constants.THREAD_SLEEP_TIME_10; - String key = topic + ":" + partition; - Assert.assertEquals(key, offsetManager.getKey(topic, partition)); + String topicName = "topic"; + int partitionId = Constants.THREAD_SLEEP_TIME_10; + String key = topicName + ":" + partitionId; + Assert.assertEquals(key, offsetManager.getKey(topicName, partitionId)); } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/parser/EventWrapperTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/parser/EventWrapperTest.java index c1fc5e8..e6d49ad 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/parser/EventWrapperTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/parser/EventWrapperTest.java @@ -39,10 +39,6 @@ package org.eclipse.ecsp.analytics.stream.base.parser; -import org.eclipse.ecsp.analytics.stream.base.parser.EventParser; -import org.eclipse.ecsp.analytics.stream.base.parser.EventWrapperBase; -import org.eclipse.ecsp.analytics.stream.base.parser.EventWrapperForSequence; -import org.eclipse.ecsp.analytics.stream.base.parser.GenericValue; import org.eclipse.ecsp.analytics.stream.base.utils.Constants; import org.junit.Assert; import org.junit.Test; @@ -50,8 +46,6 @@ import java.util.List; import java.util.Map; - - /** * {@link EventWrapperTest}. */ @@ -200,7 +194,7 @@ public void testParseWithExprFetchEvent() { Object v = w.getPropertyByExpr("data[EventID=EngineRPM]"); Assert.assertNotNull(v); Map m = (Map) v; - Assert.assertEquals(new Long(Constants.LONG_1475151880125), + Assert.assertEquals(Long.valueOf(Constants.LONG_1475151880125), w.getProperty(m, "Timestamp")); Assert.assertEquals(new String("111"), w.getProperty(m, "Data.value")); } @@ -265,7 +259,7 @@ public void testParseWithExprFetchEventForWrappedSequence() { Object v = w.getPropertyByExpr("[EventID=Location]"); Assert.assertNotNull(v); Map m = (Map) v; - Assert.assertEquals(new Long(Constants.LONG_1443717903851), + Assert.assertEquals(Long.valueOf(Constants.LONG_1443717903851), w.getProperty(m, "TimeStamp")); Assert.assertEquals(new String("N"), w.getProperty(m, "Data.heading")); } @@ -284,7 +278,7 @@ public void testParseWithExprFetchEventsForWrappedSequence() { System.out.println(v); List l = (List) v; Map m = (Map) l.get(0); - Assert.assertEquals(new Long(Constants.LONG_1443717903851), + Assert.assertEquals(Long.valueOf(Constants.LONG_1443717903851), w.getProperty(m, "TimeStamp")); Assert.assertTrue(w.getProperty(m, "Data.value").equals("100") || w.getProperty(m, "Data.value").equals("150")); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/DeviceMessagingAgentPreProcessorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/DeviceMessagingAgentPreProcessorTest.java index ae50d2f..ff2753c 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/DeviceMessagingAgentPreProcessorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/DeviceMessagingAgentPreProcessorTest.java @@ -158,7 +158,6 @@ public void testnullKey() { RetryTestEvent event = new RetryTestEvent(); event.setMessageId("msgId223"); event.setCorrelationId(msgId); - String mapKey = RetryRecordKey.getMapKey(serviceName, taskId); dmaPreProcessor.configChanged(new Properties()); dmaPreProcessor.punctuate(TestConstants.TWELVE); dmaPreProcessor.setMapKey(null); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/HiveMQMqttDispatcherWithoutToDeviceForSubServicesTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/HiveMQMqttDispatcherWithoutToDeviceForSubServicesTest.java index 398a9cf..bb384a2 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/HiveMQMqttDispatcherWithoutToDeviceForSubServicesTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/HiveMQMqttDispatcherWithoutToDeviceForSubServicesTest.java @@ -166,7 +166,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MessageGenerator.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MessageGenerator.java index 6a3806a..ab1506b 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MessageGenerator.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MessageGenerator.java @@ -128,12 +128,15 @@ public void run() { * usage(). */ public static void usage() { - System.out.println("Requires 5 arguements.\n" - + "1) Kafka topic name \n" - + "2) Key \n" - + "3) Value \n" - + "4) bootstrapserver \n" - + "5) sslEnabled"); + String textBlock = """ + Requires 5 arguements. + 1) Kafka topic name + 2) Key + 3) Value + 4) bootstrapserver + 5) sslEnabled + """; + System.out.println(textBlock); } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherIntegrationTest.java index db1f607..79cce36 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherIntegrationTest.java @@ -193,12 +193,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -240,7 +240,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformIntegrationTest.java index 3c59b7a..25131b5 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformIntegrationTest.java @@ -205,12 +205,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); mqttDispatcher.dispatch(key, value); @@ -255,7 +255,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformInvalidConfigIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformInvalidConfigIntegrationTest.java index ad229de..a5d0b2d 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformInvalidConfigIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherPlatformInvalidConfigIntegrationTest.java @@ -203,12 +203,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -277,7 +277,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLIntegrationTest.java index f2f8ea1..d3abf95 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLIntegrationTest.java @@ -172,12 +172,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -221,7 +221,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLPlatformIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLPlatformIntegrationTest.java index a17edb4..d49d70a 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLPlatformIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherSSLPlatformIntegrationTest.java @@ -175,12 +175,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -223,7 +223,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutToDeviceForSubServicesTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutToDeviceForSubServicesTest.java index 8132e9a..fa1cffc 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutToDeviceForSubServicesTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutToDeviceForSubServicesTest.java @@ -166,7 +166,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutTopicPrefixIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutTopicPrefixIntegrationTest.java index a6da853..1457290 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutTopicPrefixIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MqttDispatcherWithoutTopicPrefixIntegrationTest.java @@ -188,12 +188,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -238,7 +238,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MsgSeqPreProcessorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MsgSeqPreProcessorTest.java index d01fe79..b8b9770 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MsgSeqPreProcessorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/MsgSeqPreProcessorTest.java @@ -50,7 +50,6 @@ import org.apache.kafka.streams.state.KeyValueIterator; import org.apache.kafka.streams.state.KeyValueStore; import org.eclipse.ecsp.analytics.stream.base.StreamProcessingContext; -import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; import org.eclipse.ecsp.analytics.stream.base.stores.HarmanPersistentKVStore; import org.eclipse.ecsp.analytics.stream.base.utils.Constants; import org.eclipse.ecsp.domain.EventID; @@ -96,7 +95,7 @@ public class MsgSeqPreProcessorTest { */ @Before public void setup() { - + // Nothing to do. } /** @@ -368,8 +367,7 @@ public long offset() { */ @Override public void checkpoint() { - - + // Nothing to do. } /** @@ -393,6 +391,7 @@ public KeyValueStore getStateStore(String name) { */ @Override public void forwardDirectly(String key, String value, String topic) { + // Nothing to do. } /** @@ -437,7 +436,7 @@ public MetricRegistry getMetricRegistry() { */ @Override public void schedule(long interval, PunctuationType punctuationType, Punctuator punctuator) { - + // Nothing to do. } @@ -462,7 +461,7 @@ public void forward(Record kafkaRecord) { */ @Override public void forward(Record kafkaRecord, String name) { - + // Nothing to do. } @@ -554,7 +553,7 @@ public void init(ProcessorContext context, StateStore root) { */ @Override public void flush() { - + // Nothing to do. } @@ -563,8 +562,7 @@ public void flush() { */ @Override public void close() { - - + // Nothing to do. } /** @@ -667,7 +665,7 @@ public Object putIfAbsent(String key, Object value) { */ @Override public void putAll(List> entries) { - + // Nothing to do. } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/ProtocolTranslatorPreProcessorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/ProtocolTranslatorPreProcessorTest.java index c7891a4..e9088d3 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/ProtocolTranslatorPreProcessorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/ProtocolTranslatorPreProcessorTest.java @@ -139,7 +139,6 @@ public void setUp() throws Exception { //Event transformer list cannot be @Test(expected = IllegalArgumentException.class) public void testInitConfigException1() { - IgniteKey testKey = new ProtocolTranslatorPreProcessorTest.TestKey(); ProtocolTranslatorPreProcessorTest.TestEvent event = new ProtocolTranslatorPreProcessorTest.TestEvent(); event.setEventId(EventID.DELETE_SCHEDULE_EVENT); protocolTranslatorPreProcessor.initConfig(props); @@ -151,7 +150,6 @@ public void testInitConfigException1() { //Ignite event Serializer cannot be blank @Test(expected = IllegalArgumentException.class) public void testInitConfigException2() { - IgniteKey testKey = new ProtocolTranslatorPreProcessorTest.TestKey(); ProtocolTranslatorPreProcessorTest.TestEvent event = new ProtocolTranslatorPreProcessorTest.TestEvent(); event.setEventId(EventID.DELETE_SCHEDULE_EVENT); props.setProperty(PropertyNames.EVENT_TRANSFORMER_CLASSES, "genericIgniteEventTransformer"); @@ -164,7 +162,6 @@ public void testInitConfigException2() { //Ignite key transformer cannot be blank @Test(expected = IllegalArgumentException.class) public void testInitConfigException3() { - IgniteKey testKey = new ProtocolTranslatorPreProcessorTest.TestKey(); ProtocolTranslatorPreProcessorTest.TestEvent event = new ProtocolTranslatorPreProcessorTest.TestEvent(); event.setEventId(EventID.DELETE_SCHEDULE_EVENT); props.setProperty(PropertyNames.EVENT_TRANSFORMER_CLASSES, @@ -179,7 +176,6 @@ public void testInitConfigException3() { */ @Test(expected = IllegalArgumentException.class) public void testInitConfigException4() { - IgniteKey testKey = new ProtocolTranslatorPreProcessorTest.TestKey(); ProtocolTranslatorPreProcessorTest.TestEvent event = new ProtocolTranslatorPreProcessorTest.TestEvent(); event.setEventId(EventID.DELETE_SCHEDULE_EVENT); @@ -457,6 +453,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/SchedulerAgentPostProcessorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/SchedulerAgentPostProcessorTest.java index 6f219e8..944bb13 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/SchedulerAgentPostProcessorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/SchedulerAgentPostProcessorTest.java @@ -343,6 +343,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessor.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessor.java index f0e92cd..a851a66 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessor.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessor.java @@ -142,7 +142,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { } if (LOGGER.isDebugEnabled()) { - LOGGER.debug("Key={},Value={}", key.toString(), value.toString()); + LOGGER.debug("Key={},Value={}", key, value); } // do processing and then forward the event. @@ -158,7 +158,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -166,7 +166,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -176,7 +176,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessorMultiForwards.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessorMultiForwards.java index 4840aa5..5264a46 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessorMultiForwards.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/processors/TestStreamProcessorMultiForwards.java @@ -63,9 +63,6 @@ public class TestStreamProcessorMultiForwards implements IgniteEventStreamProces /** The log. */ private final Logger log = LoggerFactory.getLogger(TestStreamProcessor.class); - - /** The props. */ - private Properties props; /** The ctxt. */ private StreamProcessingContext, IgniteEvent> ctxt; @@ -144,7 +141,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { } if (log.isDebugEnabled()) { - log.debug("Key={},Value={}", key.toString(), value.toString()); + log.debug("Key={},Value={}", key, value); } // do processing and then forward the event. @@ -170,7 +167,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -178,7 +175,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -188,7 +185,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -198,7 +195,6 @@ public void configChanged(Properties props) { */ @Override public void initConfig(Properties props) { - this.props = props; String sourceTopicNames = (String) props.get("source.topic.name"); sourceTopics = sourceTopicNames.split(","); log.info("source topic list {}", sourceTopicNames); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/CacheBypassIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/CacheBypassIntegrationTest.java index b7d4cef..d5cfcc4 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/CacheBypassIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/CacheBypassIntegrationTest.java @@ -49,12 +49,6 @@ public class CacheBypassIntegrationTest extends KafkaStreamsApplicationTestBase /** The mutation id. */ private Optional mutationId = Optional.empty(); - /** The id. */ - private String id = "test_id"; - - /** The queue. */ - private BlockingQueue queue; - /** The logger. */ private static IgniteLogger logger = IgniteLoggerFactory.getLogger(CacheBypassIntegrationTest.class); @@ -91,7 +85,6 @@ public class CacheBypassIntegrationTest extends KafkaStreamsApplicationTestBase @Before public void setup() throws Exception, MqttException { super.setup(); - queue = new LinkedBlockingDeque(); } /** @@ -223,7 +216,6 @@ private void setOperationOnEntity(CacheEntity entity public void testCacheBypassIfRedisUnavailable() throws Exception { RedisServer408 redis = (RedisServer408) ReflectionTestUtils.getField(redisServer, "redis"); redis.stop(); - //bypass.setup(id); for (int i = 0; i < TestConstants.TWO; i++) { CacheEntity entityi = new CacheEntity<>(); IgniteEventImpl eventi = new IgniteEventImpl(); @@ -274,7 +266,6 @@ private List getRecordsFromRedis() { public void testCacheBypassWithLoadIfRedisUnavailable() throws Exception { RedisServer408 redis = (RedisServer408) ReflectionTestUtils.getField(redisServer, "redis"); redis.stop(); - //bypass.setup(id); startWorkerThreads(); Thread.sleep(TestConstants.LONG_11000); redis.start(); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/HarmanRocksDBStoreTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/HarmanRocksDBStoreTest.java index 8e979f7..20f7f16 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/HarmanRocksDBStoreTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/stores/HarmanRocksDBStoreTest.java @@ -202,10 +202,8 @@ public void testRocksDBRestoreBatch() { String key = "key1"; byte[] keyArr = key.getBytes(StandardCharsets.UTF_8); - String value = "value1"; byte[] valueArr = key.getBytes(StandardCharsets.UTF_8); - Headers header = new RecordHeaders(); - + ConsumerRecord record1 = new ConsumerRecord("testTopic", 0, 0, keyArr, valueArr); List> consumerRecords = new ArrayList<>(); diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQHandlerTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQHandlerTest.java index 10b2228..122dc60 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQHandlerTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQHandlerTest.java @@ -219,9 +219,6 @@ private IgniteBlobEvent getDummyIgniteBlobEvent() { */ public static final class DLQServiceProcessor implements StreamProcessor, IgniteEvent, IgniteKey, IgniteEvent> { - - /** The spc. */ - private StreamProcessingContext, IgniteEvent> spc; /** * Inits the. @@ -230,7 +227,6 @@ public static final class DLQServiceProcessor implements */ @Override public void init(StreamProcessingContext, IgniteEvent> spc) { - this.spc = spc; } /** @@ -265,7 +261,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -273,7 +269,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -283,7 +279,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQReprocessingTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQReprocessingTest.java index 590801d..2b260cc 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQReprocessingTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQReprocessingTest.java @@ -46,7 +46,6 @@ import org.eclipse.ecsp.domain.SpeedV1_0; import org.eclipse.ecsp.domain.Version; import org.eclipse.ecsp.entities.IgniteEventImpl; -import org.eclipse.ecsp.transform.GenericIgniteEventTransformer; import org.junit.Assert; import org.junit.Before; import org.junit.Rule; @@ -102,9 +101,6 @@ public class DLQReprocessingTest { /** The service context. */ private Map serviceContext; - /** The transformer. */ - private GenericIgniteEventTransformer transformer; - /** The key. */ private K key; @@ -139,7 +135,6 @@ public void setUp() throws Exception { value = new IgniteEventImpl(); igniteEventImpl = new IgniteEventImpl(); igniteExceptionData = new IgniteExceptionDataV1_1(); - transformer = new GenericIgniteEventTransformer(); key = (K) new String("key"); internalException = new RuntimeException(deatiledExceptionMessage); retryableIgniteBaseException = new IgniteBaseException(exceptionMessage, true, internalException, diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerFailureTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerFailureTest.java index 4731ca6..8d6b4fd 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerFailureTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerFailureTest.java @@ -39,14 +39,12 @@ package org.eclipse.ecsp.analytics.stream.base.utils; -import com.fasterxml.jackson.databind.ObjectMapper; import org.apache.kafka.clients.consumer.ConsumerConfig; import org.apache.kafka.clients.producer.ProducerConfig; import org.apache.kafka.common.serialization.Serdes; import org.apache.kafka.streams.processor.api.Record; import org.eclipse.ecsp.analytics.stream.base.Launcher; import org.eclipse.ecsp.analytics.stream.base.PropertyNames; -import org.eclipse.ecsp.analytics.stream.base.StreamBaseConstant; import org.eclipse.ecsp.analytics.stream.base.StreamProcessingContext; import org.eclipse.ecsp.analytics.stream.base.StreamProcessor; import org.eclipse.ecsp.analytics.stream.base.constants.TestConstants; @@ -104,12 +102,6 @@ public class DLQRetryHandlerFailureTest extends KafkaStreamsApplicationTestBase /** The vehicle id. */ private static String vehicleId = "vehicle-1"; - - /** The service name. */ - private static String serviceName = "Ecall"; - - /** The dql topic name. */ - private static String dqlTopicName = "ecall" + StreamBaseConstant.DLQ_TOPIC_POSFIX; /** The value ser. */ private static IngestionSerializerFstImpl valueSer = new IngestionSerializerFstImpl(); @@ -121,12 +113,6 @@ public class DLQRetryHandlerFailureTest extends KafkaStreamsApplicationTestBase @ClassRule public static final EmbeddedMongoDB MONGO_SERVER = new EmbeddedMongoDB(); - /** The mapper. */ - private ObjectMapper mapper = new ObjectMapper(); - - /** The toggle DLQ. */ - private static boolean toggleDLQ = true; - /** * Setup. * @@ -276,6 +262,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -283,6 +270,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -292,6 +280,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -368,7 +357,7 @@ public String name() { */ @Override public void process(Record, IgniteEvent> kafkaRecord) { - LOGGER.info("DLQReprocessingPreProcessorOne : Process {}"); + LOGGER.info("DLQReprocessingPreProcessorOne : Process {}, {}", kafkaRecord.key(), kafkaRecord.value()); count++; this.spc.forward(kafkaRecord); @@ -381,6 +370,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -388,6 +378,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -397,6 +388,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -453,7 +445,7 @@ public String name() { */ @Override public void process(Record, IgniteEvent> kafkaRecord) { - LOGGER.info("DLQReprocessingPreProcessorTwo : Process{}"); + LOGGER.info("DLQReprocessingPreProcessorTwo : Process {}, {}", kafkaRecord.key(), kafkaRecord.value()); count++; this.spc.forward(kafkaRecord); @@ -466,6 +458,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -473,6 +466,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -482,6 +476,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -539,7 +534,7 @@ public String name() { */ @Override public void process(Record, IgniteEvent> kafkaRecord) { - LOGGER.info("DLQReprocessingPostProcessorOne : Process{}"); + LOGGER.info("DLQReprocessingPostProcessorOne : Process {}, {}", kafkaRecord.key(), kafkaRecord.value()); count++; this.spc.forward(kafkaRecord); @@ -552,6 +547,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -559,6 +555,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -568,6 +565,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -591,9 +589,6 @@ public static final class DLQReprocessingPostProcessorTwo /** The Constant LOGGER. */ private static final Logger LOGGER = LoggerFactory.getLogger(DLQReprocessingPostProcessorTwo.class); - /** The spc. */ - private StreamProcessingContext, IgniteEvent> spc; - /** The count. */ private static int count; @@ -604,8 +599,7 @@ public static final class DLQReprocessingPostProcessorTwo */ @Override public void init(StreamProcessingContext, IgniteEvent> spc) { - this.spc = spc; - + // Nothing to do. } /** @@ -625,7 +619,7 @@ public String name() { */ @Override public void process(Record, IgniteEvent> kafkaRecord) { - LOGGER.info("DLQReprocessingPostProcessorTwo : Process{}"); + LOGGER.info("DLQReprocessingPostProcessorTwo : Process {}, {}", kafkaRecord.key(), kafkaRecord.value()); count++; } @@ -637,6 +631,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -644,6 +639,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -653,6 +649,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerTest.java index 68183ab..f4752c1 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DLQRetryHandlerTest.java @@ -260,9 +260,6 @@ private IgniteBlobEvent getDummyIgniteBlobEvent() { */ public static final class DLQServiceProcessor implements StreamProcessor, IgniteEvent, IgniteKey, IgniteEvent> { - - /** The spc. */ - private StreamProcessingContext, IgniteEvent> spc; /** * Inits the. @@ -271,7 +268,6 @@ public static final class DLQServiceProcessor implements */ @Override public void init(StreamProcessingContext, IgniteEvent> spc) { - this.spc = spc; } /** @@ -306,7 +302,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -314,7 +310,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -324,7 +320,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** @@ -426,6 +422,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -433,6 +430,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -442,6 +440,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -471,9 +470,6 @@ public String[] sources() { */ public static final class DLQReprocessingMaxRetryServiceProcessor implements StreamProcessor, IgniteEvent, IgniteKey, IgniteEvent> { - - /** The spc. */ - private StreamProcessingContext, IgniteEvent> spc; /** * Inits the. @@ -482,8 +478,7 @@ public static final class DLQReprocessingMaxRetryServiceProcessor */ @Override public void init(StreamProcessingContext, IgniteEvent> spc) { - this.spc = spc; - + // Nothing to do. } /** @@ -518,6 +513,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -525,6 +521,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -534,8 +531,9 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } - + /** * Creates the state store. * @@ -623,6 +621,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -630,6 +629,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -639,6 +639,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -709,6 +710,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -716,6 +718,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -725,6 +728,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -795,6 +799,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -802,6 +807,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -811,6 +817,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** @@ -834,9 +841,6 @@ public static final class DLQReprocessingPostProcessorTwo /** The Constant LOGGER. */ private static final Logger LOGGER = LoggerFactory.getLogger(DLQReprocessingPostProcessorTwo.class); - /** The spc. */ - private StreamProcessingContext, IgniteEvent> spc; - /** The count. */ private static int count; @@ -847,8 +851,7 @@ public static final class DLQReprocessingPostProcessorTwo */ @Override public void init(StreamProcessingContext, IgniteEvent> spc) { - this.spc = spc; - + // Nothing to do. } /** @@ -880,6 +883,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -887,6 +891,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -896,6 +901,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DeviceConnectionStatusRetrieverTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DeviceConnectionStatusRetrieverTest.java index b428cf9..05ee5de 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DeviceConnectionStatusRetrieverTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/DeviceConnectionStatusRetrieverTest.java @@ -164,7 +164,11 @@ public void testValidate() { @Test public void testLoadConnectionStatusParser() { ctx = Mockito.mock(ApplicationContext.class); + ReflectionTestUtils.setField(statusRetriever, "apiUrl", "test/url"); ReflectionTestUtils.setField(statusRetriever, "ctx", ctx); + ReflectionTestUtils.setField(statusRetriever, "connStatusParserImpl", + "org.eclipse.ecsp.stream.dma.ConnectionStatusParserTestImpl"); ReflectionTestUtils.invokeMethod(statusRetriever, "setup", new Object[0]); + Assert.assertNotNull(ReflectionTestUtils.getField(statusRetriever, "parser")); } } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorIntegrationTest.java index 9670513..8a76da0 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorIntegrationTest.java @@ -188,6 +188,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java index 23c51ec..f37ce54 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java @@ -40,9 +40,6 @@ package org.eclipse.ecsp.analytics.stream.base.utils; import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.utils.Constants; -import org.eclipse.ecsp.analytics.stream.base.utils.MqttDispatcher; -import org.eclipse.ecsp.analytics.stream.base.utils.MqttHealthMonitor; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorTest.java index 36544b6..30d3056 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherHealthMontiorTest.java @@ -245,16 +245,16 @@ public void testInitializeForcedHealthCheckEvent() { IgniteStringKey igniteStringKey = (IgniteStringKey) ReflectionTestUtils.getField(mqttDispatcherOne, "forcedCheckKey"); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, igniteStringKey.getKey()); - DeviceMessage forcedCheckValue = (DeviceMessage) ReflectionTestUtils.getField(mqttDispatcherOne, + DeviceMessage dmForcedCheckValue = (DeviceMessage) ReflectionTestUtils.getField(mqttDispatcherOne, "forcedCheckValue"); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, - forcedCheckValue.getDeviceMessageHeader().getTargetDeviceId()); + dmForcedCheckValue.getDeviceMessageHeader().getTargetDeviceId()); Assert.assertEquals(Constants.FORCED_HEALTH_DEFAULT_TEST_TOPIC_NAME, - forcedCheckValue.getDeviceMessageHeader().getDevMsgTopicSuffix()); + dmForcedCheckValue.getDeviceMessageHeader().getDevMsgTopicSuffix()); Assert.assertEquals(Constants.FORCED_HEALTH_DEFAULT_TEST_TOPIC_NAME, - forcedCheckValue.getEvent().getDevMsgTopicSuffix().get()); + dmForcedCheckValue.getEvent().getDevMsgTopicSuffix().get()); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, - forcedCheckValue.getEvent().getTargetDeviceId().get()); + dmForcedCheckValue.getEvent().getTargetDeviceId().get()); } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationSSLTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationSSLTest.java index ad75e50..786dfb4 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationSSLTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationSSLTest.java @@ -200,6 +200,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationTest.java index 36a05c0..ef08327 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherIntegrationTest.java @@ -198,6 +198,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherTest.java index 12bc30c..b768d37 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/HiveMQMqttDispatcherTest.java @@ -395,7 +395,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaDispatcherTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaDispatcherTest.java index 64f71a2..e42345e 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaDispatcherTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaDispatcherTest.java @@ -237,9 +237,9 @@ public void testSetup() { public void testSetNextHandler() { DeviceMessageHandler handler = new DefaultPostDispatchHandler(); ReflectionTestUtils.setField(dispatcher, "dmaPostDispatchHandler", handler); - DeviceMessageHandler postDispatchHandler = (DeviceMessageHandler) ReflectionTestUtils.getField(dispatcher, + DeviceMessageHandler dmPostDispatchHandler = (DeviceMessageHandler) ReflectionTestUtils.getField(dispatcher, "dmaPostDispatchHandler"); - assertNotNull(postDispatchHandler); + assertNotNull(dmPostDispatchHandler); } /** @@ -316,6 +316,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaStreamsApplicationTestBase.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaStreamsApplicationTestBase.java index ed85573..2758ab4 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaStreamsApplicationTestBase.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/KafkaStreamsApplicationTestBase.java @@ -141,9 +141,6 @@ public class KafkaStreamsApplicationTestBase { /** The launcher. */ private Launcher launcher; - - /** The enable prometheus. */ - private boolean enablePrometheus; /** * Returns up to `maxMessages` message-values from the topic. @@ -199,8 +196,8 @@ public static List> readKeyValues(String topic, Properties while (totalPollTimeMs < maxTotalPollTimeMs && continueConsuming(consumedValues.size(), maxMessages)) { totalPollTimeMs += pollIntervalMs; ConsumerRecords records = consumer.poll(pollIntervalMs); - for (ConsumerRecord record : records) { - consumedValues.add(new KeyValue<>(record.key(), record.value())); + for (ConsumerRecord consumerRecord : records) { + consumedValues.add(new KeyValue<>(consumerRecord.key(), consumerRecord.value())); } } } finally { @@ -230,10 +227,6 @@ private static boolean continueConsuming(int messagesConsumed, int maxMessages) protected void launchApplication() throws Exception { launcher = ctx.getBean(Launcher.class); launcher.setExecuteShutdownHook(false); - /* - * if (enablePrometheus) { prometheusExportServer = new HTTPServer(1234, true); - * } - */ launcher.launch(); } @@ -357,16 +350,13 @@ protected void purgeLocalStreamsState(Properties streamsConfiguration) throws IO protected void produceKeyValuesSynchronously( String topic, Collection> records, Properties producerConfig) throws ExecutionException, InterruptedException { - Producer producer = new KafkaProducer<>(producerConfig); - try { - for (KeyValue record : records) { + try (Producer producer = new KafkaProducer<>(producerConfig)) { + for (KeyValue kvRecord : records) { Future f = producer.send( - new ProducerRecord<>(topic, record.key, record.value)); + new ProducerRecord<>(topic, kvRecord.key, kvRecord.value)); f.get(); } producer.flush(); - } finally { - producer.close(); } } diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorIntegrationTest.java index 80f8a3c..b5dd4da 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorIntegrationTest.java @@ -167,11 +167,11 @@ public void setup() { */ @Test public void testMqttHealthMonitorIntegration() throws MqttException, InterruptedException { - MqttClient client = pahoMqttDispatcher.getMqttClient(PropertyNames.DEFAULT_PLATFORMID).get(); + MqttClient mqttClient = pahoMqttDispatcher.getMqttClient(PropertyNames.DEFAULT_PLATFORMID).get(); String mqttTopicToSubscribe = defaultMqttTopicNameGeneratorImpl.getMqttTopicName(forcedCheckKey, forcedCheckValue.getDeviceMessageHeader(), null).get(); - client.subscribe(mqttTopicToSubscribe); - client.setCallback(new MqttCallback() { + mqttClient.subscribe(mqttTopicToSubscribe); + mqttClient.setCallback(new MqttCallback() { @Override public void messageArrived(String topic, MqttMessage message) throws Exception { LOGGER.error("Msg received:{} on topic:{}", message, topic); @@ -181,15 +181,14 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); - Assert.assertEquals(true, mqttDispatcher.isHealthy(false)); RetryUtils.retry(Constants.TWENTY, (v) -> { return mqttTopic.length() > 0 ? Boolean.TRUE : null; @@ -219,7 +218,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java index a052d25..aceaab0 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorMultipleDispatcherIntegrationTest.java @@ -40,9 +40,6 @@ package org.eclipse.ecsp.analytics.stream.base.utils; import org.eclipse.ecsp.analytics.stream.base.Launcher; -import org.eclipse.ecsp.analytics.stream.base.utils.Constants; -import org.eclipse.ecsp.analytics.stream.base.utils.MqttDispatcher; -import org.eclipse.ecsp.analytics.stream.base.utils.MqttHealthMonitor; import org.junit.Assert; import org.junit.Before; import org.junit.Test; diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorTest.java index a5e9354..1847b66 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherHealthMontiorTest.java @@ -62,8 +62,6 @@ import java.util.Optional; - - /** * class {@link MqttDispatcherTestHealthMontior}. */ @@ -250,16 +248,16 @@ public void testInitializeForcedHealthCheckEvent() { IgniteStringKey igniteStringKey = (IgniteStringKey) ReflectionTestUtils.getField(mqttDispatcherOne, "forcedCheckKey"); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, igniteStringKey.getKey()); - DeviceMessage forcedCheckValue = (DeviceMessage) ReflectionTestUtils.getField(mqttDispatcherOne, + DeviceMessage dmForcedCheckValue = (DeviceMessage) ReflectionTestUtils.getField(mqttDispatcherOne, "forcedCheckValue"); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, - forcedCheckValue.getDeviceMessageHeader().getTargetDeviceId()); + dmForcedCheckValue.getDeviceMessageHeader().getTargetDeviceId()); Assert.assertEquals(Constants.FORCED_HEALTH_DEFAULT_TEST_TOPIC_NAME, - forcedCheckValue.getDeviceMessageHeader().getDevMsgTopicSuffix()); + dmForcedCheckValue.getDeviceMessageHeader().getDevMsgTopicSuffix()); Assert.assertEquals(Constants.FORCED_HEALTH_DEFAULT_TEST_TOPIC_NAME, - forcedCheckValue.getEvent().getDevMsgTopicSuffix().get()); + dmForcedCheckValue.getEvent().getDevMsgTopicSuffix().get()); Assert.assertEquals(Constants.FORCED_HEALTH_CHECK_DEVICE_ID, - forcedCheckValue.getEvent().getTargetDeviceId().get()); + dmForcedCheckValue.getEvent().getTargetDeviceId().get()); } } \ No newline at end of file diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherTest.java index dfb0e60..eec1a1b 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/base/utils/MqttDispatcherTest.java @@ -425,7 +425,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtilTest.java b/src/test/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtilTest.java index fa99d2f..1ac4e9b 100644 --- a/src/test/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtilTest.java +++ b/src/test/java/org/eclipse/ecsp/analytics/stream/vehicleprofile/utils/VehicleProfileClientApiUtilTest.java @@ -112,7 +112,7 @@ public void testcallVehicleProfile() { @Test public void testAppendToUrl() { String vehicleId = "vehicle1234"; - String expectedUrl = "http://vehicle-profile-api-int-svc:8080/v1.0/vehicles?clientId=" + vehicleId; + String expectedUrl; String actualUrl = ""; String urlWithoutForwardSlash = "http://vehicle-profile-api-int-svc:8080/v1.0/vehicles?clientId="; diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/ConnectionStatusHandlerTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/ConnectionStatusHandlerTest.java index c3a1a32..5fc35f2 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/ConnectionStatusHandlerTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/ConnectionStatusHandlerTest.java @@ -123,9 +123,6 @@ public String getServiceName() { public void setServiceName(String serviceName) { this.serviceName = serviceName; } - - /** The interval. */ - private long interval = 500L; /** * Sets up the environment for this test class before each test case run. @@ -257,7 +254,6 @@ public void testDMABasedOnDeviceStatus() throws Exception { */ KafkaTestUtils.sendMessages(connStatusTopic, producerProps, vehicleId.getBytes(), deviceConnStatusEvent.getBytes()); - actual = new ConcurrentHashSet(); actual = retryWithException(TestConstants.TWENTY, getStatus); Assert.assertEquals(expectedValue, actual); @@ -294,8 +290,7 @@ public void testDMABasedOnDeviceStatus() throws Exception { Thread.sleep(TestConstants.THREAD_SLEEP_TIME_3000); KafkaTestUtils.sendMessages(sourceTopicName, producerProps, vehicleId.getBytes(), speedEventWithVehicleIdAndSourceDeviceId.getBytes()); - String actualMsgRec = retryWithException(TestConstants.THIRTY, x -> testClient.getMsgReceived()); - actualMsgRec = retryWithException(TestConstants.TWENTY, x -> testClient.getMsgReceived()); + retryWithException(TestConstants.THIRTY, x -> testClient.getMsgReceived()); msgRec = testClient.getMsgReceived(); Assert.assertTrue(msgRec.contains("\"EventID\":\"Speed\"")); @@ -360,7 +355,7 @@ public void testDMABasedOnDeviceStatus() throws Exception { + "\"VehicleId\": \"Vehicle12345\",\"SourceDeviceId\": \"Device12347\"}"; KafkaTestUtils.sendMessages(sourceTopicName, producerProps, vehicleId.getBytes(), speedEventWithVehicleIdAndSourceDeviceIdDevice12347.getBytes()); - actualMsgRec = retryWithException(TestConstants.TWENTY, x -> testClient.getMsgReceived()); + retryWithException(TestConstants.TWENTY, x -> testClient.getMsgReceived()); msgRec = testClient.getMsgReceived(); Assert.assertTrue(msgRec.contains("\"EventID\":\"Speed\"")); Assert.assertTrue(msgRec.contains("\"Version\":\"1.0\"")); @@ -611,12 +606,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); } diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DMARetryBucketDAOCacheBackedInMemoryImplTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DMARetryBucketDAOCacheBackedInMemoryImplTest.java index 7b4bf9c..41ba4be 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DMARetryBucketDAOCacheBackedInMemoryImplTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DMARetryBucketDAOCacheBackedInMemoryImplTest.java @@ -145,7 +145,6 @@ public class DMARetryBucketDAOCacheBackedInMemoryImplTest { @Before public void setup() { mapKey = RetryBucketKey.getMapKey(serviceName, taskId); - // sortedDao.setBypass(bypass); key1 = new RetryBucketKey(TestConstants.THREAD_SLEEP_TIME_3000); key2 = new RetryBucketKey(TestConstants.THREAD_SLEEP_TIME_1000); key3 = new RetryBucketKey(TestConstants.THREAD_SLEEP_TIME_5000); @@ -250,12 +249,12 @@ public void testDeleteKey() { */ @Test public void testDeleteLongString() { - String mapKey = RetryBucketKey.getMapKey(serviceName, taskId); - sortedDao.deleteMessageId(mapKey, key1, "message124"); + String retryBucketMapKey = RetryBucketKey.getMapKey(serviceName, taskId); + sortedDao.deleteMessageId(retryBucketMapKey, key1, "message124"); // Cannot delte elemt that is not present Assert.assertEquals(retryMsgIds1, sortedDao.get(key1)); - sortedDao.deleteMessageId(mapKey, key1, "message123"); + sortedDao.deleteMessageId(retryBucketMapKey, key1, "message123"); Set expected = new HashSet(); expected.add("message456"); // Element Deleted @@ -307,8 +306,6 @@ public void testGetHeadMapLongBoolean() { @Test public void testGetTailMapLongBoolean() { Set expectedKeySet = new HashSet(); - - expectedKeySet = new HashSet(); expectedKeySet.add(key1); expectedKeySet.add(key3); Set actualKeySet = new HashSet(); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DMAShoulderTapRetryBucketDAOCacheBackedInMemoryImplTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DMAShoulderTapRetryBucketDAOCacheBackedInMemoryImplTest.java index c9f13b3..7951719 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DMAShoulderTapRetryBucketDAOCacheBackedInMemoryImplTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DMAShoulderTapRetryBucketDAOCacheBackedInMemoryImplTest.java @@ -303,8 +303,6 @@ public void testGetHeadMapLongBoolean() { @Test public void testGetTailMapLongBoolean() { Set expectedKeySet = new HashSet(); - - expectedKeySet = new HashSet(); expectedKeySet.add(key1); expectedKeySet.add(key3); Set actualKeySet = new HashSet(); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferIntegrationTest.java index 4a38a3b..8d3aaff 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferIntegrationTest.java @@ -315,7 +315,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -323,7 +323,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -333,7 +333,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferMultipleDevicesIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferMultipleDevicesIntegrationTest.java index d257a96..fa1f0ae 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferMultipleDevicesIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DMOfflineBufferMultipleDevicesIntegrationTest.java @@ -278,7 +278,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -286,7 +286,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -296,7 +296,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DeviceConnStatusServiceTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DeviceConnStatusServiceTest.java index f3e3a50..e1b2f63 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DeviceConnStatusServiceTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DeviceConnStatusServiceTest.java @@ -175,9 +175,9 @@ public void testDeleteKey() { */ @Test public void testDeleteKeyForSubService() { - ConcurrentHashSet value = new ConcurrentHashSet(); - value.add(deviceId2); - deviceStatusServiceImpl.put(key, value, null, Optional.of("subService1")); + ConcurrentHashSet set = new ConcurrentHashSet(); + set.add(deviceId2); + deviceStatusServiceImpl.put(key, set, null, Optional.of("subService1")); String deviceIdToDelete = deviceId2; deviceStatusServiceImpl.delete(key, deviceIdToDelete, null, Optional.of("subService1")); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/DeviceStatusAPIInMemoryServiceImplTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/DeviceStatusAPIInMemoryServiceImplTest.java index 4a44402..f6c275b 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/DeviceStatusAPIInMemoryServiceImplTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/DeviceStatusAPIInMemoryServiceImplTest.java @@ -96,7 +96,6 @@ public void testGetDeviceIdStatusFromInMemory() { */ @Test public void testGetDeviceIdStatusWhenStatusNotPresentInMemory() { - VehicleIdDeviceIdStatus vehicleIdDeviceIdStatus = new VehicleIdDeviceIdStatus(); Assert.assertNull(deviceStatusAPIInMemoryService.get(key)); } diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/KafkaDispatcherIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/KafkaDispatcherIntegrationTest.java index 2bc4f4e..500b050 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/KafkaDispatcherIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/KafkaDispatcherIntegrationTest.java @@ -353,8 +353,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - - + // Nothing to do. } /** @@ -362,8 +361,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - - + // Nothing to do. } /** @@ -373,8 +371,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdAndCorrIdUpdaterTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdAndCorrIdUpdaterTest.java index f5dc7d5..93d1f6e 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdAndCorrIdUpdaterTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdAndCorrIdUpdaterTest.java @@ -128,12 +128,6 @@ public void testAddingMessageId() { Version.V1_0, value, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); DeviceMessageHeader valueWithHeaders = deviceIdUpdater.addMessageIdAndCorrelationIdIfNotPresent(entity) .getDeviceMessageHeader(); - ShortHashCodeIdPartGenerator shcApp = new ShortHashCodeIdPartGenerator(); - String incVal = shcApp.generateIdPart(SERVICE_SP_NAME); - - boolean containsHashCode = valueWithHeaders.getMessageId().toString() - .startsWith(incVal); - // Assert.assertTrue(containsHashCode); Assert.assertNull(valueWithHeaders.getCorrelationId()); } @@ -152,12 +146,6 @@ public void testAddingCorrelationId() { DeviceMessageHeader valueWithHeaders = deviceIdUpdater.addMessageIdAndCorrelationIdIfNotPresent(entity) .getDeviceMessageHeader(); - ShortHashCodeIdPartGenerator shcApp = new ShortHashCodeIdPartGenerator(); - String incVal = shcApp.generateIdPart(SERVICE_SP_NAME); - - boolean containsHashCode = valueWithHeaders.getMessageId().toString() - .startsWith(incVal); - // Assert.assertTrue(containsHashCode); Assert.assertEquals("12345", valueWithHeaders.getCorrelationId()); } @@ -210,7 +198,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdUpdaterTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdUpdaterTest.java index 5fbbcfb..c7476ca 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdUpdaterTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/MsgIdUpdaterTest.java @@ -108,12 +108,6 @@ public void messageIdUpdationTest() { DeviceMessage entity = new DeviceMessage(transformer.toBlob(value), Version.V1_0, value, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); DeviceMessage valueWithHeaders = deviceIdUpdater.addMessageIdIfNotPresent(entity); - ShortHashCodeIdPartGenerator shcApp = new ShortHashCodeIdPartGenerator(); - String incVal = shcApp.generateIdPart(SERVICE_SP_NAME); - - boolean containsHashCode = valueWithHeaders.getDeviceMessageHeader().getMessageId() - .startsWith(incVal); - // Assert.assertTrue(containsHashCode); Assert.assertNull(valueWithHeaders.getDeviceMessageHeader().getCorrelationId()); } @@ -193,7 +187,7 @@ public void handle(IgniteKey key, DeviceMessage value) { */ @Override public void setNextHandler(DeviceMessageHandler handler) { - + // Nothing to do. } /** @@ -201,7 +195,7 @@ public void setNextHandler(DeviceMessageHandler handler) { */ @Override public void close() { - + // Nothing to do. } } @@ -218,7 +212,7 @@ public class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/SynchronizationIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/SynchronizationIntegrationTest.java index 28905d4..33b2481 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/SynchronizationIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/SynchronizationIntegrationTest.java @@ -141,54 +141,6 @@ public void testPutGetEntity() { Assert.assertEquals(entityPut.getIgniteKey(), entityRead.getIgniteKey()); } - // @Test - // public void testDeviceConnSyncWithCacheIntegration() throws InterruptedException { - // ConcurrentHashSet value = new ConcurrentHashSet(); - // value.add("deviceId12345"); - // VehicleIdDeviceIdMapping mapping = new VehicleIdDeviceIdMapping(Version.V1_0, value); - // - // ConcurrentHashSet value2 = new ConcurrentHashSet(); - // value2.add("deviceId22345"); - // VehicleIdDeviceIdMapping mapping2 = new VehicleIdDeviceIdMapping(Version.V1_0, value2); - // - // ConcurrentHashSet value3 = new ConcurrentHashSet(); - // value3.add("deviceId32345"); - // VehicleIdDeviceIdMapping mapping3 = new VehicleIdDeviceIdMapping(Version.V1_0, value3); - // - // DeviceStatusKey abc = new DeviceStatusKey("abc"); - // DeviceStatusKey efg = new DeviceStatusKey("efg"); - // DeviceStatusKey hij = new DeviceStatusKey("hij"); - // - // // Device Connection status from now on will be put in to cache from - // // HiveMq and not by DMA - // - // putToCache(abc, mapping); - // putToCache(efg, mapping2); - // putToCache(hij, mapping3); - // deviceStatusCacheBackedInMemoryDAO.initialize(); - // - // Assert.assertEquals(mapping.toString(), - // deviceStatusCacheBackedInMemoryDAO.get(abc).toString()); - // Assert.assertEquals(mapping2.toString(), - // deviceStatusCacheBackedInMemoryDAO.get(efg).toString()); - // } - - /** - * Put to cache. - * - * @param key the key - * @param value the value - */ - private void putToCache(DeviceStatusKey key, VehicleIdDeviceIdMapping value) { - PutMapOfEntitiesRequest putRequest = new PutMapOfEntitiesRequest<>(); - putRequest.withKey(key.getMapKey(serviceName)); - Map pair = new HashMap(); - pair.put(key.convertToString(), value); - putRequest.withValue(pair); - putRequest.withNamespaceEnabled(false); - cache.putMapOfEntities(putRequest); - } - /** * Test retry record sync with cache integration. * diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/DeviceStatusKeyTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/DeviceStatusKeyTest.java index 483f7de..b6c8d57 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/DeviceStatusKeyTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/DeviceStatusKeyTest.java @@ -39,7 +39,6 @@ package org.eclipse.ecsp.stream.dma.dao.key; -import org.eclipse.ecsp.stream.dma.dao.key.DeviceStatusKey; import org.junit.Assert; import org.junit.Test; @@ -81,15 +80,6 @@ public void testHashCode() { Assert.assertNotEquals(key1.hashCode(), key3.hashCode()); } - /** - * Test get key. - */ - @Test - public void testGetKey() { - DeviceStatusKey key = new DeviceStatusKey("key"); - Assert.assertEquals("key", key.getKey()); - } - /** * Test set key. */ diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryBucketKeyTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryBucketKeyTest.java index 7c1d067..dc01ae4 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryBucketKeyTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryBucketKeyTest.java @@ -94,15 +94,6 @@ public void testConvertToString() { Assert.assertEquals("1000", ts); } - /** - * Test get timestamp. - */ - @Test - public void testGetTimestamp() { - RetryBucketKey key = new RetryBucketKey(TestConstants.THREAD_SLEEP_TIME_1000); - Assert.assertEquals(TestConstants.THREAD_SLEEP_TIME_1000, key.getTimestamp()); - } - /** * Test set timestamp. */ diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryVehicleIdKeyTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryVehicleIdKeyTest.java index d7c7a17..bed6162 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryVehicleIdKeyTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/RetryVehicleIdKeyTest.java @@ -39,7 +39,6 @@ package org.eclipse.ecsp.stream.dma.dao.key; -import org.eclipse.ecsp.stream.dma.dao.key.RetryVehicleIdKey; import org.junit.Assert; import org.junit.Test; @@ -93,13 +92,13 @@ public void testEquals() { Assert.assertEquals(retryKey, retryKey); Assert.assertNotEquals(null, retryKey); - String key = "abc"; - Assert.assertNotEquals(retryKey, key); + String testKey = "abc"; + Assert.assertNotEquals(retryKey, testKey); RetryVehicleIdKey retryKey2 = new RetryVehicleIdKey(); Assert.assertNotEquals(retryKey2, retryKey); - retryKey2.setKey(key); + retryKey2.setKey(testKey); Assert.assertNotEquals(retryKey2, retryKey); retryKey2.setKey(this.key); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/ShoulderTapRetryBucketKeyTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/ShoulderTapRetryBucketKeyTest.java index 6014fdf..f3a9fd6 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/ShoulderTapRetryBucketKeyTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/dao/key/ShoulderTapRetryBucketKeyTest.java @@ -96,15 +96,6 @@ public void testConvertToString() { Assert.assertEquals("1000", ts); } - /** - * Test get timestamp. - */ - @Test - public void testGetTimestamp() { - ShoulderTapRetryBucketKey key = new ShoulderTapRetryBucketKey(TestConstants.THREAD_SLEEP_TIME_1000); - Assert.assertEquals(TestConstants.THREAD_SLEEP_TIME_1000, key.getTimestamp()); - } - /** * Test set timestamp. */ diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/handler/DMAFeedbackTopicTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/handler/DMAFeedbackTopicTest.java index cfc714a..bd710e8 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/handler/DMAFeedbackTopicTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/handler/DMAFeedbackTopicTest.java @@ -83,9 +83,6 @@ @EnableRuleMigrationSupport @TestPropertySource("/dma-connectionstatus-handler-test.properties") public class DMAFeedbackTopicTest extends KafkaStreamsApplicationTestBase { - - /** The Constant LOGGER. */ - private static final Logger LOGGER = LoggerFactory.getLogger(DMAFeedbackTopicTest.class); /** The source topic name. */ private static String sourceTopicName; @@ -218,7 +215,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } /** @@ -226,7 +223,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } /** @@ -236,7 +233,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandlerUnitTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandlerUnitTest.java index 34f7fcf..888e101 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandlerUnitTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/handler/DeviceConnectionStatusHandlerUnitTest.java @@ -242,7 +242,6 @@ public void testGetConnectionStatusIfFoundInactiveInMemory() { @Test public void testGetConnectionStatusWithOneVehicleMultipleDevices() { String requestId = "req124"; - String service = "ecall"; IgniteEventImpl event = new IgniteEventImpl(); SpeedV1_0 speed = new SpeedV1_0(); speed.setValue(Constants.THREAD_SLEEP_TIME_100); @@ -346,7 +345,6 @@ public void testGetConnectionStatusRedisdeviceIdsInCacheIsNull() { @Test public void testGetConnectionStatusIfNotFoundInMemory() { String requestId = "req124"; - String service = "ecall"; IgniteEventImpl event = new IgniteEventImpl(); SpeedV1_0 speed = new SpeedV1_0(); speed.setValue(Constants.THREAD_SLEEP_TIME_100); @@ -811,7 +809,7 @@ public void testFilterDMOffLineEntry() { bufferEntry2.setVehicleId(vehicleId); bufferedEntries.add(bufferEntry2); - getBufferedEntries("vehicle3", "eventId3", "reqId3", igniteKey, bufferedEntries); + getBufferedEntries("vehicle3", "eventId3", igniteKey, bufferedEntries); Mockito.when(offlineBufferDAO.getOfflineBufferEntriesSortedByPriority(vehicleId, true, Optional.empty(), Optional.empty())).thenReturn(bufferedEntries); @@ -837,7 +835,7 @@ public void testFilterDMOffLineEntry() { * @param bufferedEntries the buffered entries * @return the buffered entries */ - private static void getBufferedEntries(String vehicle3, String eventId3, String reqId3, IgniteStringKey igniteKey, + private static void getBufferedEntries(String vehicle3, String eventId3, IgniteStringKey igniteKey, List bufferedEntries) { DMOfflineBufferEntry bufferEntry3 = new DMOfflineBufferEntry(); bufferEntry3.setDeviceId(vehicle3); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerIntegrationTest.java index 9704645..67a719b 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerIntegrationTest.java @@ -219,12 +219,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); String speedEventWithVehicleIdAndSourceDeviceId = "{\"EventID\": \"Speed\"," @@ -269,12 +269,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -356,12 +356,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -404,12 +404,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); String speedEventWithVehicleIdAndSourceDeviceId = "{\"EventID\": \"test_Speed\"," @@ -485,12 +485,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -513,27 +513,23 @@ public void connectionLost(Throwable cause) { DeviceMessageFailureEventDataV1_0 data1 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(0).getEventData(); - Assert.assertEquals(data1.getErrorCode(), - DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data1.getErrorCode()); Assert.assertEquals(data1.getRetryAttempts(), 1); DeviceMessageFailureEventDataV1_0 data2 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(1).getEventData(); - Assert.assertEquals(data2.getErrorCode(), - DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); - Assert.assertEquals(data2.getRetryAttempts(), Constants.TWO); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data2.getErrorCode()); + Assert.assertEquals(Constants.TWO, data2.getRetryAttempts()); DeviceMessageFailureEventDataV1_0 data3 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(Constants.TWO).getEventData(); - Assert.assertEquals(data3.getErrorCode(), - DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); - Assert.assertEquals(data3.getRetryAttempts(), Constants.THREE); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data3.getErrorCode()); + Assert.assertEquals(Constants.THREE, data3.getRetryAttempts()); DeviceMessageFailureEventDataV1_0 data4 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(Constants.THREE).getEventData(); - Assert.assertEquals(data4.getErrorCode(), - DeviceMessageErrorCode.RETRY_ATTEMPTS_EXCEEDED); - Assert.assertEquals(data3.getRetryAttempts(), Constants.THREE); + Assert.assertEquals(DeviceMessageErrorCode.RETRY_ATTEMPTS_EXCEEDED, data4.getErrorCode()); + Assert.assertEquals(Constants.THREE, data3.getRetryAttempts()); } @@ -587,12 +583,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -631,23 +627,23 @@ public void connectionLost(Throwable cause) { DeviceMessageFailureEventDataV1_0 data1 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(0).getEventData(); - Assert.assertEquals(data1.getErrorCode(), DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); - Assert.assertEquals(data1.getRetryAttempts(), 1); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data1.getErrorCode()); + Assert.assertEquals(1, data1.getRetryAttempts()); DeviceMessageFailureEventDataV1_0 data2 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(1).getEventData(); - Assert.assertEquals(data2.getErrorCode(), DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); - Assert.assertEquals(data2.getRetryAttempts(), Constants.TWO); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data2.getErrorCode()); + Assert.assertEquals(Constants.TWO, data2.getRetryAttempts()); DeviceMessageFailureEventDataV1_0 data3 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(Constants.TWO).getEventData(); - Assert.assertEquals(data3.getErrorCode(), DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE); - Assert.assertEquals(data3.getRetryAttempts(), Constants.THREE); + Assert.assertEquals(DeviceMessageErrorCode.RETRYING_DEVICE_MESSAGE, data3.getErrorCode()); + Assert.assertEquals(Constants.THREE, data3.getRetryAttempts()); DeviceMessageFailureEventDataV1_0 data4 = (DeviceMessageFailureEventDataV1_0) failureEventList.get(Constants.THREE).getEventData(); - Assert.assertEquals(data4.getErrorCode(), DeviceMessageErrorCode.RETRY_ATTEMPTS_EXCEEDED); - Assert.assertEquals(data4.getRetryAttempts(), Constants.THREE); + Assert.assertEquals(DeviceMessageErrorCode.RETRY_ATTEMPTS_EXCEEDED, data4.getErrorCode()); + Assert.assertEquals(Constants.THREE, data4.getRetryAttempts()); } /** @@ -744,12 +740,12 @@ public void messageArrived(String topic, MqttMessage message) throws Exception { @Override public void deliveryComplete(IMqttDeliveryToken token) { - + // Nothing to do. } @Override public void connectionLost(Throwable cause) { - + // Nothing to do. } }); @@ -829,7 +825,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -838,7 +834,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -849,7 +845,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } @@ -938,7 +934,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { - + // Nothing to do. } @@ -947,7 +943,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { - + // Nothing to do. } @@ -958,7 +954,7 @@ public void close() { */ @Override public void configChanged(Properties props) { - + // Nothing to do. } diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerTest.java index 08ea483..5054e89 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryHandlerTest.java @@ -305,14 +305,14 @@ public void testRetryHandleSaveToOfflineBufferAndDeleteFromCache() throws Interr DeviceMessage entity = new DeviceMessage(transformer.toBlob(event), Version.V1_0, event, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); long currentTime = System.currentTimeMillis() - TestConstants.THREAD_SLEEP_TIME_10000; - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - DeviceMessage message = record.getDeviceMessage(); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + DeviceMessage message = retryRecord.getDeviceMessage(); message.setDeviceMessageHeader(message.getDeviceMessageHeader().withPendingRetries(1)); - record.setDeviceMessage(message); + retryRecord.setDeviceMessage(message); EventConfig config = new EventConfigTestImpl(); Mockito.when(eventConfigMap.get(Mockito.any())).thenReturn(config); - Mockito.when(retryEventDAO.get(Mockito.any())).thenReturn(record); + Mockito.when(retryEventDAO.get(Mockito.any())).thenReturn(retryRecord); Mockito.doNothing().when(offlineBufferDAO).addOfflineBufferEntry(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any()); Mockito.when(connectionStatusHandler.getDeviceIdIfActive(retryTestKey, entity.getDeviceMessageHeader(), @@ -345,15 +345,14 @@ public void testRetryHandleWhenAttemptsAreLessThanMaxRetry() throws InterruptedE DeviceMessage entity = new DeviceMessage(transformer.toBlob(event), Version.V1_0, event, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); long currentTime = System.currentTimeMillis() - TestConstants.THREAD_SLEEP_TIME_10000; - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - DeviceMessage message = record.getDeviceMessage(); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + DeviceMessage message = retryRecord.getDeviceMessage(); message.setDeviceMessageHeader(message.getDeviceMessageHeader().withPendingRetries(1)); - record.setDeviceMessage(message); - String retryRecordKey = "vehicleId;msg123"; + retryRecord.setDeviceMessage(message); EventConfig config = new EventConfigTestImpl(); Mockito.when(eventConfigMap.get(Mockito.any())).thenReturn(config); - Mockito.when(retryEventDAO.get(Mockito.any())).thenReturn(record); + Mockito.when(retryEventDAO.get(Mockito.any())).thenReturn(retryRecord); Mockito.doNothing().when(offlineBufferDAO).addOfflineBufferEntry(Mockito.anyString(), Mockito.any(), Mockito.any(), Mockito.any()); Mockito.when(connectionStatusHandler.getDeviceIdIfActive(retryTestKey, entity.getDeviceMessageHeader(), @@ -423,8 +422,8 @@ public void testRetryHandleWhenMaxRetryThresholdHasNotBeenReached() throws Inter .thenReturn(Optional.of("vehicleId")); // We are creating a RetryRecord in which attempts is 1 less than // maxretry. - RetryRecord record = getRetryRecord(currentTime, entity); - Mockito.when(retryEventDAO.get(new RetryRecordKey(retryRecordKey, taskId))).thenReturn(record); + RetryRecord retryRecord = getRetryRecord(currentTime, entity); + Mockito.when(retryEventDAO.get(new RetryRecordKey(retryRecordKey, taskId))).thenReturn(retryRecord); // Max Retry is set to 2 here. getRetryHandler(); TestHandler handler = new TestHandler(); @@ -482,12 +481,12 @@ public void testRetryHandleWhenMaxRetryThresholdHasNotBeenReached() throws Inter */ @NotNull private RetryRecord getRetryRecord(long currentTime, DeviceMessage entity) { - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - DeviceMessage message = record.getDeviceMessage(); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + DeviceMessage message = retryRecord.getDeviceMessage(); message.setDeviceMessageHeader(message.getDeviceMessageHeader().withPendingRetries(1)); - record.setDeviceMessage(message); - return record; + retryRecord.setDeviceMessage(message); + return retryRecord; } /** @@ -554,11 +553,11 @@ public void testRetryHandleWhenMaxRetryThresholdHasReached() throws InterruptedE entity.getDeviceMessageHeader(), "vehicleId")).thenReturn(Optional.of("vehicleId")); // We are creating a RetryRecord in which attempts is 2 to match the // maxretry. - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - record.addAttempt(currentTime + Constants.TWENTY); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + retryRecord.addAttempt(currentTime + Constants.TWENTY); - Mockito.when(retryEventDAO.get(new RetryRecordKey(retryRecordKey, taskId))).thenReturn(record); + Mockito.when(retryEventDAO.get(new RetryRecordKey(retryRecordKey, taskId))).thenReturn(retryRecord); // Max Retry is set to 2 here. retryHandler.setMaxRetry(Constants.TWO); @@ -762,7 +761,7 @@ public void handle(IgniteKey key, DeviceMessage value) { */ @Override public void setNextHandler(DeviceMessageHandler handler) { - + // Nothing to do. } /** @@ -779,7 +778,7 @@ public List getEventList() { */ @Override public void close() { - + // Nothing to do. } } diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryTestEvent.java b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryTestEvent.java index dad9f6d..74c5577 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryTestEvent.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/handler/RetryTestEvent.java @@ -57,7 +57,7 @@ public class RetryTestEvent extends IgniteEventImpl { * Instantiates a new retry test event. */ public RetryTestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerIntegrationTest.java index b4829ac..c4b2565 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerIntegrationTest.java @@ -383,7 +383,6 @@ public void testIfShoulderTapMsgDeliveredAndDeviceRemainsInActiveThenMaxRetryIsA DeviceMessageFailureEventDataV1_0 sixthFailEventData = (DeviceMessageFailureEventDataV1_0) sixthDeviceMessageFailureEvent.getEventData(); - sixthFailEventData = (DeviceMessageFailureEventDataV1_0) sixthDeviceMessageFailureEvent.getEventData(); assertEquals(DeviceMessageErrorCode.SHOULDER_TAP_RETRY_ATTEMPTS_EXCEEDED, sixthFailEventData.getErrorCode()); assertEquals(maxRetry, sixthFailEventData.getShoudlerTapRetryAttempts()); assertEquals(true, sixthFailEventData.isDeviceStatusInactive()); @@ -441,7 +440,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { IgniteEvent value = kafkaRecord.value(); AbstractIgniteEvent event = (AbstractIgniteEvent) value; if (EventID.DEVICEMESSAGEFAILURE.equals(event.getEventId())) { - LOGGER.debug("Received feedBackEvent: " + value); + LOGGER.debug("Received feedBackEvent: {}", value); } else { event.setDeviceRoutable(true); event.setShoulderTapEnabled(true); @@ -456,6 +455,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -463,6 +463,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -472,6 +473,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerTest.java index 7e532ef..809b9a4 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapRetryHandlerTest.java @@ -158,11 +158,6 @@ public void setUp() { event.setRequestId("Req123"); event.setMessageId("Msg123"); event.setBizTransactionId("Biz123"); - // Class classObject = - // getClass().getClassLoader() - // .loadClass("org.eclipse.ecsp.stream.dma.shouldertap.DummyShoulderTapInvokerImpl"); - // Mockito.when(ctx.getBean(classObject)).thenReturn((DeviceShoulderTapInvoker) - // deviceShoulderTapInvoker); Mockito.when(deviceShoulderTapInvoker.sendWakeUpMessage("Req123", vehicleId, extraParameters, spc)) .thenReturn(true); } @@ -279,11 +274,11 @@ public void testRetryHandleWhenMaxRetryThresholdHasNotBeenReached() throws Inter DeviceMessage entity = new DeviceMessage(transformer.toBlob(event), Version.V1_0, event, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - record.setExtraParameters(extraParameters); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + retryRecord.setExtraParameters(extraParameters); Mockito.when(spc.streamName()).thenReturn("topic"); - Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(record); + Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(retryRecord); // Max Retry is set to Constants.TWO here. shoulderTapRetryHandler.setRetryIntervalDivisor(Constants.TEN); @@ -352,12 +347,12 @@ public void testRetryHandleWhenMaxRetryThresholdHasReached() throws InterruptedE DeviceMessage entity = new DeviceMessage(transformer.toBlob(event), Version.V1_0, event, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - record.addAttempt(currentTime + Constants.TWENTY); - record.setExtraParameters(extraParameters); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + retryRecord.addAttempt(currentTime + Constants.TWENTY); + retryRecord.setExtraParameters(extraParameters); Mockito.when(spc.streamName()).thenReturn("topic"); - Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(record); + Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(retryRecord); // Max Retry is set to Constants.TWO here. int maxRetry = Constants.TWO; @@ -461,10 +456,10 @@ public void testSetStreamProcessingContext() throws InterruptedException { */ @Test(expected = IllegalArgumentException.class) public void testInitInvalidDeviceShoulderTapInvokerImplConfig() throws InterruptedException { - String deviceShoulderTapInvoker = + String deviceShoulderTapInvokerImpl = "org.eclipse.ecsp.stream.dma.shouldertap.ShoulderTapInvokerWAMImp"; ReflectionTestUtils.setField(shoulderTapRetryHandler, - "deviceShoulderTapInvokerImplClass", deviceShoulderTapInvoker); + "deviceShoulderTapInvokerImplClass", deviceShoulderTapInvokerImpl); shoulderTapRetryHandler.init(); } @@ -571,11 +566,11 @@ public void testRetryHandleWhenDeviceMessageVehicleIdIsAlreadyRegistered() throw DeviceMessage entity = new DeviceMessage(transformer.toBlob(event), Version.V1_0, event, sourceTopic, Constants.THREAD_SLEEP_TIME_60000); - RetryRecord record = new RetryRecord(retryTestKey, entity, currentTime); - record.addAttempt(currentTime + Constants.TEN); - record.setExtraParameters(extraParameters); + RetryRecord retryRecord = new RetryRecord(retryTestKey, entity, currentTime); + retryRecord.addAttempt(currentTime + Constants.TEN); + retryRecord.setExtraParameters(extraParameters); Mockito.when(spc.streamName()).thenReturn("topic"); - Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(record); + Mockito.when(shoulderTapRetryRecordDAO.get(Mockito.any(RetryVehicleIdKey.class))).thenReturn(retryRecord); boolean registered = shoulderTapRetryHandler.registerDevice(retryTestKey, entity, extraParameters); assertTrue(registered); diff --git a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapServiceTest.java b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapServiceTest.java index a678d59..27e76b8 100644 --- a/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapServiceTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/dma/shouldertap/DeviceShoulderTapServiceTest.java @@ -269,7 +269,7 @@ class TestEvent extends IgniteEventImpl { * Instantiates a new test event. */ public TestEvent() { - + // Nothing to do. } /** diff --git a/src/test/java/org/eclipse/ecsp/stream/scheduler/SchedulerAgentIntegrationTest.java b/src/test/java/org/eclipse/ecsp/stream/scheduler/SchedulerAgentIntegrationTest.java index 3944771..60b09d8 100644 --- a/src/test/java/org/eclipse/ecsp/stream/scheduler/SchedulerAgentIntegrationTest.java +++ b/src/test/java/org/eclipse/ecsp/stream/scheduler/SchedulerAgentIntegrationTest.java @@ -429,6 +429,7 @@ public void process(Record, IgniteEvent> kafkaRecord) { */ @Override public void punctuate(long timestamp) { + // Nothing to do. } /** @@ -436,6 +437,7 @@ public void punctuate(long timestamp) { */ @Override public void close() { + // Nothing to do. } /** @@ -445,6 +447,7 @@ public void close() { */ @Override public void configChanged(Properties props) { + // Nothing to do. } /**