This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch switch-eip
in repository https://gitbox.apache.org/repos/asf/camel.git

commit be44da2a4085ad27124795599bcb154a3856702a
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Jan 26 13:26:04 2022 +0100

    CAMEL-17552: camel-core - Switch EIP that can optimize during bootstrap
---
 .../org/apache/camel/dsl/yaml/SwitchTest.groovy    | 67 ++++++++++++++++++++++
 1 file changed, 67 insertions(+)

diff --git 
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SwitchTest.groovy
 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SwitchTest.groovy
new file mode 100644
index 0000000..2d5730c
--- /dev/null
+++ 
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/test/groovy/org/apache/camel/dsl/yaml/SwitchTest.groovy
@@ -0,0 +1,67 @@
+/*
+ * 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.dsl.yaml
+
+import org.apache.camel.dsl.yaml.support.YamlTestSupport
+import org.apache.camel.model.SwitchDefinition
+import org.apache.camel.model.ToDefinition
+import org.apache.camel.model.WhenDefinition
+
+class SwitchTest extends YamlTestSupport {
+
+    def "switch definition"() {
+        when:
+            loadRoutes '''
+                - from:
+                    uri: "direct:start"
+                    steps:    
+                      - doSwitch:  
+                          when:
+                            - simple: "{{?red}}"
+                              steps:
+                                - to: "mock:red"
+                            - simple: "{{?blue}}"
+                              steps:
+                                - to: "mock:blue"
+                          otherwise:
+                            steps:
+                              - to: "mock:other"    
+            '''
+        then:
+            context.routeDefinitions.size() == 1
+
+            with(context.routeDefinitions[0].outputs[0], SwitchDefinition) {
+                with(whenClauses[0], WhenDefinition) {
+                    expression.language == 'simple'
+                    expression.expression == '{{?red}}'
+                    with(outputs[0], ToDefinition) {
+                        endpointUri == 'mock:red'
+                    }
+                }
+                with(whenClauses[1], WhenDefinition) {
+                    expression.language == 'simple'
+                    expression.expression == '{{?blue}}'
+                    with(outputs[0], ToDefinition) {
+                        endpointUri == 'mock:blue'
+                    }
+                }
+                with(otherwise.outputs[0], ToDefinition) {
+                    endpointUri == 'mock:other'
+                }
+            }
+    }
+}

Reply via email to