public void fill (final @Nonnull Accounting accounting) { final CustomerRegistry customerRegistry = accounting.getCustomerRegistry(); final ProjectRegistry projectRegistry = accounting.getProjectRegistry(); final InvoiceRegistry invoiceRegistry = accounting.getInvoiceRegistry(); customersXml.forEach(customer -> customerRegistry.addCustomer().with(customer.toBuilder()).create()); projectsXml.forEach(project -> projectRegistry.addProject().with(project.toBuilder(accounting)).create()); invoicesxml.forEach(invoice -> invoiceRegistry.addInvoice().with(invoice.toBuilder(accounting)).create()); } }
@Nonnull public Project.Builder toBuilder (final @Nonnull Accounting accounting) { try { final Customer customer = accounting.getCustomerRegistry().findCustomers().withId(customerXml.getId()).result(); return new Project.Builder().withId(id) .withCustomer(customer) .withName(name) .withNumber(number) .withDescription(description) .withNotes(notes) .withStatus(status) .withHourlyRate(hourlyRate) .withBudget(budget) .withStartDate(startDate) .withEndDate(endDate) .withEvents(JobEventXml.toJobEvents(jobEventsXml)); } catch (NotFoundException e) { throw new RuntimeException(e); } } }
.withId(new Id("" + nextId++)) .withCustomer(acmeConsulting) .withDescription("Acme Consulting Project 1") .withName("Acme Consulting Project 1") .withStartDate(project1StartDate) .withEndDate(project1EndDate) .withNumber("PRJ ACME-1") .withEvents(je1) .withHourlyRate(rate1) .withBudget(new Money(123456, "EUR")) .create(); final Project acmeConsultingProject2 = projectRegistry.addProject() .withId(new Id("" + nextId++)) .withCustomer(acmeConsulting) .withDescription("Acme Consulting Project 2") .withName("Acme Consulting Project 2") .withStartDate(project2StartDate) .withEndDate(project2EndDate) .withNumber("PRJ ACME-2") .withEvents(je2) .withHourlyRate(rate2) .withBudget(new Money(234567, "EUR")) .create(); final Project acmeFinancingProject1 = projectRegistry.addProject() .withId(new Id("" + nextId++)) .withCustomer(acmeFinancing) .withDescription("Acme Financing Project 1")
projectRegistry.addProject().withId(projectConfig.getId("uniqueIdentifier")) .withBudget(projectConfig.getMoney("projectEstimate")) .withCustomer(customer) .withName(projectConfig.getString("projectName")) .withStartDate(projectConfig.getDate("projectStartDate")) .withEndDate(projectConfig.getDate("projectDueDate")) .withNotes(projectConfig.getString("projectNotes")) .withNumber(projectConfig.getString("projectNumber")) .withStatus(status.getMappedStatus()) .withHourlyRate(getHourlyRate(projectConfig, jobEvents)) .withEvents(jobEvents) .create();
.withBillingAddress(a1) .create(); final Project p = Project.builder().withId(new Id("2")) .withBudget(new Money(10500, "EUR")) .withCustomer(c1) .withName("Project 1") .withDescription("description of project 1") .withStartDate(parseDate("2014-01-03")) .withEndDate(parseDate("2014-02-12")) .withNotes("Notes for project 1") .withNumber("1") .withHourlyRate(new Money(43, "EUR")) .create(); assertThat(p.toString(), is("InMemoryProject(id=2, customer=InMemoryCustomer(id=1, name=Acme Corp., billingAddress=" + "Address(street=Foo Bar rd 20, city=San Francisco, state=CA, country=USA, zip=12345), "