### Question:
SpringCloudCommandRouter implements CommandRouter { @Override public void updateMembership(int loadFactor, CommandMessageFilter commandFilter) { Map<String, String> localServiceInstanceMetadata = localServiceInstance.getMetadata(); if (localServiceInstanceMetadata != null) { localServiceInstanceMetadata.put(LOAD_FACTOR, Integer.toString(loadFactor)); SerializedObject<String> serializedCommandFilter = serializer.serialize(commandFilter, String.class); localServiceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER, serializedCommandFilter.getData()); localServiceInstanceMetadata.put( SERIALIZED_COMMAND_FILTER_CLASS_NAME, serializedCommandFilter.getType().getName() ); } updateMembershipForServiceInstance(localServiceInstance, atomicConsistentHash) .ifPresent(consistentHashChangeListener::onConsistentHashChanged); } protected  SpringCloudCommandRouter(Builder builder); static Builder builder(); static boolean serviceInstanceMetadataContainsMessageRoutingInformation(ServiceInstance serviceInstance); @Override Optional<Member> findDestination(CommandMessage<?> commandMessage); @Override void updateMembership(int loadFactor, CommandMessageFilter commandFilter); @EventListener @SuppressWarnings("UnusedParameters") void resetLocalMembership(InstanceRegisteredEvent event); @EventListener @SuppressWarnings("UnusedParameters") void updateMemberships(HeartbeatEvent event);  }### Answer:
@Test public void testUpdateMembershipUpdatesLocalServiceInstanceWhenMetadataNull() { when(localServiceInstance.getMetadata()).thenReturn(null); CommandMessageFilter commandNameFilter = new CommandNameFilter(String.class.getName()); testSubject.updateMembership(LOAD_FACTOR, commandNameFilter); verifyZeroInteractions(consistentHashChangeListener); }
@Test public void testUpdateMemberShipUpdatesConsistentHash() { testSubject.updateMembership(LOAD_FACTOR, COMMAND_NAME_FILTER); AtomicReference<ConsistentHash> resultAtomicConsistentHash = getFieldValue(atomicConsistentHashField, testSubject); Set<Member> resultMemberSet = resultAtomicConsistentHash.get().getMembers(); assertFalse(resultMemberSet.isEmpty()); assertMember(LOCAL_MEMBER, resultMemberSet.iterator().next(), NOT_REGISTERED); }