Skip to content

Commit 8ee9872

Browse files
dbuosDaniel Bustamante Ospina
authored andcommitted
Enable tests in starter
1 parent c96ac09 commit 8ee9872

File tree

9 files changed

+268
-204
lines changed

9 files changed

+268
-204
lines changed

async/async-commons-starter/async-commons-starter.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ plugins {
55
id 'maven-publish'
66
}
77

8-
test.onlyIf { false }
8+
test.onlyIf { true }
99

1010
def pomConfig = {
1111
licenses {

async/async-commons-starter/src/main/java/org/reactivecommons/async/impl/config/MessageListenersConfig.java

Lines changed: 0 additions & 154 deletions
This file was deleted.
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.reactivecommons.async.impl.config;
2+
3+
import com.rabbitmq.client.AMQP;
4+
import org.assertj.core.api.Assertions;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.junit.runner.RunWith;
8+
import org.mockito.junit.MockitoJUnitRunner;
9+
import org.reactivecommons.async.impl.DiscardNotifier;
10+
import org.reactivecommons.async.impl.HandlerResolver;
11+
import org.reactivecommons.async.impl.communications.ReactiveMessageListener;
12+
import org.reactivecommons.async.impl.communications.TopologyCreator;
13+
import org.reactivecommons.async.impl.config.props.AsyncProps;
14+
import org.reactivecommons.async.impl.converters.MessageConverter;
15+
import org.reactivecommons.async.impl.ext.CustomErrorReporter;
16+
import org.reactivecommons.async.impl.listeners.ApplicationCommandListener;
17+
import reactor.core.publisher.Flux;
18+
import reactor.core.publisher.Mono;
19+
import reactor.rabbitmq.*;
20+
21+
import java.lang.reflect.Field;
22+
23+
import static org.mockito.ArgumentMatchers.any;
24+
import static org.mockito.Mockito.mock;
25+
import static org.mockito.Mockito.when;
26+
27+
@RunWith(MockitoJUnitRunner.class)
28+
public class CommandListenersConfigTest {
29+
30+
31+
private final AsyncProps props = new AsyncProps();
32+
private CommandListenersConfig config = new CommandListenersConfig(props);
33+
private final ReactiveMessageListener listener = mock(ReactiveMessageListener.class);
34+
private final TopologyCreator creator = mock(TopologyCreator.class);
35+
private final HandlerResolver handlerResolver = mock(HandlerResolver.class);
36+
private final MessageConverter messageConverter = mock(MessageConverter.class);
37+
private final DiscardNotifier discardNotifier = mock(DiscardNotifier.class);
38+
private final CustomErrorReporter customErrorReporter = mock(CustomErrorReporter.class);
39+
private final Receiver receiver = mock(Receiver.class);
40+
41+
@Before
42+
public void init() throws NoSuchFieldException, IllegalAccessException {
43+
final Field appName = CommandListenersConfig.class.getDeclaredField("appName");
44+
appName.setAccessible(true);
45+
appName.set(config, "queue");
46+
when(creator.bind(any(BindingSpecification.class))).thenReturn(Mono.just(mock(AMQP.Queue.BindOk.class)));
47+
when(creator.declare(any(ExchangeSpecification.class))).thenReturn(Mono.just(mock(AMQP.Exchange.DeclareOk.class)));
48+
when(creator.declareQueue(any(String.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
49+
when(listener.getTopologyCreator()).thenReturn(creator);
50+
when(receiver.consumeManualAck(any(String.class), any(ConsumeOptions.class))).thenReturn(Flux.empty());
51+
when(listener.getReceiver()).thenReturn(receiver);
52+
when(listener.getMaxConcurrency()).thenReturn(20);
53+
}
54+
55+
@Test
56+
public void applicationCommandListener() {
57+
final ApplicationCommandListener commandListener = config.applicationCommandListener(
58+
listener,
59+
handlerResolver,
60+
messageConverter,
61+
discardNotifier,
62+
customErrorReporter
63+
);
64+
Assertions.assertThat(commandListener).isNotNull();
65+
}
66+
}
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
package org.reactivecommons.async.impl.config;
2+
3+
import com.rabbitmq.client.AMQP;
4+
import org.assertj.core.api.Assertions;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.reactivecommons.async.impl.DiscardNotifier;
8+
import org.reactivecommons.async.impl.HandlerResolver;
9+
import org.reactivecommons.async.impl.communications.ReactiveMessageListener;
10+
import org.reactivecommons.async.impl.communications.TopologyCreator;
11+
import org.reactivecommons.async.impl.config.props.AsyncProps;
12+
import org.reactivecommons.async.impl.config.props.DirectProps;
13+
import org.reactivecommons.async.impl.converters.MessageConverter;
14+
import org.reactivecommons.async.impl.ext.CustomErrorReporter;
15+
import org.reactivecommons.async.impl.listeners.ApplicationEventListener;
16+
import reactor.core.publisher.Flux;
17+
import reactor.core.publisher.Mono;
18+
import reactor.rabbitmq.*;
19+
20+
import java.util.Collections;
21+
22+
import static org.junit.Assert.*;
23+
import static org.mockito.ArgumentMatchers.any;
24+
import static org.mockito.Mockito.mock;
25+
import static org.mockito.Mockito.when;
26+
27+
public class EventListenersConfigTest {
28+
29+
private final AsyncProps props = new AsyncProps();
30+
private final EventListenersConfig config = new EventListenersConfig(props);
31+
private final ReactiveMessageListener listener = mock(ReactiveMessageListener.class);
32+
private final TopologyCreator creator = mock(TopologyCreator.class);
33+
private final HandlerResolver handlerResolver = mock(HandlerResolver.class);
34+
private final MessageConverter messageConverter = mock(MessageConverter.class);
35+
private final DiscardNotifier discardNotifier = mock(DiscardNotifier.class);
36+
private final CustomErrorReporter customErrorReporter = mock(CustomErrorReporter.class);
37+
private final Receiver receiver = mock(Receiver.class);
38+
39+
@Before
40+
public void init() {
41+
when(handlerResolver.getEventListeners()).thenReturn(Collections.emptyList());
42+
when(creator.bind(any(BindingSpecification.class))).thenReturn(Mono.just(mock(AMQP.Queue.BindOk.class)));
43+
when(creator.declare(any(ExchangeSpecification.class))).thenReturn(Mono.just(mock(AMQP.Exchange.DeclareOk.class)));
44+
when(creator.declare(any(QueueSpecification.class))).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
45+
when(creator.declareDLQ(any(String.class), any(String.class), any(Integer.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
46+
when(creator.declareQueue(any(String.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
47+
when(creator.declareQueue(any(String.class), any(String.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
48+
when(listener.getTopologyCreator()).thenReturn(creator);
49+
when(receiver.consumeManualAck(any(String.class), any(ConsumeOptions.class))).thenReturn(Flux.empty());
50+
when(listener.getReceiver()).thenReturn(receiver);
51+
when(listener.getMaxConcurrency()).thenReturn(20);
52+
}
53+
54+
@Test
55+
public void eventListener() {
56+
final ApplicationEventListener eventListener = config.eventListener(
57+
handlerResolver,
58+
messageConverter,
59+
listener,
60+
discardNotifier,
61+
customErrorReporter
62+
);
63+
64+
Assertions.assertThat(eventListener).isNotNull();
65+
}
66+
}
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package org.reactivecommons.async.impl.config;
2+
3+
import com.rabbitmq.client.AMQP;
4+
import org.assertj.core.api.Assertions;
5+
import org.junit.Before;
6+
import org.junit.Test;
7+
import org.reactivecommons.async.impl.DiscardNotifier;
8+
import org.reactivecommons.async.impl.HandlerResolver;
9+
import org.reactivecommons.async.impl.communications.ReactiveMessageListener;
10+
import org.reactivecommons.async.impl.communications.TopologyCreator;
11+
import org.reactivecommons.async.impl.config.props.AsyncProps;
12+
import org.reactivecommons.async.impl.converters.MessageConverter;
13+
import org.reactivecommons.async.impl.ext.CustomErrorReporter;
14+
import org.reactivecommons.async.impl.listeners.ApplicationNotificationListener;
15+
import reactor.core.publisher.Flux;
16+
import reactor.core.publisher.Mono;
17+
import reactor.rabbitmq.*;
18+
19+
import java.util.Collections;
20+
21+
import static org.mockito.ArgumentMatchers.any;
22+
import static org.mockito.Mockito.mock;
23+
import static org.mockito.Mockito.when;
24+
25+
public class NotificacionListenersConfigTest {
26+
27+
private final AsyncProps props = new AsyncProps();
28+
private final NotificacionListenersConfig config = new NotificacionListenersConfig(props);
29+
private final ReactiveMessageListener listener = mock(ReactiveMessageListener.class);
30+
private final TopologyCreator creator = mock(TopologyCreator.class);
31+
private final HandlerResolver handlerResolver = mock(HandlerResolver.class);
32+
private final MessageConverter messageConverter = mock(MessageConverter.class);
33+
private final DiscardNotifier discardNotifier = mock(DiscardNotifier.class);
34+
private final CustomErrorReporter customErrorReporter = mock(CustomErrorReporter.class);
35+
private final Receiver receiver = mock(Receiver.class);
36+
37+
@Before
38+
public void init() {
39+
when(handlerResolver.getEventListeners()).thenReturn(Collections.emptyList());
40+
when(creator.bind(any(BindingSpecification.class))).thenReturn(Mono.just(mock(AMQP.Queue.BindOk.class)));
41+
when(creator.declare(any(ExchangeSpecification.class))).thenReturn(Mono.just(mock(AMQP.Exchange.DeclareOk.class)));
42+
when(creator.declare(any(QueueSpecification.class))).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
43+
when(creator.declareDLQ(any(String.class), any(String.class), any(Integer.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
44+
when(creator.declareQueue(any(String.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
45+
when(creator.declareQueue(any(String.class), any(String.class), any())).thenReturn(Mono.just(mock(AMQP.Queue.DeclareOk.class)));
46+
when(listener.getTopologyCreator()).thenReturn(creator);
47+
when(receiver.consumeManualAck(any(String.class), any(ConsumeOptions.class))).thenReturn(Flux.empty());
48+
when(listener.getReceiver()).thenReturn(receiver);
49+
when(listener.getMaxConcurrency()).thenReturn(20);
50+
}
51+
52+
@Test
53+
public void eventNotificationListener() {
54+
final ApplicationNotificationListener applicationEventListener = config.
55+
eventNotificationListener(handlerResolver, messageConverter, listener, discardNotifier, customErrorReporter);
56+
Assertions.assertThat(applicationEventListener).isNotNull();
57+
}
58+
}

0 commit comments

Comments
 (0)