This is an automated email from the ASF dual-hosted git repository. acosentino pushed a commit to branch sandbox/camel-3.x in repository https://gitbox.apache.org/repos/asf/camel.git
commit c0441889d49e5ed411044f3a9591cda72cdfdd34 Author: Andrea Cosentino <anco...@gmail.com> AuthorDate: Wed Nov 28 12:32:51 2018 +0100 CAMEL-12930 - Fixed CS and sb starter Conflicts: components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java --- .../bigquery/sql/GoogleBigQuerySQLComponent.java | 3 +- .../sql/GoogleBigQuerySQLConfiguration.java | 9 ++- .../bigquery/sql/GoogleBigQuerySQLEndpoint.java | 28 +++---- .../bigquery/sql/GoogleBigQuerySQLProducer.java | 93 +++++++++++----------- .../component/google/bigquery/sql/SqlHelper.java | 31 +++++--- .../unit/sql/GoogleBigQuerySQLComponentTest.java | 7 +- .../sql/GoogleBigQuerySQLProducerBaseTest.java | 19 ++++- .../GoogleBigQuerySQLProducerWithParamersTest.java | 6 +- .../GoogleBigQuerySQLProducerWithPatternTest.java | 4 +- .../google/bigquery/unit/sql/SqlHelperTest.java | 45 ++++------- ...oogleBigQuerySQLComponentAutoConfiguration.java | 4 + .../GoogleBigQuerySQLComponentConfiguration.java | 13 +++ 12 files changed, 140 insertions(+), 122 deletions(-) diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java index 63f1473..00ce426 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLComponent.java @@ -74,7 +74,8 @@ public class GoogleBigQuerySQLComponent extends DefaultComponent { } /** - * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default one will be used + * ConnectionFactory to obtain connection to Bigquery Service. If non + * provided the default one will be used */ public void setConnectionFactory(GoogleBigQueryConnectionFactory connectionFactory) { this.connectionFactory = connectionFactory; diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java index 25ed0dff..5e766a0 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLConfiguration.java @@ -5,9 +5,9 @@ * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * + * 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. @@ -46,7 +46,8 @@ public class GoogleBigQuerySQLConfiguration { } /** - * ConnectionFactory to obtain connection to Bigquery Service. If non provided the default will be used. + * ConnectionFactory to obtain connection to Bigquery Service. If non + * provided the default will be used. */ public GoogleBigQueryConnectionFactory getConnectionFactory() { return connectionFactory; diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java index efa0a8a..9a420f0 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLEndpoint.java @@ -26,23 +26,18 @@ import org.apache.camel.spi.UriParam; import org.apache.camel.support.DefaultEndpoint; /** - * Google BigQuery data warehouse for analytics. - * - * BigQuery Endpoint Definition - * Represents a table within a BigQuery dataset - * Contains configuration details for a single table and the utility methods (such as check, create) to ease operations - * URI Parameters: - * * Logger ID - To ensure that logging is unified under Route Logger, the logger ID can be passed on - * via an endpoint URI parameter - * * Partitioned - to indicate that the table needs to be partitioned - every UTC day to be written into a - * timestamped separate table - * side effect: Australian operational day is always split between two UTC days, and, therefore, tables - * - * Another consideration is that exceptions are not handled within the class. They are expected to bubble up and be handled - * by Camel. + * Google BigQuery data warehouse for analytics. BigQuery Endpoint Definition + * Represents a table within a BigQuery dataset Contains configuration details + * for a single table and the utility methods (such as check, create) to ease + * operations URI Parameters: * Logger ID - To ensure that logging is unified + * under Route Logger, the logger ID can be passed on via an endpoint URI + * parameter * Partitioned - to indicate that the table needs to be partitioned + * - every UTC day to be written into a timestamped separate table side effect: + * Australian operational day is always split between two UTC days, and, + * therefore, tables Another consideration is that exceptions are not handled + * within the class. They are expected to bubble up and be handled by Camel. */ -@UriEndpoint(firstVersion = "2.23.0", scheme = "google-bigquery-sql", title = "Google BigQuery Standard SQL", syntax = "google-bigquery-sql:query", - label = "cloud,messaging", producerOnly = true) +@UriEndpoint(firstVersion = "2.23.0", scheme = "google-bigquery-sql", title = "Google BigQuery Standard SQL", syntax = "google-bigquery-sql:query", label = "cloud,messaging", producerOnly = true) public class GoogleBigQuerySQLEndpoint extends DefaultEndpoint { @UriParam @@ -77,5 +72,4 @@ public class GoogleBigQuerySQLEndpoint extends DefaultEndpoint { return (GoogleBigQuerySQLComponent)super.getComponent(); } - } diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java index 118daf5..6a489a2 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/GoogleBigQuerySQLProducer.java @@ -1,29 +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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> - * 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. + * 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.component.google.bigquery.sql; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Set; + import com.google.api.services.bigquery.Bigquery; -import com.google.api.services.bigquery.model.*; +import com.google.api.services.bigquery.model.QueryParameter; +import com.google.api.services.bigquery.model.QueryParameterType; +import com.google.api.services.bigquery.model.QueryParameterValue; +import com.google.api.services.bigquery.model.QueryRequest; +import com.google.api.services.bigquery.model.QueryResponse; + import org.apache.camel.Exchange; import org.apache.camel.Message; import org.apache.camel.RuntimeExchangeException; import org.apache.camel.component.google.bigquery.GoogleBigQueryConstants; import org.apache.camel.support.DefaultProducer; -import java.util.*; - /** * Generic BigQuery Producer */ @@ -34,27 +45,24 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer { private String query; private Set<String> queryParameterNames; - public GoogleBigQuerySQLProducer(Bigquery bigquery, GoogleBigQuerySQLEndpoint endpoint, - GoogleBigQuerySQLConfiguration configuration) { + public GoogleBigQuerySQLProducer(Bigquery bigquery, GoogleBigQuerySQLEndpoint endpoint, GoogleBigQuerySQLConfiguration configuration) { super(endpoint); this.bigquery = bigquery; this.configuration = configuration; } /** - * Process the exchange - * - * The incoming exchange can be a grouped exchange in which case all the exchanges will be combined. - * - * The incoming can be + * Process the exchange The incoming exchange can be a grouped exchange in + * which case all the exchanges will be combined. The incoming can be * <ul> - * <li>A map where all map keys will map to field records. One map object maps to one bigquery row</li> - * <li>A list of maps. Each entry in the list will map to one bigquery row</li> + * <li>A map where all map keys will map to field records. One map object + * maps to one bigquery row</li> + * <li>A list of maps. Each entry in the list will map to one bigquery + * row</li> * </ul> - * The incoming message is expected to be a List of Maps - * The assumptions: - * - All incoming records go into the same table - * - Incoming records sorted by the timestamp + * The incoming message is expected to be a List of Maps The assumptions: - + * All incoming records go into the same table - Incoming records sorted by + * the timestamp */ @Override public void process(Exchange exchange) throws Exception { @@ -67,19 +75,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer { } private Long executeSQL(String translatedQuery, Map<String, Object> queryParameters) throws Exception { - QueryRequest apiQueryRequest = new QueryRequest() - .setQuery(translatedQuery) - .setUseLegacySql(false); + QueryRequest apiQueryRequest = new QueryRequest().setQuery(translatedQuery).setUseLegacySql(false); - Bigquery.Jobs.Query apiQuery = bigquery - .jobs() - .query(configuration.getProjectId(), apiQueryRequest); + Bigquery.Jobs.Query apiQuery = bigquery.jobs().query(configuration.getProjectId(), apiQueryRequest); setQueryParameters(queryParameters, apiQueryRequest); if (log.isTraceEnabled()) { - log.trace("Sending query to bigquery standard sql: {}", - translatedQuery); + log.trace("Sending query to bigquery standard sql: {}", translatedQuery); } QueryResponse apiResponse = apiQuery.execute(); @@ -89,15 +92,15 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer { } if (log.isTraceEnabled()) { - log.trace("Result of query {} is {}", - translatedQuery, apiResponse.toPrettyString()); + log.trace("Result of query {} is {}", translatedQuery, apiResponse.toPrettyString()); } return apiResponse.getNumDmlAffectedRows(); } private Map<String, Object> extractParameters(Exchange exchange) { - if (queryParameterNames == null || queryParameterNames.size() == 0) + if (queryParameterNames == null || queryParameterNames.size() == 0) { return null; + } Message message = exchange.getMessage(); @@ -124,15 +127,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer { } private void setQueryParameters(Map<String, Object> params, QueryRequest apiQueryRequest) { - if (params == null) + if (params == null) { return; + } List<QueryParameter> list = new ArrayList<>(); params.forEach((key, value) -> { QueryParameter param = new QueryParameter(); - param.setName(key) - .setParameterType(new QueryParameterType().setType("STRING")) - .setParameterValue(new QueryParameterValue().setValue(value.toString())); + param.setName(key).setParameterType(new QueryParameterType().setType("STRING")).setParameterValue(new QueryParameterValue().setValue(value.toString())); list.add(param); }); apiQueryRequest.setQueryParameters(list); @@ -145,15 +147,14 @@ public class GoogleBigQuerySQLProducer extends DefaultProducer { @Override public GoogleBigQuerySQLEndpoint getEndpoint() { - return (GoogleBigQuerySQLEndpoint) super.getEndpoint(); + return (GoogleBigQuerySQLEndpoint)super.getEndpoint(); } @Override protected void doStart() throws Exception { super.doStart(); String placeholder = ":#"; // TODO - query = SqlHelper - .resolveQuery(getEndpoint().getCamelContext(), configuration.getQuery(), placeholder); + query = SqlHelper.resolveQuery(getEndpoint().getCamelContext(), configuration.getQuery(), placeholder); queryParameterNames = SqlHelper.extractParameterNames(query); } } diff --git a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java index b293310..9ecd2e2 100644 --- a/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java +++ b/components/camel-google-bigquery/src/main/java/org/apache/camel/component/google/bigquery/sql/SqlHelper.java @@ -5,9 +5,9 @@ * 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 - * <p> - * http://www.apache.org/licenses/LICENSE-2.0 - * <p> + * + * 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. @@ -16,9 +16,6 @@ */ package org.apache.camel.component.google.bigquery.sql; -import org.apache.camel.*; -import org.apache.camel.support.ResourceHelper; - import java.io.IOException; import java.io.InputStream; import java.util.HashSet; @@ -26,6 +23,13 @@ import java.util.Set; import java.util.regex.Matcher; import java.util.regex.Pattern; +import org.apache.camel.CamelContext; +import org.apache.camel.Exchange; +import org.apache.camel.Message; +import org.apache.camel.NoTypeConversionAvailableException; +import org.apache.camel.RuntimeExchangeException; +import org.apache.camel.util.ResourceHelper; + public final class SqlHelper { private static Pattern pattern = Pattern.compile("\\$\\{(\\w+)}"); @@ -35,13 +39,13 @@ public final class SqlHelper { } /** - * Resolve the query by loading the query from the classpath or file resource if needed. + * Resolve the query by loading the query from the classpath or file + * resource if needed. */ public static String resolveQuery(CamelContext camelContext, String query, String placeholder) throws NoTypeConversionAvailableException, IOException { String answer = query; if (ResourceHelper.hasScheme(query)) { - InputStream is = ResourceHelper - .resolveMandatoryResourceAsInputStream(camelContext, query); + InputStream is = ResourceHelper.resolveMandatoryResourceAsInputStream(camelContext, query); answer = camelContext.getTypeConverter().mandatoryConvertTo(String.class, is); if (placeholder != null) { answer = answer.replaceAll(placeholder, "@"); @@ -51,8 +55,9 @@ public final class SqlHelper { } /** - * Replaces pattern in query in form of "${param}" with values from message header - * Raises an error if param value not found in headers + * Replaces pattern in query in form of "${param}" with values from message + * header Raises an error if param value not found in headers + * * @param exchange * @return Translated query text */ @@ -66,8 +71,9 @@ public final class SqlHelper { String value = message.getHeader(paramKey, String.class); if (value == null) { value = exchange.getProperty(paramKey, String.class); - if (value == null) + if (value == null) { throw new RuntimeExchangeException("SQL pattern with name '" + paramKey + "' not found in the message headers", exchange); + } } String replacement = Matcher.quoteReplacement(value); @@ -79,6 +85,7 @@ public final class SqlHelper { /** * Extracts list of parameters in form "@name" from query text + * * @param query * @return list of parameter names */ diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java index ba24d0d..5cd5d2c 100644 --- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java +++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLComponentTest.java @@ -16,17 +16,14 @@ */ package org.apache.camel.component.google.bigquery.unit.sql; -import static org.junit.Assert.assertEquals; - import org.apache.camel.CamelContext; -import org.apache.camel.component.google.bigquery.GoogleBigQueryComponent; -import org.apache.camel.component.google.bigquery.GoogleBigQueryEndpoint; import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLComponent; import org.apache.camel.component.google.bigquery.sql.GoogleBigQuerySQLEndpoint; -import org.apache.camel.component.google.bigquery.sql.SqlHelper; import org.junit.Test; import org.mockito.Mockito; +import static org.junit.Assert.assertEquals; + public class GoogleBigQuerySQLComponentTest { private CamelContext context = Mockito.mock(CamelContext.class); diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java index 244f27c..fa28b70 100644 --- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java +++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerBaseTest.java @@ -1,3 +1,19 @@ +/** + * 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.component.google.bigquery.unit.sql; import com.google.api.services.bigquery.Bigquery; @@ -37,8 +53,7 @@ public class GoogleBigQuerySQLProducerBaseTest extends CamelTestSupport { when(bigquery.jobs()).thenReturn(mockJobs); when(bigquery.jobs().query(anyString(), any())).thenReturn(mockQuery); - QueryResponse mockResponse = new QueryResponse() - .setNumDmlAffectedRows(1L); + QueryResponse mockResponse = new QueryResponse().setNumDmlAffectedRows(1L); when(mockQuery.execute()).thenReturn(mockResponse); } } diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java index 6227dfb..5eaa916 100644 --- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java +++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithParamersTest.java @@ -16,6 +16,9 @@ */ package org.apache.camel.component.google.bigquery.unit.sql; +import java.util.HashMap; +import java.util.Map; + import com.google.api.services.bigquery.model.QueryRequest; import org.apache.camel.Exchange; import org.apache.camel.RuntimeExchangeException; @@ -23,9 +26,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import java.util.HashMap; -import java.util.Map; - import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java index 11cb050..93ac997 100644 --- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java +++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/GoogleBigQuerySQLProducerWithPatternTest.java @@ -16,14 +16,14 @@ */ package org.apache.camel.component.google.bigquery.unit.sql; +import java.util.List; + import com.google.api.services.bigquery.model.QueryRequest; import org.apache.camel.Exchange; import org.junit.Before; import org.junit.Test; import org.mockito.ArgumentCaptor; -import java.util.List; - import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.verify; diff --git a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java index de46355..1ab2b2f 100644 --- a/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java +++ b/components/camel-google-bigquery/src/test/java/org/apache/camel/component/google/bigquery/unit/sql/SqlHelperTest.java @@ -16,6 +16,8 @@ */ package org.apache.camel.component.google.bigquery.unit.sql; +import java.util.Set; + import org.apache.camel.CamelContext; import org.apache.camel.Exchange; import org.apache.camel.Message; @@ -25,13 +27,23 @@ import org.junit.Ignore; import org.junit.Test; import org.mockito.Mockito; -import java.util.Set; - -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import static org.mockito.ArgumentMatchers.eq; import static org.mockito.Mockito.when; public class SqlHelperTest { + + String query = "INSERT INTO ${report}.test( -- TODO \n" + " id,\n" + " region\n" + ")\n" + "SELECT\n" + " id,\n" + " region\n" + "FROM\n" + " ${import}.test\n" + "WHERE\n" + + " rec_date = @date AND id = @id\n"; + + String expected = "INSERT INTO report_data.test( -- TODO \n" + " id,\n" + " region\n" + ")\n" + "SELECT\n" + " id,\n" + " region\n" + "FROM\n" + " import_data.test\n" + + "WHERE\n" + " rec_date = @date AND id = @id\n"; + + Exchange exchange = Mockito.mock(Exchange.class); + Message message = Mockito.mock(Message.class); + private CamelContext context = Mockito.mock(CamelContext.class); @Test @@ -47,33 +59,6 @@ public class SqlHelperTest { assertEquals("delete from test.test_sql_table where id = @id", answer); } - String query = "INSERT INTO ${report}.test( -- TODO \n" + - " id,\n" + - " region\n" + - ")\n" + - "SELECT\n" + - " id,\n" + - " region\n" + - "FROM\n" + - " ${import}.test\n" + - "WHERE\n" + - " rec_date = @date AND id = @id\n"; - - String expected = "INSERT INTO report_data.test( -- TODO \n" + - " id,\n" + - " region\n" + - ")\n" + - "SELECT\n" + - " id,\n" + - " region\n" + - "FROM\n" + - " import_data.test\n" + - "WHERE\n" + - " rec_date = @date AND id = @id\n"; - - Exchange exchange = Mockito.mock(Exchange.class); - Message message = Mockito.mock(Message.class); - @Test public void testTranslateQuery() { when(exchange.getMessage()).thenReturn(message); diff --git a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java index b245bea..4bcf9a3 100644 --- a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentAutoConfiguration.java @@ -30,7 +30,11 @@ import org.apache.camel.spring.boot.util.CamelPropertiesHelper; import org.apache.camel.spring.boot.util.ConditionalOnCamelContextAndAutoConfigurationBeans; import org.apache.camel.spring.boot.util.GroupCondition; import org.apache.camel.spring.boot.util.HierarchicalPropertiesEvaluator; +<<<<<<< HEAD import org.apache.camel.support.IntrospectionSupport; +======= +import org.apache.camel.util.IntrospectionSupport; +>>>>>>> a8ce423... CAMEL-12930 - Fixed CS and sb starter import org.apache.camel.util.ObjectHelper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java index ec27686..20d3b35 100644 --- a/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-google-bigquery-starter/src/main/java/org/apache/camel/component/google/bigquery/sql/springboot/GoogleBigQuerySQLComponentConfiguration.java @@ -21,7 +21,20 @@ import org.apache.camel.spring.boot.ComponentConfigurationPropertiesCommon; import org.springframework.boot.context.properties.ConfigurationProperties; /** +<<<<<<< HEAD * Google BigQuery data warehouse for analytics. +======= + * Google BigQuery data warehouse for analytics. BigQuery Endpoint Definition + * Represents a table within a BigQuery dataset Contains configuration details + * for a single table and the utility methods (such as check, create) to ease + * operations URI Parameters: Logger ID - To ensure that logging is unified + * under Route Logger, the logger ID can be passed on via an endpoint URI + * parameter Partitioned - to indicate that the table needs to be partitioned - + * every UTC day to be written into a timestamped separate table side effect: + * Australian operational day is always split between two UTC days, and, + * therefore, tables Another consideration is that exceptions are not handled + * within the class. They are expected to bubble up and be handled by Camel. +>>>>>>> a8ce423... CAMEL-12930 - Fixed CS and sb starter * * Generated by camel-package-maven-plugin - do not edit this file! */