@Test public void testGetPodInfo() throws RemoteApiException { Map<String, Object> data = new HashMap<>(); data.put(POD_ID, MOCK_POD_ID); data.put(EXTERNAL_POD_ID, MOCK_EXTERNAL_POD_ID); Envelope<Map<String, Object>> apiResult = new Envelope<>(); apiResult.setData(data); Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, MOCK_SESSION); doReturn(apiResult).when(httpClient) .doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = apiClient.getPodInfo(MOCK_SESSION); assertEquals(MOCK_POD_ID, podInfo.getPodId()); assertEquals(MOCK_EXTERNAL_POD_ID, podInfo.getExternalPodId()); assertTrue(podInfo.verifyPodId(MOCK_POD_ID)); assertTrue(podInfo.verifyPodId(MOCK_EXTERNAL_POD_ID)); assertFalse(podInfo.verifyPodId(MOCK_INVALID_POD_ID)); }
public PodInfo getPodInfo(String sessionToken) { Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, sessionToken); try { Envelope<Map<String, Object>> result = apiClient.doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = new PodInfo(result.getData()); return podInfo; } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } throw new IntegrationRuntimeException(COMPONENT, logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } }
PodInfoClient { public PodInfo getPodInfo(String sessionToken) { Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, sessionToken); try { Envelope<Map<String, Object>> result = apiClient.doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = new PodInfo(result.getData()); return podInfo; } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } throw new IntegrationRuntimeException(COMPONENT, logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } }
PodInfoClient { public PodInfo getPodInfo(String sessionToken) { Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, sessionToken); try { Envelope<Map<String, Object>> result = apiClient.doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = new PodInfo(result.getData()); return podInfo; } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } throw new IntegrationRuntimeException(COMPONENT, logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } PodInfoClient(HttpApiClient apiClient, LogMessageSource logMessage); }
PodInfoClient { public PodInfo getPodInfo(String sessionToken) { Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, sessionToken); try { Envelope<Map<String, Object>> result = apiClient.doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = new PodInfo(result.getData()); return podInfo; } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } throw new IntegrationRuntimeException(COMPONENT, logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } PodInfoClient(HttpApiClient apiClient, LogMessageSource logMessage); PodInfo getPodInfo(String sessionToken); }
PodInfoClient { public PodInfo getPodInfo(String sessionToken) { Map<String, String> headers = new HashMap<>(); headers.put(SESSION_TOKEN_HEADER, sessionToken); try { Envelope<Map<String, Object>> result = apiClient.doGet(POD_INFO_PATH, headers, Collections.<String, String>emptyMap(), Envelope.class); PodInfo podInfo = new PodInfo(result.getData()); return podInfo; } catch (RemoteApiException e) { if (e.getCode() == Response.Status.UNAUTHORIZED.getStatusCode()) { String message = logMessage.getMessage(UNAUTHORIZED_MESSAGE); String solution = logMessage.getMessage(UNAUTHORIZED_MESSAGE_SOLUTION); throw new UnauthorizedUserException(message, solution); } throw new IntegrationRuntimeException(COMPONENT, logMessage.getMessage(API_MSG), e, logMessage.getMessage(API_MSG_SOLUTION)); } } PodInfoClient(HttpApiClient apiClient, LogMessageSource logMessage); PodInfo getPodInfo(String sessionToken);  }