### Question:
DefaultRegistryClient implements RegistryClient { @Override public Publisher register(PublisherRegistration registration, String... data) { if (!init.get()) { throw new IllegalStateException("Client needs to be initialized before using."); } if (null == registration) { throw new IllegalArgumentException("Registration can not be null."); } if (StringUtils.isBlank(registration.getDataId())) { throw new IllegalArgumentException("DataId can not be null"); } if (StringUtils.isBlank(registration.getGroup())) { registration.setGroup(DEFAULT_GROUP); } Publisher publisher = registrationPublisherMap.get(registration); if (null != publisher) { throwDuplicateException(registration, publisher); } publisher = new DefaultPublisher(registration, workerThread, registryClientConfig); ((DefaultPublisher) publisher).setAuthManager(authManager); Publisher oldPublisher = registrationPublisherMap.putIfAbsent(registration, publisher); if (null != oldPublisher) { throwDuplicateException(registration, oldPublisher); } registerCache.addRegister(publisher); publisher.republish(data); LOGGER.info("[api] Regist publisher success, dataId: {}, group: {}, registerId: {}", publisher.getDataId(), publisher.getGroup(), publisher.getRegistId()); return publisher; } DefaultRegistryClient(RegistryClientConfig registryClientConfig); void init(); @Override Publisher register(PublisherRegistration registration, String... data); @Override Subscriber register(SubscriberRegistration registration); @Override Configurator register(ConfiguratorRegistration registration); @Override int unregister(String dataId, String group, RegistryType registryType); RegisterCache getRegisterCache(); void setUserProcessorMap(Map<Class<?>, UserProcessor> userProcessorMap); void setConnectionEventProcessorMap(Map<ConnectionEventType, ConnectionEventProcessor> connectionEventProcessorMap); void setObserverHandler(ObserverHandler observerHandler); void setServerManager(ServerManager serverManager); void setAuthManager(AuthManager authManager); void setLookoutSubscriber(LookoutSubscriber lookoutSubscriber); void setEventBus(EventBus eventBus);  }### Answer:
@Test public void testSetAppNameByRegistration() { PublisherRegistration publisherRegistration = new PublisherRegistration(dataId); final String testApp = "test-app"; publisherRegistration.setAppName(testApp); Publisher publisher = registryClient.register(publisherRegistration); PublisherRegister register = ((DefaultPublisher) publisher).assembly(); assertEquals(testApp, register.getAppName()); SubscriberRegistration subscriberRegistration = new SubscriberRegistration(dataId, mock(SubscriberDataObserver.class)); subscriberRegistration.setAppName(testApp); Subscriber subscriber = registryClient.register(subscriberRegistration); SubscriberRegister subscriberRegister = ((DefaultSubscriber) subscriber).assembly(); assertEquals(testApp, subscriberRegister.getAppName()); }
@Test public void testSetAppNameByConfig() { PublisherRegistration publisherRegistration = new PublisherRegistration(dataId); Publisher publisher = registryClient.register(publisherRegistration); PublisherRegister register = ((DefaultPublisher) publisher).assembly(); assertEquals(appName, register.getAppName()); }