From 1f982f9e7f9f38743bbc1bcf2609292579762341 Mon Sep 17 00:00:00 2001 From: emartin Date: Tue, 5 Mar 2019 16:29:36 +0000 Subject: Added Filtering of Measurement file Change-Id: I32cd7147c20cbee7273d7c7180a06d9f2fdf620b Issue-ID: DCAEGEN2-1288 Signed-off-by: emartin --- .../pmmapper/filtering/MeasFilterHandler.java | 141 ++ .../dcaegen2/services/pmmapper/model/Event.java | 2 + .../services/pmmapper/model/MapperConfig.java | 3 + .../services/pmmapper/model/MeasCollecFile.java | 1844 ++++++++++++++++++++ .../services/pmmapper/model/MeasFilterConfig.java | 53 + .../services/pmmapper/model/package-info.java | 24 + .../services/pmmapper/utils/MeasConverter.java | 76 + .../pmmapper/filtering/MeasFilterHandlerTest.java | 171 ++ .../services/pmmapper/utils/MeasConverterTest.java | 83 + src/test/resources/filter_test/meas_results.xml | 24 + .../filter_test/meas_results_filtered.xml | 22 + .../filter_test/meas_results_manyInfo.xml | 44 + .../filter_test/meas_results_manyInfo_filtered.xml | 32 + src/test/resources/filter_test/meas_type_and_r.xml | 26 + .../filter_test/meas_type_and_r_filtered.xml | 25 + .../filter_test/meas_type_and_r_manyInfo.xml | 54 + .../meas_type_and_r_manyInfo_filtered.xml | 38 + .../mapping_data/valid_data/meas_results.xml | 4 +- .../mapping_data/valid_data/meas_type_and_r.xml | 4 +- src/test/resources/valid_mapper_config.json | 2 +- 20 files changed, 2667 insertions(+), 5 deletions(-) create mode 100644 src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java create mode 100644 src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java create mode 100644 src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasFilterConfig.java create mode 100644 src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java create mode 100644 src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java create mode 100644 src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java create mode 100644 src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java create mode 100644 src/test/resources/filter_test/meas_results.xml create mode 100644 src/test/resources/filter_test/meas_results_filtered.xml create mode 100644 src/test/resources/filter_test/meas_results_manyInfo.xml create mode 100644 src/test/resources/filter_test/meas_results_manyInfo_filtered.xml create mode 100644 src/test/resources/filter_test/meas_type_and_r.xml create mode 100644 src/test/resources/filter_test/meas_type_and_r_filtered.xml create mode 100644 src/test/resources/filter_test/meas_type_and_r_manyInfo.xml create mode 100644 src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml (limited to 'src') diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java new file mode 100644 index 0000000..a6017b6 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandler.java @@ -0,0 +1,141 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.filtering; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; +import java.util.function.Function; +import java.util.stream.Collectors; +import org.onap.dcaegen2.services.pmmapper.model.Event; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasType; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasValue; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile.MeasData.MeasInfo.MeasValue.R; +import org.onap.dcaegen2.services.pmmapper.model.MeasFilterConfig.Filter; +import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; +import org.onap.logging.ref.slf4j.ONAPLogAdapter; +import org.slf4j.LoggerFactory; + +/** + * Provides filtering of the contents of the 3GPP PM Measurement file. + **/ +public class MeasFilterHandler { + private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(MeasFilterHandler.class)); + private Filter filter; + private MeasConverter converter; + + public MeasFilterHandler(MeasConverter converter) { + this.converter = converter; + } + + public void setFilter(Filter filter) { + this.filter = filter; + } + + /** + * Filters each measInfo node for measTypes that match the given measTypes from filters. + **/ + public boolean filterByMeasType(Event event) { + logger.unwrap().debug("Filtering the measurement file."); + + MeasCollecFile measCollecFile = event.getMeasCollecFile(); + if(filter.getMeasTypes().isEmpty() || measCollecFile.getMeasData().isEmpty()) { + return false; + } + + MeasData measData = measCollecFile.getMeasData().get(0); + List measInfos = measData.getMeasInfo(); + List filteredMeasInfos = new ArrayList<>(); + + for (int i = 0; i < measInfos.size(); i++) { + MeasInfo currentMeasInfo = measInfos.get(i); + List measTypesNode = currentMeasInfo.getMeasTypes(); + if(!measTypesNode.isEmpty()) { + setMeasInfosFromMeasTypes(currentMeasInfo,filteredMeasInfos); + }else { + setMeasInfoFromMeasType(currentMeasInfo,filteredMeasInfos); + } + } + + if (filteredMeasInfos.isEmpty()) { + return false; + } + + measData.setMeasInfo(filteredMeasInfos); + String filteredXMl = converter.convert(measCollecFile); + event.setBody(filteredXMl); + return true; + } + + private void setMeasInfoFromMeasType(MeasInfo currentMeasInfo, List filteredMeasInfos) { + MeasValue currentMeasValue = currentMeasInfo.getMeasValue() + .get(0); + List measResultsRNodes = currentMeasValue.getR(); + Map mappedR = measResultsRNodes.stream() + .collect(Collectors.toMap(R::getP, Function.identity())); + List filteredRs = new ArrayList<>(); + List filteredMeasTypes = currentMeasInfo.getMeasType() + .stream().filter(mt -> { + List measTypeFilters = filter.getMeasTypes(); + if (measTypeFilters.contains(mt.getValue())) { + filteredRs.add(mappedR.get(mt.getP())); + return true; + } + return false; + }) + .collect(Collectors.toList()); + if (!filteredMeasTypes.isEmpty()) { + currentMeasInfo.replaceMeasType(filteredMeasTypes); + currentMeasValue.replaceR(filteredRs); + filteredMeasInfos.add(currentMeasInfo); + } + + } + + private void setMeasInfosFromMeasTypes(MeasInfo currentMeasInfo, List filteredMeasInfos) { + MeasValue currentMeasValue = currentMeasInfo.getMeasValue() + .get(0); + List measTypesNode = currentMeasInfo.getMeasTypes(); + List measResultsNode = currentMeasValue.getMeasResults(); + List filteredMeasResults = new ArrayList<>(); + + List filteredMeasTypes = new ArrayList<>(); + for (int j = 0; j < measTypesNode.size(); j++) { + String currentMeasType = measTypesNode.get(j); + List measTypeFilters = filter.getMeasTypes(); + if (measTypeFilters.contains(currentMeasType)) { + filteredMeasTypes.add(currentMeasType); + filteredMeasResults.add(measResultsNode.get(j)); + } + } + + if (!filteredMeasTypes.isEmpty()) { + currentMeasInfo.replaceMeasTypes(filteredMeasTypes); + currentMeasValue.replaceMeasResults(filteredMeasResults); + filteredMeasInfos.add(currentMeasInfo); + } + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java index 7a7cb1f..0e82119 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/Event.java @@ -40,4 +40,6 @@ public class Event { private Map mdc; @NonNull private String publishIdentity; + + MeasCollecFile measCollecFile; } diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java index 0412ece..2f13080 100644 --- a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MapperConfig.java @@ -141,4 +141,7 @@ public class MapperConfig { @SerializedName("topic_url") private String topicUrl; } + + @SerializedName("pm-mapper-filter") + MeasFilterConfig filterConfig; } \ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java new file mode 100644 index 0000000..572b46b --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasCollecFile.java @@ -0,0 +1,1844 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.dcaegen2.services.pmmapper.model; + +import java.math.BigInteger; +import java.util.ArrayList; +import java.util.List; + +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlAttribute; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlList; +import javax.xml.bind.annotation.XmlRootElement; +import javax.xml.bind.annotation.XmlSchemaType; +import javax.xml.bind.annotation.XmlType; +import javax.xml.bind.annotation.XmlValue; +import javax.xml.bind.annotation.adapters.CollapsedStringAdapter; +import javax.xml.bind.annotation.adapters.XmlJavaTypeAdapter; +import javax.xml.datatype.Duration; +import javax.xml.datatype.XMLGregorianCalendar; + +/** + *

+ * Generated Java class using XJC to represent 3GPP PM Measurement file + * + *

+ * The following schema fragment specifies the expected content contained within + * this class. + * + *

+ * <complexType>
+ *   <complexContent>
+ *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *       <sequence>
+ *         <element name="fileHeader">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="fileSender">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                   <element name="measCollec">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *                 <attribute name="fileFormatVersion" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="vendorName" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                 <attribute name="dnPrefix" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="measData" maxOccurs="unbounded" minOccurs="0">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="managedElement">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                           <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                   <element name="measInfo" maxOccurs="unbounded" minOccurs="0">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <sequence>
+ *                             <element name="job" minOccurs="0">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                             <element name="granPeriod">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+ *                                     <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                             <element name="repPeriod" minOccurs="0">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                             <choice>
+ *                               <element name="measTypes">
+ *                                 <simpleType>
+ *                                   <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
+ *                                 </simpleType>
+ *                               </element>
+ *                               <element name="measType" maxOccurs="unbounded" minOccurs="0">
+ *                                 <complexType>
+ *                                   <simpleContent>
+ *                                     <extension base="<http://www.w3.org/2001/XMLSchema>Name">
+ *                                       <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+ *                                     </extension>
+ *                                   </simpleContent>
+ *                                 </complexType>
+ *                               </element>
+ *                             </choice>
+ *                             <element name="measValue" maxOccurs="unbounded" minOccurs="0">
+ *                               <complexType>
+ *                                 <complexContent>
+ *                                   <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                                     <sequence>
+ *                                       <choice>
+ *                                         <element name="measResults">
+ *                                           <simpleType>
+ *                                             <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
+ *                                           </simpleType>
+ *                                         </element>
+ *                                         <element name="r" maxOccurs="unbounded" minOccurs="0">
+ *                                           <complexType>
+ *                                             <simpleContent>
+ *                                               <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
+ *                                                 <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+ *                                               </extension>
+ *                                             </simpleContent>
+ *                                           </complexType>
+ *                                         </element>
+ *                                       </choice>
+ *                                       <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+ *                                     </sequence>
+ *                                     <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                                   </restriction>
+ *                                 </complexContent>
+ *                               </complexType>
+ *                             </element>
+ *                           </sequence>
+ *                           <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *         <element name="fileFooter">
+ *           <complexType>
+ *             <complexContent>
+ *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                 <sequence>
+ *                   <element name="measCollec">
+ *                     <complexType>
+ *                       <complexContent>
+ *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+ *                           <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+ *                         </restriction>
+ *                       </complexContent>
+ *                     </complexType>
+ *                   </element>
+ *                 </sequence>
+ *               </restriction>
+ *             </complexContent>
+ *           </complexType>
+ *         </element>
+ *       </sequence>
+ *     </restriction>
+ *   </complexContent>
+ * </complexType>
+ * 
+ * + * + */ +@XmlAccessorType(XmlAccessType.FIELD) +@XmlType(name = "", propOrder = { + "fileHeader", + "measData", + "fileFooter" +}) +@XmlRootElement(name = "measCollecFile") +public class MeasCollecFile { + + @XmlElement(required = true) + protected MeasCollecFile.FileHeader fileHeader; + protected List measData; + @XmlElement(required = true) + protected MeasCollecFile.FileFooter fileFooter; + + /** + * Gets the value of the fileHeader property. + * + * @return + * possible object is + * {@link MeasCollecFile.FileHeader } + * + */ + public MeasCollecFile.FileHeader getFileHeader() { + return fileHeader; + } + + /** + * Sets the value of the fileHeader property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.FileHeader } + * + */ + public void setFileHeader(MeasCollecFile.FileHeader value) { + this.fileHeader = value; + } + + /** + * Gets the value of the measData property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measData property. + * + *

+ * For example, to add a new item, do as follows: + *

+     *    getMeasData().add(newItem);
+     * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MeasCollecFile.MeasData } + * + * + */ + public List getMeasData() { + if (measData == null) { + measData = new ArrayList(); + } + return this.measData; + } + + /** + * Gets the value of the fileFooter property. + * + * @return + * possible object is + * {@link MeasCollecFile.FileFooter } + * + */ + public MeasCollecFile.FileFooter getFileFooter() { + return fileFooter; + } + + /** + * Sets the value of the fileFooter property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.FileFooter } + * + */ + public void setFileFooter(MeasCollecFile.FileFooter value) { + this.fileFooter = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="measCollec">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "measCollec" + }) + public static class FileFooter { + + @XmlElement(required = true) + protected MeasCollecFile.FileFooter.MeasCollec measCollec; + + /** + * Gets the value of the measCollec property. + * + * @return + * possible object is + * {@link MeasCollecFile.FileFooter.MeasCollec } + * + */ + public MeasCollecFile.FileFooter.MeasCollec getMeasCollec() { + return measCollec; + } + + /** + * Sets the value of the measCollec property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.FileFooter.MeasCollec } + * + */ + public void setMeasCollec(MeasCollecFile.FileFooter.MeasCollec value) { + this.measCollec = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class MeasCollec { + + @XmlAttribute(name = "endTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar endTime; + + /** + * Gets the value of the endTime property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getEndTime() { + return endTime; + } + + /** + * Sets the value of the endTime property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setEndTime(XMLGregorianCalendar value) { + this.endTime = value; + } + + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="fileSender">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *         <element name="measCollec">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *       <attribute name="fileFormatVersion" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="vendorName" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *       <attribute name="dnPrefix" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "fileSender", + "measCollec" + }) + public static class FileHeader { + + @XmlElement(required = true) + protected MeasCollecFile.FileHeader.FileSender fileSender; + @XmlElement(required = true) + protected MeasCollecFile.FileHeader.MeasCollec measCollec; + @XmlAttribute(name = "fileFormatVersion", required = true) + protected String fileFormatVersion; + @XmlAttribute(name = "vendorName") + protected String vendorName; + @XmlAttribute(name = "dnPrefix") + protected String dnPrefix; + + /** + * Gets the value of the fileSender property. + * + * @return + * possible object is + * {@link MeasCollecFile.FileHeader.FileSender } + * + */ + public MeasCollecFile.FileHeader.FileSender getFileSender() { + return fileSender; + } + + /** + * Sets the value of the fileSender property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.FileHeader.FileSender } + * + */ + public void setFileSender(MeasCollecFile.FileHeader.FileSender value) { + this.fileSender = value; + } + + /** + * Gets the value of the measCollec property. + * + * @return + * possible object is + * {@link MeasCollecFile.FileHeader.MeasCollec } + * + */ + public MeasCollecFile.FileHeader.MeasCollec getMeasCollec() { + return measCollec; + } + + /** + * Sets the value of the measCollec property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.FileHeader.MeasCollec } + * + */ + public void setMeasCollec(MeasCollecFile.FileHeader.MeasCollec value) { + this.measCollec = value; + } + + /** + * Gets the value of the fileFormatVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getFileFormatVersion() { + return fileFormatVersion; + } + + /** + * Sets the value of the fileFormatVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setFileFormatVersion(String value) { + this.fileFormatVersion = value; + } + + /** + * Gets the value of the vendorName property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getVendorName() { + return vendorName; + } + + /** + * Sets the value of the vendorName property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setVendorName(String value) { + this.vendorName = value; + } + + /** + * Gets the value of the dnPrefix property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getDnPrefix() { + return dnPrefix; + } + + /** + * Sets the value of the dnPrefix property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setDnPrefix(String value) { + this.dnPrefix = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="elementType" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class FileSender { + + @XmlAttribute(name = "localDn") + protected String localDn; + @XmlAttribute(name = "elementType") + protected String elementType; + + /** + * Gets the value of the localDn property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLocalDn() { + return localDn; + } + + /** + * Sets the value of the localDn property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLocalDn(String value) { + this.localDn = value; + } + + /** + * Gets the value of the elementType property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getElementType() { + return elementType; + } + + /** + * Sets the value of the elementType property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setElementType(String value) { + this.elementType = value; + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="beginTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class MeasCollec { + + @XmlAttribute(name = "beginTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar beginTime; + + /** + * Gets the value of the beginTime property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getBeginTime() { + return beginTime; + } + + /** + * Sets the value of the beginTime property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setBeginTime(XMLGregorianCalendar value) { + this.beginTime = value; + } + + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+     * <complexType>
+     *   <complexContent>
+     *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *       <sequence>
+     *         <element name="managedElement">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                 <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *         <element name="measInfo" maxOccurs="unbounded" minOccurs="0">
+     *           <complexType>
+     *             <complexContent>
+     *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                 <sequence>
+     *                   <element name="job" minOccurs="0">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                   <element name="granPeriod">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+     *                           <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                   <element name="repPeriod" minOccurs="0">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                   <choice>
+     *                     <element name="measTypes">
+     *                       <simpleType>
+     *                         <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
+     *                       </simpleType>
+     *                     </element>
+     *                     <element name="measType" maxOccurs="unbounded" minOccurs="0">
+     *                       <complexType>
+     *                         <simpleContent>
+     *                           <extension base="<http://www.w3.org/2001/XMLSchema>Name">
+     *                             <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+     *                           </extension>
+     *                         </simpleContent>
+     *                       </complexType>
+     *                     </element>
+     *                   </choice>
+     *                   <element name="measValue" maxOccurs="unbounded" minOccurs="0">
+     *                     <complexType>
+     *                       <complexContent>
+     *                         <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+     *                           <sequence>
+     *                             <choice>
+     *                               <element name="measResults">
+     *                                 <simpleType>
+     *                                   <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
+     *                                 </simpleType>
+     *                               </element>
+     *                               <element name="r" maxOccurs="unbounded" minOccurs="0">
+     *                                 <complexType>
+     *                                   <simpleContent>
+     *                                     <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
+     *                                       <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+     *                                     </extension>
+     *                                   </simpleContent>
+     *                                 </complexType>
+     *                               </element>
+     *                             </choice>
+     *                             <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+     *                           </sequence>
+     *                           <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *                         </restriction>
+     *                       </complexContent>
+     *                     </complexType>
+     *                   </element>
+     *                 </sequence>
+     *                 <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
+     *               </restriction>
+     *             </complexContent>
+     *           </complexType>
+     *         </element>
+     *       </sequence>
+     *     </restriction>
+     *   </complexContent>
+     * </complexType>
+     * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "managedElement", + "measInfo" + }) + public static class MeasData { + + @XmlElement(required = true) + protected MeasCollecFile.MeasData.ManagedElement managedElement; + protected List measInfo; + + /** + * Gets the value of the managedElement property. + * + * @return + * possible object is + * {@link MeasCollecFile.MeasData.ManagedElement } + * + */ + public MeasCollecFile.MeasData.ManagedElement getManagedElement() { + return managedElement; + } + + /** + * Sets the value of the managedElement property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.MeasData.ManagedElement } + * + */ + public void setManagedElement(MeasCollecFile.MeasData.ManagedElement value) { + this.managedElement = value; + } + + /** + * Gets the value of the measInfo property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measInfo property. + * + *

+ * For example, to add a new item, do as follows: + *

+         *    getMeasInfo().add(newItem);
+         * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MeasCollecFile.MeasData.MeasInfo } + * + * + */ + public List getMeasInfo() { + if (measInfo == null) { + measInfo = new ArrayList(); + } + return this.measInfo; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <attribute name="localDn" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="userLabel" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *       <attribute name="swVersion" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class ManagedElement { + + @XmlAttribute(name = "localDn") + protected String localDn; + @XmlAttribute(name = "userLabel") + protected String userLabel; + @XmlAttribute(name = "swVersion") + protected String swVersion; + + /** + * Gets the value of the localDn property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getLocalDn() { + return localDn; + } + + /** + * Sets the value of the localDn property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setLocalDn(String value) { + this.localDn = value; + } + + /** + * Gets the value of the userLabel property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getUserLabel() { + return userLabel; + } + + /** + * Sets the value of the userLabel property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setUserLabel(String value) { + this.userLabel = value; + } + + /** + * Gets the value of the swVersion property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getSwVersion() { + return swVersion; + } + + /** + * Sets the value of the swVersion property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setSwVersion(String value) { + this.swVersion = value; + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+         * <complexType>
+         *   <complexContent>
+         *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *       <sequence>
+         *         <element name="job" minOccurs="0">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *         <element name="granPeriod">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+         *                 <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *         <element name="repPeriod" minOccurs="0">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *         <choice>
+         *           <element name="measTypes">
+         *             <simpleType>
+         *               <list itemType="{http://www.w3.org/2001/XMLSchema}Name" />
+         *             </simpleType>
+         *           </element>
+         *           <element name="measType" maxOccurs="unbounded" minOccurs="0">
+         *             <complexType>
+         *               <simpleContent>
+         *                 <extension base="<http://www.w3.org/2001/XMLSchema>Name">
+         *                   <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+         *                 </extension>
+         *               </simpleContent>
+         *             </complexType>
+         *           </element>
+         *         </choice>
+         *         <element name="measValue" maxOccurs="unbounded" minOccurs="0">
+         *           <complexType>
+         *             <complexContent>
+         *               <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+         *                 <sequence>
+         *                   <choice>
+         *                     <element name="measResults">
+         *                       <simpleType>
+         *                         <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
+         *                       </simpleType>
+         *                     </element>
+         *                     <element name="r" maxOccurs="unbounded" minOccurs="0">
+         *                       <complexType>
+         *                         <simpleContent>
+         *                           <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
+         *                             <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+         *                           </extension>
+         *                         </simpleContent>
+         *                       </complexType>
+         *                     </element>
+         *                   </choice>
+         *                   <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+         *                 </sequence>
+         *                 <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *               </restriction>
+         *             </complexContent>
+         *           </complexType>
+         *         </element>
+         *       </sequence>
+         *       <attribute name="measInfoId" type="{http://www.w3.org/2001/XMLSchema}string" />
+         *     </restriction>
+         *   </complexContent>
+         * </complexType>
+         * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "job", + "granPeriod", + "repPeriod", + "measTypes", + "measType", + "measValue" + }) + public static class MeasInfo { + + protected MeasCollecFile.MeasData.MeasInfo.Job job; + @XmlElement(required = true) + protected MeasCollecFile.MeasData.MeasInfo.GranPeriod granPeriod; + protected MeasCollecFile.MeasData.MeasInfo.RepPeriod repPeriod; + @XmlList + protected List measTypes; + protected List measType; + protected List measValue; + @XmlAttribute(name = "measInfoId") + protected String measInfoId; + + /** + * Gets the value of the job property. + * + * @return + * possible object is + * {@link MeasCollecFile.MeasData.MeasInfo.Job } + * + */ + public MeasCollecFile.MeasData.MeasInfo.Job getJob() { + return job; + } + + /** + * Sets the value of the job property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.MeasData.MeasInfo.Job } + * + */ + public void setJob(MeasCollecFile.MeasData.MeasInfo.Job value) { + this.job = value; + } + + /** + * Gets the value of the granPeriod property. + * + * @return + * possible object is + * {@link MeasCollecFile.MeasData.MeasInfo.GranPeriod } + * + */ + public MeasCollecFile.MeasData.MeasInfo.GranPeriod getGranPeriod() { + return granPeriod; + } + + /** + * Sets the value of the granPeriod property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.MeasData.MeasInfo.GranPeriod } + * + */ + public void setGranPeriod(MeasCollecFile.MeasData.MeasInfo.GranPeriod value) { + this.granPeriod = value; + } + + /** + * Gets the value of the repPeriod property. + * + * @return + * possible object is + * {@link MeasCollecFile.MeasData.MeasInfo.RepPeriod } + * + */ + public MeasCollecFile.MeasData.MeasInfo.RepPeriod getRepPeriod() { + return repPeriod; + } + + /** + * Sets the value of the repPeriod property. + * + * @param value + * allowed object is + * {@link MeasCollecFile.MeasData.MeasInfo.RepPeriod } + * + */ + public void setRepPeriod(MeasCollecFile.MeasData.MeasInfo.RepPeriod value) { + this.repPeriod = value; + } + + /** + * Gets the value of the measTypes property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measTypes property. + * + *

+ * For example, to add a new item, do as follows: + *

+             *    getMeasTypes().add(newItem);
+             * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getMeasTypes() { + if (measTypes == null) { + measTypes = new ArrayList(); + } + return this.measTypes; + } + + /** + * Gets the value of the measType property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measType property. + * + *

+ * For example, to add a new item, do as follows: + *

+             *    getMeasType().add(newItem);
+             * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MeasCollecFile.MeasData.MeasInfo.MeasType } + * + * + */ + public List getMeasType() { + if (measType == null) { + measType = new ArrayList(); + } + return this.measType; + } + + /** + * Gets the value of the measValue property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measValue property. + * + *

+ * For example, to add a new item, do as follows: + *

+             *    getMeasValue().add(newItem);
+             * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MeasCollecFile.MeasData.MeasInfo.MeasValue } + * + * + */ + public List getMeasValue() { + if (measValue == null) { + measValue = new ArrayList(); + } + return this.measValue; + } + + /** + * Gets the value of the measInfoId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMeasInfoId() { + return measInfoId; + } + + /** + * Sets the value of the measInfoId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMeasInfoId(String value) { + this.measInfoId = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+             *       <attribute name="endTime" use="required" type="{http://www.w3.org/2001/XMLSchema}dateTime" />
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class GranPeriod { + + @XmlAttribute(name = "duration", required = true) + protected Duration duration; + @XmlAttribute(name = "endTime", required = true) + @XmlSchemaType(name = "dateTime") + protected XMLGregorianCalendar endTime; + + /** + * Gets the value of the duration property. + * + * @return + * possible object is + * {@link Duration } + * + */ + public Duration getDuration() { + return duration; + } + + /** + * Sets the value of the duration property. + * + * @param value + * allowed object is + * {@link Duration } + * + */ + public void setDuration(Duration value) { + this.duration = value; + } + + /** + * Gets the value of the endTime property. + * + * @return + * possible object is + * {@link XMLGregorianCalendar } + * + */ + public XMLGregorianCalendar getEndTime() { + return endTime; + } + + /** + * Sets the value of the endTime property. + * + * @param value + * allowed object is + * {@link XMLGregorianCalendar } + * + */ + public void setEndTime(XMLGregorianCalendar value) { + this.endTime = value; + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <attribute name="jobId" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class Job { + + @XmlAttribute(name = "jobId", required = true) + protected String jobId; + + /** + * Gets the value of the jobId property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getJobId() { + return jobId; + } + + /** + * Sets the value of the jobId property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setJobId(String value) { + this.jobId = value; + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <simpleContent>
+             *     <extension base="<http://www.w3.org/2001/XMLSchema>Name">
+             *       <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+             *     </extension>
+             *   </simpleContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "value" + }) + public static class MeasType { + + @XmlValue + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlSchemaType(name = "Name") + protected String value; + @XmlAttribute(name = "p", required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger p; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the p property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getP() { + return p; + } + + /** + * Sets the value of the p property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setP(BigInteger value) { + this.p = value; + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <sequence>
+             *         <choice>
+             *           <element name="measResults">
+             *             <simpleType>
+             *               <list itemType="{http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec}measResultType" />
+             *             </simpleType>
+             *           </element>
+             *           <element name="r" maxOccurs="unbounded" minOccurs="0">
+             *             <complexType>
+             *               <simpleContent>
+             *                 <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
+             *                   <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+             *                 </extension>
+             *               </simpleContent>
+             *             </complexType>
+             *           </element>
+             *         </choice>
+             *         <element name="suspect" type="{http://www.w3.org/2001/XMLSchema}boolean" minOccurs="0"/>
+             *       </sequence>
+             *       <attribute name="measObjLdn" use="required" type="{http://www.w3.org/2001/XMLSchema}string" />
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "measResults", + "r", + "suspect" + }) + public static class MeasValue { + + @XmlList + protected List measResults; + protected List r; + protected Boolean suspect; + @XmlAttribute(name = "measObjLdn", required = true) + protected String measObjLdn; + + /** + * Gets the value of the measResults property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the measResults property. + * + *

+ * For example, to add a new item, do as follows: + *

+                 *    getMeasResults().add(newItem);
+                 * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link String } + * + * + */ + public List getMeasResults() { + if (measResults == null) { + measResults = new ArrayList(); + } + return this.measResults; + } + + /** + * Gets the value of the r property. + * + *

+ * This accessor method returns a reference to the live list, + * not a snapshot. Therefore any modification you make to the + * returned list will be present inside the JAXB object. + * This is why there is not a set method for the r property. + * + *

+ * For example, to add a new item, do as follows: + *

+                 *    getR().add(newItem);
+                 * 
+ * + * + *

+ * Objects of the following type(s) are allowed in the list + * {@link MeasCollecFile.MeasData.MeasInfo.MeasValue.R } + * + * + */ + public List getR() { + if (r == null) { + r = new ArrayList(); + } + return this.r; + } + + /** + * Gets the value of the suspect property. + * + * @return + * possible object is + * {@link Boolean } + * + */ + public Boolean isSuspect() { + return suspect; + } + + /** + * Sets the value of the suspect property. + * + * @param value + * allowed object is + * {@link Boolean } + * + */ + public void setSuspect(Boolean value) { + this.suspect = value; + } + + /** + * Gets the value of the measObjLdn property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getMeasObjLdn() { + return measObjLdn; + } + + /** + * Sets the value of the measObjLdn property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setMeasObjLdn(String value) { + this.measObjLdn = value; + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+                 * <complexType>
+                 *   <simpleContent>
+                 *     <extension base="<http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec>measResultType">
+                 *       <attribute name="p" use="required" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" />
+                 *     </extension>
+                 *   </simpleContent>
+                 * </complexType>
+                 * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "", propOrder = { + "value" + }) + public static class R { + + @XmlValue + protected String value; + @XmlAttribute(name = "p", required = true) + @XmlSchemaType(name = "positiveInteger") + protected BigInteger p; + + /** + * Gets the value of the value property. + * + * @return + * possible object is + * {@link String } + * + */ + public String getValue() { + return value; + } + + /** + * Sets the value of the value property. + * + * @param value + * allowed object is + * {@link String } + * + */ + public void setValue(String value) { + this.value = value; + } + + /** + * Gets the value of the p property. + * + * @return + * possible object is + * {@link BigInteger } + * + */ + public BigInteger getP() { + return p; + } + + /** + * Sets the value of the p property. + * + * @param value + * allowed object is + * {@link BigInteger } + * + */ + public void setP(BigInteger value) { + this.p = value; + } + + } + + + public void replaceR(List filteredRs) { + this.r = filteredRs; + + } + + public void replaceMeasResults(List filteredMeasResults) { + this.measResults = filteredMeasResults; + + } + + } + + + /** + *

Java class for anonymous complex type. + * + *

The following schema fragment specifies the expected content contained within this class. + * + *

+             * <complexType>
+             *   <complexContent>
+             *     <restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
+             *       <attribute name="duration" use="required" type="{http://www.w3.org/2001/XMLSchema}duration" />
+             *     </restriction>
+             *   </complexContent>
+             * </complexType>
+             * 
+ * + * + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlType(name = "") + public static class RepPeriod { + + @XmlAttribute(name = "duration", required = true) + protected Duration duration; + + /** + * Gets the value of the duration property. + * + * @return + * possible object is + * {@link Duration } + * + */ + public Duration getDuration() { + return duration; + } + + /** + * Sets the value of the duration property. + * + * @param value + * allowed object is + * {@link Duration } + * + */ + public void setDuration(Duration value) { + this.duration = value; + } + } + + + public void replaceMeasTypes(List newMeasTypes) { + this.measTypes = newMeasTypes; + } + + public void replaceMeasType(List filteredMeasTypes) { + this.measType = filteredMeasTypes; + } + + } + + + public void setMeasInfo(List filteredMeasInfos) { + this.measInfo = filteredMeasInfos; + } + + } + +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasFilterConfig.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasFilterConfig.java new file mode 100644 index 0000000..458a6cd --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/MeasFilterConfig.java @@ -0,0 +1,53 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.model; + +import java.util.List; +import com.google.gson.annotations.SerializedName; + +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; + +@Data +@EqualsAndHashCode +@NoArgsConstructor +public class MeasFilterConfig { + + @SerializedName("filters") + public List filters; + + @Data + public class Filter { + @SerializedName("pmDefVsn") + private String dictionaryVersion; + + @SerializedName("nfType") + private String nfType; + + @SerializedName("vendor") + private String vendor; + + @SerializedName("measTypes") + private List measTypes; + + } +} diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java new file mode 100644 index 0000000..92c83be --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/model/package-info.java @@ -0,0 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +@XmlSchema(namespace = "http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec", elementFormDefault = XmlNsForm.QUALIFIED) +package org.onap.dcaegen2.services.pmmapper.model; +import javax.xml.bind.annotation.XmlSchema; +import javax.xml.bind.annotation.XmlNsForm; \ No newline at end of file diff --git a/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java new file mode 100644 index 0000000..b9c01e6 --- /dev/null +++ b/src/main/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverter.java @@ -0,0 +1,76 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.utils; + +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile; +import org.onap.logging.ref.slf4j.ONAPLogAdapter; +import org.slf4j.LoggerFactory; + +/** + * Converts 3GPP PM Measurement xml string to MeasCollecFil and vice versa. + **/ +public class MeasConverter { + private static final ONAPLogAdapter logger = new ONAPLogAdapter(LoggerFactory.getLogger(MeasConverter.class)); + + /** + * Converts 3GPP Measurement xml string to MeasCollecFile. + **/ + public MeasCollecFile convert(String eventBody) { + logger.unwrap().debug("Converting 3GPP xml string to MeasCollecFile"); + MeasCollecFile measCollecFile = null; + try { + JAXBContext jaxbContext = null; + jaxbContext = JAXBContext.newInstance(MeasCollecFile.class); + Unmarshaller unmarshaller = jaxbContext.createUnmarshaller(); + measCollecFile = (MeasCollecFile) unmarshaller.unmarshal(new StringReader(eventBody)); + } catch (JAXBException e) { + throw new MappingException("Unable to convert 3GPP xml to MeasCollecFile", e); + } + return measCollecFile; + } + + /** + * Converts MeasCollecFile to 3GPP Measurement xml string. + **/ + public String convert(MeasCollecFile measCollecFile) { + logger.unwrap().debug("Converting MeasCollecFile to 3GPP xml string"); + StringWriter writer = new StringWriter(); + try { + JAXBContext jaxbContext = JAXBContext.newInstance(MeasCollecFile.class); + Marshaller marshaller = jaxbContext.createMarshaller(); + marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE); + marshaller.setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE); + marshaller.marshal(measCollecFile, writer); + } catch (JAXBException e) { + throw new MappingException("Unable to convert MeasCollecFile to 3GPP xml", e); + } + return writer.toString(); + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java new file mode 100644 index 0000000..8b1f8aa --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java @@ -0,0 +1,171 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ + +package org.onap.dcaegen2.services.pmmapper.filtering; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; + +import java.io.IOException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.HashMap; +import java.util.List; +import java.util.stream.Collectors; + +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.MethodSource; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.onap.dcaegen2.services.pmmapper.model.Event; +import org.onap.dcaegen2.services.pmmapper.model.EventMetadata; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile; +import org.onap.dcaegen2.services.pmmapper.model.MeasFilterConfig; +import org.onap.dcaegen2.services.pmmapper.model.MeasFilterConfig.Filter; +import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; + +import io.undertow.server.HttpServerExchange; +import utils.EventUtils; + +@ExtendWith(MockitoExtension.class) +class MeasFilterHandlerTest { + + private static MeasFilterConfig filterConfig; + private static final String baseDir = "src/test/resources/filter_test/"; + private static final Path dataDirectory = Paths.get("src/test/resources/mapper_test/mapping_data/"); + private static List counters = Arrays.asList("a", "b"); + private static MeasConverter converter = new MeasConverter(); + private MeasFilterHandler objUnderTest; + @Mock + private HttpServerExchange exchange; + @Mock + private EventMetadata metaData; + + @BeforeEach + void setup() { + filterConfig = new MeasFilterConfig(); + Filter filter = filterConfig.new Filter(); + filter.setDictionaryVersion(""); + filter.setMeasTypes(counters); + filterConfig.setFilters(Arrays.asList(filter)); + objUnderTest = new MeasFilterHandler(new MeasConverter()); + objUnderTest.setFilter(filterConfig.getFilters() + .get(0)); + } + + @Test + void measTypes_byCommaSeparation() throws IOException { + String inputPath = baseDir + "meas_results"; + String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); + String expected = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); + Event event = new Event(exchange, inputXml, metaData, new HashMap(), ""); + event.setMeasCollecFile(converter.convert(inputXml)); + + objUnderTest.filterByMeasType(event); + + String actual = converter.convert(event.getMeasCollecFile()); + assertEquals(expected, actual); + } + + @Test + void measType_byID() throws IOException { + String inputPath = baseDir + "meas_type_and_r"; + String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); + String filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); + Event event = new Event(exchange, inputXml, metaData, new HashMap(), ""); + event.setMeasCollecFile(converter.convert(inputXml)); + MeasCollecFile f = converter.convert(filteredString); + String expected = converter.convert(f); + objUnderTest.filterByMeasType(event); + + String actual = converter.convert(event.getMeasCollecFile()); + assertEquals(expected, actual); + } + + @Test + void no_Filters_match() { + String inputPath = baseDir + "meas_results"; + String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); + + Filter noMatchFilter = filterConfig.new Filter(); + noMatchFilter.setMeasTypes(Arrays.asList("nomatch1", "nomatch2")); + objUnderTest.setFilter(noMatchFilter); + + Event event = new Event(exchange, inputXml, metaData, new HashMap(), ""); + event.setMeasCollecFile(converter.convert(inputXml)); + assertFalse(objUnderTest.filterByMeasType(event)); + } + + @Test + void multiple_measInfos_measResults() { + String inputPath = baseDir + "meas_results_manyInfo"; + String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); + String filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); + Event event = new Event(exchange, inputXml, metaData, new HashMap(), ""); + event.setMeasCollecFile(converter.convert(inputXml)); + MeasCollecFile f = converter.convert(filteredString); + String expected = converter.convert(f); + objUnderTest.filterByMeasType(event); + + String actual = converter.convert(event.getMeasCollecFile()); + assertEquals(expected, actual); + } + + @Test + void multiple_measInfos_measTypeAndR() { + String inputPath = baseDir + "meas_type_and_r_manyInfo"; + String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); + String filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); + Event event = new Event(exchange, inputXml, metaData, new HashMap(), ""); + event.setMeasCollecFile(converter.convert(inputXml)); + MeasCollecFile f = converter.convert(filteredString); + String expected = converter.convert(f); + objUnderTest.filterByMeasType(event); + + String actual = converter.convert(event.getMeasCollecFile()); + assertEquals(expected, actual); + } + + @ParameterizedTest + @MethodSource("getValidMeas") + void applyFilterToValidMeasurements(Event testEvent) { + objUnderTest.filterByMeasType(testEvent); + } + + static List getValidMeas() throws IOException { + final Path metadata = Paths.get("src/test/resources/valid_metadata.json"); + List events = EventUtils + .eventsFromDirectory(Paths.get(dataDirectory.toString() + "/valid_data/"), metadata) + .stream() + .map(e -> { + System.out.println(e.getBody()); + MeasCollecFile m = converter.convert(e.getBody()); + System.out.println(m.getMeasData()); + e.setMeasCollecFile(m); + return e; + }) + .collect(Collectors.toList()); + return events; + } +} diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java new file mode 100644 index 0000000..f51ec5c --- /dev/null +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 Nordix Foundation. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + * SPDX-License-Identifier: Apache-2.0 + * ============LICENSE_END========================================================= + */ +package org.onap.dcaegen2.services.pmmapper.utils; +import static org.junit.jupiter.api.Assertions.assertThrows; + +import java.io.StringReader; +import java.io.StringWriter; + +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Marshaller; +import javax.xml.bind.Unmarshaller; + +import org.junit.Before; +import org.junit.Test; +import org.junit.runner.RunWith; +import org.mockito.Mockito; +import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException; +import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile; +import org.powermock.api.mockito.PowerMockito; +import org.powermock.core.classloader.annotations.PrepareForTest; +import org.powermock.modules.junit4.PowerMockRunner; + +@RunWith(PowerMockRunner.class) +@PrepareForTest({JAXBContext.class}) +public class MeasConverterTest { + + private MeasConverter objUnderTest; + + @Before + public void setup() { + objUnderTest = new MeasConverter(); + } + @Test + public void convertToString_throws_mappingException() throws Exception { + MeasCollecFile file = new MeasCollecFile(); + PowerMockito.mockStatic(JAXBContext.class); + Marshaller marshallerMock = PowerMockito.mock(Marshaller.class); + JAXBContext jaxbContext = PowerMockito.mock(JAXBContext.class); + StringWriter w = Mockito.mock(StringWriter.class); + PowerMockito.whenNew(StringWriter.class).withNoArguments().thenReturn(w); + PowerMockito.when(JAXBContext.newInstance(MeasCollecFile.class)).thenReturn(jaxbContext); + PowerMockito.when(jaxbContext.createMarshaller()).thenReturn(marshallerMock); + PowerMockito.doThrow(new JAXBException("","")) + .when(marshallerMock).marshal( Mockito.any(MeasCollecFile.class) + ,Mockito.any(StringWriter.class)); + + assertThrows(MappingException.class, () -> { + objUnderTest.convert(file); + }); + } + + @Test + public void convertToMeasCollec_throws_mappingException() throws JAXBException { + PowerMockito.mockStatic(JAXBContext.class); + Unmarshaller unmarshallerMock = PowerMockito.mock(Unmarshaller.class); + JAXBContext jaxbContext = PowerMockito.mock(JAXBContext.class); + PowerMockito.when(JAXBContext.newInstance(MeasCollecFile.class)).thenReturn(jaxbContext); + PowerMockito.when(jaxbContext.createUnmarshaller()).thenReturn(unmarshallerMock); + PowerMockito.when(unmarshallerMock.unmarshal(Mockito.any(StringReader.class))).thenThrow(JAXBException.class); + + assertThrows(MappingException.class, () -> { + objUnderTest.convert("xmlString"); + }); + } +} diff --git a/src/test/resources/filter_test/meas_results.xml b/src/test/resources/filter_test/meas_results.xml new file mode 100644 index 0000000..5825e7b --- /dev/null +++ b/src/test/resources/filter_test/meas_results.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + z a zz b + + 99 1 27 2 + false + + + + + + + diff --git a/src/test/resources/filter_test/meas_results_filtered.xml b/src/test/resources/filter_test/meas_results_filtered.xml new file mode 100644 index 0000000..af45364 --- /dev/null +++ b/src/test/resources/filter_test/meas_results_filtered.xml @@ -0,0 +1,22 @@ + + + + + + + + + + + + a b + + 1 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/filter_test/meas_results_manyInfo.xml b/src/test/resources/filter_test/meas_results_manyInfo.xml new file mode 100644 index 0000000..2b87912 --- /dev/null +++ b/src/test/resources/filter_test/meas_results_manyInfo.xml @@ -0,0 +1,44 @@ + + + + + + + + + + + + + z aa zz bb + + 99 1 27 2 + false + + + + + + + z a zz b + + 99 1 27 2 + false + + + + + + + z a zz b + + 99 1 27 2 + false + + + + + + + diff --git a/src/test/resources/filter_test/meas_results_manyInfo_filtered.xml b/src/test/resources/filter_test/meas_results_manyInfo_filtered.xml new file mode 100644 index 0000000..4a887d5 --- /dev/null +++ b/src/test/resources/filter_test/meas_results_manyInfo_filtered.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + a b + + 1 2 + false + + + + + + + a b + + 1 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/filter_test/meas_type_and_r.xml b/src/test/resources/filter_test/meas_type_and_r.xml new file mode 100644 index 0000000..0d99e39 --- /dev/null +++ b/src/test/resources/filter_test/meas_type_and_r.xml @@ -0,0 +1,26 @@ + + + + + + + + + + + + a + z + b + + 1 + 99 + 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/filter_test/meas_type_and_r_filtered.xml b/src/test/resources/filter_test/meas_type_and_r_filtered.xml new file mode 100644 index 0000000..1b5a362 --- /dev/null +++ b/src/test/resources/filter_test/meas_type_and_r_filtered.xml @@ -0,0 +1,25 @@ + + + + + + + + + + + + + a + b + + 1 + 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/filter_test/meas_type_and_r_manyInfo.xml b/src/test/resources/filter_test/meas_type_and_r_manyInfo.xml new file mode 100644 index 0000000..dd35dfc --- /dev/null +++ b/src/test/resources/filter_test/meas_type_and_r_manyInfo.xml @@ -0,0 +1,54 @@ + + + + + + + + + + + + a + z + b + + 1 + 99 + 2 + false + + + + + + + aa + z + bb + + 1 + 99 + 2 + false + + + + + + + a + z + b + + 1 + 99 + 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml b/src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml new file mode 100644 index 0000000..db50fca --- /dev/null +++ b/src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml @@ -0,0 +1,38 @@ + + + + + + + + + + + + + a + b + + 1 + 2 + false + + + + + + + + a + b + + 1 + 2 + false + + + + + + + \ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_results.xml b/src/test/resources/mapper_test/mapping_data/valid_data/meas_results.xml index 0b76547..269fdf1 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/meas_results.xml +++ b/src/test/resources/mapper_test/mapping_data/valid_data/meas_results.xml @@ -9,8 +9,8 @@ - - + + a b c 76 27 98 diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r.xml b/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r.xml index 5f4e3c9..8ff79df 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r.xml +++ b/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r.xml @@ -9,8 +9,8 @@ - - + + a b c diff --git a/src/test/resources/valid_mapper_config.json b/src/test/resources/valid_mapper_config.json index c4423ff..6cd76bd 100644 --- a/src/test/resources/valid_mapper_config.json +++ b/src/test/resources/valid_mapper_config.json @@ -1,5 +1,5 @@ { - "pm-mapper-filter": "{ \"filters\":[]}", + "pm-mapper-filter": {"filters":[]}, "streams_subscribes": { "dmaap_subscriber": { "type": "data_router", -- cgit 1.2.3-korg