From ebee27bf1f8d03124b2fcbc13ee366b56c83b51b Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Tue, 22 Mar 2022 22:03:36 +0100 Subject: [PATCH 1/2] Kafka: fix generation of DummyProducerIT --- .../springboot/broker/kafka/domain/KafkaDomainService.java | 2 +- .../kafka/application/KafkaApplicationServiceIT.java | 7 +++---- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainService.java b/src/main/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainService.java index f266e0c066e..ae34cd556b6 100644 --- a/src/main/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainService.java +++ b/src/main/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainService.java @@ -70,6 +70,7 @@ public void addDummyProducer(final Project project) { ); projectRepository.template(project, SOURCE, "DummyProducer.java", getPath(MAIN_JAVA, packageNamePath, DUMMY_PRODUCER_PATH)); projectRepository.template(project, SOURCE, "DummyProducerTest.java", getPath(TEST_JAVA, packageNamePath, DUMMY_PRODUCER_PATH)); + projectRepository.template(project, SOURCE, "DummyProducerIT.java", getPath(TEST_JAVA, packageNamePath, DUMMY_PRODUCER_PATH)); projectRepository.template(project, SOURCE, "KafkaConfiguration.java", getPath(MAIN_JAVA, packageNamePath, secondaryKafkaPath)); } } @@ -135,6 +136,5 @@ void addTestcontainers(final Project project) { } ); springBootCommonService.updateIntegrationTestAnnotation(project, "KafkaTestContainerExtension"); - projectRepository.template(project, SOURCE, "DummyProducerIT.java", getPath(TEST_JAVA, packageNamePath, DUMMY_PRODUCER_PATH)); } } diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/application/KafkaApplicationServiceIT.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/application/KafkaApplicationServiceIT.java index 43fd02f48f5..de0e4209171 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/application/KafkaApplicationServiceIT.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/application/KafkaApplicationServiceIT.java @@ -51,10 +51,6 @@ void shouldInit() { assertFileContent(project, POM_XML, ""); assertFileContent(project, POM_XML, ""); assertFileContent(project, POM_XML, testcontainers()); - - String dummyProducerTestPath = getPath("com/mycompany/myapp/dummy/infrastructure/secondary/kafka/producer"); - assertFileExist(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerIT.java")); - assertFileContent(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerIT.java"), "class DummyProducerIT"); } @Test @@ -92,6 +88,9 @@ void shouldAddProducer() { String dummyProducerTestPath = getPath("com/mycompany/myapp/dummy/infrastructure/secondary/kafka/producer"); assertFileExist(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerTest.java")); assertFileContent(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerTest.java"), "class DummyProducerTest"); + + assertFileExist(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerIT.java")); + assertFileContent(project, getPath(TEST_JAVA, dummyProducerTestPath, "DummyProducerIT.java"), "class DummyProducerIT"); } private List kafkaClients() { From 2b1ec9598e7cbd92ccc263805d2f6b4d80996266 Mon Sep 17 00:00:00 2001 From: Pascal Grimaud Date: Wed, 23 Mar 2022 07:48:34 +0100 Subject: [PATCH 2/2] Kafka: fix unit test --- .../broker/kafka/domain/KafkaDomainServiceTest.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainServiceTest.java b/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainServiceTest.java index 2f580cf0e25..c3b90211f18 100644 --- a/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainServiceTest.java +++ b/src/test/java/tech/jhipster/lite/generator/server/springboot/broker/kafka/domain/KafkaDomainServiceTest.java @@ -51,7 +51,7 @@ void shouldInit() { verify(buildToolService, times(2)).addDependency(any(Project.class), any(Dependency.class)); verify(dockerService, times(2)).getImageNameWithVersion(anyString()); verify(projectRepository).template(any(Project.class), anyString(), anyString(), anyString(), anyString()); - verify(projectRepository, times(2)).template(any(Project.class), anyString(), anyString(), anyString()); + verify(projectRepository, times(1)).template(any(Project.class), anyString(), anyString(), anyString()); verify(springBootCommonService, times(9)).addProperties(any(Project.class), anyString(), any()); verify(springBootCommonService, times(9)).addPropertiesTest(any(Project.class), anyString(), any()); verify(springBootCommonService).updateIntegrationTestAnnotation(any(Project.class), anyString()); @@ -66,7 +66,7 @@ void shouldAddProducer() { verify(springBootCommonService).addProperties(any(Project.class), anyString(), any()); verify(springBootCommonService).addPropertiesTest(any(Project.class), anyString(), any()); - verify(projectRepository, times(5)).template(any(Project.class), anyString(), anyString(), anyString()); + verify(projectRepository, times(6)).template(any(Project.class), anyString(), anyString(), anyString()); } @Test