44
55import com .google .api .gax .grpc .ChannelPoolSettings ;
66import com .google .cloud .bigtable .gaxx .grpc .BigtableChannelPoolSettings ;
7- import java .lang .reflect .Modifier ;
8- import java .util .Set ;
97import com .google .common .collect .ImmutableSet ;
108import java .lang .reflect .Method ;
9+ import java .lang .reflect .Modifier ;
1110import java .util .Arrays ;
11+ import java .util .Set ;
1212import java .util .stream .Collectors ;
1313import org .junit .Rule ;
1414import org .junit .Test ;
@@ -33,14 +33,16 @@ public void testToBigtableChannelPoolSettingsAllFieldsSetCopiesCorrectly() throw
3333 .setPreemptiveRefreshEnabled (true )
3434 .build ();
3535
36- BigtableChannelPoolSettings copiedSettings = BigtableChannelPoolSettings .copyFrom (originalSettings );
36+ BigtableChannelPoolSettings copiedSettings =
37+ BigtableChannelPoolSettings .copyFrom (originalSettings );
3738 assertSettingsCopiedCorrectly (originalSettings , copiedSettings );
3839 }
3940
4041 @ Test
4142 public void testToBigtableChannelPoolSettingsDefaultValuesCopiesCorrectly () throws Exception {
4243 ChannelPoolSettings originalSettings = ChannelPoolSettings .builder ().build ();
43- BigtableChannelPoolSettings copiedSettings = BigtableChannelPoolSettings .copyFrom (originalSettings );
44+ BigtableChannelPoolSettings copiedSettings =
45+ BigtableChannelPoolSettings .copyFrom (originalSettings );
4446 assertSettingsCopiedCorrectly (originalSettings , copiedSettings );
4547 }
4648
@@ -56,25 +58,45 @@ private void assertSettingsCopiedCorrectly(
5658 ChannelPoolSettings originalSettings , BigtableChannelPoolSettings copiedSettings )
5759 throws Exception {
5860
59- Set <String > supportedGetters = ImmutableSet .of ("getMinRpcsPerChannel" , "getMaxRpcsPerChannel" , "getMinChannelCount" , "getMaxChannelCount" , "getInitialChannelCount" , "isPreemptiveRefreshEnabled" , "isStaticSize" );
61+ Set <String > supportedGetters =
62+ ImmutableSet .of (
63+ "getMinRpcsPerChannel" ,
64+ "getMaxRpcsPerChannel" ,
65+ "getMinChannelCount" ,
66+ "getMaxChannelCount" ,
67+ "getInitialChannelCount" ,
68+ "isPreemptiveRefreshEnabled" ,
69+ "isStaticSize" );
6070
61- Set <String > actualGetters = Arrays .stream (ChannelPoolSettings .class .getDeclaredMethods ())
62- .filter (method -> Modifier .isPublic (method .getModifiers ())
63- && Modifier .isAbstract (method .getModifiers ())
64- && (method .getName ().startsWith ("get" ) || method .getName ().startsWith ("is" )))
65- .map (Method ::getName )
66- .collect (Collectors .toSet ());
71+ Set <String > actualGetters =
72+ Arrays .stream (ChannelPoolSettings .class .getDeclaredMethods ())
73+ .filter (
74+ method ->
75+ Modifier .isPublic (method .getModifiers ())
76+ && Modifier .isAbstract (method .getModifiers ())
77+ && (method .getName ().startsWith ("get" )
78+ || method .getName ().startsWith ("is" )))
79+ .map (Method ::getName )
80+ .collect (Collectors .toSet ());
6781
68- // If this fails then we need to add support for the additional attributes on the gax ChannelPool
82+ // If this fails then we need to add support for the additional attributes on the gax
83+ // ChannelPool
6984 // Relevant things to update the copier and the other tests in this file
7085 assertThat (supportedGetters ).containsAtLeastElementsIn (actualGetters );
7186
72- assertThat (originalSettings .getInitialChannelCount ()).isEqualTo (copiedSettings .getInitialChannelCount ());
73- assertThat (originalSettings .getMaxChannelCount ()).isEqualTo (copiedSettings .getMaxChannelCount ());
74- assertThat (originalSettings .getMinChannelCount ()).isEqualTo (copiedSettings .getMinChannelCount ());
75- assertThat (originalSettings .getMaxRpcsPerChannel ()).isEqualTo (copiedSettings .getMaxRpcsPerChannel ());
76- assertThat (originalSettings .getMinRpcsPerChannel ()).isEqualTo (copiedSettings .getMinRpcsPerChannel ());
77- assertThat (originalSettings .getInitialChannelCount ()).isEqualTo (copiedSettings .getInitialChannelCount ());
78- assertThat (originalSettings .isPreemptiveRefreshEnabled ()).isEqualTo (copiedSettings .isPreemptiveRefreshEnabled ());
87+ assertThat (originalSettings .getInitialChannelCount ())
88+ .isEqualTo (copiedSettings .getInitialChannelCount ());
89+ assertThat (originalSettings .getMaxChannelCount ())
90+ .isEqualTo (copiedSettings .getMaxChannelCount ());
91+ assertThat (originalSettings .getMinChannelCount ())
92+ .isEqualTo (copiedSettings .getMinChannelCount ());
93+ assertThat (originalSettings .getMaxRpcsPerChannel ())
94+ .isEqualTo (copiedSettings .getMaxRpcsPerChannel ());
95+ assertThat (originalSettings .getMinRpcsPerChannel ())
96+ .isEqualTo (copiedSettings .getMinRpcsPerChannel ());
97+ assertThat (originalSettings .getInitialChannelCount ())
98+ .isEqualTo (copiedSettings .getInitialChannelCount ());
99+ assertThat (originalSettings .isPreemptiveRefreshEnabled ())
100+ .isEqualTo (copiedSettings .isPreemptiveRefreshEnabled ());
79101 }
80- }
102+ }
0 commit comments