### Question:
RetrieveLocationsUseCase implements RetrieveLocationsInputPort { @Override public void retrieveLocations(final RetrieveLocationsInputData inputData, final RetrieveLocationsOutputPort outputPort) { final Iterable<Location> locations = gatewaysAccessor.getLocationGateway().findAll(); final RetrieveLocationsOutputData retrieveLocationsOutputData = new RetrieveLocationsOutputData(); final List<RetrieveLocationsOutputData.Location> outputLocations = retrieveLocationsOutputData .getLocations(); locations.forEach(l -> { final RetrieveLocationsOutputData.Location outputLocation = retrieveLocationsOutputData.new Location(); outputLocation.setName(l.getName()); outputLocation.setAddress(l.getAddress()); outputLocations.add(outputLocation); }); outputPort.present(retrieveLocationsOutputData); } RetrieveLocationsUseCase(final GatewaysAccessor gatewaysAccessor); @Override void retrieveLocations(final RetrieveLocationsInputData inputData,
        final RetrieveLocationsOutputPort outputPort);  }### Answer:
@Test void test_retrieveLocations_locations_returnsAllLocations() { int numberOfLocations = 10; for (int i = 0; i < numberOfLocations; i++) { locationGateway.save(new Location()); } final RetrieveLocationsUseCase retrieveLocationsUseCase = new RetrieveLocationsUseCase( gatewaysAccessor); retrieveLocationsUseCase .retrieveLocations(new RetrieveLocationsInputData(), retrieveLocationsOutputData -> { Assertions.assertEquals(numberOfLocations, retrieveLocationsOutputData.getLocations().size()); }); }
@Test void test_retrieveLocations_noLocations_returnsEmptyList() { final RetrieveLocationsUseCase retrieveLocationsUseCase = new RetrieveLocationsUseCase( gatewaysAccessor); retrieveLocationsUseCase .retrieveLocations(new RetrieveLocationsInputData(), retrieveLocationsOutputData -> { Assertions.assertTrue(retrieveLocationsOutputData.getLocations().isEmpty()); }); }