Skip to content

Commit

Permalink
Adjust test names according to current style/Rename IgnoreDecision
Browse files Browse the repository at this point in the history
Adjust test names according to current style without the test prefix.
Furthermore, ensure all test method names are descriptive enough.
Lastly, IgnoreDecision.java should be renamed to Ignore to be inline
with the other EnqueueDecision implementations.

#2021
  • Loading branch information
smcvb committed Aug 30, 2022
1 parent 183f11a commit 37b13d3
Show file tree
Hide file tree
Showing 15 changed files with 154 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1109,7 +1109,7 @@ void testDefaultTransactionManagerIsOverriddenByProcessorSpecificInstance() thro
}

@Test
void testRegisterDeadLetterQueueConstructsDeadLetteringEventHandlerInvoker(
void registerDeadLetterQueueConstructsDeadLetteringEventHandlerInvoker(
@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue
) throws NoSuchFieldException, IllegalAccessException {
String processingGroup = "pooled-streaming";
Expand Down Expand Up @@ -1154,9 +1154,8 @@ void testRegisterDeadLetterQueueConstructsDeadLetteringEventHandlerInvoker(
}

@Test
void testRegisterDefaultDeadLetterPolicy(
@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue
) throws NoSuchFieldException, IllegalAccessException {
void registerDefaultDeadLetterPolicyIsUsed(@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue)
throws NoSuchFieldException, IllegalAccessException {
String processingGroup = "pooled-streaming";
EnqueuePolicy<EventMessage<?>> expectedPolicy = (letter, cause) -> Decisions.ignore();

Expand Down Expand Up @@ -1200,9 +1199,8 @@ void testRegisterDefaultDeadLetterPolicy(
}

@Test
void testRegisterDeadLetterPolicy(
@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue
) throws NoSuchFieldException, IllegalAccessException {
void registerDeadLetterPolicyIsUsed(@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue)
throws NoSuchFieldException, IllegalAccessException {
String processingGroup = "pooled-streaming";
EnqueuePolicy<EventMessage<?>> expectedPolicy = (letter, cause) -> Decisions.ignore();
EnqueuePolicy<EventMessage<?>> unexpectedPolicy = (letter, cause) -> Decisions.evict();
Expand Down Expand Up @@ -1250,7 +1248,7 @@ void testRegisterDeadLetterPolicy(
}

@Test
void testRegisterDeadLetteringEventHandlerInvokerConfiguration(
void registeredDeadLetteringEventHandlerInvokerConfigurationIsUsed(
@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue
) throws NoSuchFieldException, IllegalAccessException {
String processingGroup = "pooled-streaming";
Expand Down Expand Up @@ -1291,7 +1289,9 @@ void testRegisterDeadLetteringEventHandlerInvokerConfiguration(
}

@Test
void testSequencedDeadLetterProcessor(@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue) {
void sequencedDeadLetterProcessorReturnsForProcessingGroupWithDlq(
@Mock SequencedDeadLetterQueue<EventMessage<?>> deadLetterQueue
) {
String processingGroup = "pooled-streaming";
String otherProcessingGroup = "tracking";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,13 @@
public abstract class Decisions {

/**
* Construct a {@link IgnoreDecision} defining that a {@link DeadLetter dead-letter} should remain in the queue.
* Construct a {@link Ignore} defining that a {@link DeadLetter dead-letter} should remain in the queue.
*
* @param <M> The type of message contained in the {@link DeadLetter} that's been made a decision on.
* @return A {@link IgnoreDecision} defining that a {@link DeadLetter dead-letter} should remain in the queue.
* @return A {@link Ignore} defining that a {@link DeadLetter dead-letter} should remain in the queue.
*/
public static <M extends Message<?>> IgnoreDecision<M> ignore() {
return new IgnoreDecision<>();
public static <M extends Message<?>> Ignore<M> ignore() {
return new Ignore<>();
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
* @author Steven van Beelen
* @since 4.6.0
*/
public class IgnoreDecision<M extends Message<?>> implements EnqueueDecision<M> {
public class Ignore<M extends Message<?>> implements EnqueueDecision<M> {

@Override
public boolean shouldEnqueue() {
Expand All @@ -27,6 +27,6 @@ public Optional<Throwable> enqueueCause() {

@Override
public String toString() {
return "IgnoreDecision{}";
return "Ignore{}";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ void testNonEmptyOrNull() {
}

@Test
void testEmptyOrNull() {
void emptyOrNullReturnsTrueForEmptyAndNullStrings() {
assertTrue(StringUtils.emptyOrNull(""));
assertTrue(StringUtils.emptyOrNull(null));
assertFalse(StringUtils.emptyOrNull("some-string"));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,52 +98,52 @@ void testPerformResetWithResetContext() {
}

@Test
void testBuildWithNullEventHandlersListThrowsAxonConfigurationException() {
void buildWithNullEventHandlersListThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

//noinspection ConstantConditions
assertThrows(AxonConfigurationException.class, () -> builderTestSubject.eventHandlers((List<?>) null));
}

@Test
void testBuildWithEmptyEventHandlersListThrowsAxonConfigurationException() {
void buildWithEmptyEventHandlersListThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();
List<Object> testEventHandlers = Collections.emptyList();

assertThrows(AxonConfigurationException.class, () -> builderTestSubject.eventHandlers(testEventHandlers));
}

@Test
void testBuildWithoutEventHandlersListThrowsAxonConfigurationException() {
void buildWithoutEventHandlersListThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

assertThrows(AxonConfigurationException.class, builderTestSubject::build);
}

@Test
void testBuildWithNullParameterResolverFactoryThrowsAxonConfigurationException() {
void buildWithNullParameterResolverFactoryThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

//noinspection ConstantConditions
assertThrows(AxonConfigurationException.class, () -> builderTestSubject.parameterResolverFactory(null));
}

@Test
void testBuildWithNullHandlerDefinitionThrowsAxonConfigurationException() {
void buildWithNullHandlerDefinitionThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

//noinspection ConstantConditions
assertThrows(AxonConfigurationException.class, () -> builderTestSubject.handlerDefinition(null));
}

@Test
void testBuildWithNullListenerInvocationErrorHandlerThrowsAxonConfigurationException() {
void buildWithNullListenerInvocationErrorHandlerThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

//noinspection ConstantConditions
assertThrows(AxonConfigurationException.class, () -> builderTestSubject.listenerInvocationErrorHandler(null));
}

@Test
void testBuildWithNullSequencingPolicyThrowsAxonConfigurationException() {
void buildWithNullSequencingPolicyThrowsAxonConfigurationException() {
SimpleEventHandlerInvoker.Builder<?> builderTestSubject = SimpleEventHandlerInvoker.builder();

//noinspection ConstantConditions
assertThrows(AxonConfigurationException.class, () -> builderTestSubject.sequencingPolicy(null));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ void setUp() {
}

@Test
void testProcessLetterSuccessfully() throws Exception {
void taskProcessesLetterSuccessfully() throws Exception {
//noinspection unchecked
DeadLetter<EventMessage<?>> testLetter = mock(DeadLetter.class);
//noinspection unchecked
Expand All @@ -87,7 +87,7 @@ void testProcessLetterSuccessfully() throws Exception {
}

@Test
void testProcessLetterUnsuccessfully() throws Exception {
void taskProcessesLetterUnsuccessfullyWhenHandlersThrowsAnException() throws Exception {
//noinspection unchecked
DeadLetter<EventMessage<?>> testLetter = mock(DeadLetter.class);
//noinspection unchecked
Expand Down

0 comments on commit 37b13d3

Please sign in to comment.