-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOSIP-32692: Junit tests for MultiPartnerServiceController (#679)
Signed-off-by: SwethaKrish4 <[email protected]>
- Loading branch information
1 parent
49eb185
commit 622e405
Showing
4 changed files
with
73 additions
and
8 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
62 changes: 62 additions & 0 deletions
62
...src/test/java/io/mosip/pms/test/partner/controller/MultiPartnerServiceControllerTest.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,62 @@ | ||
package io.mosip.pms.test.partner.controller; | ||
|
||
import io.mosip.pms.common.response.dto.ResponseWrapper; | ||
import io.mosip.pms.partner.controller.MultiPartnerServiceController; | ||
import io.mosip.pms.partner.dto.CertificateDto; | ||
import io.mosip.pms.partner.dto.PolicyDto; | ||
import io.mosip.pms.partner.service.MultiPartnerService; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest; | ||
import org.springframework.security.test.context.support.WithMockUser; | ||
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; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
@ContextConfiguration(classes = {TestContext.class, WebApplicationContext.class}) | ||
@RunWith(SpringRunner.class) | ||
@WebMvcTest | ||
public class MultiPartnerServiceControllerTest { | ||
|
||
@InjectMocks | ||
private MultiPartnerServiceController multiPartnerServiceController; | ||
|
||
@Mock | ||
private MultiPartnerService multiPartnerService; | ||
|
||
@Test | ||
@WithMockUser(roles = {"PARTNER"}) | ||
public void getAllCertificateDetails() throws Exception { | ||
CertificateDto certificateDto = new CertificateDto(); | ||
certificateDto.setPartnerId("abc"); | ||
certificateDto.setPartnerType("Auth_Partner"); | ||
certificateDto.setIsCertificateAvailable(false); | ||
|
||
List<CertificateDto> certificateDtoList = new ArrayList<>(); | ||
certificateDtoList.add(certificateDto); | ||
|
||
Mockito.when(multiPartnerService.getAllCertificateDetails()).thenReturn(certificateDtoList); | ||
ResponseWrapper<List<CertificateDto>> response = multiPartnerServiceController.getAllCertificateDetails(); | ||
} | ||
|
||
@Test | ||
@WithMockUser(roles = {"PARTNER"}) | ||
public void getAllPoliciesRequestList() throws Exception { | ||
PolicyDto policyDto = new PolicyDto(); | ||
policyDto.setPartnerId("abc"); | ||
policyDto.setPartnerType("Auth_Partner"); | ||
policyDto.setPolicyGroup("123"); | ||
policyDto.setPolicyName("test"); | ||
List<PolicyDto> policyDtoList = new ArrayList<>(); | ||
policyDtoList.add(policyDto); | ||
Mockito.when(multiPartnerService.getAllPolicies()).thenReturn(policyDtoList); | ||
ResponseWrapper<List<PolicyDto>> response = multiPartnerServiceController.getAllPolicies(); | ||
} | ||
} |
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