package com.centurylink.cloud.sdk.servers.services;

import com.centurylink.cloud.sdk.servers.AbstractServersSdkTest;
import com.centurylink.cloud.sdk.servers.client.domain.server.metadata.ServerMetadata;
import com.centurylink.cloud.sdk.servers.services.domain.Response;
import com.google.common.util.concurrent.ListenableFuture;
import com.google.inject.Inject;
import org.testng.annotations.AfterMethod;
import org.testng.annotations.AfterTest;
import org.testng.annotations.Test;

import static com.centurylink.cloud.sdk.servers.services.TestServerSupport.anyServerConfig;

/**
 * @author ilya.drabenia
 */
@Test(groups = "LongRunning")
public class CreateServerAsyncTest extends AbstractServersSdkTest {

    @Inject
    ServerService serverService;

    Response<ServerMetadata> createServerResponse;

    @Test
    public void testCreateServerAsync() throws Exception {
        ListenableFuture<Response<ServerMetadata>> future =
                serverService.createAsync(anyServerConfig().name("CSAC"));

        createServerResponse = future.get();

        assert createServerResponse.getResult().getId() != null;
    }

    @AfterMethod
    public void deleteTestServer() {
        createServerResponse
                .waitUntilComplete();

        serverService
                .delete(createServerResponse.getResult().asRefById())
                .waitUntilComplete();
    }

}

@@ -1211,36 +1211,32 @@
 nse%0A            
-    
 .waitUntilComple
@@ -1264,20 +1264,16 @@
 Service%0A
-    
         
@@ -1330,20 +1330,16 @@
 ById())%0A
-    
         

Improve integration test tear down functionality