@SuppressWarnings("unchecked") @Test public void testBlackListCleaning() { serviceInstanceMetadata.put(LOAD_FACTOR_KEY, Integer.toString(LOAD_FACTOR)); serviceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER_KEY, serializedCommandFilterData); serviceInstanceMetadata.put(SERIALIZED_COMMAND_FILTER_CLASS_NAME_KEY, serializedCommandFilterClassName); String serviceInstanceToBeBlackListedId = "toBeBlackListed"; ServiceInstance serviceInstanceToBeBlackListed = mock(ServiceInstance.class); when(serviceInstanceToBeBlackListed.getServiceId()).thenReturn(serviceInstanceToBeBlackListedId); when(serviceInstanceToBeBlackListed.getHost()).thenReturn("host"); when(serviceInstanceToBeBlackListed.getPort()).thenReturn(0); when(serviceInstanceToBeBlackListed.getMetadata()).thenReturn( Collections.emptyMap(), serviceInstanceMetadata ); when(discoveryClient.getServices()).thenReturn( ImmutableList.of(SERVICE_INSTANCE_ID, serviceInstanceToBeBlackListedId), ImmutableList.of(SERVICE_INSTANCE_ID), ImmutableList.of(SERVICE_INSTANCE_ID, serviceInstanceToBeBlackListedId) ); when(discoveryClient.getInstances(serviceInstanceToBeBlackListedId)).thenReturn(ImmutableList .of(serviceInstanceToBeBlackListed)); testSubject.updateMemberships(mock(HeartbeatEvent.class)); Set<ServiceInstance> blackListed = getFieldValue(blackListedServiceInstancesField, testSubject); assertEquals(1, blackListed.size()); assertEquals(serviceInstanceToBeBlackListedId, blackListed.iterator().next().getServiceId()); testSubject.updateMemberships(mock(HeartbeatEvent.class)); blackListed = getFieldValue(blackListedServiceInstancesField, testSubject); assertTrue(blackListed.isEmpty()); testSubject.updateMemberships(mock(HeartbeatEvent.class)); blackListed = getFieldValue(blackListedServiceInstancesField, testSubject); assertTrue(blackListed.isEmpty()); }
@EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } protected  SpringCloudCommandRouter(Builder builder); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } 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); }
SpringCloudCommandRouter implements CommandRouter { @EventListener @SuppressWarnings("UnusedParameters") public void updateMemberships(HeartbeatEvent event) { updateMemberships(); } 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);  }