Skip to content

Commit 3a7ca04

Browse files
committed
Update UnmarshalSiteFrameTest, added unmarshalTopographicPlaceWithPolygon test
1 parent 3948af3 commit 3a7ca04

1 file changed

Lines changed: 40 additions & 1 deletion

File tree

src/test/java/org/rutebanken/netex/model/UnmarshalSiteFrameTest.java

Lines changed: 40 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
import java.math.BigDecimal;
2525

2626
import static org.junit.jupiter.api.Assertions.assertEquals;
27+
import static org.junit.jupiter.api.Assertions.assertNotNull;
2728

2829
class UnmarshalSiteFrameTest extends AbstractUnmarshalFrameTest {
2930

@@ -170,10 +171,48 @@ void unmarshalSiteFrame() throws JAXBException {
170171
GroupOfStopPlaces groupOfStopPlaces = siteFrame.getGroupsOfStopPlaces().getGroupOfStopPlaces().get(0);
171172
assertEquals("Lillehammer", groupOfStopPlaces.getName().getValue());
172173
assertEquals("NSR:StopPlace:420", groupOfStopPlaces.getMembers().getStopPlaceRef().get(0).getValue().getRef());
174+
}
175+
176+
@Test
177+
void unmarshalTopographicPlaceWithPolygon() throws JAXBException {
173178

179+
String xml = "<?xml version=\"1.0\" encoding=\"utf-8\"?>"
180+
+ "<PublicationDelivery version=\"1.0\" xmlns=\"http://www.netex.org.uk/netex\" xmlns:ns2=\"http://www.opengis.net/gml/3.2\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">"
181+
+ " <PublicationTimestamp>2016-05-18T15:00:00.0+01:00</PublicationTimestamp>"
182+
+ " <ParticipantRef>NHR</ParticipantRef>"
183+
+ " <dataObjects>"
184+
+ " <SiteFrame version=\"01\" id=\"nhr:sf:1\">"
185+
+ " <topographicPlaces>"
186+
+ " <TopographicPlace version=\"1\" id=\"NSR:TopographicPlace:1\">"
187+
+ " <Descriptor>"
188+
+ " <Name lang=\"nor\">Oslo</Name>"
189+
+ " </Descriptor>"
190+
+ " <TopographicPlaceType>municipality</TopographicPlaceType>"
191+
+ " <ns2:Polygon ns2:id=\"GEN-Polygon-1\">"
192+
+ " <ns2:exterior>"
193+
+ " <ns2:LinearRing>"
194+
+ " <ns2:posList>59.91 10.75 59.92 10.76 59.91 10.77 59.90 10.76 59.91 10.75</ns2:posList>"
195+
+ " </ns2:LinearRing>"
196+
+ " </ns2:exterior>"
197+
+ " </ns2:Polygon>"
198+
+ " </TopographicPlace>"
199+
+ " </topographicPlaces>"
200+
+ " </SiteFrame>"
201+
+ " </dataObjects>"
202+
+ "</PublicationDelivery>";
174203

204+
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
175205

176-
}
206+
@SuppressWarnings("unchecked")
207+
JAXBElement<PublicationDeliveryStructure> jaxbElement = (JAXBElement<PublicationDeliveryStructure>) unmarshaller
208+
.unmarshal(new ByteArrayInputStream(xml.getBytes()));
177209

210+
PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue();
211+
SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue();
178212

213+
TopographicPlace topographicPlace = siteFrame.getTopographicPlaces().getTopographicPlace().get(0);
214+
assertEquals("Oslo", topographicPlace.getDescriptor().getName().getValue());
215+
assertEquals(TopographicPlaceTypeEnumeration.MUNICIPALITY, topographicPlace.getTopographicPlaceType());
216+
assertNotNull(topographicPlace.getPolygon());
217+
}
179218
}

0 commit comments

Comments
 (0)