@Test public void failsToCreateWithInvalidReservedStaticIpSizeException() throws Throwable { VirtualNetworkCreateSpec spec = new VirtualNetworkCreateSpec(); spec.setName("virtualNetworkName"); spec.setRoutingType(RoutingType.ROUTED); spec.setSize(VirtualNetworkCreateSpec.DEFAULT_MIN_NETWORK_SIZE); spec.setReservedStaticIpSize(4); try { frontendClient.create("parentId", "parentKind", spec); fail("Should have failed with InvalidReservedStaticIpSizeException"); } catch (Exception ex) { assertThat(ex, instanceOf(InvalidReservedStaticIpSizeException.class)); assertThat(ex.getMessage().equals("Static IP size (4) exceeds total IP size (8) minus reserved IP size (5)"), is(true)); } }
public Task create(String parentId, String parentKind, VirtualNetworkCreateSpec spec) throws ExternalException { if (spec.getReservedStaticIpSize() + DEFAULT_RESERVED_IP_LIST_SIZE > spec.getSize()) { throw new InvalidReservedStaticIpSizeException( String.format("Static IP size (%s) exceeds total IP size (%s) minus reserved IP size (%s)", spec.getReservedStaticIpSize(), spec.getSize(), DEFAULT_RESERVED_IP_LIST_SIZE)); } CreateVirtualNetworkWorkflowDocument startState = new CreateVirtualNetworkWorkflowDocument(); startState.parentId = parentId; startState.parentKind = parentKind; startState.name = spec.getName(); startState.description = spec.getDescription(); startState.routingType = spec.getRoutingType(); startState.size = spec.getSize(); startState.reservedStaticIpSize = spec.getReservedStaticIpSize(); CreateVirtualNetworkWorkflowDocument finalState = backendClient.post( CreateVirtualNetworkWorkflowService.FACTORY_LINK, startState).getBody(CreateVirtualNetworkWorkflowDocument.class); return TaskUtils.convertBackEndToFrontEnd(finalState.taskServiceState); }
VirtualNetworkFeClient { public Task create(String parentId, String parentKind, VirtualNetworkCreateSpec spec) throws ExternalException { if (spec.getReservedStaticIpSize() + DEFAULT_RESERVED_IP_LIST_SIZE > spec.getSize()) { throw new InvalidReservedStaticIpSizeException( String.format("Static IP size (%s) exceeds total IP size (%s) minus reserved IP size (%s)", spec.getReservedStaticIpSize(), spec.getSize(), DEFAULT_RESERVED_IP_LIST_SIZE)); } CreateVirtualNetworkWorkflowDocument startState = new CreateVirtualNetworkWorkflowDocument(); startState.parentId = parentId; startState.parentKind = parentKind; startState.name = spec.getName(); startState.description = spec.getDescription(); startState.routingType = spec.getRoutingType(); startState.size = spec.getSize(); startState.reservedStaticIpSize = spec.getReservedStaticIpSize(); CreateVirtualNetworkWorkflowDocument finalState = backendClient.post( CreateVirtualNetworkWorkflowService.FACTORY_LINK, startState).getBody(CreateVirtualNetworkWorkflowDocument.class); return TaskUtils.convertBackEndToFrontEnd(finalState.taskServiceState); } }
VirtualNetworkFeClient { public Task create(String parentId, String parentKind, VirtualNetworkCreateSpec spec) throws ExternalException { if (spec.getReservedStaticIpSize() + DEFAULT_RESERVED_IP_LIST_SIZE > spec.getSize()) { throw new InvalidReservedStaticIpSizeException( String.format("Static IP size (%s) exceeds total IP size (%s) minus reserved IP size (%s)", spec.getReservedStaticIpSize(), spec.getSize(), DEFAULT_RESERVED_IP_LIST_SIZE)); } CreateVirtualNetworkWorkflowDocument startState = new CreateVirtualNetworkWorkflowDocument(); startState.parentId = parentId; startState.parentKind = parentKind; startState.name = spec.getName(); startState.description = spec.getDescription(); startState.routingType = spec.getRoutingType(); startState.size = spec.getSize(); startState.reservedStaticIpSize = spec.getReservedStaticIpSize(); CreateVirtualNetworkWorkflowDocument finalState = backendClient.post( CreateVirtualNetworkWorkflowService.FACTORY_LINK, startState).getBody(CreateVirtualNetworkWorkflowDocument.class); return TaskUtils.convertBackEndToFrontEnd(finalState.taskServiceState); } @Inject  VirtualNetworkFeClient(PhotonControllerXenonRestClient photonControllerXenonRestClient,
                                ApiFeXenonRestClient cloudStoreClient, TaskBackend taskBackend); }
VirtualNetworkFeClient { public Task create(String parentId, String parentKind, VirtualNetworkCreateSpec spec) throws ExternalException { if (spec.getReservedStaticIpSize() + DEFAULT_RESERVED_IP_LIST_SIZE > spec.getSize()) { throw new InvalidReservedStaticIpSizeException( String.format("Static IP size (%s) exceeds total IP size (%s) minus reserved IP size (%s)", spec.getReservedStaticIpSize(), spec.getSize(), DEFAULT_RESERVED_IP_LIST_SIZE)); } CreateVirtualNetworkWorkflowDocument startState = new CreateVirtualNetworkWorkflowDocument(); startState.parentId = parentId; startState.parentKind = parentKind; startState.name = spec.getName(); startState.description = spec.getDescription(); startState.routingType = spec.getRoutingType(); startState.size = spec.getSize(); startState.reservedStaticIpSize = spec.getReservedStaticIpSize(); CreateVirtualNetworkWorkflowDocument finalState = backendClient.post( CreateVirtualNetworkWorkflowService.FACTORY_LINK, startState).getBody(CreateVirtualNetworkWorkflowDocument.class); return TaskUtils.convertBackEndToFrontEnd(finalState.taskServiceState); } @Inject  VirtualNetworkFeClient(PhotonControllerXenonRestClient photonControllerXenonRestClient,
                                ApiFeXenonRestClient cloudStoreClient, TaskBackend taskBackend); Task create(String parentId,
                     String parentKind,
                     VirtualNetworkCreateSpec spec); Task delete(String networkId); VirtualSubnet get(String networkId); ResourceList<VirtualSubnet> list(String parentId,
                                          String parentKind,
                                          Optional<String> name,
                                          Optional<Integer> pageSize); ResourceList<VirtualSubnet> nextList(String pageLink); Task setDefault(String networkId); }
VirtualNetworkFeClient { public Task create(String parentId, String parentKind, VirtualNetworkCreateSpec spec) throws ExternalException { if (spec.getReservedStaticIpSize() + DEFAULT_RESERVED_IP_LIST_SIZE > spec.getSize()) { throw new InvalidReservedStaticIpSizeException( String.format("Static IP size (%s) exceeds total IP size (%s) minus reserved IP size (%s)", spec.getReservedStaticIpSize(), spec.getSize(), DEFAULT_RESERVED_IP_LIST_SIZE)); } CreateVirtualNetworkWorkflowDocument startState = new CreateVirtualNetworkWorkflowDocument(); startState.parentId = parentId; startState.parentKind = parentKind; startState.name = spec.getName(); startState.description = spec.getDescription(); startState.routingType = spec.getRoutingType(); startState.size = spec.getSize(); startState.reservedStaticIpSize = spec.getReservedStaticIpSize(); CreateVirtualNetworkWorkflowDocument finalState = backendClient.post( CreateVirtualNetworkWorkflowService.FACTORY_LINK, startState).getBody(CreateVirtualNetworkWorkflowDocument.class); return TaskUtils.convertBackEndToFrontEnd(finalState.taskServiceState); } @Inject  VirtualNetworkFeClient(PhotonControllerXenonRestClient photonControllerXenonRestClient,
                                ApiFeXenonRestClient cloudStoreClient, TaskBackend taskBackend); Task create(String parentId,
                     String parentKind,
                     VirtualNetworkCreateSpec spec); Task delete(String networkId); VirtualSubnet get(String networkId); ResourceList<VirtualSubnet> list(String parentId,
                                          String parentKind,
                                          Optional<String> name,
                                          Optional<Integer> pageSize); ResourceList<VirtualSubnet> nextList(String pageLink); Task setDefault(String networkId); static final int DEFAULT_RESERVED_IP_LIST_SIZE; }