public AccountingXml (final @Nonnull Accounting accounting) { customersXml = accounting.getCustomerRegistry().findCustomers().stream().map(customer -> new CustomerXml(customer)) .collect(toList()); projectsXml = accounting.getProjectRegistry().findProjects().stream().map(project -> new ProjectXml(project)) .collect(toList()); invoicesxml = accounting.getInvoiceRegistry().findInvoices().stream().map(invoice -> new InvoiceXml(invoice)) .collect(toList()); }
/******************************************************************************************************************* * * Reacts to the notification that a {@link Customer} has been selected by populating the presentation with * his projects. * * @param event the notification event * ******************************************************************************************************************/ @VisibleForTesting void onCustomerSelectedEvent (final @Nonnull @ListensTo CustomerSelectedEvent event) { log.info("onCustomerSelectedEvent({})", event); presentation.populate(event.getCustomer().findProjects() .stream() .map(project -> (ProjectSpi)project) .sorted(comparing(ProjectSpi::getName)) .map(project -> createPresentationModelFor(project)) .collect(toCompositePresentationModel())); }
@DataProvider(name = "projects") public static Object[][] projectProvider() { return ScenarioFactory.createScenarios().entrySet().stream() .flatMap(entry -> entry.getValue().getProjectRegistry().findProjects().stream() .map(project -> new Object[] { entry.getKey(), project })) .collect(Collectors.toList()) .toArray(new Object[0][0]); }