Skip to content

Commit

Permalink
fix checkstyle check error
Browse files Browse the repository at this point in the history
  • Loading branch information
jonyangx committed Jan 7, 2023
1 parent 7d5d46c commit 3bda8fb
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import lombok.extern.slf4j.Slf4j;

/**
* Utility class for implementing CloudEvents Http Webhook spec
*
* @see <a href="https://github.com/cloudevents/spec/blob/v1.0.2/cloudevents/http-webhook.md">CloudEvents Http Webhook</a>
*/
@Slf4j
public class WebhookUtil {
private static final Logger LOGGER = LoggerFactory.getLogger(WebhookUtil.class);

private static final String CONTENT_TYPE_HEADER = "Content-Type";
private static final String REQUEST_ORIGIN_HEADER = "WebHook-Request-Origin";
private static final String ALLOWED_ORIGIN_HEADER = "WebHook-Allowed-Origin";
Expand All @@ -53,8 +51,8 @@ public static boolean obtainDeliveryAgreement(final CloseableHttpClient httpClie
final String targetUrl,
final String requestOrigin) {

if (LOGGER.isInfoEnabled()) {
LOGGER.info("obtain webhook delivery agreement for url: {}", targetUrl);
if (log.isInfoEnabled()) {
log.info("obtain webhook delivery agreement for url: {}", targetUrl);
}

final HttpOptions builder = new HttpOptions(targetUrl);
Expand All @@ -65,8 +63,10 @@ public static boolean obtainDeliveryAgreement(final CloseableHttpClient httpClie
return StringUtils.isEmpty(allowedOrigin)
|| "*".equals(allowedOrigin) || allowedOrigin.equalsIgnoreCase(requestOrigin);
} catch (Exception e) {
LOGGER.error("HTTP Options Method is not supported at the Delivery Target: {}, "
+ "unable to obtain the webhook delivery agreement.", targetUrl);
if (log.isErrorEnabled()) {
log.error("HTTP Options Method is not supported at the Delivery Target: {}, "
+ "unable to obtain the webhook delivery agreement.", targetUrl);
}
}
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ public void testObtainDeliveryAgreement() {
CloseableHttpResponse response = mock(CloseableHttpResponse.class);
CloseableHttpClient httpClient2 = mock(CloseableHttpClient.class)) {

Mockito.when(response.getLastHeader("WebHook-Allowed-Origin")).
thenReturn(new BasicHeader("WebHook-Allowed-Origin", "*"));
Mockito.when(response.getLastHeader("WebHook-Allowed-Origin"))
.thenReturn(new BasicHeader("WebHook-Allowed-Origin", "*"));
Mockito.when(httpClient.execute(any())).thenReturn(response);
Assert.assertTrue("match logic must return true",
WebhookUtil.obtainDeliveryAgreement(httpClient, "https://eventmesh.apache.org", "*"));
Expand Down

0 comments on commit 3bda8fb

Please sign in to comment.