Package org.jclouds.cloudstack

Examples of org.jclouds.cloudstack.CloudStackClient


   @Test(expectedExceptions = IllegalStateException.class)
   public void testJobDoesntCompleteThrowsIllegalStateException() {
      String id = "1";
      String jobId = "2";

      CloudStackClient client = createMock(CloudStackClient.class);
      // the alwaysfalse predicate should blow up with IllegalStateException
      Predicate<String> jobComplete = Predicates.alwaysFalse();
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);

      expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(AsyncJob.builder().id(jobId).result("foo").build()).atLeastOnce();

      replay(client);
      replay(jobClient);
View Full Code Here


   @Test(expectedExceptions = UncheckedExecutionException.class)
   public void testJobWithErrorThrowsUncheckedExecutionException() {
      String id = "1";
      String jobId = "2";

      CloudStackClient client = createMock(CloudStackClient.class);
      Predicate<String> jobComplete = Predicates.alwaysTrue();
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);

      expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(
            AsyncJob.builder().id(jobId)
                  .error(AsyncJobError.builder().errorCode(ErrorCode.INTERNAL_ERROR).errorText("ERRROR").build())
                  .result("foo").build())
            .atLeastOnce();
View Full Code Here

         .associatedNetworkId(networkId).zoneId(zoneId).build();

   public void testReuseWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackClient client = createMock(CloudStackClient.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressClient addressClient = createMock(AddressClient.class);
      expect(client.getAddressClient()).andReturn(addressClient).atLeastOnce();

      // an address is available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of(address));
View Full Code Here

   }

   public void testAssociateWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackClient client = createMock(CloudStackClient.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressClient addressClient = createMock(AddressClient.class);
      expect(client.getAddressClient()).andReturn(addressClient).atLeastOnce();

      // no ip addresses available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of());
View Full Code Here

    }

    @Test
    public void testEnsureNetworkExistsWithProvidedExistingNetwork() throws Exception {
        final String networkId = "network-id-0123";
        final CloudStackClient mockClient = mock(CloudStackClient.class);
        final NetworkClient mockNetworkClient = mock(NetworkClient.class);
        final Network mockNetwork = mock(Network.class);
        final org.apache.provisionr.api.network.Network network = org.apache.provisionr.api.network.Network.builder()
            .option(NetworkOptions.EXISTING_NETWORK_ID, networkId).createNetwork();

        execution.setVariable(ProcessVariables.NETWORK_ID, networkId);

        when(pool.getNetwork()).thenReturn(network);
        when(mockClient.getNetworkClient()).thenReturn(mockNetworkClient);
        when(mockNetworkClient.getNetwork(networkId)).thenReturn(mockNetwork);
        when(mockNetwork.getId()).thenReturn(networkId);

        activity.execute(mockClient, pool, execution);
        assertThat(collector.getVariable(ProcessVariables.NETWORK_ID)).isEqualTo(networkId);
View Full Code Here

   public void testApply() {
      String id = "1";
      String jobId = "2";

      CloudStackClient client = createMock(CloudStackClient.class);
      Predicate<String> jobComplete = Predicates.alwaysTrue();
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);

      expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(AsyncJob.builder().id(jobId).result("foo").build()).atLeastOnce();

      replay(client);
      replay(jobClient);
View Full Code Here

   @Test(expectedExceptions = IllegalStateException.class)
   public void testJobDoesntCompleteThrowsIllegalStateException() {
      String id = "1";
      String jobId = "2";

      CloudStackClient client = createMock(CloudStackClient.class);
      // the alwaysfalse predicate should blow up with IllegalStateException
      Predicate<String> jobComplete = Predicates.alwaysFalse();
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);

      expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(AsyncJob.builder().id(jobId).result("foo").build()).atLeastOnce();

      replay(client);
      replay(jobClient);
View Full Code Here

   @Test(expectedExceptions = UncheckedExecutionException.class)
   public void testJobWithErrorThrowsUncheckedExecutionException() {
      String id = "1";
      String jobId = "2";

      CloudStackClient client = createMock(CloudStackClient.class);
      Predicate<String> jobComplete = Predicates.alwaysTrue();
      AsyncJobClient jobClient = createMock(AsyncJobClient.class);

      expect(client.getAsyncJobClient()).andReturn(jobClient).atLeastOnce();
      expect(jobClient.getAsyncJob(jobId)).andReturn(
            AsyncJob.builder().id(jobId)
                  .error(AsyncJobError.builder().errorCode(ErrorCode.INTERNAL_ERROR).errorText("ERRROR").build())
                  .result("foo").build())
            .atLeastOnce();
View Full Code Here

         .associatedNetworkId(networkId).zoneId(zoneId).build();

   public void testReuseWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackClient client = createMock(CloudStackClient.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressClient addressClient = createMock(AddressClient.class);
      expect(client.getAddressClient()).andReturn(addressClient).atLeastOnce();

      // an address is available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of(address));
View Full Code Here

   }

   public void testAssociateWorks() throws SecurityException, NoSuchMethodException {

      // create mocks
      CloudStackClient client = createMock(CloudStackClient.class);
      BlockUntilJobCompletesAndReturnResult blockUntilJobCompletesAndReturnResult = createMock(BlockUntilJobCompletesAndReturnResult.class);
      AddressClient addressClient = createMock(AddressClient.class);
      expect(client.getAddressClient()).andReturn(addressClient).atLeastOnce();

      // no ip addresses available
      expect(addressClient.listPublicIPAddresses(allocatedOnly(true).networkId(networkId))).andReturn(
            ImmutableSet.<PublicIPAddress> of());
View Full Code Here

TOP

Related Classes of org.jclouds.cloudstack.CloudStackClient

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.