@Test public void testGetAdressNotInRegistry() { when(this.location.getName()).thenReturn("friend"); List<Location> locations = new ArrayList<>(); locations.add(this.location2); locations.add(this.location); when(this.location2.getName()).thenReturn("other"); when(this.registry.getAll()).thenReturn(locations); assertThat(this.connection.getAddress("bla"), equalTo("bla")); }
public String getAddress(String name) { Location address = null; List<Location> locations = this.locationRegistry.getEntitiesWithTag(name); if (!locations.isEmpty()) { address = locations.get(0); } else { for (Location location : this.locationRegistry.getAll()) { if (name.equalsIgnoreCase(location.getName()) || name.equalsIgnoreCase(location.getTag())) { address = location; break; } } } if (address == null) { return name; } return address.getAddressString(); }
RegistryConnection { public String getAddress(String name) { Location address = null; List<Location> locations = this.locationRegistry.getEntitiesWithTag(name); if (!locations.isEmpty()) { address = locations.get(0); } else { for (Location location : this.locationRegistry.getAll()) { if (name.equalsIgnoreCase(location.getName()) || name.equalsIgnoreCase(location.getTag())) { address = location; break; } } } if (address == null) { return name; } return address.getAddressString(); } }
RegistryConnection { public String getAddress(String name) { Location address = null; List<Location> locations = this.locationRegistry.getEntitiesWithTag(name); if (!locations.isEmpty()) { address = locations.get(0); } else { for (Location location : this.locationRegistry.getAll()) { if (name.equalsIgnoreCase(location.getName()) || name.equalsIgnoreCase(location.getTag())) { address = location; break; } } } if (address == null) { return name; } return address.getAddressString(); }  }
RegistryConnection { public String getAddress(String name) { Location address = null; List<Location> locations = this.locationRegistry.getEntitiesWithTag(name); if (!locations.isEmpty()) { address = locations.get(0); } else { for (Location location : this.locationRegistry.getAll()) { if (name.equalsIgnoreCase(location.getName()) || name.equalsIgnoreCase(location.getTag())) { address = location; break; } } } if (address == null) { return name; } return address.getAddressString(); }  String getAddress(String name); }
RegistryConnection { public String getAddress(String name) { Location address = null; List<Location> locations = this.locationRegistry.getEntitiesWithTag(name); if (!locations.isEmpty()) { address = locations.get(0); } else { for (Location location : this.locationRegistry.getAll()) { if (name.equalsIgnoreCase(location.getName()) || name.equalsIgnoreCase(location.getTag())) { address = location; break; } } } if (address == null) { return name; } return address.getAddressString(); }  String getAddress(String name);  }