@Test public void testSetHostsOnMachinesExecuteCorrectCommands() { TestApplication app = TestApplication.Factory.newManagedInstanceForTests(); SshMachineLocation location1 = mock(SshMachineLocation.class); SshMachineLocation location2 = mock(SshMachineLocation.class); TagSupport tagSupport = mock(TestTagSupport.class); when(location1.tags()).thenReturn(tagSupport); when(location2.tags()).thenReturn(tagSupport); List<Entity> entities = Lists.newArrayList( entityWithCustomLocation(app, "a.example.com", "1.2.3.4", location1), entityWithCustomLocation(app, "b.example.com", "1.2.4.3", location2)); EtcHostsManager.setHostsOnMachines(entities, Attributes.ADDRESS); ArgumentCaptor<List> argument1 = ArgumentCaptor.forClass(List.class); ArgumentCaptor<List> argument2 = ArgumentCaptor.forClass(List.class); verify(location1).execCommands(anyString(), argument1.capture()); verify(location2).execCommands(anyString(), argument2.capture()); assertTrue(argument1.getValue().toString().contains("a.example.com")); assertTrue(argument1.getValue().toString().contains("1.2.3.4")); assertTrue(argument2.getValue().toString().contains("b.example.com")); assertTrue(argument2.getValue().toString().contains("1.2.4.3")); }
public static void setHostsOnMachines(Iterable<? extends Entity> machines) { setHostsOnMachines(machines, Attributes.SUBNET_ADDRESS); }
EtcHostsManager { public static void setHostsOnMachines(Iterable<? extends Entity> machines) { setHostsOnMachines(machines, Attributes.SUBNET_ADDRESS); } }
EtcHostsManager { public static void setHostsOnMachines(Iterable<? extends Entity> machines) { setHostsOnMachines(machines, Attributes.SUBNET_ADDRESS); } private  EtcHostsManager(); }
EtcHostsManager { public static void setHostsOnMachines(Iterable<? extends Entity> machines) { setHostsOnMachines(machines, Attributes.SUBNET_ADDRESS); } private  EtcHostsManager(); static void setHostsOnMachines(Iterable<? extends Entity> machines); static void setHostsOnMachines(Iterable<? extends Entity> machines, AttributeSensor<String> addressSensor); static Map<String, String> gatherIpHostnameMapping(Iterable<? extends Entity> entities); static Map<String, String> gatherIpHostnameMapping(Iterable<? extends Entity> entities, AttributeSensor<String> addressSensor); }
EtcHostsManager { public static void setHostsOnMachines(Iterable<? extends Entity> machines) { setHostsOnMachines(machines, Attributes.SUBNET_ADDRESS); } private  EtcHostsManager(); static void setHostsOnMachines(Iterable<? extends Entity> machines); static void setHostsOnMachines(Iterable<? extends Entity> machines, AttributeSensor<String> addressSensor); static Map<String, String> gatherIpHostnameMapping(Iterable<? extends Entity> entities); static Map<String, String> gatherIpHostnameMapping(Iterable<? extends Entity> entities, AttributeSensor<String> addressSensor);  }