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
assert doSplit('''-compile | |
-wsdl=some/path''') == ['-compile','-wsdl','some/path'] | |
assert doSplit('-compile -wsdl=some/path') == ['-compile','-wsdl','some/path'] | |
assert doSplit('''-compile -wsdl=some/path | |
-test ''') == ['-compile','-wsdl','some/path', '-test'] | |
assert doSplit('''-compile | |
-wsdl=some/path/to/wsdl |
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
package org.grails.demo | |
import grails.plugins.rest.client.RequestCustomizer | |
import grails.plugins.rest.client.RestResponse | |
import org.springframework.http.HttpMethod | |
import org.springframework.http.HttpStatus | |
import org.springframework.http.ResponseEntity | |
import org.springframework.web.client.RestTemplate | |
public class MockRestBuilder { |
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
package org.grails.demo | |
import grails.plugins.rest.client.RestBuilder | |
import spock.lang.Specification | |
class BaseRestBuilderSpec extends Specification { | |
def setup() { | |
RestBuilder.metaClass.constructor = { -> | |
return new MockRestBuilder() |
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
package org.grails.demo | |
import grails.plugins.rest.client.RequestCustomizer | |
import grails.plugins.rest.client.RestResponse | |
import grails.test.mixin.TestFor | |
import org.springframework.http.HttpStatus | |
import org.springframework.http.ResponseEntity | |
@TestFor(ExternalRestBuilderService) | |
class extends BaseRestBuilderSpec { |
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
package org.grails.demo | |
import grails.plugins.rest.client.RestBuilder | |
import grails.plugins.rest.client.RestResponse | |
import org.springframework.http.HttpStatus | |
class ExternalRestBuilderService { | |
void invokeRestBuilderPostWithUrl(String url) { |
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
package com.bsb.interceptor | |
import grails.artefact.Interceptor | |
import grails.util.Holders | |
import groovy.transform.CompileStatic | |
import org.hibernate.SessionFactory | |
import org.hibernate.stat.Statistics | |
@CompileStatic | |
class HibernateInterceptor implements Interceptor { |
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
// deletes all keys matching a pattern (see redis "keys" documentation for more) | |
// OK for low traffic methods, but expensive compared to other redis commands | |
// perf test before relying on this rather than storing your own set of keys to | |
// delete | |
void deleteKeysWithPattern(keyPattern) { | |
if (log.infoEnabled) log.info("Cleaning all redis keys with pattern [${keyPattern}]") | |
withRedis { Jedis redis -> | |
String[] keys = redis.keys(keyPattern) | |
if(keys) redis.del(keys) | |
} |
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
package foo | |
import grails.async.Promise | |
// more imports | |
import static grails.async.Promises.waitAll | |
import static grails.async.Promises.task | |
class ProductService { | |
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
//Go get promotions async | |
Promise<Map<String, List<Promotion>> promisePromotions = task { getPromitions(...) } | |
//Get the map from the promise | |
Map<String, List<Promotion>> promotionMessages = promisePromotions.get() | |
//Get the list of promitions from the map | |
List<Promotion> promotionMessages = promotionMessages.get(mapKey) |
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
import grails.async.Promise | |
import groovy.transform.CompileStatic | |
import groovy.util.logging.Slf4j | |
import java.util.concurrent.ExecutionException | |
import java.util.concurrent.TimeUnit | |
import java.util.concurrent.TimeoutException | |
@Slf4j | |
@CompileStatic |