@@ -664,6 +664,8 @@ void testGetDestinationOnlySubscriberStrategyReadsSubscriberDestinations()
664664 @ Test
665665 void testGetDestinationOnlySubscriberStrategyDoesNotReadProviderDestinations ()
666666 {
667+
668+ // JONAS: use this here as base for test. Check which calls are made using GetOrComputeAllDestinationsCommand
667669 final DestinationOptions options =
668670 DestinationOptions .builder ().augmentBuilder (augmenter ().retrievalStrategy (ONLY_SUBSCRIBER )).build ();
669671
@@ -1973,6 +1975,34 @@ void testPrependGetAllDestinationsCallWithMissingDestination()
19731975 verify (destinationServiceAdapter , times (1 )).getConfigurationAsJson (eq ("/v1/instanceDestinations" ), any ());
19741976 verify (destinationServiceAdapter , times (1 )).getConfigurationAsJson (eq ("/v1/subaccountDestinations" ), any ());
19751977 verifyNoMoreInteractions (destinationServiceAdapter );
1978+ }
1979+
1980+ @ Test
1981+ void testPrependGetAllDestinationsCallUsesCorrectRetrievalStrategy ()
1982+ {
1983+ // Reset Cache to re-enable the PreLookupCheck
1984+ DestinationService .Cache .reset ();
1985+
1986+ doReturn (responseServiceInstanceDestination )
1987+ .when (destinationServiceAdapter )
1988+ .getConfigurationAsJson (eq ("/v1/instanceDestinations" ), any ());
1989+ doReturn (responseServiceInstanceDestination )
1990+ .when (destinationServiceAdapter )
1991+ .getConfigurationAsJson (eq ("/v1/subaccountDestinations" ), any ());
1992+ // destination with name destinationName is provider-only
1993+ doReturn (responseSubaccountDestination )
1994+ .when (destinationServiceAdapter )
1995+ .getConfigurationAsJson (
1996+ eq ("/v1/subaccountDestinations" ),
1997+ argThat (s -> s .behalf () == TECHNICAL_USER_PROVIDER ));
1998+
1999+ final DestinationOptions options =
2000+ DestinationOptions .builder ().augmentBuilder (augmenter ().retrievalStrategy (ALWAYS_PROVIDER )).build ();
2001+
2002+ // set current tenant to be the subscriber tenant
2003+ context .setTenant (providerTenant );
19762004
2005+ Destination result = loader .tryGetDestination (destinationName , options ).get ();
2006+ assertThat (result .asHttp ().getUri ()).isEqualTo (URI .create (providerUrl ));
19772007 }
19782008}
0 commit comments