Initial round of deprecation rmovals

This commit is contained in:
Oleg Zhurakousky
2021-11-08 16:16:39 +01:00
parent f4171cae16
commit 0cfb2b413f
22 changed files with 0 additions and 1551 deletions

View File

@@ -1,58 +0,0 @@
/*
* 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.
* You may obtain a copy of the License at
*
* https://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.springframework.cloud.function.context;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*
*/
public class FunctionRegistrationTests {
@Test
public void noTypeByDefault() {
FunctionRegistration<?> registration = new FunctionRegistration<>(new Foos(),
"foos");
assertThat(registration.getType()).isNull();
assertThat(registration.getNames()).contains("foos");
}
@Test
public void wrap() {
FunctionRegistration<Foos> registration = new FunctionRegistration<>(new Foos(),
"foos").type(FunctionType.of(Foos.class).getType());
FunctionRegistration<?> other = registration.wrap();
assertThat(registration.getType().isWrapper()).isFalse();
assertThat(other.getType().isWrapper()).isTrue();
assertThat(other.getTarget()).isNotEqualTo(registration.getTarget());
}
private static class Foos implements Function<Integer, String> {
@Override
public String apply(Integer t) {
return "i=" + t;
}
}
}

View File

@@ -1,49 +0,0 @@
/*
* Copyright 2019-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.
* You may obtain a copy of the License at
*
* https://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.springframework.cloud.function.context.catalog;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import org.springframework.messaging.support.MessageBuilder;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*/
public class MessageConsumerTests {
private List<String> items = new ArrayList<>();
@Test
public void plainConsumer() {
MessageConsumer consumer = new MessageConsumer(input());
consumer.accept(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
assertThat(this.items).hasSize(1);
}
private Consumer<String> input() {
return value -> this.items.add(value);
}
}

View File

@@ -1,113 +0,0 @@
/*
* Copyright 2019-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.
* You may obtain a copy of the License at
*
* https://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.springframework.cloud.function.context.catalog;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
import java.util.function.Function;
import org.junit.jupiter.api.Test;
import org.reactivestreams.Publisher;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import org.springframework.cloud.function.core.FluxConsumer;
import org.springframework.cloud.function.core.FluxFunction;
import org.springframework.cloud.function.core.FluxToMonoFunction;
import org.springframework.cloud.function.core.MonoToFluxFunction;
import org.springframework.messaging.Message;
import org.springframework.messaging.support.MessageBuilder;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*/
public class MessageFunctionTests {
private List<String> items = new ArrayList<>();
@Test
public void plainFunction() {
MessageFunction function = new MessageFunction(uppercase());
Publisher<Message<?>> result = function.apply(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
StepVerifier.create(result).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("FOO");
assertThat(message.getHeaders()).containsEntry("foo", "bar");
});
}
@Test
public void fluxFunction() {
MessageFunction function = new MessageFunction(new FluxFunction<>(uppercase()));
Publisher<Message<?>> result = function.apply(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
StepVerifier.create(result).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("FOO");
assertThat(message.getHeaders()).containsEntry("foo", "bar");
});
}
@Test
public void fluxToMonoFunction() {
MessageFunction function = new MessageFunction(
new FluxToMonoFunction<String, String>(
flux -> flux.next().map(uppercase())));
Publisher<Message<?>> result = function.apply(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
StepVerifier.create(result).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("FOO");
assertThat(message.getHeaders()).containsEntry("foo", "bar");
});
}
@Test
public void monoToFunction() {
MessageFunction function = new MessageFunction(
new MonoToFluxFunction<String, String>(
mono -> Flux.from(mono.map(uppercase()))));
Publisher<Message<?>> result = function.apply(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
StepVerifier.create(result).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("FOO");
assertThat(message.getHeaders()).containsEntry("foo", "bar");
});
}
@Test
public void fluxConsumer() {
MessageFunction function = new MessageFunction(new FluxConsumer<>(stash()));
Publisher<Message<?>> result = function.apply(Flux
.just(MessageBuilder.withPayload("foo").setHeader("foo", "bar").build()));
StepVerifier.create(result).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo(null);
assertThat(message.getHeaders()).containsEntry("foo", "bar");
assertThat(this.items).hasSize(1);
});
}
private Consumer<String> stash() {
return value -> this.items.add(value);
}
private Function<String, String> uppercase() {
return value -> value.toUpperCase();
}
}

View File

@@ -1,79 +0,0 @@
/*
* Copyright 2019-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.
* You may obtain a copy of the License at
*
* https://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.springframework.cloud.function.context.catalog;
import java.util.Arrays;
import java.util.Collection;
import java.util.function.Supplier;
import org.junit.jupiter.api.Test;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
import static org.assertj.core.api.Assertions.assertThat;
/**
* @author Dave Syer
*/
public class MessageSupplierTests {
@Test
public void plainSupplier() {
MessageSupplier supplier = new MessageSupplier(input());
StepVerifier.create(supplier.get()).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("foo");
assertThat(message.getHeaders()).isEmpty();
});
}
@Test
public void collectionSupplier() {
MessageSupplier supplier = new MessageSupplier(inputs());
StepVerifier.create(supplier.get()).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("foo");
assertThat(message.getHeaders()).isEmpty();
}).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("bar");
assertThat(message.getHeaders()).isEmpty();
});
}
@Test
public void fluxSupplier() {
MessageSupplier supplier = new MessageSupplier(flux());
StepVerifier.create(supplier.get()).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("foo");
assertThat(message.getHeaders()).isEmpty();
}).assertNext(message -> {
assertThat(message.getPayload()).isEqualTo("bar");
assertThat(message.getHeaders()).isEmpty();
});
}
private Supplier<String> input() {
return () -> "foo";
}
private Supplier<Collection<String>> inputs() {
return () -> Arrays.asList("foo", "bar");
}
private Supplier<Flux<String>> flux() {
return () -> Flux.just("foo", "bar");
}
}