// Path: src/main/java/com/stackify/api/common/http/HttpException.java
// public class HttpException extends Exception {
// 
// 	/**
// 	 * Serial version UID
// 	 */
// 	private static final long serialVersionUID = -6349485370575426368L;
// 	
// 	/**
// 	 * HTTP status code
// 	 */
// 	private final int statusCode;
// 	
// 	/**
// 	 * Constructor
// 	 * @param statusCode HTTP status code
// 	 */
// 	public HttpException(int statusCode) {
// 		this.statusCode = statusCode;
// 	}
// 
// 	/**
// 	 * @return the statusCode
// 	 */
// 	public int getStatusCode() {
// 		return statusCode;
// 	}
// 	
// 	/**
// 	 * @return True if 4xx status code
// 	 */
// 	public boolean isClientError() {
// 		return (HttpURLConnection.HTTP_BAD_REQUEST <= statusCode) && (statusCode < HttpURLConnection.HTTP_INTERNAL_ERROR);
// 	}
// }


import java.net.HttpURLConnection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.http.HttpException;
	/**
	 * testUpdateErrorAndClear
	 */
	@Test
	public void testUpdateErrorAndClear() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();		
		
		long beforeUpdate = System.currentTimeMillis();
		scheduler.update(new HttpException(HttpURLConnection.HTTP_INTERNAL_ERROR));
		long afterUpdate = System.currentTimeMillis();

		Assert.assertTrue(beforeUpdate <= scheduler.getLastHttpError());
		Assert.assertTrue(scheduler.getLastHttpError() <= afterUpdate);
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
		
		scheduler.update(10);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateWithIncreaseAndDecrease
	 */
	@Test
	public void testUpdateWithIncreaseAndDecrease() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();
		Assert.assertEquals(1000, scheduler.getScheduleDelay());

		scheduler.update(2);
// Path: src/main/java/com/stackify/api/common/http/HttpException.java
// public class HttpException extends Exception {
// 
// 	/**
// 	 * Serial version UID
// 	 */
// 	private static final long serialVersionUID = -6349485370575426368L;
// 	
// 	/**
// 	 * HTTP status code
// 	 */
// 	private final int statusCode;
// 	
// 	/**
// 	 * Constructor
// 	 * @param statusCode HTTP status code
// 	 */
// 	public HttpException(int statusCode) {
// 		this.statusCode = statusCode;
// 	}
// 
// 	/**
// 	 * @return the statusCode
// 	 */
// 	public int getStatusCode() {
// 		return statusCode;
// 	}
// 	
// 	/**
// 	 * @return True if 4xx status code
// 	 */
// 	public boolean isClientError() {
// 		return (HttpURLConnection.HTTP_BAD_REQUEST <= statusCode) && (statusCode < HttpURLConnection.HTTP_INTERNAL_ERROR);
// 	}
// }


// Path: src/test/java/com/stackify/api/common/log/LogBackgroundServiceSchedulerTest.java
import java.net.HttpURLConnection;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
import com.stackify.api.common.http.HttpException;

	/**
	 * testUpdateErrorAndClear
	 */
	@Test
	public void testUpdateErrorAndClear() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();		
		
		long beforeUpdate = System.currentTimeMillis();
		scheduler.update(new HttpException(HttpURLConnection.HTTP_INTERNAL_ERROR));
		long afterUpdate = System.currentTimeMillis();

		Assert.assertTrue(beforeUpdate <= scheduler.getLastHttpError());
		Assert.assertTrue(scheduler.getLastHttpError() <= afterUpdate);
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
		
		scheduler.update(10);
		
		Assert.assertEquals(0, scheduler.getLastHttpError());
		Assert.assertEquals(1000, scheduler.getScheduleDelay());
	}
	
	/**
	 * testUpdateWithIncreaseAndDecrease
	 */
	@Test
	public void testUpdateWithIncreaseAndDecrease() {
		LogBackgroundServiceScheduler scheduler = new LogBackgroundServiceScheduler();
		Assert.assertEquals(1000, scheduler.getScheduleDelay());

		scheduler.update(2);
		Assert.assertEquals(1250, scheduler.getScheduleDelay());