File tree Expand file tree Collapse file tree 4 files changed +19
-29
lines changed
main/java/io/dapr/testcontainers/wait/strategy
test/java/io/dapr/testcontainers/wait/strategy Expand file tree Collapse file tree 4 files changed +19
-29
lines changed Original file line number Diff line number Diff line change @@ -49,7 +49,7 @@ protected boolean isConditionMet(Metadata metadata) {
4949 }
5050
5151 private boolean matchesActorType (Actor actor ) {
52- return actorType .equals (actor .getType ());
52+ return actor != null && actorType .equals (actor .getType ());
5353 }
5454
5555 @ Override
Original file line number Diff line number Diff line change @@ -51,34 +51,14 @@ private DaprWait() {
5151 /**
5252 * Creates a wait strategy that waits for a subscription to be registered.
5353 *
54- * @param pubsubName the name of the pub/sub component
55- * @param topic the topic name to wait for
54+ * @param pubsubName the name of the pub/sub component (can be null to match any)
55+ * @param topic the topic name to wait for (can be null to match any)
5656 * @return a new subscription wait strategy
5757 */
5858 public static SubscriptionWaitStrategy forSubscription (String pubsubName , String topic ) {
5959 return new SubscriptionWaitStrategy (pubsubName , topic );
6060 }
6161
62- /**
63- * Creates a wait strategy that waits for any subscription on a pub/sub component.
64- *
65- * @param pubsubName the name of the pub/sub component
66- * @return a new subscription wait strategy
67- */
68- public static SubscriptionWaitStrategy forPubSub (String pubsubName ) {
69- return new SubscriptionWaitStrategy (pubsubName , null );
70- }
71-
72- /**
73- * Creates a wait strategy that waits for a subscription on a specific topic.
74- *
75- * @param topic the topic name to wait for
76- * @return a new subscription wait strategy
77- */
78- public static SubscriptionWaitStrategy forTopic (String topic ) {
79- return new SubscriptionWaitStrategy (null , topic );
80- }
81-
8262 /**
8363 * Creates a wait strategy that waits for any actors to be registered.
8464 *
Original file line number Diff line number Diff line change @@ -101,6 +101,16 @@ void shouldProvideCorrectDescription() {
101101 assertEquals ("actor type 'MyActor'" , specificActor .getConditionDescription ());
102102 }
103103
104+ @ Test
105+ @ DisplayName ("Should handle null actor in list without throwing NPE" )
106+ void shouldHandleNullActorInList () {
107+ ActorWaitStrategy strategy = new ActorWaitStrategy ("TargetActor" );
108+ Metadata metadata = new Metadata ();
109+ metadata .setActors (Arrays .asList (null , createActor ("TargetActor" )));
110+
111+ assertTrue (strategy .isConditionMet (metadata ));
112+ }
113+
104114 private Metadata createMetadataWithActor (String actorType ) {
105115 Metadata metadata = new Metadata ();
106116 metadata .setActors (Collections .singletonList (createActor (actorType )));
Original file line number Diff line number Diff line change @@ -38,18 +38,18 @@ void forSubscriptionShouldCreateSubscriptionWaitStrategy() {
3838 }
3939
4040 @ Test
41- @ DisplayName ("forPubSub should create SubscriptionWaitStrategy with null topic" )
42- void forPubSubShouldCreateSubscriptionWaitStrategyWithNullTopic () {
43- SubscriptionWaitStrategy strategy = DaprWait .forPubSub ("pubsub" );
41+ @ DisplayName ("forSubscription with null topic should match any topic" )
42+ void forSubscriptionWithNullTopicShouldMatchAnyTopic () {
43+ SubscriptionWaitStrategy strategy = DaprWait .forSubscription ("pubsub" , null );
4444
4545 assertNotNull (strategy );
4646 assertEquals ("subscription for pubsub 'pubsub'" , strategy .getConditionDescription ());
4747 }
4848
4949 @ Test
50- @ DisplayName ("forTopic should create SubscriptionWaitStrategy with null pubsub" )
51- void forTopicShouldCreateSubscriptionWaitStrategyWithNullPubsub () {
52- SubscriptionWaitStrategy strategy = DaprWait .forTopic ( "orders" );
50+ @ DisplayName ("forSubscription with null pubsub should match any pubsub" )
51+ void forSubscriptionWithNullPubsubShouldMatchAnyPubsub () {
52+ SubscriptionWaitStrategy strategy = DaprWait .forSubscription ( null , "orders" );
5353
5454 assertNotNull (strategy );
5555 assertEquals ("subscription for topic 'orders'" , strategy .getConditionDescription ());
You can’t perform that action at this time.
0 commit comments