Skip to content

Commit

Permalink
Added javadocs
Browse files Browse the repository at this point in the history
  • Loading branch information
harveymmaunders committed Jan 13, 2025
1 parent c571486 commit 21c4ec8
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ms.infra.example.application.morganStanleyServices.MsApiRequest;
import com.ms.infra.example.application.morganStanleyServices.MsApiService;
import com.ms.infra.example.application.morganStanleyServices.MsRetrofitWrapper;
import com.ms.infra.example.application.responseTypes.HelloWorldGetServicesResponse;
import com.ms.infra.example.application.services.HelloWorldRestService;
Expand Down Expand Up @@ -31,8 +31,8 @@ public static void run() throws Exception {
}

public static void callHelloWorldApi() throws Exception {
MsApiRequest msApiRequest = new MsApiRequest(HttpLoggingInterceptor.Level.BODY);
msApiRequest.callEndpoint(apiEndpoint);
MsApiService msApiService = new MsApiService(HttpLoggingInterceptor.Level.BODY);
msApiService.callEndpoint(apiEndpoint);
}

public static void callHelloWorldApiWithRetrofit() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,12 @@

import java.io.IOException;

public class MsApiRequest {
/**
* This class is an alternative to the MsRetrofitWrapper for calling Morgan Stanley APIs.
* Ensure that the correct properties are set in the microprofile-config.properties file.
* To call a Morgan Stanley API, run the callEndpoint method, with the required endpoint.
*/
public class MsApiService {
/**
* Logging
*/
Expand All @@ -33,7 +38,7 @@ public class MsApiRequest {
* @param logLevel Log interceptor level
* @throws Exception throws exception if error when creating msClientAuthTokenService
*/
public MsApiRequest(HttpLoggingInterceptor.Level logLevel) throws Exception {
public MsApiService(HttpLoggingInterceptor.Level logLevel) throws Exception {
MicroprofileConfigService microprofileConfigService = new MicroprofileConfigService();
MsClientAuthTokenService msClientAuthTokenService = new MsClientAuthTokenService(microprofileConfigService);
this.urlDomain = microprofileConfigService.getMsUrlDomain();
Expand All @@ -45,7 +50,7 @@ public MsApiRequest(HttpLoggingInterceptor.Level logLevel) throws Exception {
* @param okHttpClient
* @param urlDomain
*/
public MsApiRequest(OkHttpClient okHttpClient, String urlDomain) {
public MsApiService(OkHttpClient okHttpClient, String urlDomain) {
this.okHttpClient = okHttpClient;
this.urlDomain = urlDomain;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package com.ms.infra.example.application;

import com.ms.infra.example.application.interceptors.AuthHeaderInterceptor;
import com.ms.infra.example.application.morganStanleyServices.MsApiRequest;
import com.ms.infra.example.application.morganStanleyServices.MsApiService;
import com.ms.infra.example.application.morganStanleyServices.MsClientAuthTokenService;
import okhttp3.OkHttpClient;
import okhttp3.mockwebserver.MockResponse;
Expand All @@ -18,7 +18,7 @@
import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.core.Is.is;

public class TestMsApiRequestShould {
public class TestMsApiServiceShould {
private OkHttpClient okHttpClient;
private MockWebServer mockWebServer;

Expand Down Expand Up @@ -54,9 +54,9 @@ public void call_api() throws InterruptedException, IOException {
mockWebServer.enqueue(mockResponse);

System.out.println(mockWebServer.url("/"));
MsApiRequest msApiRequest = new MsApiRequest(okHttpClient, mockWebServer.url("").toString());
MsApiService msApiService = new MsApiService(okHttpClient, mockWebServer.url("").toString());

msApiRequest.callEndpoint(TEST_ENDPOINT);
msApiService.callEndpoint(TEST_ENDPOINT);

// Check the request
RecordedRequest recordedRequest = mockWebServer.takeRequest();
Expand Down

0 comments on commit 21c4ec8

Please sign in to comment.