Skip to content

Commit 2468c93

Browse files
Move Existing Articles to core-groovy-collections Module
1 parent 621d462 commit 2468c93

File tree

10 files changed

+102
-242
lines changed

10 files changed

+102
-242
lines changed

core-groovy-collections/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,6 @@ This module contains articles about Groovy core collections
55
## Relevant articles:
66

77
- [Maps in Groovy](https://www.baeldung.com/groovy-maps)
8-
8+
- [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements)
9+
- [Lists in Groovy](https://www.baeldung.com/groovy-lists)
10+
- [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating)

core-groovy/src/test/groovy/com/baeldung/lists/ListUnitTest.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/find/ListFindUnitTest.groovy

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
package com.baeldung.lists
1+
package com.baeldung.find
22

3-
import com.baeldung.Person
3+
import com.baeldung.find.Person
44
import org.junit.Test
55

66
import static org.junit.Assert.*
77

8-
class ListUnitTest {
8+
class ListFindUnitTest {
99

1010
private final personList = [
1111
new Person("Regina", "Fitzpatrick", 25),

core-groovy/src/test/groovy/com/baeldung/map/MapUnitTest.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/find/MapFindUnitTest.groovy

Lines changed: 3 additions & 81 deletions
Original file line numberDiff line numberDiff line change
@@ -1,96 +1,18 @@
1-
package com.baeldung.map
1+
package com.baeldung.find
22

3-
import com.baeldung.Person
3+
import com.baeldung.find.Person
44
import org.junit.Test
55

66
import static org.junit.Assert.*
77

8-
class MapUnitTest {
8+
class MapFindUnitTest {
99

1010
private final personMap = [
1111
Regina : new Person("Regina", "Fitzpatrick", 25),
1212
Abagail: new Person("Abagail", "Ballard", 26),
1313
Lucian : new Person("Lucian", "Walter", 30)
1414
]
1515

16-
@Test
17-
void whenUsingEach_thenMapIsIterated() {
18-
def map = [
19-
'FF0000' : 'Red',
20-
'00FF00' : 'Lime',
21-
'0000FF' : 'Blue',
22-
'FFFF00' : 'Yellow'
23-
]
24-
25-
map.each { println "Hex Code: $it.key = Color Name: $it.value" }
26-
}
27-
28-
@Test
29-
void whenUsingEachWithEntry_thenMapIsIterated() {
30-
def map = [
31-
'E6E6FA' : 'Lavender',
32-
'D8BFD8' : 'Thistle',
33-
'DDA0DD' : 'Plum',
34-
]
35-
36-
map.each { entry -> println "Hex Code: $entry.key = Color Name: $entry.value" }
37-
}
38-
39-
@Test
40-
void whenUsingEachWithKeyAndValue_thenMapIsIterated() {
41-
def map = [
42-
'000000' : 'Black',
43-
'FFFFFF' : 'White',
44-
'808080' : 'Gray'
45-
]
46-
47-
map.each { key, val ->
48-
println "Hex Code: $key = Color Name $val"
49-
}
50-
}
51-
52-
@Test
53-
void whenUsingEachWithIndexAndEntry_thenMapIsIterated() {
54-
def map = [
55-
'800080' : 'Purple',
56-
'4B0082' : 'Indigo',
57-
'6A5ACD' : 'Slate Blue'
58-
]
59-
60-
map.eachWithIndex { entry, index ->
61-
def indent = ((index == 0 || index % 2 == 0) ? " " : "")
62-
println "$indent Hex Code: $entry.key = Color Name: $entry.value"
63-
}
64-
}
65-
66-
@Test
67-
void whenUsingEachWithIndexAndKeyAndValue_thenMapIsIterated() {
68-
def map = [
69-
'FFA07A' : 'Light Salmon',
70-
'FF7F50' : 'Coral',
71-
'FF6347' : 'Tomato',
72-
'FF4500' : 'Orange Red'
73-
]
74-
75-
map.eachWithIndex { key, val, index ->
76-
def indent = ((index == 0 || index % 2 == 0) ? " " : "")
77-
println "$indent Hex Code: $key = Color Name: $val"
78-
}
79-
}
80-
81-
@Test
82-
void whenUsingForLoop_thenMapIsIterated() {
83-
def map = [
84-
'2E8B57' : 'Seagreen',
85-
'228B22' : 'Forest Green',
86-
'008000' : 'Green'
87-
]
88-
89-
for (entry in map) {
90-
println "Hex Code: $entry.key = Color Name: $entry.value"
91-
}
92-
}
93-
9416
@Test
9517
void whenMapContainsKeyElement_thenCheckReturnsTrue() {
9618
def map = [a: 'd', b: 'e', c: 'f']

core-groovy/src/main/groovy/com/baeldung/Person.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/find/Person.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung
1+
package com.baeldung.find
22

33
class Person {
44
private String firstname

core-groovy/src/test/groovy/com/baeldung/set/SetUnitTest.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/find/SetFindUnitTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
package com.baeldung.set
1+
package com.baeldung.find
22

33
import org.junit.Test
44

55
import static org.junit.Assert.assertTrue
66

7-
class SetUnitTest {
7+
class SetFindUnitTest {
88

99
@Test
1010
void whenSetContainsElement_thenCheckReturnsTrue() {
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
package com.baeldung.iteratemap
2+
3+
import com.baeldung.find.Person
4+
import org.junit.Test
5+
6+
import static org.junit.Assert.*
7+
8+
class IterateMapUnitTest {
9+
10+
@Test
11+
void whenUsingEach_thenMapIsIterated() {
12+
def map = [
13+
'FF0000' : 'Red',
14+
'00FF00' : 'Lime',
15+
'0000FF' : 'Blue',
16+
'FFFF00' : 'Yellow'
17+
]
18+
19+
map.each { println "Hex Code: $it.key = Color Name: $it.value" }
20+
}
21+
22+
@Test
23+
void whenUsingEachWithEntry_thenMapIsIterated() {
24+
def map = [
25+
'E6E6FA' : 'Lavender',
26+
'D8BFD8' : 'Thistle',
27+
'DDA0DD' : 'Plum',
28+
]
29+
30+
map.each { entry -> println "Hex Code: $entry.key = Color Name: $entry.value" }
31+
}
32+
33+
@Test
34+
void whenUsingEachWithKeyAndValue_thenMapIsIterated() {
35+
def map = [
36+
'000000' : 'Black',
37+
'FFFFFF' : 'White',
38+
'808080' : 'Gray'
39+
]
40+
41+
map.each { key, val ->
42+
println "Hex Code: $key = Color Name $val"
43+
}
44+
}
45+
46+
@Test
47+
void whenUsingEachWithIndexAndEntry_thenMapIsIterated() {
48+
def map = [
49+
'800080' : 'Purple',
50+
'4B0082' : 'Indigo',
51+
'6A5ACD' : 'Slate Blue'
52+
]
53+
54+
map.eachWithIndex { entry, index ->
55+
def indent = ((index == 0 || index % 2 == 0) ? " " : "")
56+
println "$indent Hex Code: $entry.key = Color Name: $entry.value"
57+
}
58+
}
59+
60+
@Test
61+
void whenUsingEachWithIndexAndKeyAndValue_thenMapIsIterated() {
62+
def map = [
63+
'FFA07A' : 'Light Salmon',
64+
'FF7F50' : 'Coral',
65+
'FF6347' : 'Tomato',
66+
'FF4500' : 'Orange Red'
67+
]
68+
69+
map.eachWithIndex { key, val, index ->
70+
def indent = ((index == 0 || index % 2 == 0) ? " " : "")
71+
println "$indent Hex Code: $key = Color Name: $val"
72+
}
73+
}
74+
75+
@Test
76+
void whenUsingForLoop_thenMapIsIterated() {
77+
def map = [
78+
'2E8B57' : 'Seagreen',
79+
'228B22' : 'Forest Green',
80+
'008000' : 'Green'
81+
]
82+
83+
for (entry in map) {
84+
println "Hex Code: $entry.key = Color Name: $entry.value"
85+
}
86+
}
87+
}

core-groovy/src/test/groovy/com/baeldung/lists/ListTest.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/lists/ListUnitTest.groovy

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
package com.baeldung.groovy.lists
1+
package com.baeldung.lists
22

33
import static groovy.test.GroovyAssert.*
44
import org.junit.Test
55

6-
class ListTest{
6+
class ListUnitTest {
77

88
@Test
99
void testCreateList() {

core-groovy-collections/src/test/groovy/com/baeldung/map/MapTest.groovy renamed to core-groovy-collections/src/test/groovy/com/baeldung/maps/MapTest.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
package com.baeldung.map;
1+
package com.baeldung.maps;
22

33
import static groovy.test.GroovyAssert.*
44
import org.junit.Test

core-groovy/README.md

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@ This module contains articles about core Groovy concepts
88
- [Working with JSON in Groovy](https://www.baeldung.com/groovy-json)
99
- [Reading a File in Groovy](https://www.baeldung.com/groovy-file-read)
1010
- [Types of Strings in Groovy](https://www.baeldung.com/groovy-strings)
11-
- [A Quick Guide to Iterating a Map in Groovy](https://www.baeldung.com/groovy-map-iterating)
1211
- [An Introduction to Traits in Groovy](https://www.baeldung.com/groovy-traits)
1312
- [Closures in Groovy](https://www.baeldung.com/groovy-closures)
14-
- [Finding Elements in Collections in Groovy](https://www.baeldung.com/groovy-collections-find-elements)
15-
- [Lists in Groovy](https://www.baeldung.com/groovy-lists)
1613
- [Converting a String to a Date in Groovy](https://www.baeldung.com/groovy-string-to-date)
1714
- [Guide to I/O in Groovy](https://www.baeldung.com/groovy-io)
1815
- [[More -->]](/core-groovy-2)

0 commit comments

Comments
 (0)