Package org.jclouds.googlecomputeengine.features

Examples of org.jclouds.googlecomputeengine.features.GlobalOperationApi


   @Test
   public void testLoadNew() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      // pre-creation
      expect(nwApi.get("this-network")).andReturn(null).times(2);
      // post-creation
      expect(nwApi.get("this-network")).andReturn(network);
View Full Code Here


   @Test
   public void testApply() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      expect(nwApi.get("this-network")).andReturn(null);
      expect(nwApi.get("this-network")).andReturn(network);

      expect(createOp.getName()).andReturn("create-op");
      expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
View Full Code Here

   @Test
   public void testApplyWithGateway() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network").gatewayIPv4("1.2.3.4")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      expect(nwApi.get("this-network")).andReturn(null);
      expect(nwApi.get("this-network")).andReturn(network);

      expect(createOp.getName()).andReturn("create-op");
      expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
View Full Code Here

   @Test
   public void testApply() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      expect(nwApi.get("this-network")).andReturn(null);
      expect(nwApi.get("this-network")).andReturn(network);

      expect(createOp.getName()).andReturn("create-op");
      expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
View Full Code Here

   @Test
   public void testApplyWithGateway() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network").gatewayIPv4("1.2.3.4")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4RangeWithGateway("this-network", "0.0.0.0/0", "1.2.3.4"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      expect(nwApi.get("this-network")).andReturn(null);
      expect(nwApi.get("this-network")).andReturn(network);

      expect(createOp.getName()).andReturn("create-op");
      expect(createOp.getStatus()).andReturn(Operation.Status.DONE);
View Full Code Here

   @Test
   public void testLoadNew() {
      final GoogleComputeEngineApi api = createMock(GoogleComputeEngineApi.class);
      final NetworkApi nwApi = createMock(NetworkApi.class);
      final GlobalOperationApi globalApi = createMock(GlobalOperationApi.class);

      Network network = Network.builder().IPv4Range("0.0.0.0/0")
              .id("abcd").name("this-network")
              .selfLink(URI.create("https://www.googleapis.com/compute/v1/projects/myproject/global/networks/this-network"))
              .build();

      Operation createOp = createMock(Operation.class);

      final Supplier<String> userProject = new Supplier<String>() {
         @Override
         public String get() {
            return "myproject";
         }
      };

      expect(api.getNetworkApiForProject(userProject.get())).andReturn(nwApi).atLeastOnce();
      expect(api.getGlobalOperationApiForProject(userProject.get())).andReturn(globalApi).atLeastOnce();

      expect(nwApi.createInIPv4Range("this-network", "0.0.0.0/0"))
              .andReturn(createOp);
      expect(globalApi.get("create-op")).andReturn(createOp);
      // pre-creation
      expect(nwApi.get("this-network")).andReturn(null).times(2);
      // post-creation
      expect(nwApi.get("this-network")).andReturn(network);
View Full Code Here

TOP

Related Classes of org.jclouds.googlecomputeengine.features.GlobalOperationApi

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.