[GitHub] [camel] WillemJiang commented on a change in pull request #4900: [CAMEL-16001] Camel component for HuaweiCloud Simple Notification Services (SMN) se…

2021-01-27 Thread GitBox


WillemJiang commented on a change in pull request #4900:
URL: https://github.com/apache/camel/pull/4900#discussion_r565388052



##
File path: components/camel-huaweicloud-smn/src/test/resources/log4j2.properties
##
@@ -0,0 +1,7 @@
+

Review comment:
   We need to add the Apache License Header here.

##
File path: 
components/camel-huaweicloud-smn/src/test/resources/testconfiguration.properties
##
@@ -0,0 +1,6 @@
+## Test configurations

Review comment:
   We need to add the Apache License Header here.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [camel] WillemJiang commented on a change in pull request #4900: [CAMEL-16001] Camel component for HuaweiCloud Simple Notification Services (SMN) se…

2021-01-26 Thread GitBox


WillemJiang commented on a change in pull request #4900:
URL: https://github.com/apache/camel/pull/4900#discussion_r565053683



##
File path: 
components/camel-huaweicloud-smn/src/main/java/org/apache/camel/component/huaweicloud/smn/SimpleNotificationUtils.java
##
@@ -0,0 +1,69 @@
+/*
+ * 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.huaweicloud.smn;
+
+import com.huaweicloud.sdk.core.region.Region;
+import com.huaweicloud.sdk.smn.v2.region.SmnRegion;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * utility functions for the component
+ */
+public class SimpleNotificationUtils {
+private static final Logger LOG = 
LoggerFactory.getLogger(SimpleNotificationUtils.class.getName());
+
+/**
+ * resolves endpoint url for the given region
+ * 
+ * @param  region
+ * @return
+ */
+public static String resolveSmnServiceEndpoint(String region) {
+if (region == null) {
+return null;
+}
+
+String result = null;
+
+try {
+String formattedEndpointKey = formatEndpointKey(region);

Review comment:
   @mathewsreji  you are still use getField() method.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [camel] WillemJiang commented on a change in pull request #4900: [CAMEL-16001] Camel component for HuaweiCloud Simple Notification Services (SMN) se…

2021-01-26 Thread GitBox


WillemJiang commented on a change in pull request #4900:
URL: https://github.com/apache/camel/pull/4900#discussion_r565051872



##
File path: components/camel-huaweicloud-smn/pom.xml
##
@@ -0,0 +1,121 @@
+
+http://maven.apache.org/POM/4.0.0; 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance; 
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 
http://maven.apache.org/maven-v4_0_0.xsd;>

Review comment:
   Please add ASF license header here.





This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org




[GitHub] [camel] WillemJiang commented on a change in pull request #4900: [CAMEL-16001] Camel component for HuaweiCloud Simple Notification Services (SMN) se…

2021-01-18 Thread GitBox


WillemJiang commented on a change in pull request #4900:
URL: https://github.com/apache/camel/pull/4900#discussion_r559850830



##
File path: 
components/camel-huaweicloud-smn/src/test/java/org/apache/camel/component/huaweicloud/smn/PublishTemplatedMessageTest.java
##
@@ -0,0 +1,129 @@
+package org.apache.camel.component.huaweicloud.smn;

Review comment:
   Please add the License header on all the test java files.

##
File path: 
components/camel-huaweicloud-smn/src/test/java/org/apache/camel/component/huaweicloud/smn/PublishTemplatedMessageTest.java
##
@@ -0,0 +1,129 @@
+package org.apache.camel.component.huaweicloud.smn;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.verification.LoggedRequest;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.huaweicloud.smn.models.ServiceKeys;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.exceptions.base.MockitoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+
+public class PublishTemplatedMessageTest extends CamelTestSupport {
+
+private static final Logger LOGGER = 
LoggerFactory.getLogger(PublishTemplatedMessageTest.class.getName());
+private static int wiremockServerPort = 8080;

Review comment:
   It may cause some trouble in CI if the test port is used.
   There is a port lookup util method in Camel that you can take a look.

##
File path: 
components/camel-huaweicloud-smn/src/test/java/org/apache/camel/component/huaweicloud/smn/PublishTemplatedMessageTest.java
##
@@ -0,0 +1,129 @@
+package org.apache.camel.component.huaweicloud.smn;
+
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.HashMap;
+import java.util.Map;
+
+import com.github.tomakehurst.wiremock.WireMockServer;
+import com.github.tomakehurst.wiremock.verification.LoggedRequest;
+import org.apache.camel.BindToRegistry;
+import org.apache.camel.Exchange;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.huaweicloud.smn.models.ServiceKeys;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit4.CamelTestSupport;
+import org.junit.Assert;
+import org.junit.Test;
+import org.mockito.Mockito;
+import org.mockito.exceptions.base.MockitoException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+import static com.github.tomakehurst.wiremock.client.WireMock.*;
+
+public class PublishTemplatedMessageTest extends CamelTestSupport {
+
+private static final Logger LOGGER = 
LoggerFactory.getLogger(PublishTemplatedMessageTest.class.getName());
+private static int wiremockServerPort = 8080;
+
+TestConfiguration testConfiguration = new TestConfiguration();
+
+WireMockServer wireMockServer;
+
+@BindToRegistry("serviceKeys")
+ServiceKeys serviceKeys
+= new ServiceKeys(testConfiguration.getProperty("authKey"), 
testConfiguration.getProperty("secretKey"));
+
+protected RouteBuilder createRouteBuilder() throws Exception {
+
+// populating tag values. user has to adjust the map entries according 
to the structure of their respective templates
+Map tags = new HashMap<>();
+tags.put("name", "reji");
+tags.put("phone", "1234567890");
+
+return new RouteBuilder() {
+public void configure() {
+from("direct:publish_templated_message")
+.setProperty("CamelHwCloudSmnSubject", constant("This 
is my subjectline"))
+.setProperty("CamelHwCloudSmnTopic", 
constant(testConfiguration.getProperty("topic")))
+.setProperty("CamelHwCloudSmnMessageTtl", constant(60))
+.setProperty("CamelHwCloudSmnTemplateTags", 
constant(tags))
+.setProperty("CamelHwCloudSmnTemplateName", 
constant("hello-template"))
+
//.to("hwcloud-smn:publishMessageService?serviceKeys=#serviceKeys=publishAsTemplatedMessage"+"="+testConfiguration.getProperty("projectId")+"="+testConfiguration.getProperty("region")+"=localhost=3128=true")
+
.to("hwcloud-smn:publishMessageService?serviceKeys=#serviceKeys=publishAsTemplatedMessage"
++ "=" + 
testConfiguration.getProperty("projectId") + "="
++ testConfiguration.getProperty("region") + 
"=true")
+.log("templated notification sent")
+