A java implementation of the Binance API Specification
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.8 KiB

package com.sigmaflare.binancej;
import com.sigmaflare.binancej.entities.ServiceError;
import com.sigmaflare.binancej.exceptions.InternalServiceErrorException;
import com.sigmaflare.binancej.exceptions.IpBannedException;
import com.sigmaflare.binancej.exceptions.MalformedRequestException;
import com.sigmaflare.binancej.exceptions.RateLimitExceededException;
import org.junit.Test;
public class HttpErrorThrowerTests {
@Test(expected = IpBannedException.class)
public void testIpBannedOnHttpCode418() throws Exception {
throw HttpRequests.buildHttpException(418, ServiceError.builder().message("TEST").code(418).build());
}
@Test(expected = RateLimitExceededException.class)
public void testRateLimitOnHttpCode421() throws Exception {
throw HttpRequests.buildHttpException(429, ServiceError.builder().message("TEST").code(429).build());
}
@Test(expected = MalformedRequestException.class)
public void testMalformedRequestOnHttpCode400() throws Exception {
throw HttpRequests.buildHttpException(400, ServiceError.builder().message("TEST").code(400).build());
}
@Test(expected = InternalServiceErrorException.class)
public void testInternalServiceErrorOnHttpCode500() throws Exception {
throw HttpRequests.buildHttpException(500, ServiceError.builder().message("TEST").code(500).build());
}
@Test(expected = InternalServiceErrorException.class)
public void testInternalServiceErrorOnHttpCode504() throws Exception {
throw HttpRequests.buildHttpException(504, ServiceError.builder().message("TEST").code(504).build());
}
@Test(expected = IllegalArgumentException.class)
public void testInternalServiceThrowsOn200Ok() throws Exception {
throw HttpRequests.buildHttpException(200, ServiceError.builder().message("TEST").code(200).build());
}
}