org.apache.camel.model.ToDefinition Java Examples

The following examples show how to use org.apache.camel.model.ToDefinition. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: RoutesLoaderTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = runtime.load(source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).isEqualTo("timer:tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
Example #2
Source File: WeaveByTypeSelectFirstTest.java    From camelinaction2 with Apache License 2.0 6 votes vote down vote up
@Test
public void testWeaveByTypeSelectFirst() throws Exception {
    RouteDefinition route = context.getRouteDefinition("quotes");
    route.adviceWith(context, new AdviceWithRouteBuilder() {
        @Override
        public void configure() throws Exception {
            // find the send to and select the first which gets replaced
            weaveByType(ToDefinition.class).selectFirst().replace().to("mock:line");
        }
    });

    context.start();

    getMockEndpoint("mock:line").expectedBodiesReceived("camel rules", "donkey is bad");
    getMockEndpoint("mock:combined").expectedMessageCount(1);
    getMockEndpoint("mock:combined").message(0).body().isInstanceOf(List.class);

    template.sendBody("seda:quotes", "Camel Rules,Donkey is Bad");

    assertMockEndpointsSatisfied();
}
 
Example #3
Source File: RoutesLoaderTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).matches("timer:/*tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
Example #4
Source File: KnativeConverterTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
private static void validateSteps(RouteDefinition definition) {
    List<ProcessorDefinition<?>> outputs = definition.getOutputs();

    assertThat(outputs).hasSize(2);

    assertThat(outputs)
        .element(0)
        .isInstanceOfSatisfying(ToDefinition.class, t-> {
            assertThat(t.getEndpointUri()).isEqualTo("log:info");
        });
    assertThat(outputs)
        .element(1)
        .isInstanceOfSatisfying(ToDefinition.class, t-> {
            assertThat(t.getEndpointUri()).isEqualTo("knative:endpoint/to");
        });
}
 
Example #5
Source File: RoutesLoaderTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@ParameterizedTest
@MethodSource("parameters")
public void testLoaders(String location, Class<? extends SourceLoader> type) throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI(location);
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(type);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).matches("timer:/*tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(ToDefinition.class);
}
 
Example #6
Source File: RoutesLoaderTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadJavaWithNestedClass() throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI("classpath:MyRoutesWithNestedClass.java");
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(JavaSourceLoader.class);
    assertThat(runtime.builders).hasSize(1);
    assertThat(runtime.builders).first().isInstanceOf(RouteBuilder.class);

    RouteBuilder builder = (RouteBuilder)runtime.builders.get(0);
    builder.setContext(runtime.getCamelContext());
    builder.configure();

    List<RouteDefinition> routes = builder.getRouteCollection().getRoutes();
    assertThat(routes).hasSize(1);
    assertThat(routes.get(0).getInput().getEndpointUri()).isEqualTo("timer:tick");
    assertThat(routes.get(0).getOutputs().get(0)).isInstanceOf(SetBodyDefinition.class);
    assertThat(routes.get(0).getOutputs().get(1)).isInstanceOf(ProcessDefinition.class);
    assertThat(routes.get(0).getOutputs().get(2)).isInstanceOf(ToDefinition.class);
}
 
Example #7
Source File: RuntimeTest.java    From camel-k-runtime with Apache License 2.0 6 votes vote down vote up
@Test
public void testLoadJavaSourceWrap() throws Exception {
    KnativeComponent component = new KnativeComponent();
    component.setEnvironment(KnativeEnvironment.on(
        KnativeEnvironment.endpoint(Knative.EndpointKind.sink, "sink", "localhost", AvailablePortFinder.getNextAvailable())
    ));

    PlatformHttpServiceContextCustomizer phsc = new PlatformHttpServiceContextCustomizer();
    phsc.setBindPort(AvailablePortFinder.getNextAvailable());
    phsc.apply(runtime.getCamelContext());

    runtime.getCamelContext().addComponent("knative", component);
    runtime.addListener(RoutesConfigurer.forRoutes("classpath:MyRoutesWithBeans.java?interceptors=knative-source"));
    runtime.addListener(Runtime.Phase.Started, r ->  runtime.stop());
    runtime.run();

    assertThat(runtime.getRegistry().lookupByName("my-bean")).isInstanceOfSatisfying(MyBean.class, b -> {
        assertThat(b).hasFieldOrPropertyWithValue("name", "my-bean-name");
    });
    assertThat(runtime.getCamelContext(ModelCamelContext.class).getRouteDefinition("my-route")).satisfies(definition -> {
        assertThat(definition.getOutputs()).last().isInstanceOfSatisfying(ToDefinition.class, to -> {
            assertThat(to.getEndpointUri()).isEqualTo("knative://endpoint/sink");
        });
    });
}
 
Example #8
Source File: KnativeSourceLoaderInterceptor.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public SourceLoader.Result afterLoad(SourceLoader loader, Source source, SourceLoader.Result result) {
    return new SourceLoader.Result() {
        @Override
        public Optional<RoutesBuilder> builder() {
            return RuntimeSupport.afterConfigure(result.builder(), builder -> {
                final CamelContext camelContext = builder.getContext();
                final List<RouteDefinition> definitions = builder.getRouteCollection().getRoutes();

                if (definitions.size() == 1) {
                    final String sinkName = camelContext.resolvePropertyPlaceholders("{{knative.sink:sink}}");
                    final String sinkUri = String.format("knative://endpoint/%s", sinkName);
                    final RouteDefinition definition = definitions.get(0);

                    createSyntheticDefinition(camelContext, sinkName).ifPresent(serviceDefinition -> {
                        // publish the synthetic service definition
                        camelContext.getRegistry().bind(sinkName, serviceDefinition);
                    });

                    LOGGER.info("Add sink:{} to route:{}", sinkUri, definition.getId());

                    // assuming that route is linear like there's no content based routing
                    // or ant other EIP that would branch the flow
                    definition.getOutputs().add(new ToDefinition(sinkUri));
                } else {
                    LOGGER.warn("Cannot determine route to enrich. the knative enpoint need to explicitly be defined");
                }
            });
        }

        @Override
        public Optional<Object> configuration() {
            return result.configuration();
        }
    };
}
 
Example #9
Source File: ToStepParser.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Override
public ProcessorDefinition<?> toProcessor(Context context) {
    final Definition definition = context.node(Definition.class);
    final ToDefinition answer = new ToDefinition(definition.getEndpointUri());

    return answer;
}
 
Example #10
Source File: CamelModelHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static String getExchangePattern(ToDefinition input) {
    String pattern = input.getPattern() != null ? input.getPattern().name() : null;
    if (Strings2.isEmpty(pattern)) {
        return null;
    }
    return pattern;
}
 
Example #11
Source File: CamelModelHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static String getUri(ToDefinition input) {
    String key = input.getUri();
    if (Strings2.isEmpty(key)) {
        String ref = input.getRef();
        if (!Strings2.isEmpty(ref)) {
            return "ref:" + ref;
        }
    }
    return key;
}
 
Example #12
Source File: IntegrationRouteBuilderTest.java    From syndesis with Apache License 2.0 5 votes vote down vote up
@Test
public void testIntegrationRouteBuilder() throws Exception {
    String configurationLocation = "classpath:syndesis/integration/integration.json";

    IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.class), policyFactories);

    // initialize routes
    routeBuilder.configure();

    // Dump routes as XML for troubleshooting
    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();

    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    assertThat(route.getRoutePolicies()).hasSize(1);

    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:expression");
    assertThat(route.getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(route, 1).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 1, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 1, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 1, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1, 2, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:expression");
    assertThat(getOutput(route, 1, 2, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #13
Source File: IntegrationRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void integrationWithSchedulerTest() throws Exception {
    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {
        @Override
        protected Integration loadIntegration() {
            Integration integration = newIntegration(
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("log")
                            .putConfiguredProperty("loggerName", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "timer")
                            .build())
                        .build())
                    .build());

            final Flow flow = integration.getFlows().get(0);
            final Flow flowWithScheduler = flow.builder()
                .scheduler(new Scheduler.Builder()
                    .type(Scheduler.Type.timer)
                    .expression("1s")
                    .build())
                .build();

            return new Integration.Builder()
                .createFrom(integration)
                .flows(singleton(flowWithScheduler))
                .build();
        }
    };

    // initialize routes
    routeBuilder.configure();

    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();
    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    // Timer
    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
    assertThat(route.getOutputs()).hasSize(5);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
    assertThat(getOutput(route, 2)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 3)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 4).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 4, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 4, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
    assertThat(getOutput(route, 4, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #14
Source File: IntegrationRouteTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void integrationWithSchedulerAndSplitTest() throws Exception {
    final RouteBuilder routeBuilder = new IntegrationRouteBuilder("", Resources.loadServices(IntegrationStepHandler.class)) {
        @Override
        protected Integration loadIntegration() {
            Integration integration = newIntegration(
                new Step.Builder()
                    .id("step-1")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("log")
                            .putConfiguredProperty("loggerName", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.split)
                    .build(),
                new Step.Builder()
                    .id("step-2")
                    .stepKind(StepKind.endpoint)
                    .action(new ConnectorAction.Builder()
                        .descriptor(new ConnectorDescriptor.Builder()
                            .componentScheme("mock")
                            .putConfiguredProperty("name", "timer")
                            .build())
                        .build())
                    .build(),
                new Step.Builder()
                    .stepKind(StepKind.aggregate)
                    .build());

            final Flow flow = integration.getFlows().get(0);
            final Flow flowWithScheduler = flow.builder()
                .scheduler(new Scheduler.Builder()
                    .type(Scheduler.Type.timer)
                    .expression("1s")
                    .build())
                .build();

            return new Integration.Builder()
                .createFrom(integration)
                .flows(singleton(flowWithScheduler))
                .build();
        }
    };

    // initialize routes
    routeBuilder.configure();

    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();
    assertThat(routes.getRoutes()).hasSize(1);

    RouteDefinition route = routes.getRoutes().get(0);

    assertThat(route.getInput()).isNotNull();
    assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "timer:integration?period=1s");
    assertThat(route.getOutputs()).hasSize(5);
    assertThat(getOutput(route, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(route, 0, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 0, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 1)).hasFieldOrPropertyWithValue("uri", "log:timer");
    assertThat(getOutput(route, 2)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(route, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 2, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 2, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(route, 2, 2).getOutputs()).hasSize(3);
    assertThat(getOutput(route, 2, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 2, 2, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(route, 2, 2, 1)).hasFieldOrPropertyWithValue("uri", "mock:timer");
    assertThat(getOutput(route, 2, 2, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(route, 3)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(route, 4)).isInstanceOf(ProcessDefinition.class);
}
 
Example #15
Source File: DataMapperStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testDataMapperStep() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps());

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        List<RouteDefinition> routes = context.getRouteDefinitions();
        assertThat(routes).hasSize(1);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);

        // Atlas
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue(
            "uri",
            "atlas:mapping-flow-0-step-1.json?encoding=UTF-8&sourceMapName=" + OutMessageCaptureProcessor.CAPTURED_OUT_MESSAGES_MAP
        );

        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #16
Source File: DataMapperStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testJsonTypeProcessors() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps("{" +
                                "\"AtlasMapping\":{" +
                                    "\"dataSource\":[" +
                                        "{\"jsonType\":\"" + DataMapperStepHandler.ATLASMAP_JSON_DATA_SOURCE + "\",\"id\":\"source\",\"uri\":\"atlas:json:source\",\"dataSourceType\":\"SOURCE\"}," +
                                        "{\"jsonType\":\"" + DataMapperStepHandler.ATLASMAP_JSON_DATA_SOURCE + "\",\"id\":\"target\",\"uri\":\"atlas:json:target\",\"dataSourceType\":\"TARGET\",\"template\":null}" +
                                    "]," +
                                    "\"mappings\":{}" +
                                    "}" +
                                "}"));

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        List<RouteDefinition> routes = context.getRouteDefinitions();
        assertThat(routes).hasSize(1);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);

        // Atlas
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue(
                "uri",
                "atlas:mapping-flow-0-step-1.json?encoding=UTF-8&sourceMapName=" + OutMessageCaptureProcessor.CAPTURED_OUT_MESSAGES_MAP
        );
        assertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(4)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #17
Source File: DataMapperStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testJsonTypeProcessorsSkip() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(getTestSteps("{" +
                                "\"AtlasMapping\":{" +
                                    "\"dataSource\":[" +
                                        "{\"jsonType\":\"io.atlasmap.v2.DataSource\",\"id\":\"source\",\"uri\":\"atlas:java?className=twitter4j.Status\",\"dataSourceType\":\"SOURCE\"}," +
                                        "{\"jsonType\":\"io.atlasmap.v2.DataSource\",\"id\":\"target\",\"uri\":\"atlas:java?className=io.syndesis.connector.gmail.GmailMessageModel\",\"dataSourceType\":\"TARGET\",\"template\":null}" +
                                    "]," +
                                    "\"mappings\":{}" +
                                    "}" +
                                "}"));

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        List<RouteDefinition> routes = context.getRouteDefinitions();
        assertThat(routes).hasSize(1);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);

        // Atlas
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue(
                "uri",
                "atlas:mapping-flow-0-step-1.json?encoding=UTF-8&sourceMapName=" + OutMessageCaptureProcessor.CAPTURED_OUT_MESSAGES_MAP
        );
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #18
Source File: ExtensionStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testEndpointExtensionStepHandler() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-1")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("direct")
                        .putConfiguredProperty("name", "start")
                        .build())
                    .build())
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-2")
                .stepKind(StepKind.extension)
                .action(new StepAction.Builder()
                    .descriptor(new StepDescriptor.Builder()
                        .kind(StepAction.Kind.ENDPOINT)
                        .entrypoint("log:myLog")
                        .build())
                    .build())
                .putConfiguredProperty("Property-1", "Val-1")
                .putConfiguredProperty("Property-2", "Val-2")
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-3")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("mock")
                        .putConfiguredProperty("name", "result")
                        .build())
                    .build())
                .build()
        );

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.setAutoStartup(false);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        List<RouteDefinition> routes = context.getRouteDefinitions();
        assertThat(routes).hasSize(1);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("name", "Property-1");
        assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1");
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("name", "Property-2");
        assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2");
        assertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(3)).hasFieldOrPropertyWithValue(
            "uri",
            "log:myLog"
        );
        assertThat(route.getOutputs().get(3).getOutputs().get(4)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #19
Source File: ExtensionStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testBeanExtensionStepHandler() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-1")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("direct")
                        .putConfiguredProperty("name", "start")
                        .build())
                    .build())
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-2")
                .stepKind(StepKind.extension)
                .action(new StepAction.Builder()
                    .descriptor(new StepDescriptor.Builder()
                        .kind(StepAction.Kind.BEAN)
                        .entrypoint("io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyExtension::action")
                        .build())
                    .build())
                .putConfiguredProperty("param1", "Val-1")
                .putConfiguredProperty("param2", "Val-2")
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-3")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("mock")
                        .putConfiguredProperty("name", "result")
                        .build())
                    .build())
                .build()
        );

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.setAutoStartup(false);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        List<RouteDefinition> routes = context.getRouteDefinitions();
        assertThat(routes).hasSize(1);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue(
            "uri",
            "class:io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyExtension?method=action&bean.param1=Val-1&bean.param2=Val-2"
        );
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #20
Source File: ExtensionStepHandlerTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testStepExtensionStepHandler() throws Exception {
    final DefaultCamelContext context = new DefaultCamelContext();

    try {
        final RouteBuilder routeBuilder = newIntegrationRouteBuilder(
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-1")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("direct")
                        .putConfiguredProperty("name", "start")
                        .build())
                    .build())
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-2")
                .stepKind(StepKind.extension)
                .action(new StepAction.Builder()
                    .descriptor(new StepDescriptor.Builder()
                        .kind(StepAction.Kind.STEP)
                        .entrypoint("io.syndesis.integration.runtime.handlers.ExtensionStepHandlerTest$MyStepExtension")
                        .build())
                    .build())
                .putConfiguredProperty("param1", "Val-1")
                .putConfiguredProperty("param2", "Val-2")
                .build(),
            new io.syndesis.common.model.integration.Step.Builder()
                .id("step-3")
                .stepKind(StepKind.endpoint)
                .action(new ConnectorAction.Builder()
                    .descriptor(new ConnectorDescriptor.Builder()
                        .componentScheme("mock")
                        .putConfiguredProperty("name", "result")
                        .build())
                    .build())
                .build()
        );

        // Set up the camel context
        context.addRoutes(routeBuilder);
        context.setAutoStartup(false);
        context.start();

        // Dump routes as XML for troubleshooting
        dumpRoutes(context);

        RouteDefinition route = context.getRouteDefinitions().get(0);
        assertThat(route).isNotNull();
        assertThat(route.getInput()).isNotNull();
        assertThat(route.getInput()).hasFieldOrPropertyWithValue("uri", "direct:start");
        assertThat(route.getOutputs()).hasSize(5);
        assertThat(route.getOutputs().get(0)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs()).hasSize(2);
        assertThat(route.getOutputs().get(0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(3)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs()).hasSize(4);
        assertThat(route.getOutputs().get(3).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(1)).hasFieldOrPropertyWithValue("name", "param1");
        assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(1)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-1");
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(3).getOutputs().get(2)).hasFieldOrPropertyWithValue("name", "param2");
        assertThat(SetHeaderDefinition.class.cast(route.getOutputs().get(3).getOutputs().get(2)).getExpression()).hasFieldOrPropertyWithValue("expression", "Val-2");
        assertThat(route.getOutputs().get(3).getOutputs().get(3)).isInstanceOf(ProcessDefinition.class);
        assertThat(route.getOutputs().get(4)).isInstanceOf(PipelineDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs()).hasSize(3);
        assertThat(route.getOutputs().get(4).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).isInstanceOf(ToDefinition.class);
        assertThat(route.getOutputs().get(4).getOutputs().get(1)).hasFieldOrPropertyWithValue("uri", "mock:result");
        assertThat(route.getOutputs().get(4).getOutputs().get(2)).isInstanceOf(ProcessDefinition.class);
    } finally {
        context.stop();
    }
}
 
Example #21
Source File: IntegrationRouteBuilderTest.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Test
public void testMultiFlowIntegrationRouteBuilder() throws Exception {
    String configurationLocation = "classpath:syndesis/integration/multi-flow-integration.json";

    IntegrationRouteBuilder routeBuilder = new IntegrationRouteBuilder(configurationLocation, Resources.loadServices(IntegrationStepHandler.class), policyFactories);

    // initialize routes
    routeBuilder.configure();

    // Dump routes as XML for troubleshooting
    dumpRoutes(new DefaultCamelContext(), routeBuilder.getRouteCollection());

    RoutesDefinition routes = routeBuilder.getRouteCollection();

    assertThat(routes.getRoutes()).hasSize(3);

    RouteDefinition primaryRoute = routes.getRoutes().get(0);

    assertThat(primaryRoute.getRoutePolicies()).hasSize(1);
    assertThat(primaryRoute.getRoutePolicies().get(0)).isInstanceOf(IntegrationActivityTrackingPolicy.class);

    assertThat(primaryRoute.getInput()).isNotNull();
    assertThat(primaryRoute.getInput()).hasFieldOrPropertyWithValue("uri", "direct:expression");
    assertThat(primaryRoute.getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1)).isInstanceOf(SplitDefinition.class);
    assertThat(getOutput(primaryRoute, 1).getOutputs()).hasSize(5);
    assertThat(getOutput(primaryRoute, 1, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 1)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 1, 2, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 2, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Before");
    assertThat(getOutput(primaryRoute, 1, 3)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3).getOutputs()).hasSize(3);
    assertThat(getOutput(primaryRoute, 1, 3, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3, 1)).isInstanceOf(ChoiceDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 3, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4).getOutputs()).hasSize(2);
    assertThat(getOutput(primaryRoute, 1, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(primaryRoute, 1, 4, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Finished");

    RouteDefinition conditionalRoute = routes.getRoutes().get(1);

    assertThat(conditionalRoute.getRoutePolicies()).hasSize(1);
    assertThat(conditionalRoute.getRoutePolicies().get(0)).isInstanceOf(FlowActivityTrackingPolicy.class);

    assertThat(conditionalRoute.getInput()).isNotNull();
    assertThat(conditionalRoute.getInput()).hasFieldOrPropertyWithValue("uri", "direct");
    assertThat(conditionalRoute.getOutputs()).hasSize(5);
    assertThat(getOutput(conditionalRoute, 0)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 0).getOutputs()).hasSize(2);
    assertThat(getOutput(conditionalRoute, 0).getOutputs().get(0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 0).getOutputs().get(1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 1)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 2)).isInstanceOf(ProcessDefinition.class);
    assertThat(getOutput(conditionalRoute, 3)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 3).getOutputs()).hasSize(2);
    assertThat(getOutput(conditionalRoute, 3, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 3, 1)).isInstanceOf(LogDefinition.class);
    assertThat(getOutput(conditionalRoute, 3, 1)).hasFieldOrPropertyWithValue("message", "Body: [${bean:bodyLogger}] Found <Play>");
    assertThat(getOutput(conditionalRoute, 4)).isInstanceOf(PipelineDefinition.class);
    assertThat(getOutput(conditionalRoute, 4).getOutputs()).hasSize(3);
    assertThat(getOutput(conditionalRoute, 4, 0)).isInstanceOf(SetHeaderDefinition.class);
    assertThat(getOutput(conditionalRoute, 4, 1)).isInstanceOf(ToDefinition.class);
    assertThat(getOutput(conditionalRoute, 4, 1)).hasFieldOrPropertyWithValue("uri", "bean:io.syndesis.connector.flow.NoOpBean?method=process");
    assertThat(getOutput(conditionalRoute, 4, 2)).isInstanceOf(ProcessDefinition.class);
}
 
Example #22
Source File: CamelModelUtilsTest.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
@Test
public void testPatternNameTo() {
    ToDefinition node = new ToDefinition();
    assertEquals("to", CamelModelHelper.getPatternName(node));
}
 
Example #23
Source File: KnativeStepParser.java    From camel-k-runtime with Apache License 2.0 4 votes vote down vote up
@Override
public ProcessorDefinition<?> toProcessor(Context context) {
    return new ToDefinition(context.node(Definition.class).getEndpointUri());
}