This is an automated email from the ASF dual-hosted git repository. lburgazzoli pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel-k-runtime.git
commit ad1a50cd6a2b43fdeee37747ea132601c9151b57 Author: lburgazzoli <lburgazz...@gmail.com> AuthorDate: Sun Nov 24 15:00:38 2019 +0100 YAML: add support for Bean EIP --- .../camel/k/loader/yaml/parser/BeanStepParser.java | 30 ++++++++++++++++ .../camel/k/loader/yaml/parser/BeanTest.groovy | 40 ++++++++++++++++++++++ 2 files changed, 70 insertions(+) diff --git a/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java b/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java new file mode 100644 index 0000000..a60f712 --- /dev/null +++ b/camel-k-loader-yaml/src/main/java/org/apache/camel/k/loader/yaml/parser/BeanStepParser.java @@ -0,0 +1,30 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.k.loader.yaml.parser; + +import org.apache.camel.k.annotation.yaml.YAMLStepParser; +import org.apache.camel.model.BeanDefinition; +import org.apache.camel.model.ProcessorDefinition; + +@YAMLStepParser("bean") +public class BeanStepParser implements ProcessorStepParser { + @Override + public ProcessorDefinition<?> toProcessor(Context context) { + return context.node(BeanDefinition.class); + } +} + diff --git a/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy b/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy new file mode 100644 index 0000000..78f1486 --- /dev/null +++ b/camel-k-loader-yaml/src/test/groovy/org/apache/camel/k/loader/yaml/parser/BeanTest.groovy @@ -0,0 +1,40 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.apache.camel.k.loader.yaml.parser + + +import org.apache.camel.k.loader.yaml.TestSupport +import org.apache.camel.model.BeanDefinition + +class BeanTest extends TestSupport { + + def "definition"() { + given: + def stepContext = stepContext(''' + ref: "myBean" + method: "process" + ''') + when: + def processor = new BeanStepParser().toProcessor(stepContext) + then: + with(processor, BeanDefinition) { + ref == 'myBean' + method == 'process' + } + } + +}