1 /* 2 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved. 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"). 5 * You may not use this file except in compliance with the License. 6 * A copy of the License is located at 7 * 8 * http://aws.amazon.com/apache2.0 9 * 10 * or in the "license" file accompanying this file. This file is distributed 11 * on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either 12 * express or implied. See the License for the specific language governing 13 * permissions and limitations under the License. 14 */ 15 16 package software.amazon.awssdk.http; 17 18 import static org.assertj.core.api.Assertions.assertThat; 19 20 import org.junit.jupiter.api.Test; 21 22 public class HttpStatusFamilyTest { 23 @Test statusFamiliesAreMappedCorrectly()24 public void statusFamiliesAreMappedCorrectly() { 25 assertThat(HttpStatusFamily.of(-1)).isEqualTo(HttpStatusFamily.OTHER); 26 assertThat(HttpStatusFamily.of(HttpStatusCode.CONTINUE)).isEqualTo(HttpStatusFamily.INFORMATIONAL); 27 assertThat(HttpStatusFamily.of(HttpStatusCode.OK)).isEqualTo(HttpStatusFamily.SUCCESSFUL); 28 assertThat(HttpStatusFamily.of(HttpStatusCode.MOVED_PERMANENTLY)).isEqualTo(HttpStatusFamily.REDIRECTION); 29 assertThat(HttpStatusFamily.of(HttpStatusCode.NOT_FOUND)).isEqualTo(HttpStatusFamily.CLIENT_ERROR); 30 assertThat(HttpStatusFamily.of(HttpStatusCode.INTERNAL_SERVER_ERROR)).isEqualTo(HttpStatusFamily.SERVER_ERROR); 31 } 32 33 @Test matchingIsCorrect()34 public void matchingIsCorrect() { 35 assertThat(HttpStatusFamily.SUCCESSFUL.isOneOf()).isFalse(); 36 assertThat(HttpStatusFamily.SUCCESSFUL.isOneOf(null)).isFalse(); 37 assertThat(HttpStatusFamily.SUCCESSFUL.isOneOf(HttpStatusFamily.CLIENT_ERROR)).isFalse(); 38 assertThat(HttpStatusFamily.SUCCESSFUL.isOneOf(HttpStatusFamily.CLIENT_ERROR, HttpStatusFamily.SUCCESSFUL)).isTrue(); 39 assertThat(HttpStatusFamily.SUCCESSFUL.isOneOf(HttpStatusFamily.SUCCESSFUL, HttpStatusFamily.CLIENT_ERROR)).isTrue(); 40 assertThat(HttpStatusFamily.OTHER.isOneOf(HttpStatusFamily.values())).isTrue(); 41 } 42 } 43