/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
/** * @see #onlyPage(IterableWithMarker) */ @Deprecated public static <T> PagedIterable<T> of(IterableWithMarker<T> only) { return onlyPage(only); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { if (!input.nextMarker().isPresent()) return onlyPage(input); List<Object> args = getArgs(request); Optional<Object> arg0 = Optional.fromNullable(args.size() > 0 ? args.get(0) : null); return advance(input, markerToNextForArg0(arg0)); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { if (!input.nextMarker().isPresent()) return onlyPage(input); List<Object> args = getArgs(request); Optional<Object> arg0 = Optional.fromNullable(args.size() > 0 ? args.get(0) : null); return advance(input, markerToNextForArg0(arg0)); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { return input.nextMarker().isPresent() ? advance(input, markerToNextForArgs(getArgs(request))) : onlyPage(input); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { return input.nextMarker().isPresent() ? advance(input, markerToNextForArgs(getArgs(request))) : onlyPage(input); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { return input.nextMarker().isPresent() ? advance(input, markerToNextForArgs(getArgs(request))) : onlyPage(input); }
@Override public PagedIterable<T> apply(IterableWithMarker<T> input) { return input.nextMarker().isPresent() ? advance(input, markerToNextForArgs(getArgs(request))) : onlyPage(input); }
@Test public void testExecute() throws Exception { expect(networkApi.listNetworkDomainsWithDatacenterIdAndName(datacenterId, DEFAULT_NETWORK_DOMAIN_NAME)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(networkDomain)))); expect(networkApi.listVlans(networkDomain.id())) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(vlan)))); replay(networkApi, api, template, location); executeAndAssert(); }
private void publicIpBlockExpectations() { final PublicIpBlock publicIpBlock = publicIpBlockBuilder.state(State.NORMAL).build(); expect(networkApi.listPublicIPv4AddressBlocks(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(publicIpBlock)))); networkApi.removePublicIpBlock(publicIpBlock.id()); expectLastCall(); }
private void natRuleExpectations() { final NatRule natRule = natRuleBuilder.state(State.NORMAL).build(); expect(networkApi.listNatRules(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(natRule)))); networkApi.deleteNatRule(natRule.id()); expectLastCall(); }
@Test(dependsOnMethods = "testApply_NatRuleNotInNormalState") public void testApply_PublicIpBlockNotInNormalState() throws Exception { final Server server = serverBuilder.state(State.NORMAL).build(); loadServerExpectations(server); networkApiExpectations(); natRuleExpectations(); final PublicIpBlock publicIpBlock = publicIpBlockBuilder.state(State.FAILED_CHANGE).build(); expect(networkApi.listPublicIPv4AddressBlocks(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(publicIpBlock)))); firewallRuleAndPortListExpectations(); powerOffAndDeleteServerExpectations(); applyAndAssertDeleted(); }
@Test(dependsOnMethods = "testApply_ServerNotInNormalState") public void testApply_NatRuleNotInNormalState() throws Exception { final Server server = serverBuilder.state(State.NORMAL).build(); loadServerExpectations(server); networkApiExpectations(); final NatRule natRule = natRuleBuilder.state(State.FAILED_ADD).build(); expect(networkApi.listNatRules(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(natRule)))); publicIpBlockExpectations(); firewallRuleAndPortListExpectations(); powerOffAndDeleteServerExpectations(); applyAndAssertDeleted(); }
@Test(dependsOnMethods = "testServerToServerWithExternalIpApplyNetworkInfoNull") public void testServerToServerWithExternalIpApplyNoMathingNatRuleFound() { String internalIp = "192.168.1.1"; String natIp = "192.168.1.2"; String networkDomainId = "NetworkDomain1"; server = Server.builder().id("serverId").name("serverName").datacenterId("NA1") .networkInfo(NetworkInfo.create(networkDomainId, nic, new ArrayList<NIC>())).cpu(cpu).deployed(true) .state(State.NORMAL).sourceImageId("imageId").started(false).createTime(new Date()).memoryGb(1024) .guest(Guest.builder().osCustomization(false).operatingSystem(os).build()).build(); PagedIterable<NatRule> natRules = PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(natRule))); expect(dimensionDataCloudControlApi.getNetworkApi()).andReturn(networkApi); expect(networkApi.listNatRules(networkDomainId)).andReturn(natRules); expect(nic.privateIpv4()).andReturn(internalIp); expect(natRule.internalIp()).andReturn(natIp); EasyMock.replay(dimensionDataCloudControlApi, networkApi, natRule, nic); ServerWithExternalIp result = new ServerToServerWithExternalIp(dimensionDataCloudControlApi).apply(server); assertNotNull(result); assertEquals(result.server(), server); assertNull(result.externalIp()); } }
@Test(dependsOnMethods = "testApply_PublicIpBlockNotInNormalState") public void testApply_FirewallRuleNotInNormalState() throws Exception { final Server server = serverBuilder.state(State.NORMAL).build(); loadServerExpectations(server); networkApiExpectations(); natRuleExpectations(); publicIpBlockExpectations(); final FirewallRule firewallRule = firewallRuleBuilder.state(State.FAILED_CHANGE).destination( FirewallRuleTarget.builder() .portList(FirewallRuleTarget.PortList.create("portListId", null, null, null, null)).build()).build(); expect(networkApi.listFirewallRules(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(firewallRule)))); powerOffAndDeleteServerExpectations(); applyAndAssertDeleted(); }
private void firewallRuleAndPortListExpectations() { final FirewallRule firewallRule = firewallRuleBuilder.state(State.NORMAL).destination(FirewallRuleTarget.builder() .portList(FirewallRuleTarget.PortList.create("portListId", null, null, null, null)).build()).build(); expect(networkApi.listFirewallRules(jcloudsNetworkDomainId)) .andReturn(PagedIterables.onlyPage(IterableWithMarkers.from(Lists.newArrayList(firewallRule)))); networkApi.deleteFirewallRule(firewallRule.id()); expectLastCall(); networkApi.deletePortList(firewallRule.destination().portList().id()); expectLastCall(); }