private String renderMoveForm(PhysicalPort port, Model model, RedirectAttributes redirectAttrs) {
    List<UnallocatedPortView> unallocatedPorts =
        physicalPortService
            .findUnallocatedPorts()
            .stream()
            .filter(x -> x.isAvailable(port.getSVlan(), port.getAllowedVlan().orElse(Vlan.none())))
            .collect(Collectors.toList());

    if (unallocatedPorts.isEmpty()) {
      messageManager.addInfoFlashMessage(
          redirectAttrs, "info_physicalport_nounallocated", port.isVlanRequired() ? "EVPL" : "EPL");
      return redirectPortListPage(port);
    }

    long numberOfVirtualPorts =
        port instanceof UniPort ? virtualPortService.countForUniPort((UniPort) port) : 0;
    long numberOfReservations = reservationService.countForPhysicalPort(port);
    long numberOfActiveReservations =
        reservationService.countActiveReservationsForPhysicalPort(port);

    model.addAttribute(
        "relatedObjects",
        new RelatedObjects(numberOfVirtualPorts, numberOfReservations, numberOfActiveReservations));
    model.addAttribute("physicalPort", new PhysicalPortMoveView(port));
    model.addAttribute("unallocatedPhysicalPorts", unallocatedPorts);

    if (!model.containsAttribute("movePhysicalPortCommand")) {
      // Only add when not present. Otherwise validatione errors are
      // automagically removed by Spring :(
      model.addAttribute("movePhysicalPortCommand", new MovePhysicalPortCommand(port));
    }

    return PAGE_URL + "/move";
  }
  @Test
  public void listAllUnallocatedPortsShouldSetPorts() throws Exception {
    when(physicalPortServiceMock.findUnallocatedPorts())
        .thenReturn(
            FluentIterable.from(
                    Iterables.cycle(
                        new UnallocatedPortView(
                            new NbiPortFactory().setSuggestedNocLabel("NOC label").create(),
                            Collections.emptyList())))
                .limit(100)
                .toList());

    mockMvc
        .perform(get("/noc/physicalports/free"))
        .andExpect(status().isOk())
        .andExpect(
            model().<Collection<?>>attribute(DATA_LIST, hasSize(WebUtils.MAX_ITEMS_PER_PAGE)))
        .andExpect(model().attribute("filterSelect", PhysicalPortFilter.UN_ALLOCATED))
        .andExpect(
            model()
                .attribute(
                    WebUtils.MAX_PAGES_KEY,
                    (int) Math.ceil((float) 100 / WebUtils.MAX_ITEMS_PER_PAGE)));
  }