Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: test CI #183

Merged
merged 1 commit into from
May 7, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 20 additions & 20 deletions src/test/java/com/whatsapp/api/WhatsappApiServiceGeneratorTest.java
Original file line number Diff line number Diff line change
@@ -1,34 +1,38 @@
package com.whatsapp.api;

import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;

import java.io.IOException;
import java.net.ProxySelector;
import java.net.URISyntaxException;

import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

import com.whatsapp.api.domain.errors.WhatsappApiError;
import com.whatsapp.api.exception.WhatsappApiException;
import com.whatsapp.api.utils.proxy.CustomHttpProxySelector;
import com.whatsapp.api.utils.proxy.CustomProxyAuthenticator;

import okhttp3.Authenticator;
import okhttp3.MediaType;
import okhttp3.OkHttpClient;
import okhttp3.ResponseBody;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import retrofit2.Response;

public class WhatsappApiServiceGeneratorTest extends TestUtils {
import java.io.IOException;
import java.net.ProxySelector;
import java.net.URISyntaxException;

import static org.junit.jupiter.api.Assertions.*;


class WhatsappApiServiceGeneratorTest extends TestUtils {

@BeforeEach
void resetProxy() {
WhatsappApiServiceGenerator.sharedClient = WhatsappApiServiceGenerator.createDefaultHttpClient();
}


@AfterAll
static void resetSharedOkHttpClientToDefault() {
// reset the OkHttpClient to its default settings, preventing errors in other tests that do not utilize a proxy
WhatsappApiServiceGenerator.sharedClient = WhatsappApiServiceGenerator.createDefaultHttpClient();
}

/**
* Method under test:
* {@link WhatsappApiServiceGenerator#getSharedClient}
Expand All @@ -44,10 +48,6 @@ void testGetSharedClient() {
/**
* Method under test:
* {@link WhatsappApiServiceGenerator#getWhatsappApiError}
*
* @throws IOException
* @throws URISyntaxException
* @throws WhatsappApiException
*/
@Test
void testGetWhatsappApiError() throws IOException, URISyntaxException {
Expand All @@ -60,8 +60,8 @@ void testGetWhatsappApiError() throws IOException, URISyntaxException {
assertEquals(136025, apiError.error().code(), "Error code should be 136025");
assertEquals(2388093, apiError.error().errorSubcode(), "Error code should be 136025");
assertEquals(false, apiError.error().isTransient(), "Error code should be 136025");
assertEquals("O c\u00F3digo inserido est\u00E1 incorreto.", apiError.error().errorUserMsg(), "Error code should be 136025");
assertEquals("N\u00E3o foi poss\u00EDvel verificar o c\u00F3digo", apiError.error().errorUserSubtitle(), "Error code should be 136025");
assertEquals("O código inserido está incorreto.", apiError.error().errorUserMsg(), "Error code should be 136025");
assertEquals("Não foi possível verificar o código", apiError.error().errorUserSubtitle(), "Error code should be 136025");

}

Expand Down