private void createValidStates() throws Throwable { this.endpointState = ModelUtils.createEndpoint(this); this.networkState = ModelUtils.createNetwork(this, this.endpointState); this.subnetState = ModelUtils.createSubnet(this, this.networkState, this.endpointState); this.subnetRangeState1 = ModelUtils .createSubnetRange(this, this.subnetState, this.startIpInRange1, this.endIpInRange1); this.subnetRangeState2 = ModelUtils .createSubnetRange(this, this.subnetState, this.startIpInRange2, this.endIpInRange2); }
@Test public void testAllocateSpecificIPWithNoRanges() throws Throwable { SubnetService.SubnetState subnetState = ModelUtils.createSubnet(this, this .networkState, this.endpointState); IPAddressAllocationTaskState allocationTask = createIpAddressAllocationTask( subnetState.documentSelfLink, ComputeService.FACTORY_LINK + "/machine-1"); allocationTask.requestType = RequestType.ALLOCATE_SPECIFIC_IP; allocationTask.ipAddresses.add(SPECIFIC_IP); IPAddressAllocationTaskState allocationTaskResult; addFakeCallBack(allocationTask); // task should not fail, but no IP addresses are allocated allocationTaskResult = performTask(allocationTask); assertNotNull(allocationTaskResult); assertEquals(0, allocationTaskResult.rsrcToAllocatedIpsMap.size()); assertEquals(0, allocationTaskResult.subnetRangeLinks.size()); assertEquals(0, allocationTaskResult.ipAddresses.size()); assertEquals(0, allocationTaskResult.ipAddressLinks.size()); }
@Test public void testAllocationTaskServiceWithNoRanges() throws Throwable { SubnetService.SubnetState subnetState = ModelUtils.createSubnet(this, this .networkState, this.endpointState); IPAddressAllocationTaskState allocationTask = createIpAddressAllocationTask( subnetState.documentSelfLink, ComputeService.FACTORY_LINK + "/machine-1"); IPAddressAllocationTaskState allocationTaskResult; addFakeCallBack(allocationTask); // task should not fail, but no IP addresses are allocated allocationTaskResult = performTask(allocationTask); assertNotNull(allocationTaskResult); assertEquals(0, allocationTaskResult.rsrcToAllocatedIpsMap.size()); assertEquals(0, allocationTaskResult.subnetRangeLinks.size()); }