package com.github.dikhan.pagerduty.client.events;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class ApiServiceFactoryTest {

    @Test
    public void apiServiceFactoryProducesRightDefaultApiServiceImpl() {
        String eventApi = "eventApi";
        ApiServiceFactory apiServiceFactory = new ApiServiceFactory(eventApi);

        ApiService apiService = apiServiceFactory.getDefault();
        HttpApiServiceImpl httpApiService = new HttpApiServiceImpl(eventApi);
        assertThat(apiService).isExactlyInstanceOf(HttpApiServiceImpl.class);
        assertThat(apiService).isEqualTo(httpApiService);
    }

    @Test
    public void apiServiceFactoryWithProxyParamsProducesRightDefaultApiServiceImpl() {
        String eventApi = "eventApi";
        String proxyHost = "localhost";
        Integer proxyPort = 8080;
        ApiServiceFactory apiServiceFactory = new ApiServiceFactory(eventApi, proxyHost, proxyPort);

        ApiService apiService = apiServiceFactory.getDefault();
        HttpApiServiceImpl httpApiService = new HttpApiServiceImpl(eventApi, proxyHost, proxyPort);
        assertThat(apiService).isExactlyInstanceOf(HttpApiServiceImpl.class);
        assertThat(apiService).isEqualTo(httpApiService);
    }
}
@@ -45,16 +45,57 @@
 vents;%0A%0A
+import com.mashape.unirest.http.Unirest;%0A
 import o
@@ -1299,19 +1299,86 @@
 piService);%0A
+        // reset uni rest settings%0A        Unirest.setProxy(null);%0A
     %7D%0A%7D

reset Unirest proxy static settings so it does not affect other tests