|
| 1 | +/* |
| 2 | + * Copyright 2021 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | + |
| 17 | +package org.springframework.amqp.core; |
| 18 | + |
| 19 | +import static org.assertj.core.api.Assertions.assertThat; |
| 20 | + |
| 21 | +import java.util.List; |
| 22 | + |
| 23 | +import org.junit.jupiter.api.Test; |
| 24 | + |
| 25 | +/** |
| 26 | + * @author Björn Michael |
| 27 | + * @since 2.4 |
| 28 | + */ |
| 29 | +public class DeclarablesTests { |
| 30 | + |
| 31 | + @Test |
| 32 | + public void getDeclarables() { |
| 33 | + List<Queue> queues = List.of( |
| 34 | + new Queue("q1", false, false, true), |
| 35 | + new Queue("q2", false, false, true)); |
| 36 | + Declarables declarables = new Declarables(queues); |
| 37 | + |
| 38 | + assertThat(declarables.getDeclarables()).hasSameElementsAs(queues); |
| 39 | + } |
| 40 | + |
| 41 | + @Test |
| 42 | + public void getDeclarablesByType() { |
| 43 | + Queue queue = new Queue("queue"); |
| 44 | + TopicExchange exchange = new TopicExchange("exchange"); |
| 45 | + Binding binding = BindingBuilder.bind(queue).to(exchange).with("foo.bar"); |
| 46 | + Declarables declarables = new Declarables(queue, exchange, binding); |
| 47 | + |
| 48 | + assertThat(declarables.getDeclarablesByType(Queue.class)).containsExactlyInAnyOrder(queue); |
| 49 | + assertThat(declarables.getDeclarablesByType(Exchange.class)).containsExactlyInAnyOrder(exchange); |
| 50 | + assertThat(declarables.getDeclarablesByType(Binding.class)).containsExactlyInAnyOrder(binding); |
| 51 | + assertThat(declarables.getDeclarablesByType(Declarable.class)).containsExactlyInAnyOrder( |
| 52 | + queue, exchange, binding); |
| 53 | + } |
| 54 | + |
| 55 | +} |
0 commit comments