Skip to content

Commit

Permalink
MOSIP-33042 / MOSIP-33713: Added test cases (#266)
Browse files Browse the repository at this point in the history
* Added registerListener to start_hub
* Removed extra logs
* Removed additional logs
* MOSIP-33042 / MOSIP-33713: Added test cases
* Changes in push-trigger
* Reverting last commit
* MOSIP-33042/MOSIP-33713: Changes in surefire plugin
* MOSIP-33042/MOSIP-33713: Modified test cases

---------

Signed-off-by: HimajaDhanyamraju2 <[email protected]>
Co-authored-by: HimajaDhanyamraju2 <[email protected]>
Signed-off-by: Vishwa <[email protected]>
  • Loading branch information
HimajaDhanyamraju2 and HimajaDhanyamraju2 authored Jun 11, 2024
1 parent d211bcd commit e949635
Show file tree
Hide file tree
Showing 3 changed files with 274 additions and 65 deletions.
150 changes: 95 additions & 55 deletions kafka-admin-client/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<name>kafka-admin-client</name>
<url>http://maven.apache.org</url>
<description>Project of MOSIP kafka admin client</description>

<scm>
<connection>scm:git:git://github.com/mosip/websub.git</connection>
<developerConnection>scm:git:ssh://github.com:mosip/websub.git</developerConnection>
Expand All @@ -38,18 +38,41 @@
<maven.compiler.source>17</maven.compiler.source>
<maven.compiler.target>17</maven.compiler.target>
<maven.compiler.version>3.8.0</maven.compiler.version>
<apache.kafka.version>2.8.0</apache.kafka.version>
<junit.version>4.13.2</junit.version>
<mockito.version>3.11.2</mockito.version>
<powermock.version>2.0.9</powermock.version>
<maven.surefire.plugin.version>2.22.0</maven.surefire.plugin.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.kafka</groupId>
<artifactId>kafka-clients</artifactId>
<version>2.8.0</version>
<version>${apache.kafka.version}</version>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.2</version>
<version>${junit.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.mockito</groupId>
<artifactId>mockito-core</artifactId>
<version>${mockito.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-module-junit4</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.powermock</groupId>
<artifactId>powermock-api-mockito2</artifactId>
<version>${powermock.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
Expand All @@ -70,32 +93,47 @@
</executions>
<configuration>
<generateGitPropertiesFile>true</generateGitPropertiesFile>
<generateGitPropertiesFilename>${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<generateGitPropertiesFilename>
${project.build.outputDirectory}/git.properties</generateGitPropertiesFilename>
<includeOnlyProperties>
<includeOnlyProperty>^git.build.(time|version)$</includeOnlyProperty>
<includeOnlyProperty>^git.commit.id.(abbrev|full)$</includeOnlyProperty>
</includeOnlyProperties>
<commitIdGenerationMode>full</commitIdGenerationMode>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<!-- <format>json</format> -->
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>${maven.surefire.plugin.version}</version>
<configuration>
<skipTests>false</skipTests>
<skip>false</skip>
<argLine>
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
--illegal-access=debug
--enable-preview
</argLine>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
<version>3.2.0</version>
<executions>
<execution>
<id>attach-javadocs</id>
<goals>
<goal>jar</goal>
</goals>
</execution>
</executions>
<configuration>
<doclint>none</doclint>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
Expand All @@ -106,39 +144,39 @@
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-source-plugin</artifactId>
<inherited>true</inherited>
<version>2.2.1</version>
<executions>
<execution>
<id>attach-sources</id>
<goals>
<goal>jar-no-fork</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-gpg-plugin</artifactId>
<version>1.5</version>
<executions>
<execution>
<id>sign-artifacts</id>
<phase>verify</phase>
<goals>
<goal>sign</goal>
</goals>
<configuration>
<gpgArguments>
<arg>--pinentry-mode</arg>
<arg>loopback</arg>
</gpgArguments>
</configuration>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
Expand Down Expand Up @@ -172,8 +210,10 @@
</goals>
<configuration>
<target>
<!-- Create a shell script to run the JAR file with executable permission -->
<chmod file="${project.build.directory}/*.jar" perm="ugo+rx"/>
<!-- Create a shell script to run the JAR file
with executable permission -->
<chmod file="${project.build.directory}/*.jar"
perm="ugo+rx" />
</target>
</configuration>
</execution>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import java.util.Optional;
import java.util.Properties;
import java.util.Set;
import java.util.concurrent.ExecutionException;

import org.apache.kafka.clients.admin.Admin;
import org.apache.kafka.clients.admin.AdminClientConfig;
import org.apache.kafka.clients.admin.CreateTopicsResult;
Expand All @@ -17,8 +15,6 @@
import org.apache.kafka.clients.admin.NewTopic;
import org.apache.kafka.clients.admin.TopicDescription;
import org.apache.kafka.common.KafkaFuture;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class MosipKafkaAdminClient {

Expand All @@ -37,15 +33,14 @@ public void createTopic(String topicName) throws Exception {
// get the async result for the new topic creation
KafkaFuture<Void> future = result.values().get(topicName);
// call get() to block until topic creation has completed or failed
future.get();
future.get();
}
}


public boolean isTopicsPresent(String topics) throws Exception {
List<String> topicsList = Arrays.asList(topics.split(","));
Set<String> kafkaTopics = getAllTopics();
return topicsList.stream().allMatch(kafkaTopics::contains);
List<String> topicsList = Arrays.asList(topics.split(","));
Set<String> kafkaTopics = getAllTopics();
return topicsList.stream().allMatch(kafkaTopics::contains);
}

public Set<String> getAllTopics() throws Exception {
Expand All @@ -56,7 +51,6 @@ public Set<String> getAllTopics() throws Exception {
}
}


public Map<String, TopicDescription> describeTopic(String topic) throws Exception {
try (Admin admin = Admin.create(properties)) {
DescribeTopicsResult result = admin.describeTopics(Collections.singleton(topic));
Expand Down
Loading

0 comments on commit e949635

Please sign in to comment.