@Test
@SuppressWarnings({ "unchecked", "rawtypes" })

public void testCreateContainer_success() throws Exception {
	CreateContainerCmd ccc = Mockito.mock( CreateContainerCmd.class );
	Mockito.when( ccc.withEnv( Mockito.anyListOf( String.class ))).thenReturn( ccc );
	Mockito.when( ccc.withBinds( Mockito.anyListOf( Bind.class ))).thenReturn( ccc );
	Mockito.when( ccc.withVolumes( Mockito.anyListOf( Volume.class ))).thenReturn( ccc );
	Mockito.when( ccc.withName( Mockito.anyString())).thenReturn( ccc );
	Mockito.when( this.dockerClient.createContainerCmd( Mockito.anyString())).thenReturn( ccc );
	CreateContainerResponse containerResponse = Mockito.mock( CreateContainerResponse.class );
	Mockito.when( ccc.exec()).thenReturn( containerResponse );
	Mockito.when( containerResponse.getId()).thenReturn( "cid" );
	StartContainerCmd scc = Mockito.mock( StartContainerCmd.class );
	Mockito.when( this.dockerClient.startContainerCmd( Mockito.anyString())).thenReturn( scc );
	// Create the container (mock)
	final String imageId = "toto";
	this.configurator.createContainer( imageId );
	// Check the client
	Mockito.verify( this.dockerClient ).createContainerCmd( imageId );
	Mockito.verify( this.dockerClient ).startContainerCmd( "cid" );
	Mockito.verifyNoMoreInteractions( this.dockerClient );
	// Check the user data
	Assert.assertEquals( 1, this.containerIdToVolume.size());
	File dir = this.containerIdToVolume.values().iterator().next();
	Assert.assertTrue( dir.isDirectory());
	Assert.assertTrue( new File( dir, USER_DATA_FILE ).isFile());
	// Check the creation request
	Mockito.verify( ccc ).withName( Mockito.anyString());
	ArgumentCaptor<List> env = ArgumentCaptor.forClass( List.class );
	Mockito.verify( ccc ).withEnv( env.capture());
	List<String> effectiveEnv = env.getValue();
	Assert.assertEquals( 2, effectiveEnv.size());
	Assert.assertEquals( "RBCF_VERSION=latest", effectiveEnv.get( 0 ));
	Assert.assertEquals( "AGENT_PARAMETERS=file:" + USER_DATA_DIR + USER_DATA_FILE, effectiveEnv.get( 1 ));
	// Volumes
	ArgumentCaptor<List> volumes = ArgumentCaptor.forClass( List.class );
	Mockito.verify( ccc ).withVolumes( volumes.capture());
	List<Volume> effectiveVolumes = volumes.getValue();
	Assert.assertNotNull( effectiveVolumes );
	Assert.assertEquals( 1, effectiveVolumes.size());
	Volume effectiveVolume = effectiveVolumes.get( 0 );
	Assert.assertNotNull( effectiveVolume );
	Assert.assertEquals( USER_DATA_DIR, effectiveVolume.getPath());
	// Bounds
	ArgumentCaptor<List> bounds = ArgumentCaptor.forClass( List.class );
	Mockito.verify( ccc ).withBinds( bounds.capture());
	List<Bind> effectiveBounds = bounds.getValue();
	Assert.assertNotNull( effectiveBounds );
	Assert.assertEquals( 1, effectiveBounds.size());
	Bind effectiveBind = effectiveBounds.get( 0 );
	Assert.assertNotNull( effectiveBind );
	Assert.assertEquals( dir.getAbsolutePath(), effectiveBind.getPath());
	Assert.assertEquals( effectiveVolume, effectiveBind.getVolume());
}