2323import static org .mockito .Mockito .doReturn ;
2424import static org .mockito .Mockito .mock ;
2525
26- import com .aalyria .spacetime .api .nbi . v1alpha . Nbi . ListEntitiesRequest ;
27- import com .aalyria .spacetime .api .nbi . v1alpha . Nbi . ListEntitiesResponse ;
28- import com .aalyria .spacetime .api .nbi . v1alpha . NetOpsGrpc ;
26+ import com .aalyria .spacetime .api .model . v1 . ModelGrpc ;
27+ import com .aalyria .spacetime .api .model . v1 . ModelOuterClass . ListEntitiesRequest ;
28+ import com .aalyria .spacetime .api .model . v1 . ModelOuterClass . ListEntitiesResponse ;
2929import com .google .common .io .Resources ;
3030import com .google .gson .Gson ;
3131import com .sun .net .httpserver .HttpExchange ;
@@ -64,9 +64,9 @@ public class SpacetimeCallCredentialsTest {
6464 @ Rule
6565 public final MockOidcTokenHttpServer oidcTokenServer = new MockOidcTokenHttpServer (/* port= */ 0 );
6666
67- // Mocks the NBI server with a no-op implementation.
68- NetOpsGrpc . NetOpsImplBase netOpsServiceImpl =
69- mock (NetOpsGrpc . NetOpsImplBase .class , delegatesTo (new NetOpsGrpc . NetOpsImplBase () {}));
67+ // Mocks the Model server with a no-op implementation.
68+ ModelGrpc . ModelImplBase modelServiceImpl =
69+ mock (ModelGrpc . ModelImplBase .class , delegatesTo (new ModelGrpc . ModelImplBase () {}));
7070
7171 private static final String HOST = "nbi.example.spacetime.aalyria.com" ;
7272 private static final String AGENT_EMAIL = "some@example.com" ;
@@ -75,7 +75,7 @@ public class SpacetimeCallCredentialsTest {
7575 "eyJhbGciOiJSUzI1NiIsImtpZCI6IjcyMTk0YjI2MzU0YzIzYzBiYTU5YTZkNzUxZGZmYWEyNTg2NTkwNGUiLCJ0eXAiOiJKV1QifQ.eyJhdWQiOiJodHRwczovL3d3dy5nb29nbGVhcGlzLmNvbS9vYXV0aDIvdjQvdG9rZW4iLCJleHAiOjE2ODE3OTIzMTksImlhdCI6MTY4MTc4ODcxOSwiaXNzIjoiY2RwaS1hZ2VudEBhNWEtc3BhY2V0aW1lLWdrZS1iYWNrLWRldi5pYW0uZ3NlcnZpY2VhY2NvdW50LmNvbSIsInN1YiI6ImNkcGktYWdlbnRAYTVhLXNwYWNldGltZS1na2UtYmFjay1kZXYuaWFtLmdzZXJ2aWNlYWNjb3VudC5jb20iLCJ0YXJnZXRfYXVkaWVuY2UiOiI2MDI5MjQwMzEzOS1tZTY4dGpnYWpsNWRjZGJwbmxtMmVrODMwbHZzbnNscS5hcHBzLmdvb2dsZXVzZXJjb250ZW50LmNvbSJ9.QyOi7vkFCwdmjT4ChT3_yVY4ZObUJkZkYC0q7alF_thiotdJKRiSo1ZHp_XnS0nM4WSWcQYLGHUDdAMPS0R22brFGzCl8ndgNjqI38yp_LDL8QVTqnLBGUj-m3xB5wH17Q_Dt8riBB4IE-mSS8FB-R6sqSwn-seMfMDydScC0FrtOF3-2BCYpIAlf1AQKN083QdtKgNEVDi72npPr2MmsWV3tct6ydXHWNbxG423kfSD6vCZSUTvWXAuVjuOwnbc2LHZS04U-jiLpvHxu06OwHOQ5LoGVPyd69o8Ny_Bapd2m0YCX2xJr8_HH2nw1jH7EplFf-owbBYz9ZtQoQ2YTA" ;
7676 private static final String PATH_TO_PRIVATE_KEY =
7777 "com/aalyria/spacetime/authentication/resources/test_private_key.pem" ;
78- private static final String MOCK_NBI_SERVER_NAME = "mockNbiServer " ;
78+ private static final String MOCK_NBI_SERVER_NAME = "mockModelServer " ;
7979 // The number of threads to spawn in order to test the synchronization logic.
8080 private static final int NUM_THREADS = 100 ;
8181
@@ -124,13 +124,13 @@ public void handle(HttpExchange exchange) throws IOException {
124124
125125 @ Test
126126 public void testCustomCallCredentials () throws Exception {
127- // Creates a mock gRPC server for the NBI with an interceptor to verify
127+ // Creates a mock gRPC server with an interceptor to verify
128128 // requests' metadata.
129129 AtomicInteger numVerifiedOidcTokensReceived = new AtomicInteger (0 );
130130 grpcCleanup .register (
131131 InProcessServerBuilder .forName (MOCK_NBI_SERVER_NAME )
132132 .directExecutor ()
133- .addService (netOpsServiceImpl )
133+ .addService (modelServiceImpl )
134134 .intercept (
135135 new ServerInterceptor () {
136136 @ Override
@@ -152,15 +152,15 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
152152 grpcCleanup .register (
153153 InProcessChannelBuilder .forName (MOCK_NBI_SERVER_NAME ).directExecutor ().build ());
154154
155- // Mocks the listEntities method in the NBI to return an empty response when invoked.
155+ // Mocks the listEntities method to return an empty response when invoked.
156156 doAnswer (
157157 invocation -> {
158158 var streamObserver =
159159 (StreamObserver <ListEntitiesResponse >) invocation .getArguments ()[1 ];
160160 ResponseHelper .complete (streamObserver , ListEntitiesResponse .newBuilder ().build ());
161161 return null ;
162162 })
163- .when (netOpsServiceImpl )
163+ .when (modelServiceImpl )
164164 .listEntities (any (ListEntitiesRequest .class ), any (StreamObserver .class ));
165165
166166 String privateKey = Resources .toString (Resources .getResource (PATH_TO_PRIVATE_KEY ), UTF_8 );
@@ -180,7 +180,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
180180 for (int i = 0 ; i < NUM_THREADS ; ++i ) {
181181 executor .submit (
182182 () -> {
183- NetOpsGrpc .newBlockingStub (channel )
183+ ModelGrpc .newBlockingStub (channel )
184184 .withCallCredentials (callCredentials )
185185 .listEntities (ListEntitiesRequest .newBuilder ().build ());
186186 });
@@ -192,7 +192,7 @@ public <ReqT, RespT> ServerCall.Listener<ReqT> interceptCall(
192192 // Verifies that each thread successfully received a token from the OIDC Token
193193 // Service.
194194 assertEquals (NUM_THREADS , oidcTokenServer .numCalls .get ());
195- // Verifies that each thread passed a valid token to the mock NBI gRPC Server.
195+ // Verifies that each thread passed a valid token to the mock gRPC Server.
196196 assertEquals (NUM_THREADS , numVerifiedOidcTokensReceived .get ());
197197 }
198198
@@ -202,23 +202,22 @@ public void testTokenRefreshedAtExpirationTime() throws Exception {
202202 grpcCleanup .register (
203203 InProcessServerBuilder .forName (MOCK_NBI_SERVER_NAME )
204204 .directExecutor ()
205- .addService (netOpsServiceImpl )
205+ .addService (modelServiceImpl )
206206 .build ()
207207 .start ());
208208 ManagedChannel channel =
209209 grpcCleanup .register (
210210 InProcessChannelBuilder .forName (MOCK_NBI_SERVER_NAME ).directExecutor ().build ());
211211
212- // Mocks the listEntities method in the NBI to return an empty response when
213- // invoked.
212+ // Mocks the listEntities method to return an empty response when invoked.
214213 doAnswer (
215214 invocation -> {
216215 var streamObserver =
217216 (StreamObserver <ListEntitiesResponse >) invocation .getArguments ()[1 ];
218217 ResponseHelper .complete (streamObserver , ListEntitiesResponse .newBuilder ().build ());
219218 return null ;
220219 })
221- .when (netOpsServiceImpl )
220+ .when (modelServiceImpl )
222221 .listEntities (any (ListEntitiesRequest .class ), any (StreamObserver .class ));
223222
224223 String privateKey = Resources .toString (Resources .getResource (PATH_TO_PRIVATE_KEY ), UTF_8 );
@@ -239,7 +238,7 @@ public void testTokenRefreshedAtExpirationTime() throws Exception {
239238 fakeClock );
240239
241240 // Calls ListEntities so that an initial OIDC token is created.
242- NetOpsGrpc .newBlockingStub (channel )
241+ ModelGrpc .newBlockingStub (channel )
243242 .withCallCredentials (callCredentials )
244243 .listEntities (ListEntitiesRequest .newBuilder ().build ());
245244
@@ -257,7 +256,7 @@ public void testTokenRefreshedAtExpirationTime() throws Exception {
257256 for (int i = 0 ; i < NUM_THREADS ; ++i ) {
258257 executor .submit (
259258 () -> {
260- NetOpsGrpc .newBlockingStub (channel )
259+ ModelGrpc .newBlockingStub (channel )
261260 .withCallCredentials (callCredentials )
262261 .listEntities (ListEntitiesRequest .newBuilder ().build ());
263262 });
0 commit comments