-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
extras: - move date patternt to constant Signed-off-by: Kathurima Kimathi <[email protected]>
- Loading branch information
1 parent
aef54e6
commit a3014be
Showing
7 changed files
with
72 additions
and
34 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
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
54 changes: 54 additions & 0 deletions
54
api/src/test/java/org/openmrs/module/mycarehub/api/rest/ApiClientTest.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,54 @@ | ||
package org.openmrs.module.mycarehub.api.rest; | ||
|
||
import static org.junit.Assert.*; | ||
import static org.mockito.Mockito.*; | ||
import static org.powermock.api.mockito.PowerMockito.mockStatic; | ||
|
||
import org.junit.Before; | ||
import org.junit.Test; | ||
import org.junit.runner.RunWith; | ||
import org.mockito.Mock; | ||
import org.openmrs.api.AdministrationService; | ||
import org.openmrs.api.context.Context; | ||
import org.openmrs.module.mycarehub.utils.MyCareHubUtil; | ||
import org.powermock.api.mockito.PowerMockito; | ||
import org.powermock.core.classloader.annotations.PowerMockIgnore; | ||
import org.powermock.core.classloader.annotations.PrepareForTest; | ||
import org.powermock.modules.junit4.PowerMockRunner; | ||
import retrofit2.Retrofit; | ||
|
||
@RunWith(PowerMockRunner.class) | ||
@PrepareForTest({RestApiService.class, Retrofit.class, Context.class, MyCareHubUtil.class}) | ||
@PowerMockIgnore("javax.net.ssl.*") | ||
public class ApiClientTest { | ||
|
||
@Mock private MyCareHubUtil myCareHubUtil; | ||
|
||
@Before | ||
public void setUp() { | ||
mockStatic(ApiClient.class); | ||
mockStatic(RestApiService.class); | ||
AdministrationService administrationService = mock(AdministrationService.class); | ||
|
||
mockStatic(Context.class); | ||
PowerMockito.when(Context.getAdministrationService()).thenReturn(administrationService); | ||
|
||
myCareHubUtil = mock(MyCareHubUtil.class); | ||
} | ||
|
||
@Test | ||
public void testGetRestServiceWithValidApiUrl() { | ||
when(MyCareHubUtil.getApiUrl()).thenReturn("https://example.com"); | ||
|
||
RestApiService restApiService = ApiClient.getRestService(); | ||
} | ||
|
||
@Test | ||
public void testGetRestServiceWithInvalidApiUrl() { | ||
when(MyCareHubUtil.getApiUrl()).thenReturn("invalid_url"); | ||
|
||
RestApiService restApiService = ApiClient.getRestService(); | ||
|
||
assertNull(restApiService); | ||
} | ||
} |
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