package io.ljunggren.fedex.api.model;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import org.junit.Test;
public class HttpStatusCodeTest {
@Test
public void getByCodeKnownTest() {
assertEquals(HttpStatusCode.OK, HttpStatusCode.getByCode(200));
assertEquals(HttpStatusCode.THROTTLING, HttpStatusCode.getByCode(429));
assertEquals(HttpStatusCode.INVALID_INPUT, HttpStatusCode.getByCode(422));
assertEquals(HttpStatusCode.SERVER_ERROR, HttpStatusCode.getByCode(500));
assertEquals(HttpStatusCode.SERVICE_UNAVAILABLE, HttpStatusCode.getByCode(503));
}
@Test
public void getByCodeUnknownTest() {
assertNull(HttpStatusCode.getByCode(404));
}
@Test
public void getTextByCodeKnownTest() {
assertEquals("Too many requests", HttpStatusCode.getTextByCode(429));
}
@Test
public void getTextByCodeUnknownTest() {
assertNull(HttpStatusCode.getTextByCode(404));
}
@Test
public void isRetryableTest() {
assertTrue(HttpStatusCode.THROTTLING.isRetryable());
assertTrue(HttpStatusCode.SERVER_ERROR.isRetryable());
assertTrue(HttpStatusCode.SERVICE_UNAVAILABLE.isRetryable());
assertFalse(HttpStatusCode.OK.isRetryable());
assertFalse(HttpStatusCode.INVALID_INPUT.isRetryable());
}
}