This file contains hidden or 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
class Decorated { | |
@Intercepted(MyInterceptor.class) | |
def intercepted(String something) { | |
println "within method" | |
} | |
} | |
class MyInterceptor implements Interceptor { |
This file contains hidden or 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
// "Write a method which will remove any given character from a String" | |
// The method will be the 'minus' method 'some string ' - 's' == 'ome tring' | |
def check() { | |
assert 'some string' - 's' == 'ome tring' | |
assert '' - 'a' == '' | |
assert 'something else' - 'z' == 'something else' | |
} | |
// Easy one |
This file contains hidden or 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
CharSequence.metaClass.getLowerStripped = { | |
delegate.toLowerCase().replaceAll(/\s/, '') | |
} | |
def check() { | |
assert !''.palindrom | |
assert !'palindrom'.palindrom | |
assert 'madam'.palindrom | |
assert 'Evil is a name of foeman as I live'.palindrom | |
} |
This file contains hidden or 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
Integer.metaClass.getBuzzOrFizz = { | |
String str= '' | |
if (delegate % 3 == 0) { | |
str += 'Fizz' | |
} | |
if (delegate % 5 == 0) { | |
str += 'Buzz' | |
} | |
if (!str) { | |
return delegate.toString() |
This file contains hidden or 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
export JAVA_HOME=$(readlink -f /usr/bin/javac | sed "s:bin/javac::") |
This file contains hidden or 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
class MyAsyncSpec { | |
@Test | |
void asyncTestRequest(TestContext context) { | |
// startsWith async => creates context.async() | |
def client | |
setup { | |
client = vertx.createHttpClient(...) | |
} | |
when { | |
client.getNow('/api') |
This file contains hidden or 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
import io.vertx.core.Handler | |
import io.vertx.groovy.ext.unit.Async | |
import io.vertx.groovy.ext.unit.TestContext | |
import io.vertx.groovy.ext.unit.junit.VertxUnitRunner | |
import org.junit.runner.RunWith | |
@RunWith(VertxUnitRunner.class) | |
abstract class GroovyTestBase { | |
public GroovyTestBase() { |
This file contains hidden or 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
// create an object | |
public class SomeObject { | |
public Date someDate; | |
public Integer someInt; | |
public String someString; | |
public Double someDouble; | |
} | |
// create vertx handler | |
router.put("/vertx", ctx -> { |
This file contains hidden or 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
plugins { | |
id 'java' | |
id 'eclipse' | |
id 'idea' | |
id 'com.github.johnrengelman.shadow' version '1.2.1' | |
} | |
repositories { | |
mavenLocal() | |
mavenCentral() |