Skip to content

Commit 75e300b

Browse files
committed
code style
1 parent 077b784 commit 75e300b

File tree

5 files changed

+78
-62
lines changed

5 files changed

+78
-62
lines changed

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationService.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import javax.annotation.Nonnull;
1717
import javax.annotation.Nullable;
1818

19-
import lombok.Setter;
2019
import org.apache.commons.lang3.exception.ExceptionUtils;
2120

2221
import com.github.benmanes.caffeine.cache.Caffeine;
@@ -42,6 +41,7 @@
4241
import lombok.Getter;
4342
import lombok.NoArgsConstructor;
4443
import lombok.RequiredArgsConstructor;
44+
import lombok.Setter;
4545
import lombok.extern.slf4j.Slf4j;
4646

4747
/**
@@ -125,7 +125,13 @@ static ResilienceConfiguration createResilienceConfiguration(
125125
Try<Destination>
126126
tryGetDestination( @Nonnull final String destinationName, @Nonnull final DestinationOptions options )
127127
{
128-
return Cache.getOrComputeDestination(this, destinationName, options, this::loadAndParseDestination, prependGetAllDestinationCall);
128+
return Cache
129+
.getOrComputeDestination(
130+
this,
131+
destinationName,
132+
options,
133+
this::loadAndParseDestination,
134+
prependGetAllDestinationCall);
129135
}
130136

131137
Destination loadAndParseDestination( final String destName, final DestinationOptions options )
@@ -845,7 +851,7 @@ private static Try<Destination> getOrComputeDestination(
845851
@Nonnull final String destinationName,
846852
@Nonnull final DestinationOptions options,
847853
@Nonnull final BiFunction<String, DestinationOptions, Destination> destinationDownloader,
848-
@Nonnull final Boolean prependGetAllCall)
854+
@Nonnull final Boolean prependGetAllCall )
849855
{
850856
if( !cacheEnabled ) {
851857
return Try.ofSupplier(() -> destinationDownloader.apply(destinationName, options));

cloudplatform/connectivity-destination-service/src/main/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeSingleDestinationCommand.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ static Try<GetOrComputeSingleDestinationCommand> prepareCommand(
6464
@Nonnull final Cache<CacheKey, ReentrantLock> isolationLocks,
6565
@Nonnull final BiFunction<String, DestinationOptions, Destination> destinationRetriever,
6666
@Nullable final GetOrComputeAllDestinationsCommand getAllCommand,
67-
@Nonnull final Boolean prependGetAllDestinationCall)
67+
@Nonnull final Boolean prependGetAllDestinationCall )
6868
{
6969
final Supplier<Destination> destinationSupplier =
7070
() -> destinationRetriever.apply(destinationName, destinationOptions);

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceAuthenticationTest.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -443,8 +443,6 @@ private void mockAdapterResponse(
443443
"authTokens",
444444
tokens != null ? List.of(tokens) : Collections.emptyList());
445445

446-
doReturn(new Gson().toJson(destination))
447-
.when(mockAdapter)
448-
.getConfigurationAsJson(any(), eq(expectedStrategy));
446+
doReturn(new Gson().toJson(destination)).when(mockAdapter).getConfigurationAsJson(any(), eq(expectedStrategy));
449447
}
450448
}

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/DestinationServiceTest.java

Lines changed: 51 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1920,57 +1920,55 @@ private String createHttpDestinationServiceResponse( final String name, final St
19201920
""", name, url);
19211921
}
19221922

1923-
@Test
1924-
void testPrependGetAllDestinationsCall()
1925-
{
1926-
doReturn(responseServiceInstanceDestination)
1927-
.when(destinationServiceAdapter)
1928-
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1929-
doReturn(responseSubaccountDestination)
1930-
.when(destinationServiceAdapter)
1931-
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1932-
1933-
loader.setPrependGetAllDestinationCall(true);
1934-
1935-
final DestinationOptions options =
1936-
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
1937-
Destination result = loader.tryGetDestination(destinationName).get();
1938-
1939-
// verify all results are cached
1940-
verify(destinationServiceAdapter, times(1))
1941-
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1942-
verify(destinationServiceAdapter, times(1))
1943-
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1944-
verify(destinationServiceAdapter, times(1))
1945-
.getConfigurationAsJson(eq("/v1/destinations/" + destinationName), any());
1946-
verifyNoMoreInteractions(destinationServiceAdapter);
1947-
1948-
loader.setPrependGetAllDestinationCall(false);
1949-
}
1950-
1951-
@Test
1952-
void testPrependGetAllDestinationsCallWithMissingDestination()
1953-
{
1954-
doReturn(responseServiceInstanceDestination)
1955-
.when(destinationServiceAdapter)
1956-
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1957-
doReturn(responseSubaccountDestination)
1958-
.when(destinationServiceAdapter)
1959-
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1960-
1961-
loader.setPrependGetAllDestinationCall(true);
1962-
1963-
final DestinationOptions options =
1964-
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
1965-
assertThatThrownBy(() -> loader.tryGetDestination("thisDestinationDoesNotExist").get()).isInstanceOf(DestinationAccessException.class).hasMessageContaining("was not found among the destinations of the current tenant.");
1966-
1967-
// verify all results are cached
1968-
verify(destinationServiceAdapter, times(1))
1969-
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1970-
verify(destinationServiceAdapter, times(1))
1971-
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1972-
verifyNoMoreInteractions(destinationServiceAdapter);
1973-
1974-
loader.setPrependGetAllDestinationCall(false);
1975-
}
1923+
@Test
1924+
void testPrependGetAllDestinationsCall()
1925+
{
1926+
doReturn(responseServiceInstanceDestination)
1927+
.when(destinationServiceAdapter)
1928+
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1929+
doReturn(responseSubaccountDestination)
1930+
.when(destinationServiceAdapter)
1931+
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1932+
1933+
loader.setPrependGetAllDestinationCall(true);
1934+
1935+
final DestinationOptions options =
1936+
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
1937+
Destination result = loader.tryGetDestination(destinationName).get();
1938+
1939+
// verify all results are cached
1940+
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1941+
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1942+
verify(destinationServiceAdapter, times(1))
1943+
.getConfigurationAsJson(eq("/v1/destinations/" + destinationName), any());
1944+
verifyNoMoreInteractions(destinationServiceAdapter);
1945+
1946+
loader.setPrependGetAllDestinationCall(false);
1947+
}
1948+
1949+
@Test
1950+
void testPrependGetAllDestinationsCallWithMissingDestination()
1951+
{
1952+
doReturn(responseServiceInstanceDestination)
1953+
.when(destinationServiceAdapter)
1954+
.getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1955+
doReturn(responseSubaccountDestination)
1956+
.when(destinationServiceAdapter)
1957+
.getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1958+
1959+
loader.setPrependGetAllDestinationCall(true);
1960+
1961+
final DestinationOptions options =
1962+
DestinationOptions.builder().augmentBuilder(augmenter().retrievalStrategy(ALWAYS_PROVIDER)).build();
1963+
assertThatThrownBy(() -> loader.tryGetDestination("thisDestinationDoesNotExist").get())
1964+
.isInstanceOf(DestinationAccessException.class)
1965+
.hasMessageContaining("was not found among the destinations of the current tenant.");
1966+
1967+
// verify all results are cached
1968+
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/instanceDestinations"), any());
1969+
verify(destinationServiceAdapter, times(1)).getConfigurationAsJson(eq("/v1/subaccountDestinations"), any());
1970+
verifyNoMoreInteractions(destinationServiceAdapter);
1971+
1972+
loader.setPrependGetAllDestinationCall(false);
1973+
}
19761974
}

cloudplatform/connectivity-destination-service/src/test/java/com/sap/cloud/sdk/cloudplatform/connectivity/GetOrComputeDestinationCommandTest.java

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,14 @@ void testDefaultTokenExchangeStrategy()
7272

7373
final GetOrComputeSingleDestinationCommand sut =
7474
GetOrComputeSingleDestinationCommand
75-
.prepareCommand("destination", options, destinationCache, isolationLocks, ( foo, bar ) -> null, null, false)
75+
.prepareCommand(
76+
"destination",
77+
options,
78+
destinationCache,
79+
isolationLocks,
80+
( foo, bar ) -> null,
81+
null,
82+
false)
7683
.get();
7784

7885
assertThat(sut.getExchangeStrategy()).isEqualTo(DestinationServiceTokenExchangeStrategy.LOOKUP_THEN_EXCHANGE);
@@ -440,7 +447,14 @@ void testForwardUserTokenStrategyForUserPropagationDestinationWithoutPrincipalUn
440447
.executeWithTenant(
441448
t1,
442449
() -> GetOrComputeSingleDestinationCommand
443-
.prepareCommand(DESTINATION_NAME, options, destinationCache, isolationLocks, function, null, false)
450+
.prepareCommand(
451+
DESTINATION_NAME,
452+
options,
453+
destinationCache,
454+
isolationLocks,
455+
function,
456+
null,
457+
false)
444458
.get());
445459

446460
final Try<Destination> shouldBeFailure = TenantAccessor.executeWithTenant(t1, sut::execute);

0 commit comments

Comments
 (0)