This repository has been archived by the owner on Apr 28, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add more information on Javadoc.
- Loading branch information
Showing
3 changed files
with
69 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
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,59 @@ | ||
package org.jinstagram.http; | ||
|
||
import static org.junit.Assert.*; | ||
|
||
import java.util.HashMap; | ||
import java.util.Map; | ||
|
||
import org.junit.Test; | ||
|
||
public class APILimitUtilsTest { | ||
|
||
@Test | ||
public void remainingBetweenMinAndMax() { | ||
int limitValue = 5000; | ||
int remainingValue = 3999; | ||
|
||
Map<String, String> headers = new HashMap<String, String>(); | ||
headers.put(APILimitUtils.LIMIT_HEADER_KEY, String.valueOf(limitValue)); | ||
headers.put(APILimitUtils.REMAINING_HEADER_KEY, String.valueOf(remainingValue)); | ||
|
||
assertTrue(limitValue == Integer.valueOf(APILimitUtils.getAPILimitStatus(headers))); | ||
assertTrue(remainingValue == Integer.valueOf(APILimitUtils.getRemainingLimitStatus(headers))); | ||
} | ||
|
||
@Test | ||
public void remainingBetweenMax() { | ||
int limitValue = 5000; | ||
int remainingValue = limitValue; | ||
|
||
Map<String, String> headers = new HashMap<String, String>(); | ||
headers.put(APILimitUtils.LIMIT_HEADER_KEY, String.valueOf(limitValue)); | ||
headers.put(APILimitUtils.REMAINING_HEADER_KEY, String.valueOf(remainingValue)); | ||
|
||
assertTrue(limitValue == APILimitUtils.getAPILimitStatus(headers)); | ||
assertTrue(remainingValue == APILimitUtils.getRemainingLimitStatus(headers)); | ||
} | ||
|
||
@Test | ||
public void remainingZero() { | ||
int limitValue = 5000; | ||
int remainingValue = 0; | ||
|
||
Map<String, String> headers = new HashMap<String, String>(); | ||
headers.put(APILimitUtils.LIMIT_HEADER_KEY, String.valueOf(limitValue)); | ||
headers.put(APILimitUtils.REMAINING_HEADER_KEY, String.valueOf(remainingValue)); | ||
|
||
assertTrue(limitValue == APILimitUtils.getAPILimitStatus(headers)); | ||
assertTrue(remainingValue == APILimitUtils.getRemainingLimitStatus(headers)); | ||
} | ||
|
||
@Test | ||
public void emptyHeader() { | ||
int defaultErrorValue = -1; | ||
Map<String, String> headers = new HashMap<String, String>(); | ||
|
||
assertTrue(defaultErrorValue == APILimitUtils.getAPILimitStatus(headers)); | ||
assertTrue(defaultErrorValue == APILimitUtils.getRemainingLimitStatus(headers)); | ||
} | ||
} |