// Path: src/main/java/com/stackify/api/common/ApiConfiguration.java
// @ToString
// @Getter
// @Builder(builderClassName = "Builder", toBuilder = true, builderMethodName = "newBuilder")
// public class ApiConfiguration {
// 
//     public static final String TRANSPORT_DIRECT = "direct";
//     public static final String TRANSPORT_AGENT_SOCKET = "agent_socket";
// 
//     private static final String DEFAULT_TRANSPORT = TRANSPORT_DIRECT;
//     private static final String DEFAULT_AGENT_SOCKET_PATH_UNIX = "/usr/local/stackify/stackify.sock";
// 
//     /**
//      * Default API URL
//      */
//     private static final String DEFAULT_API_URL = "https://api.stackify.com";
// 
//     /**
//      * API URL
//      */
//     private final String apiUrl;
// 
//     /**
//      * API Key
//      */
//     private final String apiKey;
// 
//     /**
//      * Application name
//      */
//     private final String application;
// 
//     /**
//      * Environment
//      */
//     private final String environment;
// 
//     /**
//      * Environment details
//      */
//     private final EnvironmentDetail envDetail;
// 
//     /**
//      * Add #SKIPJSON tag to messages containing Json
//      */
//     private final Boolean skipJson;
// 
//     /**
//      * Allow logging from com.stackify.*
//      */
//     private final Boolean allowComDotStackify;
// 
//     /**
//      * Http Proxy Host ie) 10.20.30.40
//      */
//     private final String httpProxyHost;
// 
//     /**
//      * Http Proxy Port ie) 8080
//      */
//     private final String httpProxyPort;
// 
//     private final String transport;
// 
//     /**
//      * @return the apiUrl
//      */
//     public String getApiUrl() {
//         return apiUrl != null ? apiUrl : DEFAULT_API_URL;
//     }
// 
//     public String getTransport() {
//         return transport != null ? transport : DEFAULT_TRANSPORT;
//     }
// 
//     public String getAgentSocketPath() {
//         return DEFAULT_AGENT_SOCKET_PATH_UNIX;
//     }
// }


import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.ApiConfiguration;

		HttpClient httpClient = new HttpClient(Mockito.mock(ApiConfiguration.class));
		
		String world = httpClient.post("path", "hello".getBytes());
		
		Assert.assertNotNull(world);
		Assert.assertEquals("world", world);
	}

	/**
	 * testPostWithHttpError
	 * @throws Exception 
	 */
	@Test(expected = HttpException.class)
	public void testPostWithHttpError() throws Exception {
		
		URL url = PowerMockito.mock(URL.class);
		PowerMockito.whenNew(URL.class).withArguments(Mockito.anyString()).thenReturn(url);
		
		HttpURLConnection connection = PowerMockito.mock(HttpURLConnection.class);
		
		PowerMockito.when(url.openConnection(Proxy.NO_PROXY)).thenReturn(connection);
		
		ByteArrayOutputStream postBody = new ByteArrayOutputStream();
		PowerMockito.when(connection.getOutputStream()).thenReturn(postBody);
		
		ByteArrayInputStream contents = new ByteArrayInputStream("world".getBytes());
		PowerMockito.when(connection.getInputStream()).thenReturn(contents);
		PowerMockito.when(connection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);

// Path: src/main/java/com/stackify/api/common/ApiConfiguration.java
// @ToString
// @Getter
// @Builder(builderClassName = "Builder", toBuilder = true, builderMethodName = "newBuilder")
// public class ApiConfiguration {
// 
//     public static final String TRANSPORT_DIRECT = "direct";
//     public static final String TRANSPORT_AGENT_SOCKET = "agent_socket";
// 
//     private static final String DEFAULT_TRANSPORT = TRANSPORT_DIRECT;
//     private static final String DEFAULT_AGENT_SOCKET_PATH_UNIX = "/usr/local/stackify/stackify.sock";
// 
//     /**
//      * Default API URL
//      */
//     private static final String DEFAULT_API_URL = "https://api.stackify.com";
// 
//     /**
//      * API URL
//      */
//     private final String apiUrl;
// 
//     /**
//      * API Key
//      */
//     private final String apiKey;
// 
//     /**
//      * Application name
//      */
//     private final String application;
// 
//     /**
//      * Environment
//      */
//     private final String environment;
// 
//     /**
//      * Environment details
//      */
//     private final EnvironmentDetail envDetail;
// 
//     /**
//      * Add #SKIPJSON tag to messages containing Json
//      */
//     private final Boolean skipJson;
// 
//     /**
//      * Allow logging from com.stackify.*
//      */
//     private final Boolean allowComDotStackify;
// 
//     /**
//      * Http Proxy Host ie) 10.20.30.40
//      */
//     private final String httpProxyHost;
// 
//     /**
//      * Http Proxy Port ie) 8080
//      */
//     private final String httpProxyPort;
// 
//     private final String transport;
// 
//     /**
//      * @return the apiUrl
//      */
//     public String getApiUrl() {
//         return apiUrl != null ? apiUrl : DEFAULT_API_URL;
//     }
// 
//     public String getTransport() {
//         return transport != null ? transport : DEFAULT_TRANSPORT;
//     }
// 
//     public String getAgentSocketPath() {
//         return DEFAULT_AGENT_SOCKET_PATH_UNIX;
//     }
// }


// Path: src/test/java/com/stackify/api/common/http/HttpClientTest.java
import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.net.HttpURLConnection;
import java.net.Proxy;
import java.net.URL;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.ApiConfiguration;


		HttpClient httpClient = new HttpClient(Mockito.mock(ApiConfiguration.class));
		
		String world = httpClient.post("path", "hello".getBytes());
		
		Assert.assertNotNull(world);
		Assert.assertEquals("world", world);
	}

	/**
	 * testPostWithHttpError
	 * @throws Exception 
	 */
	@Test(expected = HttpException.class)
	public void testPostWithHttpError() throws Exception {
		
		URL url = PowerMockito.mock(URL.class);
		PowerMockito.whenNew(URL.class).withArguments(Mockito.anyString()).thenReturn(url);
		
		HttpURLConnection connection = PowerMockito.mock(HttpURLConnection.class);
		
		PowerMockito.when(url.openConnection(Proxy.NO_PROXY)).thenReturn(connection);
		
		ByteArrayOutputStream postBody = new ByteArrayOutputStream();
		PowerMockito.when(connection.getOutputStream()).thenReturn(postBody);
		
		ByteArrayInputStream contents = new ByteArrayInputStream("world".getBytes());
		PowerMockito.when(connection.getInputStream()).thenReturn(contents);
		PowerMockito.when(connection.getResponseCode()).thenReturn(HttpURLConnection.HTTP_INTERNAL_ERROR);

		HttpClient httpClient = new HttpClient(Mockito.mock(ApiConfiguration.class));