forked from eugenp/tutorials
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move Existing Articles to core-groovy-collections Module
- Loading branch information
1 parent
621d462
commit 2468c93
Showing
10 changed files
with
102 additions
and
242 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
6 changes: 3 additions & 3 deletions
6
...vy/com/baeldung/lists/ListUnitTest.groovy → ...com/baeldung/find/ListFindUnitTest.groovy
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
84 changes: 3 additions & 81 deletions
84
...roovy/com/baeldung/map/MapUnitTest.groovy → .../com/baeldung/find/MapFindUnitTest.groovy
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
2 changes: 1 addition & 1 deletion
2
...rc/main/groovy/com/baeldung/Person.groovy → ...st/groovy/com/baeldung/find/Person.groovy
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 |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package com.baeldung | ||
package com.baeldung.find | ||
|
||
class Person { | ||
private String firstname | ||
|
4 changes: 2 additions & 2 deletions
4
...roovy/com/baeldung/set/SetUnitTest.groovy → .../com/baeldung/find/SetFindUnitTest.groovy
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
87 changes: 87 additions & 0 deletions
87
core-groovy-collections/src/test/groovy/com/baeldung/iteratemap/IterateMapUnitTest.groovy
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,87 @@ | ||
package com.baeldung.iteratemap | ||
|
||
import com.baeldung.find.Person | ||
import org.junit.Test | ||
|
||
import static org.junit.Assert.* | ||
|
||
class IterateMapUnitTest { | ||
|
||
@Test | ||
void whenUsingEach_thenMapIsIterated() { | ||
def map = [ | ||
'FF0000' : 'Red', | ||
'00FF00' : 'Lime', | ||
'0000FF' : 'Blue', | ||
'FFFF00' : 'Yellow' | ||
] | ||
|
||
map.each { println "Hex Code: $it.key = Color Name: $it.value" } | ||
} | ||
|
||
@Test | ||
void whenUsingEachWithEntry_thenMapIsIterated() { | ||
def map = [ | ||
'E6E6FA' : 'Lavender', | ||
'D8BFD8' : 'Thistle', | ||
'DDA0DD' : 'Plum', | ||
] | ||
|
||
map.each { entry -> println "Hex Code: $entry.key = Color Name: $entry.value" } | ||
} | ||
|
||
@Test | ||
void whenUsingEachWithKeyAndValue_thenMapIsIterated() { | ||
def map = [ | ||
'000000' : 'Black', | ||
'FFFFFF' : 'White', | ||
'808080' : 'Gray' | ||
] | ||
|
||
map.each { key, val -> | ||
println "Hex Code: $key = Color Name $val" | ||
} | ||
} | ||
|
||
@Test | ||
void whenUsingEachWithIndexAndEntry_thenMapIsIterated() { | ||
def map = [ | ||
'800080' : 'Purple', | ||
'4B0082' : 'Indigo', | ||
'6A5ACD' : 'Slate Blue' | ||
] | ||
|
||
map.eachWithIndex { entry, index -> | ||
def indent = ((index == 0 || index % 2 == 0) ? " " : "") | ||
println "$indent Hex Code: $entry.key = Color Name: $entry.value" | ||
} | ||
} | ||
|
||
@Test | ||
void whenUsingEachWithIndexAndKeyAndValue_thenMapIsIterated() { | ||
def map = [ | ||
'FFA07A' : 'Light Salmon', | ||
'FF7F50' : 'Coral', | ||
'FF6347' : 'Tomato', | ||
'FF4500' : 'Orange Red' | ||
] | ||
|
||
map.eachWithIndex { key, val, index -> | ||
def indent = ((index == 0 || index % 2 == 0) ? " " : "") | ||
println "$indent Hex Code: $key = Color Name: $val" | ||
} | ||
} | ||
|
||
@Test | ||
void whenUsingForLoop_thenMapIsIterated() { | ||
def map = [ | ||
'2E8B57' : 'Seagreen', | ||
'228B22' : 'Forest Green', | ||
'008000' : 'Green' | ||
] | ||
|
||
for (entry in map) { | ||
println "Hex Code: $entry.key = Color Name: $entry.value" | ||
} | ||
} | ||
} |
4 changes: 2 additions & 2 deletions
4
...groovy/com/baeldung/lists/ListTest.groovy → ...vy/com/baeldung/lists/ListUnitTest.groovy
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
2 changes: 1 addition & 1 deletion
2
...st/groovy/com/baeldung/map/MapTest.groovy → ...t/groovy/com/baeldung/maps/MapTest.groovy
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
Oops, something went wrong.