forked from paulkokos/discountFinderAndroid
-
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.
Merge branch 'TestingCalls' into dev
- Loading branch information
Showing
2 changed files
with
67 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,6 +5,9 @@ | |
|
||
import org.junit.Test; | ||
|
||
import eu.jnksoftware.discountfinderandroid.models.discountPreferences.DiscountPreferencesPostResponse; | ||
import eu.jnksoftware.discountfinderandroid.models.discountPreferences.DiscountPreferencesRequest; | ||
import eu.jnksoftware.discountfinderandroid.models.discountPreferences.DiscountPreferencesResponse; | ||
import eu.jnksoftware.discountfinderandroid.models.token.User; | ||
import eu.jnksoftware.discountfinderandroid.services.IuserService; | ||
import eu.jnksoftware.discountfinderandroid.services.MockUserService; | ||
|
@@ -48,6 +51,48 @@ public void testLogin() throws Exception{ | |
Assert.assertEquals("5100",userResponse.body().getRefreshToken()); | ||
Assert.assertEquals("5100",userResponse.body().getExpiresIn().toString()); | ||
} | ||
@Test | ||
public void testRegister() throws Exception{ | ||
BehaviorDelegate<IuserService>delegate=mockRetrofit.create(IuserService.class); | ||
IuserService mockService=new MockUserService(delegate); | ||
Call<User> doregister=mockService.register("nikos","delis","[email protected]","123455"); | ||
retrofit2.Response<User> registerResponse=doregister.execute(); | ||
Assert.assertEquals("access",registerResponse.body().getAccessToken()); | ||
Assert.assertEquals("refresh",registerResponse.body().getRefreshToken()); | ||
Assert.assertEquals("Bearer",registerResponse.body().getTokenType()); | ||
Assert.assertEquals("5000",registerResponse.body().getExpiresIn().toString()); | ||
} | ||
@Test | ||
public void testPutPreferences() throws Exception{ | ||
DiscountPreferencesRequest discountPreferencesRequest=new DiscountPreferencesRequest(); | ||
discountPreferencesRequest.setPrice("140"); | ||
discountPreferencesRequest.setCategory("shoes"); | ||
discountPreferencesRequest.setTags("tag"); | ||
BehaviorDelegate<IuserService>delegate=mockRetrofit.create(IuserService.class); | ||
IuserService mockService=new MockUserService(delegate); | ||
Call<DiscountPreferencesResponse> putPreference=mockService.putDiscountPreferences(1,discountPreferencesRequest,"auth"); | ||
retrofit2.Response<DiscountPreferencesResponse> putPreferenceResponse=putPreference.execute(); | ||
Assert.assertEquals("1",putPreferenceResponse.body().getCategory().toString()); | ||
Assert.assertEquals("1",putPreferenceResponse.body().getId().toString()); | ||
|
||
Assert.assertEquals("tag",putPreferenceResponse.body().getTags()); | ||
} | ||
|
||
@Test | ||
public void testPostPreferences() throws Exception{ | ||
DiscountPreferencesRequest discountPreferencesRequest=new DiscountPreferencesRequest(); | ||
discountPreferencesRequest.setPrice("140"); | ||
discountPreferencesRequest.setCategory("shoes"); | ||
discountPreferencesRequest.setTags("tag"); | ||
BehaviorDelegate<IuserService>delegate=mockRetrofit.create(IuserService.class); | ||
IuserService mockService=new MockUserService(delegate); | ||
Call<DiscountPreferencesPostResponse> postPreference=mockService.postDiscountPreferences(discountPreferencesRequest,"auth"); | ||
retrofit2.Response<DiscountPreferencesPostResponse> postPreferenceResponse=postPreference.execute(); | ||
Assert.assertEquals("shoes",postPreferenceResponse.body().getCategory()); | ||
Assert.assertEquals("1",postPreferenceResponse.body().getId().toString()); | ||
Assert.assertEquals("40",postPreferenceResponse.body().getPrice()); | ||
Assert.assertEquals("tag",postPreferenceResponse.body().getTags()); | ||
} | ||
|
||
|
||
} |