-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Hit Sonar quality gate * Add Kafka Streams exec context tests * Add properties utils tests * Add test on topic with serdes * Lint * Improve Dlq serialization tests * Lint
- Loading branch information
Loïc GREFFIER
authored
Sep 19, 2023
1 parent
061a86e
commit e214078
Showing
19 changed files
with
284 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
59 changes: 59 additions & 0 deletions
59
...ore/src/test/java/com/michelin/kstreamplify/context/KafkaStreamsExecutionContextTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
package com.michelin.kstreamplify.context; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNull; | ||
|
||
import java.util.Properties; | ||
import org.apache.kafka.streams.StreamsConfig; | ||
import org.junit.jupiter.api.BeforeEach; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class KafkaStreamsExecutionContextTest { | ||
|
||
@BeforeEach | ||
void setUp() { | ||
KafkaStreamsExecutionContext.setProperties(null); | ||
} | ||
|
||
@Test | ||
void shouldNotRegisterPropertiesWhenNull() { | ||
KafkaStreamsExecutionContext.registerProperties(null); | ||
assertNull(KafkaStreamsExecutionContext.getProperties()); | ||
} | ||
|
||
@Test | ||
void shouldAddPrefixToAppId() { | ||
Properties properties = new Properties(); | ||
properties.put(StreamsConfig.APPLICATION_ID_CONFIG, "appId"); | ||
properties.put("prefix.self", "abc."); | ||
|
||
KafkaStreamsExecutionContext.registerProperties(properties); | ||
|
||
assertEquals("abc.", KafkaStreamsExecutionContext.getPrefix()); | ||
assertEquals("abc.appId", KafkaStreamsExecutionContext.getProperties() | ||
.get(StreamsConfig.APPLICATION_ID_CONFIG)); | ||
} | ||
|
||
@Test | ||
void shouldNotAddPrefixToAppIdIfNoPrefix() { | ||
Properties properties = new Properties(); | ||
properties.put(StreamsConfig.APPLICATION_ID_CONFIG, "appId"); | ||
|
||
KafkaStreamsExecutionContext.registerProperties(properties); | ||
|
||
assertEquals("", KafkaStreamsExecutionContext.getPrefix()); | ||
assertEquals("appId", KafkaStreamsExecutionContext.getProperties() | ||
.get(StreamsConfig.APPLICATION_ID_CONFIG)); | ||
} | ||
|
||
@Test | ||
void shouldNotAddPrefixToAppIdIfNotAppId() { | ||
Properties properties = new Properties(); | ||
properties.put("prefix.self", "abc."); | ||
|
||
KafkaStreamsExecutionContext.registerProperties(properties); | ||
|
||
assertEquals("abc.", KafkaStreamsExecutionContext.getPrefix()); | ||
assertNull(KafkaStreamsExecutionContext.getProperties().get(StreamsConfig.APPLICATION_ID_CONFIG)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...amplify/rest/DlqExceptionHandlerTest.java → ...mplify/error/DlqExceptionHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...st/DlqProductionExceptionHandlerTest.java → ...or/DlqProductionExceptionHandlerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...plify/rest/GenericErrorProcessorTest.java → ...lify/error/GenericErrorProcessorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...streamplify/rest/ProcessingErrorTest.java → ...treamplify/error/ProcessingErrorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...treamplify/rest/ProcessingResultTest.java → ...reamplify/error/ProcessingResultTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...eamplify-core/src/test/java/com/michelin/kstreamplify/properties/PropertiesUtilsTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package com.michelin.kstreamplify.properties; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
import java.util.Properties; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class PropertiesUtilsTest { | ||
|
||
@Test | ||
void shouldLoadProperties() { | ||
Properties properties = PropertiesUtils.loadProperties(); | ||
|
||
assertTrue(properties.containsKey("server.port")); | ||
assertTrue(properties.containsValue(8080)); | ||
|
||
assertTrue(properties.containsKey("kafka.properties.application.id")); | ||
assertTrue(properties.containsValue("appId")); | ||
} | ||
|
||
@Test | ||
void shouldLoadKafkaProperties() { | ||
Properties properties = PropertiesUtils.loadKafkaProperties(PropertiesUtils.loadProperties()); | ||
|
||
assertTrue(properties.containsKey("application.id")); | ||
assertTrue(properties.containsValue("appId")); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...amplify-core/src/test/java/com/michelin/kstreamplify/rest/DefaultProbeControllerTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package com.michelin.kstreamplify.rest; | ||
|
||
import static org.junit.jupiter.api.Assertions.assertNotEquals; | ||
import static org.junit.jupiter.api.Assertions.assertNotNull; | ||
|
||
import com.michelin.kstreamplify.initializer.KafkaStreamsInitializer; | ||
import org.junit.jupiter.api.Test; | ||
|
||
class DefaultProbeControllerTest { | ||
@Test | ||
void shouldCreateServerWithDefaultHostAndPort() { | ||
DefaultProbeController controller = new DefaultProbeController(new KafkaStreamsInitializer()); | ||
|
||
assertNotNull(controller.server.getAddress().getAddress().getHostName()); | ||
assertNotEquals(0, controller.server.getAddress().getPort()); | ||
} | ||
} |
Oops, something went wrong.