|
24 | 24 | import java.math.BigDecimal; |
25 | 25 |
|
26 | 26 | import static org.junit.jupiter.api.Assertions.assertEquals; |
| 27 | +import static org.junit.jupiter.api.Assertions.assertNotNull; |
27 | 28 |
|
28 | 29 | class UnmarshalSiteFrameTest extends AbstractUnmarshalFrameTest { |
29 | 30 |
|
@@ -170,10 +171,48 @@ void unmarshalSiteFrame() throws JAXBException { |
170 | 171 | GroupOfStopPlaces groupOfStopPlaces = siteFrame.getGroupsOfStopPlaces().getGroupOfStopPlaces().get(0); |
171 | 172 | assertEquals("Lillehammer", groupOfStopPlaces.getName().getValue()); |
172 | 173 | assertEquals("NSR:StopPlace:420", groupOfStopPlaces.getMembers().getStopPlaceRef().get(0).getValue().getRef()); |
| 174 | + } |
| 175 | + |
| 176 | + @Test |
| 177 | + void unmarshalTopographicPlaceWithPolygon() throws JAXBException { |
173 | 178 |
|
| 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>"; |
174 | 203 |
|
| 204 | + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); |
175 | 205 |
|
176 | | - } |
| 206 | + @SuppressWarnings("unchecked") |
| 207 | + JAXBElement<PublicationDeliveryStructure> jaxbElement = (JAXBElement<PublicationDeliveryStructure>) unmarshaller |
| 208 | + .unmarshal(new ByteArrayInputStream(xml.getBytes())); |
177 | 209 |
|
| 210 | + PublicationDeliveryStructure publicationDeliveryStructure = jaxbElement.getValue(); |
| 211 | + SiteFrame siteFrame = (SiteFrame) publicationDeliveryStructure.getDataObjects().getCompositeFrameOrCommonFrame().get(0).getValue(); |
178 | 212 |
|
| 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 | + } |
179 | 218 | } |
0 commit comments