org.apache.camel.model.FromDefinition Java Examples

The following examples show how to use org.apache.camel.model.FromDefinition. 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: IntegrationRouteLoaderTest.java    From syndesis with Apache License 2.0 6 votes vote down vote up
@Test
public void integrationRouteLoaderTest() throws Exception {
    IntegrationRouteLoader irl = new IntegrationRouteLoader();
    TestRuntime runtime = new TestRuntime();

    irl.load(runtime,
        Sources.fromURI("classpath:/syndesis/integration/integration.syndesis?language=syndesis"));

    assertThat(runtime.builders).hasSize(1);
    final RoutesBuilder routeBuilder = runtime.builders.get(0);
    assertThat(routeBuilder).isInstanceOf(RouteBuilder.class);

    RouteBuilder rb = (RouteBuilder) routeBuilder;
    // initialize routes
    rb.configure();
    final RoutesDefinition routeCollection = rb.getRouteCollection();
    final List<RouteDefinition> routes = routeCollection.getRoutes();
    assertThat(routes).hasSize(1);
    final RouteDefinition route = routes.get(0);
    final FromDefinition input = route.getInput();
    assertThat(input).isNotNull();
    assertThat(input.getEndpointUri()).isEqualTo("direct:expression");
}
 
Example #2
Source File: KnativeConverterTest.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Test
public void testLoadRoutes() throws Exception {
    TestRuntime runtime = new TestRuntime();
    Source source = Sources.fromURI("classpath:route.yaml");
    SourceLoader loader = RoutesConfigurer.load(runtime, source);

    assertThat(loader).isInstanceOf(YamlSourceLoader.class);
    assertThat(runtime.builders).hasSize(1);

    runtime.camelContext.addRoutes(runtime.builders.get(0));

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

    // definition
    assertThat(routes)
        .first()
        .extracting(RouteDefinition::getId)
        .isEqualTo("knative");
    assertThat(routes)
        .first()
        .extracting(RouteDefinition::getGroup)
        .isEqualTo("flows");

    // input
    assertThat(routes)
        .first()
        .extracting(RouteDefinition::getInput)
        .isInstanceOfSatisfying(FromDefinition.class, t-> {
            assertThat(t.getEndpointUri()).isEqualTo("knative:endpoint/from");
        });

    // outputs
    assertThat(routes)
        .first()
        .satisfies(KnativeConverterTest::validateSteps);
}
 
Example #3
Source File: IntegrationTest.java    From camel-k-runtime with Apache License 2.0 5 votes vote down vote up
@Test
public void testRestDSL() {
    configureRoutes(
        "classpath:routes-with-rest-dsl.js"
    );

    ModelCamelContext mcc = context.adapt(ModelCamelContext.class);
    List<RestDefinition> rests = mcc.getRestDefinitions();
    List<RouteDefinition> routes = mcc.getRouteDefinitions();

    assertThat(rests).hasSize(1);
    assertThat(rests).first().hasFieldOrPropertyWithValue("produces", "text/plain");
    assertThat(rests).first().satisfies(definition -> {
        assertThat(definition.getVerbs()).hasSize(1);
        assertThat(definition.getVerbs()).first().isInstanceOfSatisfying(GetVerbDefinition.class, get -> {
            assertThat(get).hasFieldOrPropertyWithValue("uri", "/say/hello");
        });
    });

    assertThat(routes).hasSize(1);
    assertThat(routes).first().satisfies(definition -> {
        assertThat(definition.getInput()).isInstanceOf(FromDefinition.class);
        assertThat(definition.getOutputs()).hasSize(1);
        assertThat(definition.getOutputs()).first().satisfies(output -> {
            assertThat(output).isInstanceOf(TransformDefinition.class);
        });
    });
}
 
Example #4
Source File: CamelModelHelper.java    From fabric8-forge with Apache License 2.0 5 votes vote down vote up
public static String getUri(FromDefinition input) {
    String key = input.getUri();
    if (Strings2.isEmpty(key)) {
        String ref = input.getRef();
        if (!Strings2.isEmpty(ref)) {
            return "ref:" + ref;
        }
    }
    return key;
}
 
Example #5
Source File: CamelXmlHelper.java    From fabric8-forge with Apache License 2.0 4 votes vote down vote up
protected static void addInputs(CamelCatalog camelCatalog, NodeDto owner, List<FromDefinition> inputs) {
    Map<String, Integer> nodeCounts = new HashMap<>();
    for (FromDefinition input : inputs) {
        addChild(camelCatalog, owner, input, nodeCounts);
    }
}