Turned on checkstyle

This commit is contained in:
Marcin Grzejszczak
2019-02-01 15:48:32 +01:00
parent 94e9b8f2f8
commit e4b08a083c
268 changed files with 5114 additions and 3993 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ public class FunctionProperties {
private String type = "function";
public String getName() {
return name;
return this.name;
}
public void setName(String name) {
@@ -37,10 +37,11 @@ public class FunctionProperties {
}
public String getType() {
return type;
return this.type;
}
public void setType(String type) {
this.type = type;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,6 +23,7 @@ import org.springframework.boot.context.properties.EnableConfigurationProperties
/**
* @author Mark Fisher
*/
// @checkstyle:off
@SpringBootApplication
@EnableConfigurationProperties(FunctionProperties.class)
public class OpenWhiskActionApplication {
@@ -30,4 +31,6 @@ public class OpenWhiskActionApplication {
public static void main(String[] args) {
SpringApplication.run(OpenWhiskActionApplication.class, args);
}
}
// @checkstyle:on

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -23,18 +23,16 @@ import java.util.Map;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import reactor.core.publisher.Flux;
/**
* @author Mark Fisher
* @author Kamesh Sampath
@@ -43,6 +41,7 @@ import reactor.core.publisher.Flux;
public class OpenWhiskActionHandler extends OpenWhiskFunctionInitializer {
private static final String NO_INPUT_PROVIDED = "No input provided";
private static Log logger = LogFactory.getLog(OpenWhiskFunctionInitializer.class);
@Autowired
@@ -61,7 +60,7 @@ public class OpenWhiskActionHandler extends OpenWhiskFunctionInitializer {
public Object run(@RequestBody OpenWhiskActionRequest request) {
Object input = convertEvent(request.getValue());
Object result = NO_INPUT_PROVIDED;
if(input !=null ) {
if (input != null) {
Publisher<?> output = apply(extract(input));
result = result(input, output);
}
@@ -104,17 +103,20 @@ public class OpenWhiskActionHandler extends OpenWhiskFunctionInitializer {
private Object convertToFunctionParamType(Object payload) {
try {
return mapper.convertValue(payload, getInputType());
} catch (Exception e) {
return this.mapper.convertValue(payload, getInputType());
}
catch (Exception e) {
throw new IllegalStateException("Cannot convert event payload", e);
}
}
private String serializeBody(Object body) {
try {
return "{\"result\":" + mapper.writeValueAsString(body) + "}";
} catch (JsonProcessingException e) {
return "{\"result\":" + this.mapper.writeValueAsString(body) + "}";
}
catch (JsonProcessingException e) {
throw new IllegalStateException("Cannot convert output", e);
}
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -41,7 +41,7 @@ public class OpenWhiskActionRequest {
private Map<String, Object> value;
public String getActionName() {
return actionName;
return this.actionName;
}
public void setActionName(String actionName) {
@@ -49,7 +49,7 @@ public class OpenWhiskActionRequest {
}
public String getActivationId() {
return activationId;
return this.activationId;
}
public void setActivationId(String activationId) {
@@ -57,7 +57,7 @@ public class OpenWhiskActionRequest {
}
public String getApiKey() {
return apiKey;
return this.apiKey;
}
public void setApiKey(String apiKey) {
@@ -65,7 +65,7 @@ public class OpenWhiskActionRequest {
}
public String getDeadline() {
return deadline;
return this.deadline;
}
public void setDeadline(String deadline) {
@@ -73,7 +73,7 @@ public class OpenWhiskActionRequest {
}
public String getNamespace() {
return namespace;
return this.namespace;
}
public void setNamespace(String namespace) {
@@ -81,10 +81,11 @@ public class OpenWhiskActionRequest {
}
public Map<String, Object> getValue() {
return value;
return this.value;
}
public void setValue(Map<String, Object> value) {
this.value = value;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -24,13 +24,12 @@ import java.util.function.Supplier;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.function.context.FunctionCatalog;
import org.springframework.cloud.function.context.catalog.FunctionInspector;
import reactor.core.publisher.Flux;
/**
* @author Dave Syer
* @author Mark Fisher
@@ -76,8 +75,8 @@ public class OpenWhiskFunctionInitializer {
}
protected Class<?> getInputType() {
if (inspector != null) {
return inspector.getInputType(function());
if (this.inspector != null) {
return this.inspector.getInputType(function());
}
return Object.class;
}
@@ -89,7 +88,7 @@ public class OpenWhiskFunctionInitializer {
protected Publisher<?> apply(Publisher<?> input) {
if (this.function != null) {
return function.apply(input);
return this.function.apply(input);
}
if (this.consumer != null) {
this.consumer.accept(input);
@@ -100,4 +99,5 @@ public class OpenWhiskFunctionInitializer {
}
throw new IllegalStateException("No function defined");
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -28,7 +28,7 @@ public class OpenWhiskInitRequest {
private String main;
public String getName() {
return name;
return this.name;
}
public void setName(String name) {
@@ -36,7 +36,7 @@ public class OpenWhiskInitRequest {
}
public boolean isBinary() {
return binary;
return this.binary;
}
public void setBinary(boolean binary) {
@@ -44,10 +44,11 @@ public class OpenWhiskInitRequest {
}
public String getMain() {
return main;
return this.main;
}
public void setMain(String main) {
this.main = main;
}
}

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2017 the original author or authors.
* Copyright 2012-2019 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,7 +21,6 @@ import java.util.Map;
import java.util.function.Function;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,11 +60,11 @@ public class OpenWhiskActionHandlerTest {
testData.put("name", "Spring");
Map<String, Object> eventData = new HashMap<>();
eventData.put("payload", testData);
actionHandler.init(new OpenWhiskInitRequest());
this.actionHandler.init(new OpenWhiskInitRequest());
OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest();
actionRequest.setActionName("test_action");
actionRequest.setValue(eventData);
Object result = actionHandler.run(actionRequest);
Object result = this.actionHandler.run(actionRequest);
assertNotNull(result);
assertEquals("{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}",
result);
@@ -75,10 +74,10 @@ public class OpenWhiskActionHandlerTest {
public void testHandlerWithoutPayload() {
Map<String, String> testData = new HashMap<>();
testData.put("name", "Spring");
actionHandler.init(new OpenWhiskInitRequest());
this.actionHandler.init(new OpenWhiskInitRequest());
OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest();
actionRequest.setActionName("test_action");
Object result = actionHandler.run(actionRequest);
Object result = this.actionHandler.run(actionRequest);
assertNotNull(result);
assertEquals("{\"result\":\"No input provided\"}", result);
}
@@ -111,6 +110,7 @@ public class OpenWhiskActionHandlerTest {
private final String GREETINGS_FORMAT = "Hello, %s";
private String name;
private String message;
public Greetings() {
@@ -122,21 +122,22 @@ public class OpenWhiskActionHandlerTest {
}
public String getMessage() {
return message;
return this.message;
}
public void setMessage(String message) {
this.message = String.format(GREETINGS_FORMAT,
this.name != null ? name : "nobody");
this.message = String.format(this.GREETINGS_FORMAT,
this.name != null ? this.name : "nobody");
}
public String getName() {
return name;
return this.name;
}
public void setName(String name) {
this.name = name;
}
}
}

View File

@@ -1,2 +1,2 @@
function.name: greeter
function.type: function
function.name:greeter
function.type:function