groovy

groovy closure for complex object prblm stateme2

[亡魂溺海] 提交于 2020-01-17 05:12:09
问题 I have an java interface public interface IPerson { Person addPerson(String name ); Person addPerson(String name1,String name2); Person addPerson(String name,String[] details); Person addPerson(String name,String name1,String[] details); Person addPerson(String name,List<String> details); } With PersonImpl .java being: class PersonImpl implemets Iperson { .. // and interface methods implemtation } and my person.java looks like class Person { def firstName; def lastName; } And my PersonTest

How to restore metaclass on object to original class definition

删除回忆录丶 提交于 2020-01-17 03:14:08
问题 I've been trying to create a TEMPORARY override on new objects, and then to remove the override on the objects themselves. I'm not sure if this can be done, but here is what I've tried so far. // Say I have a class like: class Validator { boolean validate() { println "code here to return actual true/false"; false } } // I have two integration points one of them is Here before construction: // First integration point: // Save actual validate function def realValidate = Validator.&validate //

Mule - accessing the exception stack and logging a particular part

旧巷老猫 提交于 2020-01-17 02:53:10
问题 I have a Mule flow that evaluates a payload an depending on the value, may throw an exception using Groovy. My flow looks as follows: <flow name="test-flow" doc:name="test-flow"> <vm:inbound-endpoint path="testexception.in" exchange-pattern="request-response" doc:name="VM"/> <choice doc:name="Choice"> <when expression="#[payload == 'Goodbye']"> <logger message="**************** #[payload] ****************" level="INFO" doc:name="Logger"/> </when> <otherwise> <scripting:component doc:name=

Does groovy @CompileStatic imply @TypeChecked?

人盡茶涼 提交于 2020-01-17 01:37:18
问题 I have been adding both @TypeChecked and @CompileStatic to groovy code. The compiler accepts this, but is it redundant? Does TypeChecked add anything that CompileStatic does not? The docs seems to imply that CompileStatic is a superset, but stop short of saying so outright. I would like to compile statically while occasionally disabling strict type checking, to let groovy auto-typecast while still catching misspelled references or missing methods. An example: @TypeChecked @CompileStatic class

Cant call pl-sql stored procedure with OUT Parameter oracletypes.cursor

狂风中的少年 提交于 2020-01-16 18:26:26
问题 I need some help to call a Oracle Stored Procedure in Groovy and receive a ResultSet by an Output Parameter. I can call stored procedure with output parameters of other data types, but for CURSOR I cannot find the way. "I'm always getting the error "java.sql.SQLException: Cursor is closed." The parameter (bellow) is: " Sql.out(OracleTypes.CURSOR), // lista de possiveis varios items a consumir " Below my code (The connection is already openI def consumeProvisioning(Sql sql) { int nRes sql.call

Jenkins-Groovy - Jfrog Artifactory - getting exception while downloading artifacts Calculated MD5 checksum is different from original

梦想的初衷 提交于 2020-01-16 07:32:28
问题 I am working with Jenkins - Groovy Script, uploading and downloading artifacts to and from jfrog artifactory. Below is the code for upload and download zip folder. stage("Upload Artifact to Jfrog"){ def server = Artifactory.server 'JfrogTAArtifactory' def uploadSpec = """{ "files": [ { "pattern": "${env.WORKSPACE}\\${artifactsfoldername}\\API-${env.BUILD_NUMBER}.zip", "target": "internal-repo/folderName/subFolder/", "props": "type=zip;status=ready" } ] }""" def buildInfo = server.upload

Groovy @Delegate class annotations are not supported in the pipeline shared library jenkins

喜欢而已 提交于 2020-01-16 05:21:25
问题 jenkins ver. 2.89.4 workflow-cps ver 2.42 When i try to run a pipeline that loads the library, i get the following exception: Unsupported expression for CPS transformation @ line -1, column -1 The Groovy class to which the link is referenced: final class Bindings implements Serializable{ @Delegate private final Map map Bindings(Map map) { this.map = map } @Override boolean containsKey(Object key) { return true } @Override Object get(Object key) { return map.getOrDefault(key, null) } } You can

Grails/Groovy: Modify a “query” closure at runtime

耗尽温柔 提交于 2020-01-16 04:58:08
问题 In a gorm domain class, I can do def q = { property1{ eq('attr', 0) } } MyDomainClass.list(q) How could I modify the closure 'q' (or create a new closure that would contain the restrictions that closure 'q' has) at runtime so for example I could add another property restriction? More details Actually my problem is how to create combined criteria in a Domain Class Hierarchy. class Parent{ int pAttr static def getCriteria(){ def dummyParentCriteria = { eq('pAttr', 0) } } } class Child extends

Mule ESB Groovy Unicode output issue

江枫思渺然 提交于 2020-01-16 00:42:08
问题 I have this little chain of components in my Mule ESB project: <set-payload value="Получена заявка ##[sessionVars['ticketID']]" doc:name="Set SMS Text"/> <scripting:transformer doc:name="Send SMS" ignoreBadInput="true"> <scripting:script engine="Groovy"><![CDATA[ new File("/tmp/groovy.out").withWriter { out -> out.println message.payload } ]]></scripting:script> </scripting:transformer> When message passes this chain in /tmp/groovy.out I can see "Џолучена заЯвка #4041" instead of expected

Execute Jenkins Pipeline from inside DSL

让人想犯罪 __ 提交于 2020-01-15 11:35:28
问题 I do have a pipeline, p1, configured with 3 parameters, param1 as ChoiceParam, and param2 and param3 as runParameters, that retrieve different build-ids to pass them as versions. I do also have annother pipeline, p2, from which i'd like to run p1. p2 does also have the same parameters configured, so, inside the dsl, i need to call p1 with params1,params2,params3 , as params should be inherited in p2 But i'm unable, as i've tried any single way i can think of. Can anyone help me ? p2: build()