-
Notifications
You must be signed in to change notification settings - Fork 80
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Added support for multiple class level kafka listeners for the same topic - `operationId` for class level kafka listeners is now assigned the value of the class name instead of the first method name in that class
- Loading branch information
1 parent
29c754f
commit 8ce3c36
Showing
5 changed files
with
213 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
97 changes: 97 additions & 0 deletions
97
...ngwolf-core/src/test/java/io/github/stavshamir/springwolf/asyncapi/MessageHelperTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
package io.github.stavshamir.springwolf.asyncapi; | ||
|
||
import com.google.common.collect.ImmutableMap; | ||
import com.google.common.collect.ImmutableSet; | ||
import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message; | ||
import org.junit.Test; | ||
|
||
import java.util.Collections; | ||
import java.util.Map; | ||
import java.util.Set; | ||
|
||
import static io.github.stavshamir.springwolf.asyncapi.MessageHelper.messageObjectToSet; | ||
import static io.github.stavshamir.springwolf.asyncapi.MessageHelper.toMessageObjectOrComposition; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
import static org.assertj.core.api.Assertions.assertThatThrownBy; | ||
|
||
public class MessageHelperTest { | ||
|
||
@Test | ||
public void toMessageObjectOrComposition_emptySet() { | ||
assertThatThrownBy(() -> toMessageObjectOrComposition(Collections.emptySet())) | ||
.isInstanceOf(IllegalArgumentException.class); | ||
} | ||
|
||
@Test | ||
public void toMessageObjectOrComposition_oneMessage() { | ||
Message message = Message.builder() | ||
.name("foo") | ||
.build(); | ||
|
||
Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message)); | ||
|
||
assertThat(asObject) | ||
.isInstanceOf(Message.class) | ||
.isEqualTo(message); | ||
} | ||
|
||
|
||
@Test | ||
public void toMessageObjectOrComposition_multipleMessages() { | ||
Message message1 = Message.builder() | ||
.name("foo") | ||
.build(); | ||
|
||
Message message2 = Message.builder() | ||
.name("bar") | ||
.build(); | ||
|
||
Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message1, message2)); | ||
|
||
assertThat(asObject) | ||
.isInstanceOf(Map.class) | ||
.isEqualTo(ImmutableMap.of("oneOf", ImmutableSet.of(message1, message2))); | ||
} | ||
|
||
@Test | ||
public void messageObjectToSet_notAMessageOrAMap() { | ||
Object string = "foo"; | ||
|
||
Set<Message> messages = messageObjectToSet(string); | ||
|
||
assertThat(messages) | ||
.isEmpty(); | ||
} | ||
|
||
@Test | ||
public void messageObjectToSet_Message() { | ||
Message message = Message.builder() | ||
.name("foo") | ||
.build(); | ||
Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message)); | ||
|
||
Set<Message> messages = messageObjectToSet(asObject); | ||
|
||
assertThat(messages) | ||
.containsExactly(message); | ||
} | ||
|
||
@Test | ||
public void messageObjectToSet_SetOfMessage() { | ||
Message message1 = Message.builder() | ||
.name("foo") | ||
.build(); | ||
|
||
Message message2 = Message.builder() | ||
.name("bar") | ||
.build(); | ||
|
||
Object asObject = toMessageObjectOrComposition(ImmutableSet.of(message1, message2)); | ||
|
||
Set<Message> messages = messageObjectToSet(asObject); | ||
|
||
assertThat(messages) | ||
.containsExactlyInAnyOrder(message1, message2); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters