-
Notifications
You must be signed in to change notification settings - Fork 146
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created test class for PartnerServiceEventsInitializer (#686)
* Created Test class for MissingCredentialsItemReader => MissingCredentialsItemReaderTest * Created Test Class for IdAuthFraudAnalysisEventManager =>IdAuthFraudAnalysisEventManagerTest * Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest * Created Test Class for PartnerServiceCallbackController =>PartnerServiceCallbackControllerTest * Created test class for PartnerServiceEventsInitializer => PartnerServiceEventsInitializerTest Co-authored-by: Vipul Dhurve <[email protected]>
- Loading branch information
1 parent
7d9352c
commit 15adf1f
Showing
1 changed file
with
66 additions
and
0 deletions.
There are no files selected for viewing
66 changes: 66 additions & 0 deletions
66
.../mosip/authentication/common/service/websub/impl/PartnerServiceEventsInitializerTest.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,66 @@ | ||
package io.mosip.authentication.common.service.websub.impl; | ||
|
||
import io.mosip.authentication.common.service.helper.WebSubHelper; | ||
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.core.env.Environment; | ||
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; | ||
|
||
@RunWith(SpringRunner.class) | ||
@WebMvcTest | ||
@ContextConfiguration(classes = {TestContext.class, WebApplicationContext.class}) | ||
public class PartnerServiceEventsInitializerTest { | ||
|
||
@InjectMocks | ||
private PartnerServiceEventsInitializer partnerServiceEventsInitializer; | ||
|
||
@Mock | ||
private Environment env; | ||
|
||
@Mock | ||
private WebSubHelper webSubHelper; | ||
|
||
/** | ||
* This class tests the doRegister method | ||
*/ | ||
@Test | ||
public void doRegisterTest(){ | ||
partnerServiceEventsInitializer.doRegister(); | ||
} | ||
|
||
/** | ||
* This class tests the tryRegisterTopicPartnerServiceEvents method | ||
* when Exception is thrown | ||
*/ | ||
@Test | ||
public void tryRegisterTopicPartnerServiceEventsTest(){ | ||
ReflectionTestUtils.setField(partnerServiceEventsInitializer, "webSubHelper", null); | ||
ReflectionTestUtils.invokeMethod(partnerServiceEventsInitializer, "tryRegisterTopicPartnerServiceEvents"); | ||
} | ||
|
||
/** | ||
* This class tests the doSubscribe method | ||
*/ | ||
@Test | ||
public void doSubscribeTest(){ | ||
ReflectionTestUtils.setField(partnerServiceEventsInitializer, "partnerServiceCallbackURL", "ida-websub-partner-service-callback-url"); | ||
partnerServiceEventsInitializer.doSubscribe(); | ||
} | ||
|
||
/** | ||
* This class tests the subscribeForPartnerServiceEvents method | ||
* when Exception is thrown | ||
*/ | ||
@Test(expected = Exception.class) | ||
public void subscribeForPartnerServiceEventsTest(){ | ||
ReflectionTestUtils.invokeMethod(partnerServiceEventsInitializer, "subscribeForPartnerServiceEvents"); | ||
} | ||
|
||
} |