DockerUtils { public static DockerClient createDockerClient( Map<String,String> targetProperties ) throws TargetException { Logger logger = Logger.getLogger( DockerHandler.class.getName()); logger.fine( "Setting the target properties." ); String edpt = targetProperties.get( DockerHandler.ENDPOINT ); if( Utils.isEmptyOrWhitespaces( edpt )) edpt = DockerHandler.DEFAULT_ENDPOINT; Builder config = DefaultDockerClientConfig.createDefaultConfigBuilder() .withDockerHost( edpt ) .withRegistryUsername( targetProperties.get( DockerHandler.USER )) .withRegistryPassword( targetProperties.get( DockerHandler.PASSWORD )) .withRegistryEmail( targetProperties.get( DockerHandler.EMAIL )) .withApiVersion( targetProperties.get( DockerHandler.VERSION )); DockerClientBuilder clientBuilder = DockerClientBuilder.getInstance( config.build()); return clientBuilder.build(); } private  DockerUtils(); static DockerClient createDockerClient( Map<String,String> targetProperties ); static void deleteImageIfItExists( String imageId, DockerClient dockerClient ); static Image findImageByIdOrByTag( String name, DockerClient dockerClient ); static Image findImageById( String imageId, List<Image> images ); static Image findImageByTag( String imageTag, List<Image> images ); static Container findContainerByIdOrByName( String name, DockerClient dockerClient ); static ContainerState getContainerState( String containerId, DockerClient dockerClient ); static void configureOptions( Map<String,String> options, CreateContainerCmd cmd ); static Object prepareParameter( String rawValue, Class<?> clazz ); static boolean extractBoolean( Boolean bool ); static String findDefaultImageVersion( String rawVersion ); static String buildContainerNameFrom( String scopedInstancePath, String applicationName ); static final String LATEST; }
@Test public void testEmptyConfiguration() throws Exception { Map<String,String> map = new HashMap<> (); DockerClient client = DockerUtils.createDockerClient( map ); Assert.assertNotNull( client ); }