diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml index deee72e3d..d68486f58 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/pom.xml @@ -3,7 +3,6 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - org.springframework.cloud spring-cloud-function-adapter-openwhisk jar diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java index 5866d7171..fc5c03e10 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/main/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskFunctionInitializer.java @@ -23,6 +23,7 @@ import java.util.function.Supplier; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.cloud.function.context.FunctionCatalog; import org.springframework.cloud.function.context.catalog.FunctionInspector; @@ -55,7 +56,6 @@ public class OpenWhiskFunctionInitializer { @Autowired private FunctionProperties properties; - @SuppressWarnings("unchecked") protected void initialize() { logger.info("Initializing - OpenWhisk Function Initializer"); if (!this.initialized.compareAndSet(false, true)) { @@ -65,9 +65,11 @@ public class OpenWhiskFunctionInitializer { String type = this.properties.getType(); if ("function".equals(type)) { this.function = this.catalog.lookup(Function.class, name); - } else if ("consumer".equals(type)) { + } + else if ("consumer".equals(type)) { this.consumer = this.catalog.lookup(Consumer.class, name); - } else if ("supplier".equals(type)) { + } + else if ("supplier".equals(type)) { this.supplier = this.catalog.lookup(Supplier.class, name); } } diff --git a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java index 35a2185ef..79ab0946c 100644 --- a/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java +++ b/spring-cloud-function-adapters/spring-cloud-function-adapter-openwhisk/src/test/java/org/springframework/cloud/function/adapter/openwhisk/OpenWhiskActionHandlerTest.java @@ -16,9 +16,15 @@ package org.springframework.cloud.function.adapter.openwhisk; +import java.util.HashMap; +import java.util.Map; +import java.util.function.Function; + import com.fasterxml.jackson.databind.ObjectMapper; + import org.junit.Test; import org.junit.runner.RunWith; + import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.autoconfigure.EnableAutoConfiguration; import org.springframework.boot.autoconfigure.jackson.JacksonAutoConfiguration; @@ -31,10 +37,6 @@ import org.springframework.context.annotation.Scope; import org.springframework.test.context.TestPropertySource; import org.springframework.test.context.junit4.SpringRunner; -import java.util.HashMap; -import java.util.Map; -import java.util.function.Function; - import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; @@ -65,14 +67,14 @@ public class OpenWhiskActionHandlerTest { actionRequest.setValue(eventData); Object result = actionHandler.run(actionRequest); assertNotNull(result); - assertEquals("{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}", result); + assertEquals("{\"result\":{\"name\":\"Spring\",\"message\":\"Hello, Spring\"}}", + result); } @Test public void testHandlerWithoutPayload() { Map testData = new HashMap<>(); testData.put("name", "Spring"); - Map eventData = new HashMap<>(); actionHandler.init(new OpenWhiskInitRequest()); OpenWhiskActionRequest actionRequest = new OpenWhiskActionRequest(); actionRequest.setActionName("test_action"); @@ -82,8 +84,8 @@ public class OpenWhiskActionHandlerTest { } @Configuration - @Import({ContextFunctionCatalogAutoConfiguration.class, - JacksonAutoConfiguration.class}) + @Import({ ContextFunctionCatalogAutoConfiguration.class, + JacksonAutoConfiguration.class }) protected static class OWFunctionConfig { @Bean @@ -97,7 +99,6 @@ public class OpenWhiskActionHandlerTest { return new OpenWhiskActionHandler(); } - @Bean public FunctionProperties properties() { return new FunctionProperties(); @@ -125,7 +126,8 @@ public class OpenWhiskActionHandlerTest { } public void setMessage(String message) { - this.message = String.format(GREETINGS_FORMAT, this.name != null ? name : "nobody"); + this.message = String.format(GREETINGS_FORMAT, + this.name != null ? name : "nobody"); } public String getName() { diff --git a/spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/CompiledClassDefinition.java b/spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/CompiledClassDefinition.java index fac62a66c..11560bb01 100644 --- a/spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/CompiledClassDefinition.java +++ b/spring-cloud-function-compiler/src/main/java/org/springframework/cloud/function/compiler/java/CompiledClassDefinition.java @@ -16,8 +16,6 @@ package org.springframework.cloud.function.compiler.java; -import java.io.File; - /** * Encapsulates a name with the bytes for its class definition. * @@ -36,7 +34,9 @@ public class CompiledClassDefinition { if (classname.startsWith("/")) { classname = classname.substring(1); } - classname = classname.replace('/', '.').substring(0, classname.length()-6); //strip off .class + classname = classname.replace('/', '.').substring(0, classname.length() - 6); // strip + // off + // .class } public String getName() { @@ -47,8 +47,10 @@ public class CompiledClassDefinition { return bytes; } + @Override public String toString() { - return "CompiledClassDefinition(name=" + getName() + ",#bytes=" + getBytes().length + ")"; + return "CompiledClassDefinition(name=" + getName() + ",#bytes=" + + getBytes().length + ")"; } public String getClassName() { diff --git a/spring-cloud-function-stream/pom.xml b/spring-cloud-function-stream/pom.xml index 442d3e60a..79240c467 100644 --- a/spring-cloud-function-stream/pom.xml +++ b/spring-cloud-function-stream/pom.xml @@ -47,7 +47,6 @@ org.springframework.cloud spring-cloud-stream-binder-servlet - ${servlet-binder.version} true