@Test
public void serviceOnConnectedTest() {

  final GrpcTccCoordinateCommand coordinateCommand =
      GrpcTccCoordinateCommand.newBuilder()
          .setGlobalTxId(globalTxId)
          .setLocalTxId(localTxId)
          .setParentTxId(parentTxId)
          .setMethod(methodName)
          .setServiceName(serviceName)
      .build();
  final GrpcServiceConfig[] requestCaptor = new GrpcServiceConfig[1];
  TccEventServiceImplBase serviceImpl = new TccEventServiceImplBase() {
    @Override
    public void onConnected(GrpcServiceConfig request, StreamObserver<GrpcTccCoordinateCommand> responseObserver) {
      requestCaptor[0] = request;
      // Just send the coordinateCommand back
      responseObserver.onNext(coordinateCommand);
      responseObserver.onCompleted();
    }
  };
  serviceRegistry.addService(serviceImpl);
  service.onConnected();
  assertThat(requestCaptor[0].getServiceName(), is(serviceConfig.serviceName()));
  assertThat(requestCaptor[0].getInstanceId(), is(serviceConfig.instanceId()));
  verify(handler).onReceive(globalTxId, localTxId,parentTxId, methodName);
}