@@ -122,43 +122,47 @@ public void testEnableKeyManagementWithExceptionOnGetManagedKey() throws Excepti
122122
123123 @ Test
124124 public void testEnableKeyManagementWithClientSideServiceException () throws Exception {
125- doTestWithClientSideServiceException ((mockStub , networkError ) -> {
126- try {
127- when (mockStub .enableKeyManagement (any (), any ())).thenThrow (networkError );
128- } catch (ServiceException e ) {
129- // We are just setting up the mock, so no exception is expected here.
130- throw new RuntimeException ("Unexpected ServiceException" , e );
131- }
132- return null ;
133- }, (client ) -> {
134- try {
135- client .enableKeyManagement ("cust" , "namespace" );
136- } catch (IOException e ) {
137- throw new RuntimeException (e );
138- }
139- return null ;
140- });
125+ doTestWithClientSideServiceException (
126+ (mockStub , networkError ) -> {
127+ try {
128+ when (mockStub .enableKeyManagement (any (), any ())).thenThrow (networkError );
129+ } catch (ServiceException e ) {
130+ // We are just setting up the mock, so no exception is expected here.
131+ throw new RuntimeException ("Unexpected ServiceException" , e );
132+ }
133+ return null ;
134+ },
135+ (client ) -> {
136+ try {
137+ client .enableKeyManagement ("cust" , "namespace" );
138+ } catch (IOException e ) {
139+ throw new RuntimeException (e );
140+ }
141+ return null ;
142+ });
141143 }
142144
143145 @ Test
144146 public void testGetManagedKeysWithClientSideServiceException () throws Exception {
145147 // Similar test for getManagedKeys method
146- doTestWithClientSideServiceException ((mockStub , networkError ) -> {
147- try {
148- when (mockStub .getManagedKeys (any (), any ())).thenThrow (networkError );
149- } catch (ServiceException e ) {
150- // We are just setting up the mock, so no exception is expected here.
151- throw new RuntimeException ("Unexpected ServiceException" , e );
152- }
153- return null ;
154- }, (client ) -> {
155- try {
156- client .getManagedKeys ("cust" , "namespace" );
157- } catch (IOException | KeyException e ) {
158- throw new RuntimeException (e );
159- }
160- return null ;
161- });
148+ doTestWithClientSideServiceException (
149+ (mockStub , networkError ) -> {
150+ try {
151+ when (mockStub .getManagedKeys (any (), any ())).thenThrow (networkError );
152+ } catch (ServiceException e ) {
153+ // We are just setting up the mock, so no exception is expected here.
154+ throw new RuntimeException ("Unexpected ServiceException" , e );
155+ }
156+ return null ;
157+ },
158+ (client ) -> {
159+ try {
160+ client .getManagedKeys ("cust" , "namespace" );
161+ } catch (IOException | KeyException e ) {
162+ throw new RuntimeException (e );
163+ }
164+ return null ;
165+ });
162166 }
163167
164168 @ Test
@@ -213,22 +217,24 @@ public void testRotateSTKWithExceptionOnGetSystemKey() throws Exception {
213217
214218 @ Test
215219 public void testRotateSTKWithClientSideServiceException () throws Exception {
216- doTestWithClientSideServiceException ((mockStub , networkError ) -> {
217- try {
218- when (mockStub .rotateSTK (any (), any ())).thenThrow (networkError );
219- } catch (ServiceException e ) {
220- // We are just setting up the mock, so no exception is expected here.
221- throw new RuntimeException ("Unexpected ServiceException" , e );
222- }
223- return null ;
224- }, (client ) -> {
225- try {
226- client .rotateSTK ();
227- } catch (IOException e ) {
228- throw new RuntimeException (e );
229- }
230- return null ;
231- });
220+ doTestWithClientSideServiceException (
221+ (mockStub , networkError ) -> {
222+ try {
223+ when (mockStub .rotateSTK (any (), any ())).thenThrow (networkError );
224+ } catch (ServiceException e ) {
225+ // We are just setting up the mock, so no exception is expected here.
226+ throw new RuntimeException ("Unexpected ServiceException" , e );
227+ }
228+ return null ;
229+ },
230+ (client ) -> {
231+ try {
232+ client .rotateSTK ();
233+ } catch (IOException e ) {
234+ throw new RuntimeException (e );
235+ }
236+ return null ;
237+ });
232238 }
233239
234240 private void
0 commit comments