private void checkDeployment(Deployment deployment) {
    assertNotNull(deployment);
    assertNotNull(deployment.name(), "Name cannot be Null for Deployment" + deployment);
    assertTrue(
        deployment.roleList().size() > 0,
        "There should be atleast 1 Virtual machine for a deployment  ");
    assertNotNull(deployment.label(), "Label cannot be Null for Deployment" + deployment);

    Deployment.Slot slot = deployment.slot();
    assertTrue((slot == Deployment.Slot.PRODUCTION) || (slot == Deployment.Slot.STAGING));
    assertEquals(deployment.name(), DEPLOYMENT);
  }
  public void testCreate() {
    final DeploymentParams params =
        DeploymentParams.builder()
            .name(DEPLOYMENT)
            .os(OSImage.Type.LINUX)
            .sourceImageName(DeploymentApiLiveTest.IMAGE_NAME)
            .mediaLink(
                AzureComputeServiceAdapter.createMediaLink(
                    storageService.serviceName(), DEPLOYMENT))
            .username("test")
            .password("supersecurePassword1!")
            .size(RoleSize.Type.BASIC_A0)
            .externalEndpoints(
                ImmutableSet.of(DeploymentParams.ExternalEndpoint.inboundTcpToLocalPort(22, 22)))
            .build();
    final String requestId = api().create(params);
    assertTrue(operationSucceeded.apply(requestId), requestId);

    deployment = api().get(DEPLOYMENT);
    assertNotNull(deployment);
    assertTrue(deploymentCreated.apply(deployment), deployment.toString());
    assertThat(deployment.name()).isEqualTo(DEPLOYMENT);
    assertThat(deployment.status()).isEqualTo(Deployment.Status.RUNNING);
    assertThat(deployment.label()).isEqualTo(DEPLOYMENT);
    assertThat(deployment.slot()).isEqualTo(Deployment.Slot.PRODUCTION);
    assertThat(deployment.roleList().size()).isEqualTo(1);
    assertThat(deployment.roleInstanceList().size()).isEqualTo(1);
  }
  @Test(dependsOnMethods = "testGet")
  public void testDelete() {
    final List<Role> roles =
        api.getDeploymentApiForService(cloudService.name()).get(DEPLOYMENT).roleList();

    assertTrue(
        new ConflictManagementPredicate(api) {

          @Override
          protected String operation() {
            return api().delete(deployment.name());
          }
        }.apply(deployment.name()));

    assertTrue(deploymentGone.apply(deployment), deployment.toString());
    Logger.getAnonymousLogger().log(Level.INFO, "deployment deleted: {0}", deployment);

    assertTrue(
        new ConflictManagementPredicate(api) {

          @Override
          protected String operation() {
            return api.getCloudServiceApi().delete(cloudService.name());
          }
        }.apply(cloudService.name()));

    for (Role r : roles) {
      final Role.OSVirtualHardDisk disk = r.osVirtualHardDisk();
      if (disk != null) {
        assertTrue(
            new ConflictManagementPredicate(api) {

              @Override
              protected String operation() {
                return api.getDiskApi().delete(disk.diskName());
              }
            }.apply(disk.diskName()));
      }
    }
  }
 @Test(dependsOnMethods = "testCreate")
 public void testGet() {
   Deployment foundDeployment = api().get(deployment.name());
   assertThat(foundDeployment).isEqualToComparingFieldByField(deployment);
 }