@Test public void testCreateLogFileTailURI() throws Exception { LoggingCookieStore.INSTANCE.getCookiesMap().clear(); final String expectedHostName = "c6401.ambari.apache.org"; final String expectedPort = "61888"; final String expectedComponentName = "hdfs_namenode"; final String expectedBaseURI = "http: final String expectedTailFileURI = expectedBaseURI + "?component_name=" + expectedComponentName + "&host_name=" + expectedHostName + "&pageSize=50"; EasyMockSupport mockSupport = new EasyMockSupport(); CredentialStoreService credentialStoreServiceMock = mockSupport.createMock(CredentialStoreService.class); Cluster clusterMock = mockSupport.createMock(Cluster.class); LoggingRequestHelperImpl.NetworkConnection networkConnectionMock = mockSupport.createMock(LoggingRequestHelperImpl.NetworkConnection.class); mockSupport.replayAll(); LoggingRequestHelper helper = new LoggingRequestHelperImpl("c6401.ambari.apache.org", "61888", "http", credentialStoreServiceMock, clusterMock, networkConnectionMock); String result = helper.createLogFileTailURI(expectedBaseURI, expectedComponentName, expectedHostName); assertEquals("LogFile Tail URI was not generated as expected", expectedTailFileURI, result); mockSupport.verifyAll(); }
@Override public String createLogFileTailURI(String baseURI, String componentName, String hostName) { return baseURI + "?" + COMPONENT_QUERY_PARAMETER_NAME + "=" + componentName + "&" + HOST_QUERY_PARAMETER_NAME + "=" + hostName + "&" + PAGE_SIZE_QUERY_PARAMETER_NAME + "=" + DEFAULT_PAGE_SIZE; }
LoggingRequestHelperImpl implements LoggingRequestHelper { @Override public String createLogFileTailURI(String baseURI, String componentName, String hostName) { return baseURI + "?" + COMPONENT_QUERY_PARAMETER_NAME + "=" + componentName + "&" + HOST_QUERY_PARAMETER_NAME + "=" + hostName + "&" + PAGE_SIZE_QUERY_PARAMETER_NAME + "=" + DEFAULT_PAGE_SIZE; } }
LoggingRequestHelperImpl implements LoggingRequestHelper { @Override public String createLogFileTailURI(String baseURI, String componentName, String hostName) { return baseURI + "?" + COMPONENT_QUERY_PARAMETER_NAME + "=" + componentName + "&" + HOST_QUERY_PARAMETER_NAME + "=" + hostName + "&" + PAGE_SIZE_QUERY_PARAMETER_NAME + "=" + DEFAULT_PAGE_SIZE; } LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster); protected  LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster, NetworkConnection networkConnection); }
LoggingRequestHelperImpl implements LoggingRequestHelper { @Override public String createLogFileTailURI(String baseURI, String componentName, String hostName) { return baseURI + "?" + COMPONENT_QUERY_PARAMETER_NAME + "=" + componentName + "&" + HOST_QUERY_PARAMETER_NAME + "=" + hostName + "&" + PAGE_SIZE_QUERY_PARAMETER_NAME + "=" + DEFAULT_PAGE_SIZE; } LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster); protected  LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster, NetworkConnection networkConnection); int getLogSearchConnectTimeoutInMilliseconds(); void setLogSearchConnectTimeoutInMilliseconds(int logSearchConnectTimeoutInMilliseconds); int getLogSearchReadTimeoutInMilliseconds(); void setLogSearchReadTimeoutInMilliseconds(int logSearchReadTimeoutInMilliseconds); LogQueryResponse sendQueryRequest(Map<String, String> queryParameters); Set<String> sendGetLogFileNamesRequest(String componentName, String hostName); @Override LogLevelQueryResponse sendLogLevelQueryRequest(String componentName, String hostName); @Override String createLogFileTailURI(String baseURI, String componentName, String hostName); }
LoggingRequestHelperImpl implements LoggingRequestHelper { @Override public String createLogFileTailURI(String baseURI, String componentName, String hostName) { return baseURI + "?" + COMPONENT_QUERY_PARAMETER_NAME + "=" + componentName + "&" + HOST_QUERY_PARAMETER_NAME + "=" + hostName + "&" + PAGE_SIZE_QUERY_PARAMETER_NAME + "=" + DEFAULT_PAGE_SIZE; } LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster); protected  LoggingRequestHelperImpl(String hostName, String portNumber, String protocol, CredentialStoreService credentialStoreService, Cluster cluster, NetworkConnection networkConnection); int getLogSearchConnectTimeoutInMilliseconds(); void setLogSearchConnectTimeoutInMilliseconds(int logSearchConnectTimeoutInMilliseconds); int getLogSearchReadTimeoutInMilliseconds(); void setLogSearchReadTimeoutInMilliseconds(int logSearchReadTimeoutInMilliseconds); LogQueryResponse sendQueryRequest(Map<String, String> queryParameters); Set<String> sendGetLogFileNamesRequest(String componentName, String hostName); @Override LogLevelQueryResponse sendLogLevelQueryRequest(String componentName, String hostName); @Override String createLogFileTailURI(String baseURI, String componentName, String hostName);  }