Skip to content

Commit

Permalink
remove Wochentag in PDF if single day is selected (#146)
Browse files Browse the repository at this point in the history
  • Loading branch information
Der-Alex-K authored Oct 8, 2024
1 parent cc6921b commit 760da4d
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,6 @@ public class MessstelleninformationenPdfComponent {
private String wochentag;

private String kommentar;

private boolean wochentagNeeded;
}
Original file line number Diff line number Diff line change
Expand Up @@ -160,12 +160,14 @@ static MessstelleninformationenPdfComponent fillMessstelleninformationen(final M
optionsDTO.getZeitraum().sort(LocalDate::compareTo);
messstelleninformationen.setMesszeitraum(
String.format("%s - %s", optionsDTO.getZeitraum().get(0).format(DDMMYYYY), optionsDTO.getZeitraum().get(1).format(DDMMYYYY)));
messstelleninformationen.setWochentagNeeded(true);
messstelleninformationen
.setWochentag(StringUtils.defaultIfEmpty(tagesTyp, KEINE_DATEN_VORHANDEN));
} else {
messstelleninformationen.setMesszeitraum(optionsDTO.getZeitraum().get(0).format(DDMMYYYY));
messstelleninformationen.setWochentagNeeded(false);
}
messstelleninformationen.setKommentar(messstelle.getKommentar());
messstelleninformationen
.setWochentag(StringUtils.defaultIfEmpty(tagesTyp, KEINE_DATEN_VORHANDEN));
return messstelleninformationen;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
<td>Messzeitraum:</td>
<td>{{messzeitraum}}</td>
</tr>
{{#wochentagNeeded}}
<tr>
<td>Wochentag:</td>
<td>{{wochentag}}</td>
</tr>
{{/wochentagNeeded}}
<tr>
<td>Kommentar:</td>
<td>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import static org.hamcrest.MatcherAssert.assertThat;
import static org.hamcrest.Matchers.is;
import static org.hamcrest.Matchers.nullValue;

import de.muenchen.dave.domain.dtos.OptionsDTO;
import de.muenchen.dave.domain.dtos.messstelle.MessstelleOptionsDTO;
Expand All @@ -20,6 +21,7 @@
import java.math.BigDecimal;
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
Expand Down Expand Up @@ -138,18 +140,34 @@ void fillBasicPdf_Messstelle() {
@Test
void fillMessstelleninformationen() {
final DateTimeFormatter DDMMYYYY = DateTimeFormatter.ofPattern("dd.MM.yyyy");
final MessstelleninformationenPdfComponent informationen = new MessstelleninformationenPdfComponent();
MessstelleninformationenPdfComponent informationen = new MessstelleninformationenPdfComponent();
final Messstelle messstelle = MessstelleRandomFactory.getMessstelle();
final String tagesTyp = TagesTyp.SAMSTAG.name();
final MessstelleOptionsDTO optionsDTO = new MessstelleOptionsDTO();
optionsDTO.setZeitraum(List.of(LocalDate.now()));
final ArrayList<LocalDate> localDates = new ArrayList<>();
localDates.add(LocalDate.now());
localDates.add(LocalDate.now());
optionsDTO.setZeitraum(localDates);

FillPdfBeanService.fillMessstelleninformationen(informationen, messstelle, optionsDTO, tagesTyp);
assertThat(informationen.getStandort(), is(messstelle.getStandort()));
assertThat(informationen.getDetektierteFahrzeuge(), is(messstelle.getDetektierteVerkehrsarten()));
assertThat(informationen.getMesszeitraum(), is(optionsDTO.getZeitraum().get(0).format(DDMMYYYY)));
assertThat(informationen.getMesszeitraum(),
is(String.format("%s - %s", optionsDTO.getZeitraum().get(0).format(DDMMYYYY), optionsDTO.getZeitraum().get(0).format(DDMMYYYY))));
assertThat(informationen.getWochentag(), is(tagesTyp));
assertThat(informationen.isWochentagNeeded(), is(true));
assertThat(informationen.getKommentar(), is(messstelle.getKommentar()));

informationen = new MessstelleninformationenPdfComponent();
optionsDTO.setZeitraum(List.of(LocalDate.now()));
FillPdfBeanService.fillMessstelleninformationen(informationen, messstelle, optionsDTO, tagesTyp);
assertThat(informationen.getStandort(), is(messstelle.getStandort()));
assertThat(informationen.getDetektierteFahrzeuge(), is(messstelle.getDetektierteVerkehrsarten()));
assertThat(informationen.getMesszeitraum(), is(optionsDTO.getZeitraum().get(0).format(DDMMYYYY)));
assertThat(informationen.isWochentagNeeded(), is(false));
assertThat(informationen.getWochentag(), is(nullValue()));
assertThat(informationen.getKommentar(), is(messstelle.getKommentar()));

}

@Test
Expand Down

0 comments on commit 760da4d

Please sign in to comment.