diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/core/functions/LoginHandler.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/core/functions/LoginHandler.java index baf2227..000ab00 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/core/functions/LoginHandler.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/core/functions/LoginHandler.java @@ -13,12 +13,12 @@ import org.eclipse.ui.ISharedImages; import org.eclipse.ui.PlatformUI; -import com.developer.nefarious.zjoule.plugin.login.LoginWizard; +import com.developer.nefarious.zjoule.plugin.login.SapLoginWizard; /** * Handles the "Login" action for connecting to a BTP subaccount. *

- * This class extends {@link Action} and launches a {@link LoginWizard} in a + * This class extends {@link Action} and launches a {@link SapLoginWizard} in a * {@link WizardDialog} when the action is triggered. It also manages the icon for the action. */ public class LoginHandler extends Action { @@ -60,12 +60,12 @@ private LoginHandler(final Shell shell, final Browser browser) { /** * Executes the "Login" action. *

- * This method launches the {@link LoginWizard} in a {@link WizardDialog}, + * This method launches the {@link SapLoginWizard} in a {@link WizardDialog}, * allowing the user to log in to their BTP subaccount. */ @Override public void run() { - LoginWizard wizard = new LoginWizard(browser); + SapLoginWizard wizard = new SapLoginWizard(browser); WizardDialog dialog = new WizardDialog(shell, wizard); dialog.open(); } diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/LoginWizard.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/SapLoginWizard.java similarity index 78% rename from com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/LoginWizard.java rename to com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/SapLoginWizard.java index e7db0d9..b190ca7 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/LoginWizard.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/SapLoginWizard.java @@ -7,9 +7,9 @@ import com.developer.nefarious.zjoule.plugin.auth.AuthClientHelper; import com.developer.nefarious.zjoule.plugin.auth.IAuthClient; import com.developer.nefarious.zjoule.plugin.auth.SessionManager; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; -import com.developer.nefarious.zjoule.plugin.login.api.LoginClient; -import com.developer.nefarious.zjoule.plugin.login.api.LoginClientHelper; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.SapLoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.SapLoginClientHelper; import com.developer.nefarious.zjoule.plugin.login.memory.TemporaryMemoryAccessToken; import com.developer.nefarious.zjoule.plugin.login.memory.TemporaryMemoryDeployment; import com.developer.nefarious.zjoule.plugin.login.memory.TemporaryMemoryResourceGroup; @@ -26,24 +26,24 @@ * It integrates with temporary memory components and client objects to handle authentication * and session management. */ -public class LoginWizard extends Wizard { +public class SapLoginWizard extends Wizard { /** The browser instance used for login-related UI updates. */ private Browser browser; /** The client responsible for managing the login process. */ - private ILoginClient loginClient; + private ISapLoginClient sapLoginClient; /** * Constructs a new {@code LoginWizard} instance. * * @param browser the {@link Browser} instance used for login-related UI updates. */ - public LoginWizard(final Browser browser) { + public SapLoginWizard(final Browser browser) { this.browser = browser; setWindowTitle("AI Provider Setup"); - loginClient = createLoginClient(); + sapLoginClient = createLoginClient(); } /** @@ -57,21 +57,21 @@ public LoginWizard(final Browser browser) { */ @Override public void addPages() { - addPage(new FirstLoginWizardPage(loginClient)); - addPage(new SecondLoginWizardPage(loginClient, TemporaryMemoryResourceGroup.getInstance(), TemporaryMemoryDeployment.getInstance())); + addPage(new FirstLoginWizardPage(sapLoginClient)); + addPage(new SecondLoginWizardPage(sapLoginClient, TemporaryMemoryResourceGroup.getInstance(), TemporaryMemoryDeployment.getInstance())); } /** - * Creates and initializes the {@link ILoginClient} used for the login process. + * Creates and initializes the {@link ISapLoginClient} used for the login process. * - * @return a new {@link ILoginClient} instance. + * @return a new {@link ISapLoginClient} instance. */ - private ILoginClient createLoginClient() { + private ISapLoginClient createLoginClient() { TemporaryMemoryAccessToken tmpMemoryAccessToken = TemporaryMemoryAccessToken.getInstance(); TemporaryMemoryServiceKey tmpMemoryServiceKey = TemporaryMemoryServiceKey.getInstance(); IAuthClient tmpAuthClient = new AuthClient(tmpMemoryAccessToken, tmpMemoryServiceKey, new AuthClientHelper()); - return new LoginClient(new LoginClientHelper(), tmpAuthClient); + return new SapLoginClient(new SapLoginClientHelper(), tmpAuthClient); } /** diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClient.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClient.java similarity index 97% rename from com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClient.java rename to com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClient.java index ea45916..8e8fa0b 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClient.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClient.java @@ -10,7 +10,7 @@ * The {@code ILoginClient} defines methods for retrieving deployments and resource groups * by interacting with the SAP AI Core API. */ -public interface ILoginClient { +public interface ISapLoginClient { /** * Retrieves a list of deployments from the SAP AI Core API. diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClientHelper.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClientHelper.java similarity index 96% rename from com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClientHelper.java rename to com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClientHelper.java index df801b7..3fc70e7 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ILoginClientHelper.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/ISapLoginClientHelper.java @@ -8,7 +8,7 @@ * The {@code ILoginClientHelper} defines methods for creating API request URIs * and parsing JSON response bodies into their corresponding Java objects. */ -public interface ILoginClientHelper { +public interface ISapLoginClientHelper { /** * Creates a URI for the given API endpoint. diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClient.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClient.java similarity index 71% rename from com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClient.java rename to com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClient.java index b9c7a39..98a7ee2 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClient.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClient.java @@ -10,19 +10,19 @@ import com.developer.nefarious.zjoule.plugin.models.ServiceKey; /** - * Implements the {@link ILoginClient} interface for managing API interactions related to login operations. + * Implements the {@link ISapLoginClient} interface for managing API interactions related to login operations. *

* The {@code LoginClient} class communicates with SAP AI Core APIs to retrieve deployments - * and resource groups, leveraging an {@link IAuthClient} for authentication and an {@link ILoginClientHelper} + * and resource groups, leveraging an {@link IAuthClient} for authentication and an {@link ISapLoginClientHelper} * for building requests and parsing responses. */ -public class LoginClient implements ILoginClient { +public class SapLoginClient implements ISapLoginClient { /** The HTTP client used for making API requests. */ private HttpClient httpClient; /** Helper class for constructing requests and parsing responses. */ - private ILoginClientHelper loginClientHelper; + private ISapLoginClientHelper sapLoginClientHelper; /** The authentication client used for retrieving access tokens. */ private IAuthClient authClient; @@ -30,12 +30,12 @@ public class LoginClient implements ILoginClient { /** * Constructs a new {@code LoginClient} instance. * - * @param loginClientHelper the helper for constructing requests and parsing responses. + * @param sapLoginClientHelper the helper for constructing requests and parsing responses. * @param authClient the authentication client for retrieving access tokens. */ - public LoginClient(final ILoginClientHelper loginClientHelper, final IAuthClient authClient) { + public SapLoginClient(final ISapLoginClientHelper sapLoginClientHelper, final IAuthClient authClient) { httpClient = HttpClient.newHttpClient(); - this.loginClientHelper = loginClientHelper; + this.sapLoginClientHelper = sapLoginClientHelper; this.authClient = authClient; } @@ -45,7 +45,7 @@ public LoginClient(final ILoginClientHelper loginClientHelper, final IAuthClient @Override public GetDeploymentsResponse getDeployments(final ServiceKey serviceKey, final String resourceGroup) throws IOException, InterruptedException { - URI endpoint = loginClientHelper.createAuthUri(serviceKey.getServiceURL() + "/lm/deployments"); + URI endpoint = sapLoginClientHelper.createAuthUri(serviceKey.getServiceURL() + "/lm/deployments"); HttpRequest request = HttpRequest.newBuilder() .uri(endpoint) @@ -56,7 +56,7 @@ public GetDeploymentsResponse getDeployments(final ServiceKey serviceKey, final HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - return loginClientHelper.parseDeploymentsResponseToObject(response.body()); + return sapLoginClientHelper.parseDeploymentsResponseToObject(response.body()); } /** @@ -65,7 +65,7 @@ public GetDeploymentsResponse getDeployments(final ServiceKey serviceKey, final @Override public GetResourceGroupsResponse getResourceGroups(final ServiceKey serviceKey) throws IOException, InterruptedException { - URI endpoint = loginClientHelper.createAuthUri(serviceKey.getServiceURL() + "/admin/resourceGroups"); + URI endpoint = sapLoginClientHelper.createAuthUri(serviceKey.getServiceURL() + "/admin/resourceGroups"); HttpRequest request = HttpRequest.newBuilder() .uri(endpoint) @@ -75,6 +75,6 @@ public GetResourceGroupsResponse getResourceGroups(final ServiceKey serviceKey) HttpResponse response = httpClient.send(request, HttpResponse.BodyHandlers.ofString()); - return loginClientHelper.parseResourceGroupsResponseToObject(response.body()); + return sapLoginClientHelper.parseResourceGroupsResponseToObject(response.body()); } } diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClientHelper.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClientHelper.java similarity index 88% rename from com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClientHelper.java rename to com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClientHelper.java index 458bf40..0df69a7 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/LoginClientHelper.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/api/SapLoginClientHelper.java @@ -9,9 +9,9 @@ *

* The {@code LoginClientHelper} provides utility methods for creating URIs * and parsing API responses into their corresponding Java objects. - * Implements the {@link ILoginClientHelper} interface. + * Implements the {@link ISapLoginClientHelper} interface. */ -public class LoginClientHelper implements ILoginClientHelper { +public class SapLoginClientHelper implements ISapLoginClientHelper { /** The {@link Gson} instance for parsing JSON responses. */ private Gson gson; @@ -21,7 +21,7 @@ public class LoginClientHelper implements ILoginClientHelper { *

* Initializes a {@link Gson} instance for JSON parsing. */ - public LoginClientHelper() { + public SapLoginClientHelper() { gson = new Gson(); } diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ResourceGroupSelectionAdapter.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ResourceGroupSelectionAdapter.java index a16c6b8..567b821 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ResourceGroupSelectionAdapter.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ResourceGroupSelectionAdapter.java @@ -6,7 +6,7 @@ import org.eclipse.swt.events.SelectionEvent; import com.developer.nefarious.zjoule.plugin.login.api.GetDeploymentsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.pages.SecondLoginWizardPage; import com.developer.nefarious.zjoule.plugin.memory.IMemoryObject; import com.developer.nefarious.zjoule.plugin.models.ServiceKey; @@ -24,7 +24,7 @@ public class ResourceGroupSelectionAdapter extends SelectionAdapter { private SecondLoginWizardPage secondLoginWizardPage; /** The login client for retrieving deployments. */ - private ILoginClient loginClient; + private ISapLoginClient sapLoginClient; /** The memory manager for storing the selected resource group. */ private IMemoryObject memoryResourceGroup; @@ -33,17 +33,17 @@ public class ResourceGroupSelectionAdapter extends SelectionAdapter { * Constructs a new {@code ResourceGroupSelectionAdapter}. * * @param secondLoginWizardPage the {@link SecondLoginWizardPage} containing the resource group dropdown. - * @param loginClient the {@link ILoginClient} for retrieving deployments. + * @param sapLoginClient the {@link ISapLoginClient} for retrieving deployments. * @param memoryResourceGroup the {@link IMemoryObject} used to store the selected resource group. */ // @formatter:off public ResourceGroupSelectionAdapter( final SecondLoginWizardPage secondLoginWizardPage, - final ILoginClient loginClient, + final ISapLoginClient sapLoginClient, final IMemoryObject memoryResourceGroup) { // @formatter:on this.secondLoginWizardPage = secondLoginWizardPage; - this.loginClient = loginClient; + this.sapLoginClient = sapLoginClient; this.memoryResourceGroup = memoryResourceGroup; } @@ -71,7 +71,7 @@ private void enableTheDeploymentSelection() { private void handleAvailableDeployments() throws IOException, InterruptedException { String selectedResourceGroup = secondLoginWizardPage.getResourceGroupDropdown().getText(); ServiceKey serviceKey = secondLoginWizardPage.getServiceKey(); - GetDeploymentsResponse getDeploymentsResponse = loginClient.getDeployments(serviceKey, selectedResourceGroup); + GetDeploymentsResponse getDeploymentsResponse = sapLoginClient.getDeployments(serviceKey, selectedResourceGroup); secondLoginWizardPage.setDeploymentsForSelection(getDeploymentsResponse.getDeployments()); memoryResourceGroup.save(selectedResourceGroup); enableTheDeploymentSelection(); diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ServiceKeyModifyListener.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ServiceKeyModifyListener.java index bdad579..eb0a71b 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ServiceKeyModifyListener.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/events/ServiceKeyModifyListener.java @@ -6,7 +6,7 @@ import org.eclipse.swt.events.ModifyListener; import com.developer.nefarious.zjoule.plugin.login.api.GetResourceGroupsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.pages.FirstLoginWizardPage; import com.developer.nefarious.zjoule.plugin.login.utils.JsonValidator; import com.developer.nefarious.zjoule.plugin.models.ServiceKey; @@ -24,7 +24,7 @@ public class ServiceKeyModifyListener implements ModifyListener { private FirstLoginWizardPage firstLoginWizardPage; /** The login client used for validating the service key and retrieving resource groups. */ - private ILoginClient loginClient; + private ISapLoginClient sapLoginClient; /** A {@link Gson} instance for parsing the service key from JSON. */ private Gson gson; @@ -33,17 +33,17 @@ public class ServiceKeyModifyListener implements ModifyListener { * Constructs a new {@code ServiceKeyModifyListener}. * * @param firstLoginWizardPage the {@link FirstLoginWizardPage} containing the service key input field. - * @param loginClient the {@link ILoginClient} for validating the service key and retrieving resource groups. + * @param sapLoginClient the {@link ISapLoginClient} for validating the service key and retrieving resource groups. * @param gson the {@link Gson} instance for parsing the service key JSON. */ // @formatter:off public ServiceKeyModifyListener( final FirstLoginWizardPage firstLoginWizardPage, - final ILoginClient loginClient, + final ISapLoginClient sapLoginClient, final Gson gson) { // @formatter:on this.firstLoginWizardPage = firstLoginWizardPage; - this.loginClient = loginClient; + this.sapLoginClient = sapLoginClient; this.gson = gson; } @@ -76,7 +76,7 @@ private void enableNextButton() { * @throws InterruptedException if the resource group retrieval is interrupted. */ private void handleValidServiceKey(final ServiceKey serviceKey) throws IOException, InterruptedException { - GetResourceGroupsResponse getResourceGroupsResponse = loginClient.getResourceGroups(serviceKey); + GetResourceGroupsResponse getResourceGroupsResponse = sapLoginClient.getResourceGroups(serviceKey); firstLoginWizardPage.setResourceGroupsOnTheSecondPage(getResourceGroupsResponse); firstLoginWizardPage.setServiceKey(serviceKey); clearMessageLog(); diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/FirstLoginWizardPage.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/FirstLoginWizardPage.java index dcf385a..41c2fe5 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/FirstLoginWizardPage.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/FirstLoginWizardPage.java @@ -10,7 +10,7 @@ import org.eclipse.swt.widgets.Text; import com.developer.nefarious.zjoule.plugin.login.api.GetResourceGroupsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.events.ServiceKeyModifyListener; import com.developer.nefarious.zjoule.plugin.login.utils.ResourceGroupIdExtractor; import com.developer.nefarious.zjoule.plugin.models.ServiceKey; @@ -47,19 +47,19 @@ public class FirstLoginWizardPage extends WizardPage { private ServiceKey serviceKey; /** The login client for handling API interactions. */ - private ILoginClient loginClient; + private ISapLoginClient sapLoginClient; /** * Constructs a new {@code FirstLoginWizardPage}. * - * @param loginClient the {@link ILoginClient} used for API interactions during the login process. + * @param sapLoginClient the {@link ISapLoginClient} used for API interactions during the login process. */ - public FirstLoginWizardPage(final ILoginClient loginClient) { + public FirstLoginWizardPage(final ISapLoginClient sapLoginClient) { super(PAGE_ID); setTitle("Provide credentials"); setDescription("Attach the Service Key json file content for the SAP AI Core service."); setPageComplete(false); // Initially set the page as incomplete - this.loginClient = loginClient; + this.sapLoginClient = sapLoginClient; } /** @@ -80,7 +80,7 @@ public void createControl(final Composite parent) { textField.setLayoutData(gridData); // Add a ModifyListener to monitor textField changes - textField.addModifyListener(new ServiceKeyModifyListener(this, loginClient, new Gson())); + textField.addModifyListener(new ServiceKeyModifyListener(this, sapLoginClient, new Gson())); // Hidden error text widget errorText = new Text(container, SWT.READ_ONLY | SWT.MULTI | SWT.WRAP); diff --git a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/SecondLoginWizardPage.java b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/SecondLoginWizardPage.java index f2421c6..42c1389 100644 --- a/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/SecondLoginWizardPage.java +++ b/com.developer.nefarious.zjoule.plugin/src/com/developer/nefarious/zjoule/plugin/login/pages/SecondLoginWizardPage.java @@ -11,7 +11,7 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.events.DeploymentSelectionAdapter; import com.developer.nefarious.zjoule.plugin.login.events.ResourceGroupSelectionAdapter; import com.developer.nefarious.zjoule.plugin.memory.IMemoryObject; @@ -48,7 +48,7 @@ public class SecondLoginWizardPage extends WizardPage { private List deploymentsForSelection = new ArrayList<>(); /** Client for handling API interactions. */ - private ILoginClient loginClient; + private ISapLoginClient sapLoginClient; /** Memory interface for managing resource group data. */ private IMemoryObject memoryResourceGroup; @@ -59,13 +59,13 @@ public class SecondLoginWizardPage extends WizardPage { /** * Constructs a new {@code SecondLoginWizardPage}. * - * @param loginClient the {@link ILoginClient} used for API interactions during the login process. + * @param sapLoginClient the {@link ISapLoginClient} used for API interactions during the login process. * @param memoryResourceGroup the {@link IMemoryObject} for resource group memory management. * @param memoryDeployment the {@link IMemoryObject} for deployment memory management. */ // @formatter:off public SecondLoginWizardPage( - final ILoginClient loginClient, + final ISapLoginClient sapLoginClient, final IMemoryObject memoryResourceGroup, final IMemoryObject memoryDeployment) { // @formatter:on @@ -73,7 +73,7 @@ public SecondLoginWizardPage( setTitle("Select the model"); setDescription("Choose the Resource Group and the Deployment ID."); setPageComplete(false); // Initially set the page as incomplete - this.loginClient = loginClient; + this.sapLoginClient = sapLoginClient; this.memoryResourceGroup = memoryResourceGroup; this.memoryDeployment = memoryDeployment; } @@ -97,7 +97,7 @@ public void createControl(final Composite parent) { // Add a SelectionListener to enable the deployment dropdown when a valid resource group is selected resourceGroupDropdown - .addSelectionListener(new ResourceGroupSelectionAdapter(this, loginClient, memoryResourceGroup)); + .addSelectionListener(new ResourceGroupSelectionAdapter(this, sapLoginClient, memoryResourceGroup)); // Create label and dropdown for deployment ID selection Label deploymentLabel = new Label(container, SWT.NONE); diff --git a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientHelperTest.java b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientHelperTest.java similarity index 91% rename from com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientHelperTest.java rename to com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientHelperTest.java index 1024098..af37bdf 100644 --- a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientHelperTest.java +++ b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientHelperTest.java @@ -13,12 +13,12 @@ import com.developer.nefarious.zjoule.plugin.login.api.GetDeploymentsResponse; import com.developer.nefarious.zjoule.plugin.login.api.GetResourceGroupsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.LoginClientHelper; +import com.developer.nefarious.zjoule.plugin.login.api.SapLoginClientHelper; import com.google.gson.Gson; -public class LoginClientHelperTest { +public class SapLoginClientHelperTest { - private LoginClientHelper cut; + private SapLoginClientHelper cut; private String randomWord() { final String[] WORDS = { "apple", "banana", "grape" }; @@ -28,7 +28,7 @@ private String randomWord() { @BeforeEach public void setUp() { - cut = new LoginClientHelper(); + cut = new SapLoginClientHelper(); } @Test diff --git a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientTest.java b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientTest.java similarity index 86% rename from com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientTest.java rename to com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientTest.java index d0c2b84..104d2f6 100644 --- a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/LoginClientTest.java +++ b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/api/SapLoginClientTest.java @@ -24,14 +24,14 @@ import com.developer.nefarious.zjoule.plugin.auth.IAuthClient; import com.developer.nefarious.zjoule.plugin.login.api.GetDeploymentsResponse; import com.developer.nefarious.zjoule.plugin.login.api.GetResourceGroupsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClientHelper; -import com.developer.nefarious.zjoule.plugin.login.api.LoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClientHelper; +import com.developer.nefarious.zjoule.plugin.login.api.SapLoginClient; import com.developer.nefarious.zjoule.plugin.models.ServiceKey; -public class LoginClientTest { +public class SapLoginClientTest { - private ILoginClient cut; + private ISapLoginClient cut; MockedStatic mockedStaticHttpClient; @@ -47,7 +47,7 @@ public class LoginClientTest { private IAuthClient mockAuthClient; @Mock - private ILoginClientHelper mockLoginClientHelper; + private ISapLoginClientHelper mockSapLoginClientHelper; @Mock private Builder mockBuilder; @@ -68,7 +68,7 @@ public void setUp() { mockedStaticHttpRequest = mockStatic(HttpRequest.class); mockedStaticHttpRequest.when(HttpRequest::newBuilder).thenReturn(mockBuilder); - cut = spy(new LoginClient(mockLoginClientHelper, mockAuthClient)); + cut = spy(new SapLoginClient(mockSapLoginClientHelper, mockAuthClient)); } @Test @@ -83,7 +83,7 @@ public void shouldPlumbDeployments() throws IOException, InterruptedException { String mockEndpointInStringFormat = mockServiceURL + "/lm/deployments"; URI mockEndpointInURIFormat = mock(URI.class); - when(mockLoginClientHelper.createAuthUri(mockEndpointInStringFormat)).thenReturn(mockEndpointInURIFormat); + when(mockSapLoginClientHelper.createAuthUri(mockEndpointInStringFormat)).thenReturn(mockEndpointInURIFormat); when(mockBuilder.uri(mockEndpointInURIFormat)).thenReturn(mockBuilder); String mockToken = "access-token"; @@ -99,7 +99,7 @@ public void shouldPlumbDeployments() throws IOException, InterruptedException { String mockResponseBody = "response-content"; when(mockHttpResponse.body()).thenReturn(mockResponseBody); - when(mockLoginClientHelper.parseDeploymentsResponseToObject(mockResponseBody)).thenReturn(expectedValue); + when(mockSapLoginClientHelper.parseDeploymentsResponseToObject(mockResponseBody)).thenReturn(expectedValue); // Act GetDeploymentsResponse returnValue = cut.getDeployments(mockServiceKey, mockResourceGroup); @@ -122,7 +122,7 @@ public void shouldPlumbResourceGroups() throws IOException, InterruptedException String mockEndpointInStringFormat = mockServiceURL + "/admin/resourceGroups"; URI mockEndpointInURIFormat = mock(URI.class); - when(mockLoginClientHelper.createAuthUri(mockEndpointInStringFormat)).thenReturn(mockEndpointInURIFormat); + when(mockSapLoginClientHelper.createAuthUri(mockEndpointInStringFormat)).thenReturn(mockEndpointInURIFormat); when(mockBuilder.uri(mockEndpointInURIFormat)).thenReturn(mockBuilder); String mockToken = "access-token"; @@ -137,7 +137,7 @@ public void shouldPlumbResourceGroups() throws IOException, InterruptedException String mockResponseBody = "response-content"; when(mockHttpResponse.body()).thenReturn(mockResponseBody); - when(mockLoginClientHelper.parseResourceGroupsResponseToObject(mockResponseBody)).thenReturn(expectedValue); + when(mockSapLoginClientHelper.parseResourceGroupsResponseToObject(mockResponseBody)).thenReturn(expectedValue); // Act GetResourceGroupsResponse returnValue = cut.getResourceGroups(mockServiceKey); diff --git a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ResourceGroupSelectionAdapterTest.java b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ResourceGroupSelectionAdapterTest.java index f9a3395..fc6ad5f 100644 --- a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ResourceGroupSelectionAdapterTest.java +++ b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ResourceGroupSelectionAdapterTest.java @@ -15,7 +15,7 @@ import org.mockito.MockitoAnnotations; import com.developer.nefarious.zjoule.plugin.login.api.GetDeploymentsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.events.ResourceGroupSelectionAdapter; import com.developer.nefarious.zjoule.plugin.login.pages.SecondLoginWizardPage; import com.developer.nefarious.zjoule.plugin.memory.IMemoryObject; @@ -30,7 +30,7 @@ public class ResourceGroupSelectionAdapterTest { private SecondLoginWizardPage mockSecondLoginWizardPage; @Mock - private ILoginClient mockLoginClient; + private ISapLoginClient mockSapLoginClient; @Mock private IMemoryObject mockMemoryResourceGroup; @@ -38,7 +38,7 @@ public class ResourceGroupSelectionAdapterTest { @BeforeEach public void setUp() { MockitoAnnotations.openMocks(this); - cut = new ResourceGroupSelectionAdapter(mockSecondLoginWizardPage, mockLoginClient, mockMemoryResourceGroup); + cut = new ResourceGroupSelectionAdapter(mockSecondLoginWizardPage, mockSapLoginClient, mockMemoryResourceGroup); } @Test @@ -59,7 +59,7 @@ public void shouldEnableTheDeploymentSelection() throws IOException, Interrupted when(mockSecondLoginWizardPage.getServiceKey()).thenReturn(mockServiceKey); GetDeploymentsResponse mockGetDeploymentsResponse = mock(GetDeploymentsResponse.class); - when(mockLoginClient.getDeployments(mockServiceKey, mockText)).thenReturn(mockGetDeploymentsResponse); + when(mockSapLoginClient.getDeployments(mockServiceKey, mockText)).thenReturn(mockGetDeploymentsResponse); List mockDeployments = mock(List.class); when(mockGetDeploymentsResponse.getDeployments()).thenReturn(mockDeployments); diff --git a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ServiceKeyModifyListenerTest.java b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ServiceKeyModifyListenerTest.java index 34ab835..8ac44bf 100644 --- a/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ServiceKeyModifyListenerTest.java +++ b/com.developer.nefarious.zjoule.test/src/com/developer/nefarious/zjoule/test/login/events/ServiceKeyModifyListenerTest.java @@ -16,7 +16,7 @@ import org.mockito.MockitoAnnotations; import com.developer.nefarious.zjoule.plugin.login.api.GetResourceGroupsResponse; -import com.developer.nefarious.zjoule.plugin.login.api.ILoginClient; +import com.developer.nefarious.zjoule.plugin.login.api.ISapLoginClient; import com.developer.nefarious.zjoule.plugin.login.events.ServiceKeyModifyListener; import com.developer.nefarious.zjoule.plugin.login.pages.FirstLoginWizardPage; import com.developer.nefarious.zjoule.plugin.login.utils.JsonValidator; @@ -33,7 +33,7 @@ public class ServiceKeyModifyListenerTest { private FirstLoginWizardPage mockFirstLoginWizardPage; @Mock - private ILoginClient mockLoginClient; + private ISapLoginClient mockSapLoginClient; @Mock private Gson mockGson; @@ -44,7 +44,7 @@ public class ServiceKeyModifyListenerTest { @BeforeEach public void setUp() { MockitoAnnotations.openMocks(this); - cut = spy(new ServiceKeyModifyListener(mockFirstLoginWizardPage, mockLoginClient, mockGson)); + cut = spy(new ServiceKeyModifyListener(mockFirstLoginWizardPage, mockSapLoginClient, mockGson)); } @Test @@ -109,7 +109,7 @@ public void shouldEnableTheNextButtonIfInputIsValid() throws IOException, Interr when(mockGson.fromJson(mockInputTextTrimmed, ServiceKey.class)).thenReturn(mockServiceKey); when(mockServiceKey.isValid()).thenReturn(true); GetResourceGroupsResponse mockGetResourceGroupsResponse = mock(GetResourceGroupsResponse.class); - when(mockLoginClient.getResourceGroups(mockServiceKey)).thenReturn(mockGetResourceGroupsResponse); + when(mockSapLoginClient.getResourceGroups(mockServiceKey)).thenReturn(mockGetResourceGroupsResponse); // Act cut.modifyText(mockModifyEvent); // Assert @@ -131,7 +131,7 @@ public void shouldGracefullyHandleAnyError() throws IOException, InterruptedExce } when(mockGson.fromJson(mockInputTextTrimmed, ServiceKey.class)).thenReturn(mockServiceKey); when(mockServiceKey.isValid()).thenReturn(true); - when(mockLoginClient.getResourceGroups(mockServiceKey)).thenThrow(new IOException()); + when(mockSapLoginClient.getResourceGroups(mockServiceKey)).thenThrow(new IOException()); // Act cut.modifyText(mockModifyEvent); // Assert