@@ -25,56 +25,56 @@ public final class ErrorTypeTest {
2525
2626    @ Test 
2727    public  void  testNameMustBeCamelCase () throws  Exception  {
28-         assertThatThrownBy (() -> ErrorType .of (ErrorType .Code .FAILED_PRECONDITION , "foo" ))
28+         assertThatThrownBy (() -> ErrorType .create (ErrorType .Code .FAILED_PRECONDITION , "foo" ))
2929                .isInstanceOf (IllegalArgumentException .class )
3030                .hasMessageStartingWith ("ErrorType names must be UpperCamelCase: foo" );
3131
32-         assertThatThrownBy (() -> ErrorType .custom ("foo" ,  400 ))
32+         assertThatThrownBy (() -> ErrorType .client ("foo" ))
3333                .isInstanceOf (IllegalArgumentException .class )
3434                .hasMessageStartingWith ("ErrorType names must be UpperCamelCase: foo" );
35-         assertThatThrownBy (() -> ErrorType .custom ("fooBar" ,  400 ))
35+         assertThatThrownBy (() -> ErrorType .client ("fooBar" ))
3636                .isInstanceOf (IllegalArgumentException .class )
3737                .hasMessageStartingWith ("ErrorType names must be UpperCamelCase: fooBar" );
38-         assertThatThrownBy (() -> ErrorType .custom ("" ,  400 ))
38+         assertThatThrownBy (() -> ErrorType .client ("" ))
3939                .isInstanceOf (IllegalArgumentException .class )
4040                .hasMessageStartingWith ("ErrorType names must be UpperCamelCase: " );
4141    }
4242
4343    @ Test 
4444    public  void  testDefaultErrorTypeHttpErrorCodes () throws  Exception  {
45-         assertThat (ErrorType .UNKNOWN .httpErrorCode ()).isEqualTo (500 );
4645        assertThat (ErrorType .PERMISSION_DENIED .httpErrorCode ()).isEqualTo (403 );
4746        assertThat (ErrorType .INVALID_ARGUMENT .httpErrorCode ()).isEqualTo (400 );
48-         assertThat (ErrorType .FAILED_PRECONDITION .httpErrorCode ()).isEqualTo (400 );
47+         assertThat (ErrorType .FAILED_PRECONDITION .httpErrorCode ()).isEqualTo (500 );
4948        assertThat (ErrorType .INTERNAL .httpErrorCode ()).isEqualTo (500 );
5049    }
5150
5251    @ Test 
5352    public  void  testCustomErrors () throws  Exception  {
54-         ErrorType  custom400  = ErrorType .custom ("MyDesc" ,  400 );
55-         assertThat (custom400 .code ()).isEqualTo (ErrorType .Code .CUSTOM );
56-         assertThat (custom400 .httpErrorCode ()).isEqualTo (400 );
57-         assertThat (custom400 .name ()).isEqualTo ("MyDesc" );
53+         ErrorType  customClient  = ErrorType .client ("MyDesc" );
54+         assertThat (customClient .code ()).isEqualTo (ErrorType .Code .CUSTOM_CLIENT );
55+         assertThat (customClient .httpErrorCode ()).isEqualTo (400 );
56+         assertThat (customClient .name ()).isEqualTo ("MyDesc" );
5857
59-         ErrorType  custom500  = ErrorType .custom ("MyDesc" , 500 );
60-         assertThat (custom500 .code ()).isEqualTo (ErrorType .Code .CUSTOM );
61-         assertThat (custom500 .httpErrorCode ()).isEqualTo (500 );
62-         assertThat (custom500 .name ()).isEqualTo ("MyDesc" );
63- 
64-         assertThatThrownBy (() -> ErrorType .custom ("MyDesc" , 403 ))
65-                 .isInstanceOf (IllegalArgumentException .class )
66-                 .hasMessage ("CUSTOM ErrorTypes must have HTTP error code 400 or 500" );
58+         ErrorType  customServer  = ErrorType .server ("MyDesc" );
59+         assertThat (customServer .code ()).isEqualTo (ErrorType .Code .CUSTOM_SERVER );
60+         assertThat (customServer .httpErrorCode ()).isEqualTo (500 );
61+         assertThat (customServer .name ()).isEqualTo ("MyDesc" );
6762    }
6863
6964    @ Test 
7065    public  void  testCanCreateNewErrorTypes () throws  Exception  {
71-         ErrorType  error  = ErrorType .of (ErrorType .Code .FAILED_PRECONDITION , "MyDesc" );
66+         ErrorType  error  = ErrorType .create (ErrorType .Code .FAILED_PRECONDITION , "MyDesc" );
7267        assertThat (error .code ()).isEqualTo (ErrorType .Code .FAILED_PRECONDITION );
73-         assertThat (error .httpErrorCode ()).isEqualTo (400 );
68+         assertThat (error .httpErrorCode ()).isEqualTo (500 );
7469        assertThat (error .name ()).isEqualTo ("MyDesc" );
7570
76-         assertThatThrownBy (() -> ErrorType .of (ErrorType .Code .CUSTOM , "MyDesc" ))
71+         assertThatThrownBy (() -> ErrorType .create (ErrorType .Code .CUSTOM_CLIENT , "MyDesc" ))
72+                 .isInstanceOf (IllegalArgumentException .class )
73+                 .hasMessage ("Use the client() or server() methods to construct ErrorTypes with code CUSTOM_CLIENT " 
74+                         + "or CUSTOM_SERVER" );
75+         assertThatThrownBy (() -> ErrorType .create (ErrorType .Code .CUSTOM_SERVER , "MyDesc" ))
7776                .isInstanceOf (IllegalArgumentException .class )
78-                 .hasMessage ("Use the custom() method to construct ErrorTypes with code CUSTOM" );
77+                 .hasMessage ("Use the client() or server() methods to construct ErrorTypes with code CUSTOM_CLIENT " 
78+                         + "or CUSTOM_SERVER" );
7979    }
8080}
0 commit comments