Skip to content

Commit

Permalink
Aufruf von deprecated toFeld-Methode ersetzt
Browse files Browse the repository at this point in the history
  • Loading branch information
Oli B committed Jan 9, 2024
1 parent 0eff4af commit 2090f84
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 31 deletions.
7 changes: 4 additions & 3 deletions lib/src/main/java/gdv/xport/satz/xml/TeildatensatzXml.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import gdv.xport.feld.AlphaNumFeld;
import gdv.xport.feld.Bezeichner;
import gdv.xport.feld.ByteAdresse;
import gdv.xport.feld.Feld;
import gdv.xport.satz.Teildatensatz;
import gdv.xport.util.SatzTyp;
Expand Down Expand Up @@ -95,7 +96,7 @@ public void updateWith(Map<String, FeldXml> felder) {
for (FeldReferenz referenz : this.feldReferenzen) {
FeldXml feldXml = getFeld(felder, referenz.getId());
feldXml.setInhalt(referenz.getAuspraegung());
this.addFeld(feldXml, byteAddress, referenz);
this.addFeld(feldXml, ByteAdresse.of(byteAddress), referenz);
byteAddress += feldXml.getAnzahlBytes();
}
updateSatzendeWith(byteAddress, felder);
Expand All @@ -118,7 +119,7 @@ private void updateSatzendeWith(final int startAddress, final Map<String, FeldXm
FeldReferenz referenz = referenzen.get(i);
FeldXml feldXml = felder.get(referenz.getId());
endAddress -= feldXml.getAnzahlBytes();
Feld feld = feldXml.toFeld(endAddress + 1, referenz, this).mitConfig(getConfig());
Feld feld = feldXml.toFeld(ByteAdresse.of(endAddress + 1), referenz, this).mitConfig(getConfig());
endeDatenfelder.add(feld);
}
int length = endAddress + 1 - startAddress;
Expand All @@ -136,7 +137,7 @@ private void updateSatzendeWith(final int startAddress, final Map<String, FeldXm
}
}

private void addFeld(final FeldXml feldXml, final int byteAddress, final FeldReferenz referenz) {
private void addFeld(final FeldXml feldXml, final ByteAdresse byteAddress, final FeldReferenz referenz) {
Feld feld = feldXml.toFeld(byteAddress, referenz, this).mitConfig(getConfig());
if (!this.hasFeld(feld.getBezeichner())) {
super.add(feld);
Expand Down
31 changes: 3 additions & 28 deletions lib/src/test/java/gdv/xport/satz/xml/FeldXmlTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -104,40 +104,21 @@ public void testVuNummer() throws XMLStreamException {
assertEquals("test ", vuNr.getInhalt());
}

/**
* Test-Methode fuer {@link FeldXml#toFeld(int)}.
*/
@Test
public void testToNumFeld() {
checkToFeld(feldXml, NumFeld.class);
}

/**
* Test-Methode fuer {@link FeldXml#toFeld(int)}.
*
* @throws XMLStreamException the XML stream exception
*/
@Test
public void testToAlphaNumFeld() throws XMLStreamException {
checkToFeld(createFeldXmlFrom("feldVuNr.xml"), AlphaNumFeld.class);
}

/**
* Test-Methode fuer {@link FeldXml#toFeld(int)}.
*
* @throws XMLStreamException the XML stream exception
*/
@Test
public void testToDatumFeld() throws XMLStreamException {
checkToFeld(createFeldXmlFrom("feldDatum.xml"), Datum.class);
}

/**
* Test-Methode fuer {@link FeldXml#toFeld(int)} mit einer
* Gleitkommazahl.
*
* @throws XMLStreamException the XML stream exception
*/
@Test
public void testToGleitkomma() throws XMLStreamException {
FeldXml gleitkomma = createFeldXmlFrom("feldFliesskomma.xml");
Expand All @@ -155,23 +136,17 @@ public void testToGleitkomma() throws XMLStreamException {
public void testToFeldBezeichner() throws XMLStreamException {
FeldXml gleitkomma = createFeldXmlFrom("feldFliesskomma.xml");
FeldReferenz referenz = new FeldReferenz(createXMLEventReader("feldreferenzZuzahlungsbetragInWE.xml"));
Feld feld = gleitkomma.toFeld(160, referenz);
Feld feld = gleitkomma.toFeld(ByteAdresse.of(160), referenz);
assertEquals(Bezeichner.ZUZAHLUNGSBETRAG_IN_WE, feld.getBezeichner());
}

/**
* Test-Methode fuer {@link FeldXml#toFeld(int)} mit einer
* Gleitkommazahl.
*
* @throws XMLStreamException the XML stream exception
*/
@Test
public void testToUhrzeit() throws XMLStreamException {
checkToFeld(createFeldXmlFrom("feldUhrzeit.xml"), NumFeld.class);
}

private static void checkToFeld(final FeldXml input, final Class<? extends Feld> expected) {
Feld converted = input.toFeld(42);
Feld converted = input.toFeld(ByteAdresse.of(42));
assertEquals(42, converted.getByteAdresse());
assertTrue(converted + ": bezeichnung expected", StringUtils.isNotEmpty(converted.getBezeichnung()));
assertEquals(input.getBezeichnung(), converted.getBezeichnung());
Expand All @@ -184,7 +159,7 @@ public void testToDatum() throws XMLStreamException {
FeldXml datum = createFeldXmlFrom("feldDatum.xml");
datum.setInhalt("21052021");
FeldReferenz referenz = new FeldReferenz(createXMLEventReader("feldreferenzDatum.xml"));
Feld converted = datum.toFeld(10, referenz);
Feld converted = datum.toFeld(ByteAdresse.of(10), referenz);
assertEquals(datum.getInhalt(), converted.getInhalt());
}

Expand Down

0 comments on commit 2090f84

Please sign in to comment.