Skip to content

Commit

Permalink
chore: Resolve java generics issues after updating to spec 2.6.0
Browse files Browse the repository at this point in the history
  • Loading branch information
timonback committed Jun 11, 2023
1 parent e0afdfe commit c8c3127
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.core.annotation.Order;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
Expand Down Expand Up @@ -61,6 +62,8 @@ private ChannelItem buildChannel(List<OperationData> operationDataList) {
// AsyncApi does not support multiple bindings on a single channel
Map<String, ? extends ChannelBinding> channelBinding = operationDataList.get(0).getChannelBinding();
Map<String, ? extends OperationBinding> operationBinding = operationDataList.get(0).getOperationBinding();
Map<String, Object> opBinding = new HashMap<>(operationBinding);
Map<String, Object> chBinding = new HashMap<>(channelBinding);
String operationId = operationDataList.get(0).getChannelName() + "_" + this.getOperationType().operationName;
String description = operationDataList.get(0).getDescription();

Expand All @@ -72,11 +75,11 @@ private ChannelItem buildChannel(List<OperationData> operationDataList) {
.description(description)
.operationId(operationId)
.message(getMessageObject(operationDataList))
.bindings(operationBinding)
.bindings(opBinding)
.build();

ChannelItem.ChannelItemBuilder channelBuilder = ChannelItem.builder()
.bindings(channelBinding);
.bindings(chBinding);
channelBuilder = switch (getOperationType()) {
case PUBLISH -> channelBuilder.publish(operation);
case SUBSCRIBE -> channelBuilder.subscribe(operation);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
import com.asyncapi.v2._6_0.model.channel.ChannelItem;
import com.asyncapi.v2._6_0.model.channel.operation.Operation;
import com.asyncapi.v2._6_0.model.server.Server;
import com.asyncapi.v2.binding.channel.ChannelBinding;
import com.asyncapi.v2.binding.message.MessageBinding;
import com.asyncapi.v2.binding.operation.OperationBinding;
import io.github.stavshamir.springwolf.asyncapi.scanners.beans.DefaultBeanMethodsScanner;
import io.github.stavshamir.springwolf.asyncapi.scanners.channels.ChannelsScanner;
import io.github.stavshamir.springwolf.asyncapi.types.channel.bindings.EmptyChannelBinding;
Expand Down Expand Up @@ -88,7 +86,7 @@ private ChannelItem buildChannel(FunctionalChannelBeanData beanData, String oper
.bindings(buildOperationBinding())
.build();

Map<String, ? extends ChannelBinding> channelBinding = buildChannelBinding();
Map<String, Object> channelBinding = buildChannelBinding();
return beanData.getBeanType() == FunctionalChannelBeanData.BeanType.CONSUMER
? ChannelItem.builder().bindings(channelBinding).publish(operation).build()
: ChannelItem.builder().bindings(channelBinding).subscribe(operation).build();
Expand All @@ -99,12 +97,12 @@ private ChannelItem buildChannel(FunctionalChannelBeanData beanData, String oper
return Map.of(protocolName, new EmptyMessageBinding());
}

private Map<String, ? extends OperationBinding> buildOperationBinding() {
private Map<String, Object> buildOperationBinding() {
String protocolName = getProtocolName();
return Map.of(protocolName, new EmptyOperationBinding());
}

private Map<String, ? extends ChannelBinding> buildChannelBinding() {
private Map<String, Object> buildChannelBinding() {
String protocolName = getProtocolName();
return Map.of(protocolName, new EmptyChannelBinding());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
package io.github.stavshamir.springwolf.asyncapi.scanners.channels.annotation;

import com.asyncapi.v2.binding.operation.OperationBinding;
import com.asyncapi.v2._6_0.model.channel.ChannelItem;
import com.asyncapi.v2._6_0.model.channel.operation.Operation;
import com.asyncapi.v2.binding.channel.kafka.KafkaChannelBinding;
import com.asyncapi.v2.binding.message.kafka.KafkaMessageBinding;
import com.asyncapi.v2.binding.operation.kafka.KafkaOperationBinding;
import com.asyncapi.v2._6_0.model.channel.ChannelItem;
import com.asyncapi.v2._6_0.model.channel.operation.Operation;
import io.github.stavshamir.springwolf.asyncapi.scanners.classes.ComponentClassScanner;
import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.Message;
import io.github.stavshamir.springwolf.asyncapi.types.channel.operation.message.PayloadReference;
Expand Down Expand Up @@ -140,7 +139,7 @@ void scan_componentHasKafkaListenerMethods_withGroupId() {
Map<String, ChannelItem> actualChannels = methodLevelKafkaListenerScanner.scan();

// Then the returned collection contains a correct binding
Map<String, ? extends OperationBinding> actualBindings = actualChannels.get(TOPIC)
Map<String, Object> actualBindings = actualChannels.get(TOPIC)
.getPublish()
.getBindings();

Expand Down

0 comments on commit c8c3127

Please sign in to comment.