Java 类org.apache.camel.catalog.connector.CamelConnectorCatalog 实例源码

项目:syndesis    文件:DeploymentDescriptorIT.java   
private static void assertActionDataShapes(final CamelConnectorCatalog connectorCatalog, final JsonNode action, final String actionName,
    final String... coordinates) {

    final String connectorJSon = connectorCatalog.connectorJSon(coordinates[0], coordinates[1], coordinates[2]);
    JsonNode connectorJson;
    try {
        connectorJson = MAPPER.readTree(connectorJSon);
    } catch (final IOException e) {
        fail("Unable to parse connector JSON descriptor", e);
        return; // never happens
    }

    final String connectorInputDataType = connectorJson.get("inputDataType").asText();
    final String connectorOutputDataType = connectorJson.get("outputDataType").asText();

    final JsonNode actionDescriptor = action.get("descriptor");
    final JsonNode inputDataShape = actionDescriptor.get("inputDataShape");
    if ("json".equals(connectorInputDataType)) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as JSON, deployment descriptor does not", actionName)
            .isEqualTo("json-schema");
        assertThat(inputDataShape.get("type"))
            .as("shapes of kind `json-schema` should not define type, input data shape of %s does", actionName).isNull();
    }

    final JsonNode outputDataShape = actionDescriptor.get("outputDataShape");
    if ("json".equals(connectorOutputDataType)) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as JSON, deployment descriptor does not", actionName)
            .isEqualTo("json-schema");
        assertThat(outputDataShape.get("type"))
            .as("shapes of kind `json-schema` should not define type, output data shape of %s does", actionName).isNull();
    }

    if (connectorInputDataType.startsWith("java:")) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as java, deployment descriptor does not", actionName)
            .isEqualTo("java");
        assertThat(inputDataShape.get("type").asText())
            .as("Connector input data shape for action %s differs in class name from deployment", actionName)
            .isEqualTo(connectorInputDataType.substring(5));
    }

    if (connectorOutputDataType.startsWith("java:")) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as java, deployment descriptor does not", actionName)
            .isEqualTo("java");
        assertThat(outputDataShape.get("type").asText())
            .as("Connector output data shape for action %s differs in class name from deployment", actionName)
            .isEqualTo(connectorOutputDataType.substring(5));
    }

    if ("none".equals(connectorInputDataType)) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as none, deployment descriptor does not", actionName)
            .isEqualTo("none");
        assertThat(inputDataShape.get("type"))
            .as("shapes of kind `none` should not define type, input data shape of %s does", actionName).isNull();
    }

    if ("none".equals(connectorOutputDataType)) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as none, deployment descriptor does not", actionName)
            .isEqualTo("none");
        assertThat(outputDataShape.get("type"))
            .as("shapes of kind `none` should not define type, output data shape of %s does", actionName).isNull();
    }
}
项目:syndesis-rest    文件:DeploymentDescriptorIT.java   
private static void assertActionDataShapes(final CamelConnectorCatalog connectorCatalog, final JsonNode action,
    final String actionName, final String... coordinates) {

    final String connectorJSon = connectorCatalog.connectorJSon(coordinates[0], coordinates[1], coordinates[2]);
    JsonNode connectorJson;
    try {
        connectorJson = MAPPER.readTree(connectorJSon);
    } catch (final IOException e) {
        fail("Unable to parse connector JSON descriptor", e);
        return; // never happens
    }

    final String connectorInputDataType = connectorJson.get("inputDataType").asText();
    final String connectorOutputDataType = connectorJson.get("outputDataType").asText();

    final JsonNode actionDefinition = action.get("definition");
    final JsonNode inputDataShape = actionDefinition.get("inputDataShape");
    if ("json".equals(connectorInputDataType)) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as JSON, deployment descriptor does not",
                actionName)
            .isEqualTo("json-schema");
        assertThat(inputDataShape.get("type"))
            .as("shapes of kind `json-schema` should not define type, input data shape of %s does", actionName)
            .isNull();
    }

    final JsonNode outputDataShape = actionDefinition.get("outputDataShape");
    if ("json".equals(connectorOutputDataType)) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as JSON, deployment descriptor does not",
                actionName)
            .isEqualTo("json-schema");
        assertThat(outputDataShape.get("type"))
            .as("shapes of kind `json-schema` should not define type, output data shape of %s does", actionName)
            .isNull();
    }

    if (connectorInputDataType.startsWith("java:")) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as java, deployment descriptor does not",
                actionName)
            .isEqualTo("java");
        assertThat(inputDataShape.get("type").asText())
            .as("Connector input data shape for action %s differs in class name from deployment", actionName)
            .isEqualTo(connectorInputDataType.substring(5));
    }

    if (connectorOutputDataType.startsWith("java:")) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as java, deployment descriptor does not",
                actionName)
            .isEqualTo("java");
        assertThat(outputDataShape.get("type").asText())
            .as("Connector output data shape for action %s differs in class name from deployment", actionName)
            .isEqualTo(connectorOutputDataType.substring(5));
    }

    if ("none".equals(connectorInputDataType)) {
        assertThat(inputDataShape.get("kind").asText())
            .as("Connector defines input data shape for action %s as none, deployment descriptor does not",
                actionName)
            .isEqualTo("none");
        assertThat(inputDataShape.get("type"))
            .as("shapes of kind `none` should not define type, input data shape of %s does", actionName).isNull();
    }

    if ("none".equals(connectorOutputDataType)) {
        assertThat(outputDataShape.get("kind").asText())
            .as("Connector defines output data shape for action %s as none, deployment descriptor does not",
                actionName)
            .isEqualTo("none");
        assertThat(outputDataShape.get("type"))
            .as("shapes of kind `none` should not define type, output data shape of %s does", actionName).isNull();
    }
}