Skip to content

Refactor: Remove CloudPlatform classes - #111

Merged
Johannes-Schneider merged 17 commits into
mainfrom
bli-201/remove-cloudplatform-usage
Nov 3, 2023
Merged

Johannes-Schneider merged 17 commits into
mainfrom
bli-201/remove-cloudplatform-usage

Conversation

@Johannes-Schneider

@Johannes-Schneider Johannes-Schneider commented Nov 1, 2023 •

Copy link
Copy Markdown
Contributor

Context

BLI: https://github.com/SAP/cloud-sdk-java-backlog/issues/201

This PR removes classes related to the CloudPlatform from the SDK.

Feature Scope

  • Remove classes
    • CloudPlatformAccessor
    • CloudPlatformFacade (and implementations)
    • CloudPlatform (and implementations)
    • CloudPlatformException → still used productively (e.g. in HttpClient4 and 5 modules)
  • Migration guide updated → will be done in refactor: Remove ServiceBindingLibWorkaround Class #307
  • Release notes updated

@Johannes-Schneider
Johannes-Schneider marked this pull request as ready for review November 2, 2023 08:31
@Johannes-Schneider Johannes-Schneider added please merge Request to merge a pull request please review Request to review a pull request labels Nov 2, 2023
private Stream<Map<String, Object>> streamServiceCredentialsByPlan( @Nonnull final String serviceName )
{
return DefaultServiceBindingAccessor
.getInstance()

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(Comment/Question)

I'm not sure what is expected best practice for this API:

  • invoke getInstance everytime, not storing the accessor, making (local) mocking and future workarounds difficult
  • invoke getInstance upon class instantiation, storing the accessor, allowing for easy (local) mocking and future workarounds

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good question.

In general, I imagined the getInstance method to be called every time. Otherwise, applications might be overwriting the instance at some point and run into unexpected and hard to debug issues since the instance they set is not actually being used everywhere.
(Consider our regular Accessor classes: We are calling the underlying Facade every time as well)

With regards to mocking / testing:
I share your concern: I don't like the fact that customers / we have to know this implementation detail to effectively mock this class - that is: It is not apparent from any API that we are using this static instance inside the implementation.
However, mocking this statically stored instance is pretty easy and straight forwards (given the fact that you KNOW that it is being used) IMO.

newtork
newtork previously approved these changes Nov 2, 2023

@newtork newtork left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Hopefully we will not regret removing all those test cases. I know it's unused code but now we definitely have to trust security library to handle their test coverage just as well 😁

Comment on lines -653 to -662
@Test
public void dwcBindingDoesNotThrow()
{
final MegacliteServiceBinding serviceBinding =
MegacliteServiceBinding
.forService(ServiceIdentifier.DESTINATION)
.providerConfiguration()
.name("destination-paas")
.version("v1")
.build();

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this test be migrated to the new service binding?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's being tested here was our implementation of converting ServiceBinding instances into the Map<String, JsonObject> format we used to have in our ScpCfCloudPlatform.

Therefore, I don't think we need to migrate this test as we simply no longer offer this functionality.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MegacliteServiceBinding.getCredentials() returns Map<String, Object> to ScpCfTenantFacadestreamServiceCredentialsByPlan(). This functionality is new.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a corresponding test for the added method.

Comment thread release_notes_next_major.md Resolved
Co-authored-by: Charles Dubois <103174266+CharlesDuboisSAP@users.noreply.github.com>
@Johannes-Schneider
Johannes-Schneider merged commit 4011b5d into main Nov 3, 2023
@Johannes-Schneider
Johannes-Schneider deleted the bli-201/remove-cloudplatform-usage branch November 3, 2023 08:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

please merge Request to merge a pull request please review Request to review a pull request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants