add more collection examples (#2243)

* minor logging fix

* spring security sso

* use basic auth

* use form login

* cleanup

* cleanup

* final cleanup

* second client app for sso

* spring boot bootstrap

* add logic

* cleanup

* add simple controller

* add thymeleaf and security

* minor fix

* minor fix

* add more boot properties

* fix live test

* fix live test

* minor fix

* semaphores

* fix configuration

* kotlin collection

* add more collection examples
This commit is contained in:
Doha2012 2017-07-10 07:47:58 +02:00 committed by Grzegorz Piwowarek
parent 2e119a5e99
commit 2f3398beaf
1 changed files with 25 additions and 0 deletions

View File

@ -118,4 +118,29 @@ class CollectionsTest {
assertTrue(resultMap[2]!!.contains(5)) assertTrue(resultMap[2]!!.contains(5))
} }
@Test
fun whenApplyFunctionToAllItems_thenSuccess () {
val theList = listOf(1, 2, 3, 4, 5, 6)
val resultList = theList.map{ it * it }
print(resultList)
assertEquals(4, resultList[1])
assertEquals(9, resultList[2])
}
@Test
fun whenApplyMultiOutputFunctionToAllItems_thenSuccess () {
val theList = listOf("John", "Tom")
val resultList = theList.flatMap{ it.toLowerCase().toList()}
print(resultList)
assertEquals(7, resultList.size)
assertTrue(resultList.contains('j'))
}
@Test
fun whenApplyFunctionToAllItemsWithStartingValue_thenSuccess () {
val theList = listOf(1, 2, 3, 4, 5, 6)
val finalResult = theList.fold( 1000, { oldResult, currentItem -> oldResult + (currentItem *currentItem)})
print(finalResult)
assertEquals(1091, finalResult)
}
} }