Commit ee7034e8 authored by HankG's avatar HankG

Merge branch 'final-cleanup-changes' into 'develop'

Add Test for PageDataUrl creator from HTTP Header directly

See merge request !29
parents 76069964 d616a314
......@@ -5,15 +5,69 @@ import org.junit.Test
class TestPageDataUrl {
val firstUrl = "http://localhost/1";
val firstUrl = "http://localhost/1"
val firstCursor = "<$firstUrl> ; rel=\"first\""
val lastUrl = "http://localhost/100";
val lastUrl = "http://localhost/100"
val lastCursor = "<$lastUrl> ; rel=\"last\""
val nextUrl = "http://localhost/4";
val nextUrl = "http://localhost/4"
val nextCursor = "<$nextUrl> ; rel=\"next\""
val previousUrl = "http://localhost/3";
val previousUrl = "http://localhost/3"
val previousCursor = "<$previousUrl> ; rel=\"previous\""
@Test
fun testFullHeaderOneString()
{
val headers = mapOf("field1" to listOf("string1, string2"),
"Link" to listOf("$nextCursor,$previousCursor,$firstCursor,$lastCursor")
)
val pageData = PageDataUrls.fromHeaderLinkField(headers)
TestCase.assertEquals(firstUrl,pageData.first)
TestCase.assertEquals(lastUrl,pageData.last)
TestCase.assertEquals(previousUrl,pageData.previous)
TestCase.assertEquals(nextUrl,pageData.next)
}
@Test
fun testFullHeaderManyStrings()
{
val headers = mapOf("field1" to listOf("string1, string2"),
"Link" to listOf(nextCursor, previousCursor, firstCursor,lastCursor)
)
val pageData = PageDataUrls.fromHeaderLinkField(headers)
TestCase.assertEquals(firstUrl,pageData.first)
TestCase.assertEquals(lastUrl,pageData.last)
TestCase.assertEquals(previousUrl,pageData.previous)
TestCase.assertEquals(nextUrl,pageData.next)
}
@Test
fun testFullHeaderWithoutLinkField()
{
val headers = mapOf("field1" to listOf("string1, string2"),
"field2" to listOf("$nextCursor,$previousCursor,$firstCursor,$lastCursor")
)
val pageData = PageDataUrls.fromHeaderLinkField(headers)
TestCase.assertTrue(pageData.first.isEmpty())
TestCase.assertTrue(pageData.last.isEmpty())
TestCase.assertTrue(pageData.next.isEmpty())
TestCase.assertTrue(pageData.previous.isEmpty())
}
@Test
fun testEmptyHeader()
{
val headers = mapOf<String, Collection<String>>()
val pageData = PageDataUrls.fromHeaderLinkField(headers)
TestCase.assertTrue(pageData.first.isEmpty())
TestCase.assertTrue(pageData.last.isEmpty())
TestCase.assertTrue(pageData.next.isEmpty())
TestCase.assertTrue(pageData.previous.isEmpty())
}
@Test
fun testEmptyString()
{
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment