forked from mosip/resident-services
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MOSIP-21674 Added junit for GrievanceServiceImpl.
- Loading branch information
Showing
5 changed files
with
69 additions
and
3 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
64 changes: 64 additions & 0 deletions
64
...t/resident-service/src/test/java/io/mosip/resident/test/service/GrievanceServiceTest.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,64 @@ | ||
package io.mosip.resident.test.service; | ||
|
||
import io.mosip.kernel.core.http.ResponseWrapper; | ||
import io.mosip.resident.dto.GrievanceRequestDTO; | ||
import io.mosip.resident.dto.MainRequestDTO; | ||
import io.mosip.resident.exception.ApisResourceAccessException; | ||
import io.mosip.resident.repository.ResidentGrievanceRepository; | ||
import io.mosip.resident.service.impl.GrievanceServiceImpl; | ||
import io.mosip.resident.service.impl.IdentityServiceImpl; | ||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.InjectMocks; | ||
import org.mockito.Mock; | ||
import org.mockito.Mockito; | ||
import org.mockito.junit.MockitoJUnitRunner; | ||
import org.springframework.cloud.context.config.annotation.RefreshScope; | ||
import org.springframework.core.env.Environment; | ||
import org.springframework.test.context.ContextConfiguration; | ||
|
||
import java.io.IOException; | ||
|
||
import static org.junit.Assert.assertNotNull; | ||
|
||
/** | ||
* This class is used to create service class test for grievance API. | ||
* @Author Kamesh Shekhar Prasad | ||
*/ | ||
@RunWith(MockitoJUnitRunner.class) | ||
@RefreshScope | ||
@ContextConfiguration | ||
public class GrievanceServiceTest { | ||
|
||
@InjectMocks | ||
private GrievanceServiceImpl grievanceService = new GrievanceServiceImpl(); | ||
|
||
@Mock | ||
private Environment environment; | ||
|
||
@Mock | ||
private IdentityServiceImpl identityService; | ||
|
||
@Mock | ||
private ResidentGrievanceRepository residentGrievanceRepository; | ||
|
||
private MainRequestDTO<GrievanceRequestDTO> grievanceRequestDTOMainRequestDTO; | ||
|
||
@Before | ||
public void setup() throws Exception { | ||
grievanceRequestDTOMainRequestDTO = new MainRequestDTO<>(); | ||
GrievanceRequestDTO grievanceRequestDTO = new GrievanceRequestDTO(); | ||
grievanceRequestDTO.setEventId("12121212121212"); | ||
grievanceRequestDTO.setMessage("message"); | ||
grievanceRequestDTOMainRequestDTO.setRequest(grievanceRequestDTO); | ||
Mockito.when(environment.getProperty(Mockito.anyString())).thenReturn("Kamesh"); | ||
Mockito.when(identityService.getAvailableclaimValue(Mockito.anyString())).thenReturn("kamesh"); | ||
} | ||
|
||
@Test | ||
public void testGetGrievanceTicket() throws IOException, ApisResourceAccessException { | ||
ResponseWrapper<Object> actualResult = grievanceService.getGrievanceTicket(grievanceRequestDTOMainRequestDTO); | ||
assertNotNull(actualResult); | ||
} | ||
} |