/******************************************************************************************************************* * * 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())); }
@Nonnull public Invoice.Builder toBuilder (final @Nonnull Accounting accounting) { try { final Project customer = accounting.getProjectRegistry().findProjects().withId(projectXml.getId()).result(); return new Invoice.Builder().withId(id) .withNumber(number) .withProject(customer) .withDate(date) .withDueDate(dueDate) .withEarnings(earnings) .withTax(tax) .withJobEvents(JobEventXml.toJobEvents(jobEventsXml)); } catch (NotFoundException e) { throw new RuntimeException(e); } } }
@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]); }
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()); }