private List<List<Location>> buildGridOfLocations() { List<Location> northMostFirst = liveCellLocations.stream().sorted().collect(toList()); Location northMost = northMostFirst.get(0); Location southMost = northMostFirst.get(northMostFirst.size() - 1); List<Location> westMostFirst = liveCellLocations.stream().sorted(byWestMostFirst).collect(toList()); Location westMost = westMostFirst.get(0); Location eastMost = westMostFirst.get(westMostFirst.size() - 1); Location topLeft = getTopLeft(northMost, westMost); Location topRight = getTopRight(northMost, eastMost); Location bottomLeft = getBottomLeft(northMost, southMost); List<Location> topRow = topRowWith(topLeft, topRight); return gridWith(topRow, topLeft, bottomLeft); }
@Test public void receiveAnOrder() throws Exception { when(request.getMethod()).thenReturn("POST"); when(request.getRequestURI()).thenReturn("/orders"); when(request.getParameter("order_code")).thenReturn("1234"); when(request.getParameter("article_code")).thenReturn("ABCD"); when(request.getParameter("address")).thenReturn("Some Place"); ordersController.service(); assertEquals(1, orders.size()); assertEquals(new Order("1234", "ABCD", "Some Place"), orders.get(0)); }