@@ -47,6 +47,7 @@ import com.amazonaws.services.lambda.runtime.events.SNSEvent;
|
|||||||
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
import com.amazonaws.services.lambda.runtime.events.SQSEvent;
|
||||||
import com.amazonaws.services.lambda.runtime.events.ScheduledEvent;
|
import com.amazonaws.services.lambda.runtime.events.ScheduledEvent;
|
||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
@@ -65,7 +66,6 @@ import org.springframework.util.MimeType;
|
|||||||
import org.springframework.util.StreamUtils;
|
import org.springframework.util.StreamUtils;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -1506,7 +1506,7 @@ public class FunctionInvokerTests {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
invoker.handleRequest(targetStream, output, null);
|
invoker.handleRequest(targetStream, output, null);
|
||||||
fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// TODO: handle exception
|
// TODO: handle exception
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
package org.springframework.cloud.function.serverless.web;
|
package org.springframework.cloud.function.serverless.web;
|
||||||
|
|
||||||
import jakarta.servlet.http.HttpServletRequest;
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
|
||||||
@@ -25,7 +26,8 @@ import org.springframework.web.bind.annotation.RestController;
|
|||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Oleg Zhurakousky
|
* @author Oleg Zhurakousky
|
||||||
@@ -55,7 +57,7 @@ public class AsyncStartTests {
|
|||||||
ServerlessHttpServletResponse response = new ServerlessHttpServletResponse();
|
ServerlessHttpServletResponse response = new ServerlessHttpServletResponse();
|
||||||
try {
|
try {
|
||||||
mvc.service(request, response);
|
mvc.service(request, response);
|
||||||
fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
assertThat(e).isInstanceOf(IllegalStateException.class);
|
assertThat(e).isInstanceOf(IllegalStateException.class);
|
||||||
|
|||||||
@@ -166,6 +166,8 @@ public final class FunctionTypeUtils {
|
|||||||
* @return instance of {@link Class} as raw representation of the provided {@link Type}
|
* @return instance of {@link Class} as raw representation of the provided {@link Type}
|
||||||
*/
|
*/
|
||||||
public static Class<?> getRawType(Type type) {
|
public static Class<?> getRawType(Type type) {
|
||||||
|
// ((WildcardType) type).getUpperBounds();
|
||||||
|
// Class cazz = ResolvableType.forType(type).getRawClass();
|
||||||
if (type instanceof WildcardType) {
|
if (type instanceof WildcardType) {
|
||||||
return Object.class;
|
return Object.class;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ import java.util.function.Supplier;
|
|||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
import com.fasterxml.jackson.databind.JsonNode;
|
import com.fasterxml.jackson.databind.JsonNode;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -433,9 +433,13 @@ public class BeanFactoryAwareFunctionRegistryTests {
|
|||||||
public void testReactiveFunctionWithImperativeInputAndOutputFail() {
|
public void testReactiveFunctionWithImperativeInputAndOutputFail() {
|
||||||
FunctionCatalog catalog = this.configureCatalog();
|
FunctionCatalog catalog = this.configureCatalog();
|
||||||
Function<String, String> reverse = catalog.lookup("reverseFlux");
|
Function<String, String> reverse = catalog.lookup("reverseFlux");
|
||||||
Assertions.assertThrows(ClassCastException.class, () -> {
|
try {
|
||||||
String result = reverse.apply("reverseFlux");
|
String result = reverse.apply("reverseFlux");
|
||||||
});
|
Assertions.fail();
|
||||||
|
}
|
||||||
|
catch (ClassCastException e) {
|
||||||
|
// ignore
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -41,7 +41,7 @@ import java.util.stream.IntStream;
|
|||||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
import com.google.protobuf.StringValue;
|
import com.google.protobuf.StringValue;
|
||||||
import org.junit.jupiter.api.Assertions;
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.BeforeEach;
|
import org.junit.jupiter.api.BeforeEach;
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
@@ -491,7 +491,8 @@ public class SimpleFunctionRegistryTests {
|
|||||||
.build()
|
.build()
|
||||||
));
|
));
|
||||||
|
|
||||||
Assertions.assertIterableEquals(result.blockFirst(), Arrays.asList("item1", "item2"));
|
List<String> blockFirst = result.blockFirst();
|
||||||
|
Assertions.assertThatIterable(blockFirst).isEqualTo(Arrays.asList("item1", "item2"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings({ "rawtypes", "unchecked" })
|
@SuppressWarnings({ "rawtypes", "unchecked" })
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ import java.util.function.Function;
|
|||||||
import java.util.function.Supplier;
|
import java.util.function.Supplier;
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
import com.google.gson.Gson;
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Disabled;
|
import org.junit.jupiter.api.Disabled;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
@@ -116,14 +116,13 @@ public class ContextFunctionCatalogInitializerTests {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void missingType() {
|
public void missingType() {
|
||||||
Assertions.assertThrows(BeanCreationException.class, () -> {
|
try {
|
||||||
create(MissingTypeConfiguration.class);
|
create(MissingTypeConfiguration.class);
|
||||||
assertThat(this.context.getBean("function"))
|
Assertions.fail();
|
||||||
.isInstanceOf(FunctionRegistration.class);
|
}
|
||||||
assertThat((Function<?, ?>) this.catalog.lookup(Function.class, "function"))
|
catch (BeanCreationException e) {
|
||||||
.isInstanceOf(Function.class);
|
// ignore, the test call must fail
|
||||||
// TODO: support for type inference from functional bean registrations
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
|||||||
@@ -21,8 +21,8 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
|
|
||||||
|
import org.assertj.core.api.Assertions;
|
||||||
import org.junit.jupiter.api.AfterEach;
|
import org.junit.jupiter.api.AfterEach;
|
||||||
import org.junit.jupiter.api.Assertions;
|
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import reactor.core.publisher.Flux;
|
import reactor.core.publisher.Flux;
|
||||||
import reactor.test.StepVerifier;
|
import reactor.test.StepVerifier;
|
||||||
@@ -43,7 +43,6 @@ import org.springframework.messaging.Message;
|
|||||||
import org.springframework.messaging.support.MessageBuilder;
|
import org.springframework.messaging.support.MessageBuilder;
|
||||||
|
|
||||||
import static org.assertj.core.api.Assertions.assertThat;
|
import static org.assertj.core.api.Assertions.assertThat;
|
||||||
import static org.junit.jupiter.api.Assertions.fail;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
@@ -83,7 +82,7 @@ public class RoutingFunctionTests {
|
|||||||
assertThat(function).isNotNull();
|
assertThat(function).isNotNull();
|
||||||
try {
|
try {
|
||||||
function.apply(message);
|
function.apply(message);
|
||||||
fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
// Good
|
// Good
|
||||||
@@ -207,7 +206,7 @@ public class RoutingFunctionTests {
|
|||||||
.build();
|
.build();
|
||||||
try {
|
try {
|
||||||
function.apply(message);
|
function.apply(message);
|
||||||
fail();
|
Assertions.fail();
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
assertThat(e.getMessage()).isEqualTo("EL1005E: Type cannot be found 'java.lang.Runtime'");
|
assertThat(e.getMessage()).isEqualTo("EL1005E: Type cannot be found 'java.lang.Runtime'");
|
||||||
|
|||||||
Reference in New Issue
Block a user