From 3c5fe5df885efb1034e4881d1026a9aea2a2b3c5 Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 11:54:25 +0530 Subject: [PATCH 1/6] Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest --- authentication/pom.xml | 1 + 1 file changed, 1 insertion(+) diff --git a/authentication/pom.xml b/authentication/pom.xml index 48a1cf52725..d26f1127cce 100644 --- a/authentication/pom.xml +++ b/authentication/pom.xml @@ -267,6 +267,7 @@ none + ${java.home}/bin/javadoc From c5e7eb5b26c0b0fe356ad9c0296fb781f01cdd2f Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 11:55:30 +0530 Subject: [PATCH 2/6] Revert "Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest" This reverts commit 3c5fe5df885efb1034e4881d1026a9aea2a2b3c5. --- authentication/pom.xml | 1 - 1 file changed, 1 deletion(-) diff --git a/authentication/pom.xml b/authentication/pom.xml index d26f1127cce..48a1cf52725 100644 --- a/authentication/pom.xml +++ b/authentication/pom.xml @@ -267,7 +267,6 @@ none - ${java.home}/bin/javadoc From 23b13de83a130e22f733958f36b324376c74d8a0 Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 11:56:30 +0530 Subject: [PATCH 3/6] Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest --- .../InternalAuthWebSubInitializerTest.java | 38 +++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java diff --git a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java new file mode 100644 index 00000000000..7e3035eefec --- /dev/null +++ b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java @@ -0,0 +1,38 @@ +package io.mosip.authentication.internal.service.listener; + +import io.mosip.authentication.common.service.helper.WebSubHelper; +import io.mosip.authentication.common.service.websub.impl.IdAuthFraudAnalysisEventPublisher; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.InjectMocks; +import org.mockito.Mock; +import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.TestContext; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.web.context.WebApplicationContext; + +@WebMvcTest +@ContextConfiguration(classes = {TestContext.class, WebApplicationContext.class}) +@RunWith(SpringRunner.class) +public class InternalAuthWebSubInitializerTest { + + @InjectMocks + private InternalAuthWebSubInitializer internalAuthWebSubInitializer; + + @Mock + protected WebSubHelper webSubHelper; + + @Mock + private IdAuthFraudAnalysisEventPublisher fraudEventPublisher; + + @Test + public void doInitSubscriptionsTest(){ + internalAuthWebSubInitializer.doInitSubscriptions(); + } + + @Test + public void doRegisterTopicsTest(){ + internalAuthWebSubInitializer.doRegisterTopics(); + } +} From f676666cf107ab87fbddc7a310fbad89cf0dff3f Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 12:25:30 +0530 Subject: [PATCH 4/6] Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest --- .../listener/InternalAuthWebSubInitializerTest.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java index 7e3035eefec..32f517430d8 100644 --- a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java +++ b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java @@ -2,6 +2,7 @@ import io.mosip.authentication.common.service.helper.WebSubHelper; import io.mosip.authentication.common.service.websub.impl.IdAuthFraudAnalysisEventPublisher; +import org.apache.commons.lang3.builder.ReflectionDiffBuilder; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -10,6 +11,7 @@ import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.TestContext; import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.context.WebApplicationContext; @WebMvcTest @@ -26,13 +28,22 @@ public class InternalAuthWebSubInitializerTest { @Mock private IdAuthFraudAnalysisEventPublisher fraudEventPublisher; + /** + * This class tests the doInitSubscriptions method + */ @Test public void doInitSubscriptionsTest(){ internalAuthWebSubInitializer.doInitSubscriptions(); } + /** + * This class tests the doRegisterTopics method + */ @Test public void doRegisterTopicsTest(){ internalAuthWebSubInitializer.doRegisterTopics(); +// when fraudEventPublisher is null + ReflectionTestUtils.setField(internalAuthWebSubInitializer, "fraudEventPublisher", null); + internalAuthWebSubInitializer.doRegisterTopics(); } } From 52310ee8a528e8d3208025af7a9eaca64ed1eead Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 12:30:40 +0530 Subject: [PATCH 5/6] Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest --- .../listener/InternalAuthWebSubInitializerTest.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java index 32f517430d8..7c854b896be 100644 --- a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java +++ b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java @@ -3,6 +3,8 @@ import io.mosip.authentication.common.service.helper.WebSubHelper; import io.mosip.authentication.common.service.websub.impl.IdAuthFraudAnalysisEventPublisher; import org.apache.commons.lang3.builder.ReflectionDiffBuilder; +import org.apache.http.HttpStatus; +import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; import org.mockito.InjectMocks; @@ -34,6 +36,7 @@ public class InternalAuthWebSubInitializerTest { @Test public void doInitSubscriptionsTest(){ internalAuthWebSubInitializer.doInitSubscriptions(); + Assert.assertEquals(HttpStatus.SC_OK, internalAuthWebSubInitializer.doInitSubscriptions()); } /** @@ -41,9 +44,9 @@ public void doInitSubscriptionsTest(){ */ @Test public void doRegisterTopicsTest(){ - internalAuthWebSubInitializer.doRegisterTopics(); + Assert.assertEquals(HttpStatus.SC_OK, internalAuthWebSubInitializer.doRegisterTopics()); // when fraudEventPublisher is null ReflectionTestUtils.setField(internalAuthWebSubInitializer, "fraudEventPublisher", null); - internalAuthWebSubInitializer.doRegisterTopics(); + Assert.assertEquals(HttpStatus.SC_OK, internalAuthWebSubInitializer.doRegisterTopics()); } } From a5242170a8de914b79e039906e422865c49e64e2 Mon Sep 17 00:00:00 2001 From: Vipul Dhurve Date: Wed, 19 Jan 2022 12:34:17 +0530 Subject: [PATCH 6/6] Created Test class for InternalAuthWebSubInitializer => InternalAuthWebSubInitializerTest --- .../listener/InternalAuthWebSubInitializerTest.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java index 7c854b896be..edd907dbe67 100644 --- a/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java +++ b/authentication/authentication-internal-service/src/test/java/io/mosip/authentication/internal/service/listener/InternalAuthWebSubInitializerTest.java @@ -45,6 +45,13 @@ public void doInitSubscriptionsTest(){ @Test public void doRegisterTopicsTest(){ Assert.assertEquals(HttpStatus.SC_OK, internalAuthWebSubInitializer.doRegisterTopics()); + } + + /** + * This class tests the doRegisterTopics method + */ + @Test + public void doRegisterTopicsTest1(){ // when fraudEventPublisher is null ReflectionTestUtils.setField(internalAuthWebSubInitializer, "fraudEventPublisher", null); Assert.assertEquals(HttpStatus.SC_OK, internalAuthWebSubInitializer.doRegisterTopics());