Skip to content

Instantly share code, notes, and snippets.

Last active September 25, 2015 09:07
Show Gist options
  • Save d10xa/c9ce30139b7dfeac0702 to your computer and use it in GitHub Desktop.
Save d10xa/c9ce30139b7dfeac0702 to your computer and use it in GitHub Desktop.
package ru.d10xa.hibernate
import javax.persistence.*
class Language {
@Id @GeneratedValue Long id;
String name
Integer year
interface LanguageRepository
extends CrudRepository<Language, Long> {
Language findByName(String name)
buildscript {
repositories {
dependencies {
apply plugin: 'groovy'
apply plugin: 'spring-boot'
repositories {
maven { url "" }
dependencies {
compile 'org.codehaus.groovy:groovy-all:2.4.4'
compile 'org.springframework.boot:spring-boot-starter-data-jpa'
compile 'com.h2database:h2'
testCompile 'org.springframework.boot:spring-boot-starter-test'
testCompile 'org.spockframework:spock-core:0.7-groovy-2.0'
testCompile 'org.spockframework:spock-spring:0.7-groovy-2.0'
sourceSets.test.groovy {
srcDir projectDir.absolutePath
test.outputs.upToDateWhen { false }
package ru.d10xa.hibernate
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.test.SpringApplicationContextLoader
import org.springframework.test.context.ContextConfiguration
import org.springframework.transaction.annotation.EnableTransactionManagement
import org.springframework.transaction.annotation.Transactional
import spock.lang.Specification
import spock.lang.Unroll
@ContextConfiguration(loader = SpringApplicationContextLoader, classes = Spec)
public class Spec extends Specification {
LanguageRepository repo;
def '#name appeared in #year'() {
given:[name: 'java', year: 1995] as Language)[name: 'groovy', year: 2003] as Language)[name: 'javascript', year: 1995] as Language)
def language = repo.findByName(name)
language.year == year
name | year
'java' | 1995
'groovy' | 2003
'javascript' | 1995
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment