HostRegistryImpl implements HostRegistry { @Override public ContainerHostInfo getContainerHostInfoByContainerName( final String containerName ) throws HostDisconnectedException { Preconditions.checkArgument( !StringUtils.isBlank( containerName ), "Invalid container name" ); for ( ResourceHostInfo resourceHostInfo : hosts.asMap().values() ) { for ( ContainerHostInfo containerHostInfo : resourceHostInfo.getContainers() ) { if ( containerName.equalsIgnoreCase( containerHostInfo.getContainerName() ) ) { return containerHostInfo; } } } throw new HostDisconnectedException( String.format( HOST_NOT_CONNECTED_MSG, containerName ) ); }  @Override void updateResourceHostEntryTimestamp( final String resourceHostId ); @Override ContainerHostInfo getContainerHostInfoById( final String id ); @Override ContainerHostInfo getContainerHostInfoByHostname( final String hostname ); @Override ContainerHostInfo getContainerHostInfoByContainerName( final String containerName ); @Override Set<ContainerHostInfo> getContainerHostsInfo(); @Override ResourceHostInfo getResourceHostInfoById( final String id ); @Override ResourceHostInfo getResourceHostInfoByHostname( final String hostname ); @Override Set<ResourceHostInfo> getResourceHostsInfo(); @Override ResourceHostInfo getResourceHostByContainerHost( final ContainerHostInfo containerHostInfo ); @Override HostInfo getHostInfoById( final String hostId ); @Override void removeResourceHost( final String id ); @Override void addHostListener( final HostListener listener ); @Override void removeHostListener( final HostListener listener ); void init(); void dispose(); @Override boolean pingHost( String hostIp );  }
@Test(expected = HostDisconnectedException.class) public void testGetContainerHostInfoByContainerName() throws Exception { assertNotNull( registry.getContainerHostInfoByContainerName( CONTAINER_HOSTNAME ) ); doReturn( "" ).when( containerHostInfo ).getContainerName(); registry.getContainerHostInfoByContainerName( CONTAINER_HOSTNAME ); }