@Test
  public void testNotifyAcquiredNode() throws ProActiveException, RMException {

    when(nodeSource.getName()).thenReturn("Node source Name");
    vmwareInfrastructure.nodeSource = nodeSource;
    vmwareInfrastructure.configure(
        "username",
        "password",
        "endpoint",
        "test.activeeon.com",
        "http://localhost:8088/connector-iaas",
        "vmware-image",
        "1",
        "512",
        "vmUsername",
        "vmPassword",
        "2",
        "3",
        "wget -nv test.activeeon.com/rest/node.jar",
        "-Dnew=value");

    vmwareInfrastructure.connectorIaasController = connectorIaasController;

    when(node.getProperty(VMWareInfrastructure.INSTANCE_ID_NODE_PROPERTY)).thenReturn("123");

    when(node.getNodeInformation()).thenReturn(nodeInformation);

    when(nodeInformation.getName()).thenReturn("nodename");

    vmwareInfrastructure.notifyAcquiredNode(node);

    assertThat(vmwareInfrastructure.nodesPerInstances.get("123").isEmpty(), is(false));
    assertThat(vmwareInfrastructure.nodesPerInstances.get("123").size(), is(1));
    assertThat(vmwareInfrastructure.nodesPerInstances.get("123").contains("nodename"), is(true));
  }
  @Test
  public void testAcquireNode() {

    when(nodeSource.getName()).thenReturn("Node source Name");
    vmwareInfrastructure.nodeSource = nodeSource;

    vmwareInfrastructure.configure(
        "username",
        "password",
        "endpoint",
        "test.activeeon.com",
        "http://localhost:8088/connector-iaas",
        "vmware-image",
        "512",
        "1",
        "vmUsername",
        "vmPassword",
        "1",
        "3",
        "wget -nv test.activeeon.com/rest/node.jar",
        "-Dnew=value");

    vmwareInfrastructure.connectorIaasController = connectorIaasController;

    vmwareInfrastructure.rmUrl = "http://test.activeeon.com";

    when(connectorIaasController.createInfrastructure(
            "node_source_name", "username", "password", "endpoint", false))
        .thenReturn("node_source_name");

    when(connectorIaasController.createInstances(
            "node_source_name", "node_source_name", "vmware-image", 1, 1, 512))
        .thenReturn(Sets.newHashSet("123", "456"));

    vmwareInfrastructure.acquireNode();

    verify(connectorIaasController, times(1)).waitForConnectorIaasToBeUP();

    verify(connectorIaasController)
        .createInfrastructure("node_source_name", "username", "password", "endpoint", false);

    verify(connectorIaasController)
        .createInstances("node_source_name", "node_source_name", "vmware-image", 1, 1, 512);

    verify(connectorIaasController, times(2))
        .executeScriptWithCredentials(
            anyString(), anyString(), anyList(), anyString(), anyString());
  }
  @Test(expected = IllegalArgumentException.class)
  public void tesConfigureNotEnoughParameters() {

    when(nodeSource.getName()).thenReturn("Node source Name");
    vmwareInfrastructure.nodeSource = nodeSource;

    vmwareInfrastructure.configure(
        "username",
        "password",
        "endpoint",
        "test.activeeon.com",
        "http://localhost:8088/connector-iaas",
        "publicKeyName",
        "2",
        "3",
        "wget -nv test.activeeon.com/rest/node.jar",
        "-Dnew=value");
  }
  @Test
  public void testRemoveNode() throws ProActiveException, RMException {
    when(nodeSource.getName()).thenReturn("Node source Name");
    vmwareInfrastructure.nodeSource = nodeSource;

    vmwareInfrastructure.configure(
        "username",
        "password",
        "endpoint",
        "test.activeeon.com",
        "http://localhost:8088/connector-iaas",
        "vmware-image",
        "1",
        "512",
        "vmUsername",
        "vmPassword",
        "2",
        "3",
        "wget -nv test.activeeon.com/rest/node.jar",
        "-Dnew=value");

    vmwareInfrastructure.connectorIaasController = connectorIaasController;

    when(node.getProperty(VMWareInfrastructure.INSTANCE_ID_NODE_PROPERTY)).thenReturn("123");

    when(node.getNodeInformation()).thenReturn(nodeInformation);

    when(node.getProActiveRuntime()).thenReturn(proActiveRuntime);

    when(nodeInformation.getName()).thenReturn("nodename");

    vmwareInfrastructure.nodesPerInstances.put("123", Sets.newHashSet("nodename"));

    vmwareInfrastructure.removeNode(node);

    verify(proActiveRuntime).killNode("nodename");

    verify(connectorIaasController).terminateInstance("node_source_name", "123");

    assertThat(vmwareInfrastructure.nodesPerInstances.isEmpty(), is(true));
  }
  @Test
  public void testConfigure() {
    when(nodeSource.getName()).thenReturn("Node source Name");
    vmwareInfrastructure.nodeSource = nodeSource;

    vmwareInfrastructure.configure(
        "username",
        "password",
        "endpoint",
        "test.activeeon.com",
        "http://localhost:8088/connector-iaas",
        "vmware-image",
        "1",
        "512",
        "vmUsername",
        "vmPassword",
        "2",
        "3",
        "wget -nv test.activeeon.com/rest/node.jar",
        "-Dnew=value");
  }
 @Test
 public void testGetDescription() {
   assertThat(
       vmwareInfrastructure.getDescription(),
       is("Handles nodes from the Amazon Elastic Compute Cloud Service."));
 }