Skip to content

Commit 86d4c0b

Browse files
authored
Merge branch 'master' into geroza/BAEL-14138_update-and-move-Spring-HAETOAS-article
2 parents 01af809 + 9f0d708 commit 86d4c0b

File tree

210 files changed

+5671
-537
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

210 files changed

+5671
-537
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
.idea/
2020
*.iml
2121
*.iws
22+
out/
2223

2324
# Mac
2425
.DS_Store
@@ -27,6 +28,9 @@
2728
log/
2829
target/
2930

31+
# Gradle
32+
.gradle/
33+
3034
spring-openid/src/main/resources/application.properties
3135
.recommenders/
3236
/spring-hibernate4/nbproject/

core-groovy-2/README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Groovy
2+
3+
## Relevant articles:
4+
5+
- [String Matching in Groovy](http://www.baeldung.com/)
6+
- [Groovy def Keyword]
7+

core-groovy-2/pom.xml

Lines changed: 131 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,131 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
4+
<modelVersion>4.0.0</modelVersion>
5+
<artifactId>core-groovy-2</artifactId>
6+
<version>1.0-SNAPSHOT</version>
7+
<name>core-groovy-2</name>
8+
<packaging>jar</packaging>
9+
10+
<parent>
11+
<groupId>com.baeldung</groupId>
12+
<artifactId>parent-modules</artifactId>
13+
<version>1.0.0-SNAPSHOT</version>
14+
</parent>
15+
16+
<dependencies>
17+
<dependency>
18+
<groupId>org.codehaus.groovy</groupId>
19+
<artifactId>groovy</artifactId>
20+
<version>${groovy.version}</version>
21+
</dependency>
22+
<dependency>
23+
<groupId>org.codehaus.groovy</groupId>
24+
<artifactId>groovy-all</artifactId>
25+
<version>${groovy-all.version}</version>
26+
<type>pom</type>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.codehaus.groovy</groupId>
30+
<artifactId>groovy-dateutil</artifactId>
31+
<version>${groovy.version}</version>
32+
</dependency>
33+
<dependency>
34+
<groupId>org.codehaus.groovy</groupId>
35+
<artifactId>groovy-sql</artifactId>
36+
<version>${groovy-sql.version}</version>
37+
</dependency>
38+
<dependency>
39+
<groupId>org.junit.platform</groupId>
40+
<artifactId>junit-platform-runner</artifactId>
41+
<version>${junit.platform.version}</version>
42+
<scope>test</scope>
43+
</dependency>
44+
<dependency>
45+
<groupId>org.hsqldb</groupId>
46+
<artifactId>hsqldb</artifactId>
47+
<version>${hsqldb.version}</version>
48+
<scope>test</scope>
49+
</dependency>
50+
<dependency>
51+
<groupId>org.spockframework</groupId>
52+
<artifactId>spock-core</artifactId>
53+
<version>${spock-core.version}</version>
54+
<scope>test</scope>
55+
</dependency>
56+
</dependencies>
57+
58+
<build>
59+
<plugins>
60+
<plugin>
61+
<groupId>org.codehaus.gmavenplus</groupId>
62+
<artifactId>gmavenplus-plugin</artifactId>
63+
<version>${gmavenplus-plugin.version}</version>
64+
<executions>
65+
<execution>
66+
<goals>
67+
<goal>addSources</goal>
68+
<goal>addTestSources</goal>
69+
<goal>compile</goal>
70+
<goal>compileTests</goal>
71+
</goals>
72+
</execution>
73+
</executions>
74+
</plugin>
75+
<plugin>
76+
<artifactId>maven-failsafe-plugin</artifactId>
77+
<version>${maven-failsafe-plugin.version}</version>
78+
<dependencies>
79+
<dependency>
80+
<groupId>org.junit.platform</groupId>
81+
<artifactId>junit-platform-surefire-provider</artifactId>
82+
<version>${junit.platform.version}</version>
83+
</dependency>
84+
</dependencies>
85+
<executions>
86+
<execution>
87+
<id>junit5</id>
88+
<goals>
89+
<goal>integration-test</goal>
90+
<goal>verify</goal>
91+
</goals>
92+
<configuration>
93+
<includes>
94+
<include>**/*Test5.java</include>
95+
</includes>
96+
</configuration>
97+
</execution>
98+
</executions>
99+
</plugin>
100+
<plugin>
101+
<artifactId>maven-surefire-plugin</artifactId>
102+
<version>2.20.1</version>
103+
<configuration>
104+
<useFile>false</useFile>
105+
<includes>
106+
<include>**/*Test.java</include>
107+
<include>**/*Spec.java</include>
108+
</includes>
109+
</configuration>
110+
</plugin>
111+
</plugins>
112+
</build>
113+
114+
<repositories>
115+
<repository>
116+
<id>central</id>
117+
<url>http://jcenter.bintray.com</url>
118+
</repository>
119+
</repositories>
120+
121+
<properties>
122+
<junit.platform.version>1.0.0</junit.platform.version>
123+
<groovy.version>2.5.6</groovy.version>
124+
<groovy-all.version>2.5.6</groovy-all.version>
125+
<groovy-sql.version>2.5.6</groovy-sql.version>
126+
<hsqldb.version>2.4.0</hsqldb.version>
127+
<spock-core.version>1.1-groovy-2.4</spock-core.version>
128+
<gmavenplus-plugin.version>1.6</gmavenplus-plugin.version>
129+
</properties>
130+
</project>
131+
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
package com.baeldung.defkeyword
2+
3+
import org.codehaus.groovy.runtime.NullObject
4+
import org.codehaus.groovy.runtime.typehandling.GroovyCastException
5+
6+
import groovy.transform.TypeChecked
7+
import groovy.transform.TypeCheckingMode
8+
9+
@TypeChecked
10+
class DefUnitTest extends GroovyTestCase {
11+
12+
def id
13+
def firstName = "Samwell"
14+
def listOfCountries = ['USA', 'UK', 'FRANCE', 'INDIA']
15+
16+
@TypeChecked(TypeCheckingMode.SKIP)
17+
def multiply(x, y) {
18+
return x*y
19+
}
20+
21+
@TypeChecked(TypeCheckingMode.SKIP)
22+
void testDefVariableDeclaration() {
23+
24+
def list
25+
assert list.getClass() == org.codehaus.groovy.runtime.NullObject
26+
assert list.is(null)
27+
28+
list = [1,2,4]
29+
assert list instanceof ArrayList
30+
}
31+
32+
@TypeChecked(TypeCheckingMode.SKIP)
33+
void testTypeVariables() {
34+
int rate = 200
35+
try {
36+
rate = [12] //GroovyCastException
37+
rate = "nill" //GroovyCastException
38+
} catch(GroovyCastException) {
39+
println "Cannot assign anything other than integer"
40+
}
41+
}
42+
43+
@TypeChecked(TypeCheckingMode.SKIP)
44+
void testDefVariableMultipleAssignment() {
45+
def rate
46+
assert rate == null
47+
assert rate.getClass() == org.codehaus.groovy.runtime.NullObject
48+
49+
rate = 12
50+
assert rate instanceof Integer
51+
52+
rate = "Not Available"
53+
assert rate instanceof String
54+
55+
rate = [1, 4]
56+
assert rate instanceof List
57+
58+
assert divide(12, 3) instanceof BigDecimal
59+
assert divide(1, 0) instanceof String
60+
61+
}
62+
63+
def divide(int x, int y) {
64+
if(y==0) {
65+
return "Should not divide by 0"
66+
} else {
67+
return x/y
68+
}
69+
}
70+
71+
def greetMsg() {
72+
println "Hello! I am Groovy"
73+
}
74+
75+
void testDefVsType() {
76+
def int count
77+
assert count instanceof Integer
78+
}
79+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.baeldung.strings
2+
3+
import spock.lang.Specification
4+
5+
import java.util.regex.Pattern
6+
7+
class StringMatchingSpec extends Specification {
8+
9+
def "pattern operator example"() {
10+
given: "a pattern"
11+
def p = ~'foo'
12+
13+
expect:
14+
p instanceof Pattern
15+
16+
and: "you can use slash strings to avoid escaping of blackslash"
17+
def digitPattern = ~/\d*/
18+
digitPattern.matcher('4711').matches()
19+
}
20+
21+
def "match operator example"() {
22+
expect:
23+
'foobar' ==~ /.*oba.*/
24+
25+
and: "matching is strict"
26+
!('foobar' ==~ /foo/)
27+
}
28+
29+
def "find operator example"() {
30+
when: "using the find operator"
31+
def matcher = 'foo and bar, baz and buz' =~ /(\w+) and (\w+)/
32+
33+
then: "will find groups"
34+
matcher.size() == 2
35+
36+
and: "can access groups using array"
37+
matcher[0][0] == 'foo and bar'
38+
matcher[1][2] == 'buz'
39+
40+
and: "you can use it as a predicate"
41+
'foobarbaz' =~ /bar/
42+
}
43+
44+
}

core-java-8-2/src/test/java/com/baeldung/UnitTest.java

Lines changed: 0 additions & 18 deletions
This file was deleted.

0 commit comments

Comments
 (0)