Skip to content

Commit 7da2a7e

Browse files
committed
[ASMT-1130] Added decoding for Cat004Item100Subfield1 - Area Name
1 parent 7c6e651 commit 7da2a7e

File tree

2 files changed

+27
-2
lines changed

2 files changed

+27
-2
lines changed

src/main/java/jlg/jade/asterix/cat004/item100/Cat004Item100Subfield1.java

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
import jlg.jade.asterix.AsterixItemLength;
88
import jlg.jade.asterix.DecodingNotImplemented;
99
import jlg.jade.asterix.FixedLengthAsterixData;
10+
import jlg.jade.common.IA5Decoder;
1011

1112
/**
1213
* Cat004 Item100 Subfield1 - Area Name
@@ -16,19 +17,25 @@
1617
* characters are filled with space character
1718
*/
1819
public class Cat004Item100Subfield1 extends FixedLengthAsterixData {
20+
private String areaName;
21+
1922
@Override
2023
protected int setSizeInBytes() {
2124
return AsterixItemLength.SIX_BYTES.getValue();
2225
}
2326

2427
@Override
25-
@DecodingNotImplemented(reason = "Item not needed yet")
2628
protected void decodeFromByteArray(byte[] input, int offset) {
27-
appendNotImplementedMsg();
29+
this.areaName = IA5Decoder.decodeFromSixBytes(input, offset);
30+
appendItemDebugMsg("Area Name", this.areaName);
2831
}
2932

3033
@Override
3134
protected String setDisplayName() {
3235
return "Cat004Item100Subfield1 - Area Name";
3336
}
37+
38+
public String getAreaName() {
39+
return areaName;
40+
}
3441
}

src/test/java/jlg/jade/test/asterix/cat004/item100/Cat004Item100Subfield1Test.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
package jlg.jade.test.asterix.cat004.item100;
66

77
import jlg.jade.asterix.cat004.item100.Cat004Item100Subfield1;
8+
import jlg.jade.common.IA5Decoder;
89
import jlg.jade.test.utils.MandatoryFixedLengthAsterixTests;
10+
import org.junit.Test;
11+
12+
import static org.junit.Assert.assertEquals;
913

1014
public class Cat004Item100Subfield1Test extends MandatoryFixedLengthAsterixTests<Cat004Item100Subfield1> {
1115

@@ -18,4 +22,18 @@ protected int setExpectedItemSizeInBytes() {
1822
protected Cat004Item100Subfield1 setFixedLengthAsterixDataInstance() {
1923
return new Cat004Item100Subfield1();
2024
}
25+
26+
@Test
27+
public void the_decode_method_should_correctly_decode_data() {
28+
// arrange
29+
byte[] input = {57, 5, 52, (byte) 203, (byte) 1, (byte) 202};
30+
int offset = 0;
31+
Cat004Item100Subfield1 item100Subfield1 = new Cat004Item100Subfield1();
32+
33+
// act
34+
item100Subfield1.decode(input, offset, input.length);
35+
36+
// assert
37+
assertEquals("Data not decoded correctly - Area Name", "NPT420GJ", item100Subfield1.getAreaName());
38+
}
2139
}

0 commit comments

Comments
 (0)