Skip to content

Commit

Permalink
add customer name, phone number and email in email notification to fa…
Browse files Browse the repository at this point in the history
…rmer
  • Loading branch information
Benjamin POCHAT authored and Benjamin POCHAT committed Feb 10, 2021
1 parent 2ce2b7e commit e04d066
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,25 @@ public void notifyByMail(Order order) {
String recipient = StreamSupport.stream(breeders.spliterator(), false).map(Breeder::getEmail).collect(Collectors.joining(","));
String subject = "nouvelle commande !";
String body = String.format(
"<div>La commande n° %s a été enregistrée</div>"
+ "<div><ul>"
+ "<li>Montant de la commande : %s €TTC</li>"
+ "<li>Quantité commandée : %s kg</li>"
+ "</ul></div>",
"<div>La commande n° %s a été enregistrée</div>" +
"<div>" +
"<ul>" +
"<li>Client :" +
"<ul>" +
"<li>Nom : %s %s</li>" +
"<li>Email : %s</li>" +
"<li>Téléphone : %s</li>" +
"</ul>" +
"</li>" +
"<li>Montant de la commande : %s €TTC</li>" +
"<li>Quantité commandée : %s kg</li>" +
"</ul>" +
"</div>",
order.getId(),
order.getCustomer().getFirstName(),
order.getCustomer().getName(),
order.getCustomer().getEmail(),
order.getCustomer().getPhoneNumber(),
order.getOrderedItems().stream()
.mapToDouble(item -> {
Batch batch = batchRepository.findById(item.getBatch().getId()).orElseThrow();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,19 @@ public void notifyByMail_should_format_a_mail_correctly() {
verify(spyedService).sendMail(
eq("[email protected]"),
eq("nouvelle commande !"),
eq("<div>La commande n° 1 a été enregistrée</div><div><ul><li>Montant de la commande : 1350.0 €TTC</li><li>Quantité commandée : 100.0 kg</li></ul></div>"));
eq("<div>La commande n° 1 a été enregistrée</div>" +
"<div>" +
"<ul>" +
"<li>Client :" +
"<ul>" +
"<li>Nom : Virginie WALTER</li>" +
"<li>Email : [email protected]</li>" +
"<li>Téléphone : 04 32 10 98 87</li>" +
"</ul>" +
"</li>" +
"<li>Montant de la commande : 1350.0 €TTC</li>" +
"<li>Quantité commandée : 100.0 kg</li>" +
"</ul>" +
"</div>"));
}
}

0 comments on commit e04d066

Please sign in to comment.