diff options
Diffstat (limited to 'src/test')
77 files changed, 1234 insertions, 265 deletions
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java index 46994b3..ce051e4 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/AppTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -24,6 +24,7 @@ import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; @@ -37,6 +38,7 @@ import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.Arrays; +import java.util.HashMap; import java.util.List; import com.google.gson.Gson; @@ -83,7 +85,7 @@ class AppTest { private static final Path dataDirectory = Paths.get("src/test/resources/mapper_test/mapping_data/"); private static final Path metadata = Paths.get("src/test/resources/valid_metadata.json"); private static final Path template = Paths.get("src/main/resources/mapping.ftl"); - private static final Path schema = Paths.get("src/main/resources/measCollec_plusString.xsd"); + private static final Path schema = Paths.get("src/main/resources/schemas/"); private static final String config = "valid_mapper_config.json"; private App objUnderTest; @@ -153,8 +155,9 @@ class AppTest { } @Test - void testHandleBackPressure() { - Event event = utils.EventUtils.makeMockEvent("", mock(EventMetadata.class)); + void testHandleBackPressure() throws Exception{ + Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), + "", mock(EventMetadata.class), new HashMap<>(), ""); App.handleBackPressure(event); verify(event.getHttpServerExchange(), times(1)).setStatusCode(StatusCodes.TOO_MANY_REQUESTS); verify(event.getHttpServerExchange(), times(1)).unDispatch(); @@ -166,8 +169,9 @@ class AppTest { } @Test - void testReceiveRequest() { - Event event = utils.EventUtils.makeMockEvent("", mock(EventMetadata.class)); + void testReceiveRequest() throws Exception { + Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), + "", mock(EventMetadata.class), new HashMap<>(), ""); App.receiveRequest(event); verify(event.getHttpServerExchange(), times(1)).setStatusCode(StatusCodes.OK); verify(event.getHttpServerExchange(), times(1)).unDispatch(); @@ -212,14 +216,14 @@ class AppTest { } @Test - void testValidateXML_success() throws IOException { + void testValidateXML_success() throws Exception { XMLValidator mockValidator = new XMLValidator(schema); MapperConfig mockConfig = Mockito.mock(MapperConfig.class); - String metadataFileContents = new String(Files.readAllBytes(metadata)); + String metadataFileContents = new String(Files.readAllBytes(Paths.get(dataDirectory + "/32.435/meas_results/metadata.json"))); eventMetadata = new Gson().fromJson(metadataFileContents, EventMetadata.class); - Path testFile = Paths.get(dataDirectory + "/valid_data/meas_results.xml"); + Path testFile = Paths.get(dataDirectory + "/32.435/meas_results/test.xml"); Event mockEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), eventMetadata); boolean result = App.validate(mockValidator, mockEvent, mockConfig); @@ -228,17 +232,16 @@ class AppTest { } @Test - void testValidateXML_failure() throws IOException { + void testValidateXML_failure() throws Exception { XMLValidator mockValidator = new XMLValidator(schema); MapperConfig mockConfig = Mockito.mock(MapperConfig.class); String metadataFileContents = new String(Files.readAllBytes(metadata)); eventMetadata = new Gson().fromJson(metadataFileContents, EventMetadata.class); - - Path testFile = Paths.get("src/test/resources/xml_validator_test/test_data/invalid/no_managed_element.xml"); - Event mockEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), eventMetadata); - - boolean result = App.validate(mockValidator, mockEvent, mockConfig); + Path testFile = Paths.get("src/test/resources/xml_validator_test/test_data/lte/no_managed_element/test.xml"); + Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), + EventUtils.fileContentsToString(testFile), eventMetadata, new HashMap<>(), ""); + boolean result = App.validate(mockValidator, event, mockConfig); assertFalse(result); } 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 index 34b71f4..5cd1634 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MeasFilterHandlerTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -26,43 +26,40 @@ import static org.junit.Assert.assertTrue; import static org.mockito.Mockito.mock; import static org.mockito.Mockito.when; -import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.ArrayList; 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.Arguments; 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.model.measurement.common.MeasurementFile; import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; import io.undertow.server.HttpServerExchange; +import utils.ArgumentCreator; import utils.EventUtils; @ExtendWith(MockitoExtension.class) class MeasFilterHandlerTest { + private static final Path FILTER_DIRECTORY = Paths.get("src/test/resources/filter_test/"); 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 MeasConverter converter = new MeasConverter(); private MeasFilterHandler objUnderTest; @Mock private HttpServerExchange exchange; - @Mock - private EventMetadata metaData; @BeforeEach void setup() { @@ -70,34 +67,8 @@ class MeasFilterHandlerTest { } @Test - void measTypes_byCommaSeparation() throws IOException { - String inputPath = baseDir + "meas_results"; - String expected = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); - Event event = generateEvent(inputPath, generateValidFilter()); - - 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 filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); - Event event = generateEvent(inputPath, generateValidFilter()); - MeasCollecFile f = converter.convert(filteredString); - String expected = converter.convert(f); - - objUnderTest.filterByMeasType(event); - - String actual = converter.convert(event.getMeasCollecFile()); - assertEquals(expected, actual); - } - - @Test void skip_mapping_when_no_Filters_match() { - String inputPath = baseDir + "meas_results"; + String inputPath = baseDir + "lte/meas_results/test.xml"; Filter noMatchFilter = new MeasFilterConfig().new Filter(); noMatchFilter.setMeasTypes(Arrays.asList("nomatch1", "nomatch2")); Event event = generateEvent(inputPath, noMatchFilter); @@ -111,7 +82,7 @@ class MeasFilterHandlerTest { @Test void remove_events_that_does_not_match_filter() { - String inputPath = baseDir + "meas_type_and_r_manyInfo"; + String inputPath = baseDir + "lte/meas_type_and_r_manyinfo/test.xml"; Filter matchFilter = new MeasFilterConfig().new Filter(); matchFilter.setMeasTypes(Arrays.asList("a", "b")); @@ -129,71 +100,29 @@ class MeasFilterHandlerTest { @Test void skip_mapping_when_MeasData_isEmpty() { - String inputPath = baseDir + "meas_results"; + String inputPath = baseDir + "lte/meas_results/test.xml"; Event event = generateEvent(inputPath, generateValidFilter()); - event.getMeasCollecFile().replaceMeasData(Arrays.asList()); + event.getMeasurement().replacementMeasurementData(Arrays.asList()); assertFalse(objUnderTest.filterByMeasType(event)); } @Test void skip_filtering_if_filter_or_meastypes_isEmpty() { - String inputPath = baseDir + "meas_results"; + String inputPath = baseDir + "lte/meas_results/test.xml"; Filter emptyMeastypesFilter = new MeasFilterConfig().new Filter(); emptyMeastypesFilter.setMeasTypes(Arrays.asList()); Event event = generateEvent(inputPath, emptyMeastypesFilter); - MeasCollecFile originalMeasCollec = event.getMeasCollecFile(); + MeasurementFile originalMeasCollec = event.getMeasurement(); assertTrue(objUnderTest.filterByMeasType(event)); - assertEquals(originalMeasCollec,event.getMeasCollecFile()); + assertEquals(originalMeasCollec,event.getMeasurement()); event.setFilter(null); assertTrue(objUnderTest.filterByMeasType(event)); - assertEquals(originalMeasCollec,event.getMeasCollecFile()); - } - - @Test - void multiple_measInfos_measResults() { - String inputPath = baseDir + "meas_results_manyInfo"; - String filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); - Event event = generateEvent(inputPath, generateValidFilter()); - - 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 filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); - Event event = generateEvent(inputPath, generateValidFilter()); - - 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_measValues() { - String inputPath = baseDir + "meas_type_and_r_manyMeasvalue"; - String filteredString = EventUtils.fileContentsToString(Paths.get(inputPath + "_filtered.xml")); - Event event = generateEvent(inputPath, generateValidFilter()); - - MeasCollecFile f = converter.convert(filteredString); - String expected = converter.convert(f); - objUnderTest.filterByMeasType(event); - - String actual = converter.convert(event.getMeasCollecFile()); - assertEquals(expected, actual); + assertEquals(originalMeasCollec,event.getMeasurement()); } @Test @@ -208,30 +137,34 @@ class MeasFilterHandlerTest { @Test void invalid_fileType() { Event event = mock(Event.class); - List<String> invalidFiletypes = Arrays.asList("Bpm.xml","Dpm.xml","Apm.xml.gz","Apm.xm1","asdf","bsdf"); + List<String> invalidFileTypes = Arrays.asList("Bpm.xml","Dpm.xml","Apm.xml.gz","Apm.xm1","asdf","bsdf"); when(event.getHttpServerExchange()).thenReturn(exchange); - when(exchange.getRequestPath()) - .thenReturn(invalidFiletypes.toString()); - - invalidFiletypes.forEach(c -> assertFalse(objUnderTest.filterByFileType(event))); + invalidFileTypes.forEach(fileName -> { + when(exchange.getRequestPath()) + .thenReturn(fileName); + assertFalse(objUnderTest.filterByFileType(event)); + }); } - @ParameterizedTest - @MethodSource("getValidMeas") - void applyFilterToValidMeasurements(Event testEvent) { + @MethodSource("getEvents") + void filter_valid_measurements(Event expectedEvent, Event testEvent) { objUnderTest.filterByMeasType(testEvent); + String actual = converter.convert(testEvent.getMeasurement()); + String expected = converter.convert(expectedEvent.getMeasurement()); + assertEquals(expected, actual); + } private Event generateEvent(String inputPath, Filter filter) { - String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml")); - Event event = new Event(exchange, inputXml, metaData, new HashMap<>(), ""); - event.setMeasCollecFile(converter.convert(inputXml)); + EventMetadata metadata = new EventMetadata(); + metadata.setFileFormatType(MeasConverter.LTE_FILE_TYPE); + Event event = EventUtils.makeMockEvent(EventUtils.fileContentsToString(Paths.get(inputPath)), metadata); event.setFilter(filter); return event; } - private Filter generateValidFilter() { + private static Filter generateValidFilter() { Filter filter; filter = new MeasFilterConfig().new Filter(); filter.setDictionaryVersion("1.0"); @@ -239,17 +172,17 @@ class MeasFilterHandlerTest { return filter; } - static List<Event> getValidMeas() throws IOException { - final Path metadata = Paths.get("src/test/resources/valid_metadata.json"); - List<Event> events = EventUtils - .eventsFromDirectory(Paths.get(dataDirectory.toString() + "/valid_data/"), metadata) - .stream() - .map(e -> { - MeasCollecFile m = converter.convert(e.getBody()); - e.setMeasCollecFile(m); - return e; - }) - .collect(Collectors.toList()); - return events; + private static List<Arguments> getEvents() { + ArgumentCreator creator = (Path path, EventMetadata metadata) -> { + Path expectedEventPath = Paths.get(path.toString()+"/expected.xml"); + Path testEventPath = Paths.get(path.toString()+"/test.xml"); + Event expectedEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(expectedEventPath), metadata); + Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testEventPath), metadata); + testEvent.setFilter(generateValidFilter()); + return Arguments.of(expectedEvent, testEvent); + }; + return EventUtils.generateEventArguments(FILTER_DIRECTORY, "/nr", creator); + } + } diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilterTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilterTest.java index abe1b39..bf232ea 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilterTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/filtering/MetadataFilterTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,24 +20,34 @@ package org.onap.dcaegen2.services.pmmapper.filtering; +import com.google.gson.Gson; +import io.undertow.server.HttpServerExchange; +import java.io.IOException; +import java.nio.file.Files; +import java.util.HashMap; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.extension.ExtendWith; import org.junit.jupiter.params.ParameterizedTest; +import org.junit.jupiter.params.provider.Arguments; import org.junit.jupiter.params.provider.MethodSource; 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.MapperConfig; import org.powermock.core.classloader.annotations.PrepareForTest; +import utils.ArgumentCreator; import utils.ConfigUtils; import utils.EventUtils; -import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; import java.util.List; import static org.junit.jupiter.api.Assertions.assertFalse; import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.junit.jupiter.api.Assertions.fail; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; @ExtendWith(MockitoExtension.class) @PrepareForTest(MapperConfig.class) @@ -56,7 +66,7 @@ public class MetadataFilterTest { private static MapperConfig multipleFilterConfig; @BeforeEach - void setup() throws Exception { + void setup() { validConfig = ConfigUtils.getMapperConfigFromFile(VALID_MAPPER_CONFIG_FILE); noFilterConfig = ConfigUtils.getMapperConfigFromFile(NO_FILTER_CONFIG_FILE); multipleFilterConfig = ConfigUtils.getMapperConfigFromFile(MULTIPLE_FILTER_CONFIG_FILE); @@ -89,13 +99,30 @@ public class MetadataFilterTest { assertFalse(metadataFilter.filter(testEvent)); } - private static List<Event> getEventsWithValidMetadata() throws IOException { - Path validDataDirectory = Paths.get(DATA_DIRECTORY.toString() + "/valid/"); - return EventUtils.eventsFromDirectory(validDataDirectory, VALID_METADATA); + private static List<Arguments> getEventsWithValidMetadata() { + return getEvents(VALID_METADATA); } - private static List<Event> getEventsWithInvalidMetadata() throws IOException { - Path validDataDirectory = Paths.get(DATA_DIRECTORY.toString() + "/valid/"); - return EventUtils.eventsFromDirectory(validDataDirectory, INCORRECT_METADATA); + private static List<Arguments> getEventsWithInvalidMetadata() { + return getEvents(INCORRECT_METADATA); + } + + private static List<Arguments> getEvents(Path metadataFile) { + ArgumentCreator creator = (Path path, EventMetadata metadata) -> { + EventMetadata testMetadata = null; + try { + testMetadata = new Gson().fromJson(new String(Files.readAllBytes(metadataFile)), EventMetadata.class); + } catch (IOException e) { + fail("Failed to read contents of metadata file"); + } + testMetadata.setFileFormatType(metadata.getFileFormatType()); + Path testEventPath = Paths.get(path.toString()+"/test.xml"); + Event testEvent = new Event(mock( + HttpServerExchange.class, RETURNS_DEEP_STUBS), + EventUtils.fileContentsToString(testEventPath), testMetadata, new HashMap<>(), ""); + + return Arguments.of(testEvent); + }; + return EventUtils.generateEventArguments(DATA_DIRECTORY, "/nr", creator); } }
\ No newline at end of file diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/mapping/MapperTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/mapping/MapperTest.java index f623d57..2356a57 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/mapping/MapperTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/mapping/MapperTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,8 +20,8 @@ package org.onap.dcaegen2.services.pmmapper.mapping; -import static org.junit.Assert.assertNotNull; import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.junit.jupiter.api.Assertions.fail; import static org.mockito.ArgumentMatchers.any; import static org.mockito.Mockito.RETURNS_DEEP_STUBS; import static org.mockito.Mockito.doThrow; @@ -37,6 +37,7 @@ import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; import java.util.List; import org.everit.json.schema.Schema; @@ -47,28 +48,33 @@ 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.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.junit.jupiter.MockitoExtension; import org.onap.dcaegen2.services.pmmapper.exceptions.MappingException; +import org.onap.dcaegen2.services.pmmapper.exceptions.TemplateIdentificationException; 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.utils.MeasConverter; import org.powermock.reflect.Whitebox; +import utils.ArgumentCreator; import utils.EventUtils; @ExtendWith(MockitoExtension.class) class MapperTest { - private static EventMetadata eventMetadata; + private static EventMetadata fourthGenerationMetadata; + private static EventMetadata fifthGenerationMetadata; private static Schema vesSchema; private static MeasConverter converter; private Mapper objUnderTest; private static final Path schema = Paths.get("src/test/resources/mapper_test/CommonEventFormat_30.1-ONAP.json"); - private static final Path metadata = Paths.get("src/test/resources/valid_metadata.json"); - private static final Path mapping = Paths.get("src/main/resources/mapping.ftl"); + private static final Path METADATA_DIRECTORY = Paths.get("src/test/resources/metadata/"); + private static final Path FIFTH_GENERATION_METADATA = Paths.get(METADATA_DIRECTORY.toString()+"/valid_5g_metadata.json"); + private static final Path FOURTH_GENERATION_METADATA = Paths.get(METADATA_DIRECTORY.toString()+"/valid_4g_metadata.json"); + private static final Path TEMPLATES_DIRECTORY = Paths.get("src/main/resources/templates/"); private static final Path dataDirectory = Paths.get("src/test/resources/mapper_test/mapping_data/"); @@ -77,40 +83,60 @@ class MapperTest { JSONObject ves = new JSONObject(new String(Files.readAllBytes(schema))); vesSchema = SchemaLoader.load(ves); - String metadataFileContents = new String(Files.readAllBytes(metadata)); - eventMetadata = new Gson().fromJson(metadataFileContents, EventMetadata.class); - converter = mock(MeasConverter.class); + String fourthGenMetadataFileContents = new String(Files.readAllBytes(FOURTH_GENERATION_METADATA)); + fourthGenerationMetadata = new Gson().fromJson(fourthGenMetadataFileContents, EventMetadata.class); + String fifthGenMetadataFileContents = new String(Files.readAllBytes(FIFTH_GENERATION_METADATA)); + fifthGenerationMetadata = new Gson().fromJson(fifthGenMetadataFileContents, EventMetadata.class); + converter = new MeasConverter(); } @BeforeEach void setup() { - objUnderTest = new Mapper(mapping,converter); + objUnderTest = new Mapper(TEMPLATES_DIRECTORY, converter); } @ParameterizedTest @MethodSource("getValidEvents") void testValidEvent(Event testEvent) { - when(converter.convert(any(MeasCollecFile.class))).thenReturn(testEvent.getBody()); vesSchema.validate(new JSONObject(objUnderTest.map(testEvent))); } @Test - void testFailureToProcess() throws IOException, TemplateException { + void testFailureToProcessLte() throws Exception { Template mappingTemplateMock = mock(Template.class, RETURNS_DEEP_STUBS); doThrow(new TemplateException(mock(Environment.class))).when(mappingTemplateMock) .process(any(), any()); - Whitebox.setInternalState(objUnderTest, "mappingTemplate", mappingTemplateMock); - Path testFile = Paths.get(dataDirectory + "/valid_data/no_measdata.xml"); - Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), eventMetadata); + HashMap<String, Template> templates = new HashMap<>(); + templates.put("org.3GPP.32.435#measCollec", mappingTemplateMock); + Whitebox.setInternalState(objUnderTest, "templates", templates); + Path testFile = Paths.get(dataDirectory + "/32.435/no_measdata/test.xml"); + Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), fourthGenerationMetadata); + assertThrows(MappingException.class, () -> objUnderTest.map(testEvent)); + } + + @Test + void testFailureToProcessNr() throws Exception { + Template mappingTemplateMock = mock(Template.class, RETURNS_DEEP_STUBS); + doThrow(new TemplateException(mock(Environment.class))).when(mappingTemplateMock) + .process(any(), any()); + HashMap<String, Template> templates = new HashMap<>(); + templates.put("org.3GPP.28.550#measData", mappingTemplateMock); + Whitebox.setInternalState(objUnderTest, "templates", templates); + Path testFile = Paths.get(dataDirectory + "/28.550/no_measdata/test.xml"); + Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), fifthGenerationMetadata); + assertThrows(MappingException.class, () -> objUnderTest.map(testEvent)); + } + + @Test + void testFailureToParseLte() { assertThrows(MappingException.class, () -> - objUnderTest.map(testEvent)); + objUnderTest.map(EventUtils.makeMockEvent("not xml", fourthGenerationMetadata))); } @Test - void testFailureToParse() { - when(converter.convert(any(MeasCollecFile.class))).thenCallRealMethod(); + void testFailureToParseNr() { assertThrows(MappingException.class, () -> - objUnderTest.map(EventUtils.makeMockEvent("not xml", eventMetadata))); + objUnderTest.map(EventUtils.makeMockEvent("not xml", fifthGenerationMetadata))); } @Test @@ -119,6 +145,19 @@ class MapperTest { } @Test + void testInvalidTemplateDirectory() { + assertThrows(IllegalArgumentException.class, () -> new Mapper(Paths.get("fake dir"), new MeasConverter())); + } + @Test + void testTemplateNotFound() { + EventMetadata testMetadata = mock(EventMetadata.class); + when(testMetadata.getFileFormatType()).thenReturn(MeasConverter.LTE_FILE_TYPE, "InvalidFormat"); + Path testFile = Paths.get(dataDirectory + "/32.435/no_measdata/test.xml"); + Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testFile), testMetadata); + assertThrows(TemplateIdentificationException.class, () -> objUnderTest.map(testEvent)); + } + + @Test void testNullPath() { assertThrows(NullPointerException.class, () -> new Mapper(null,converter)); } @@ -133,22 +172,20 @@ class MapperTest { assertThrows(NullPointerException.class, () -> objUnderTest.map(mock(Event.class))); } - @Test - void testMapEvents() throws IOException { - List<Event> events = getValidEvents(); - List<Event> expectedEvents = objUnderTest.mapEvents(events); - expectedEvents.forEach(event -> { - when(converter.convert(any(MeasCollecFile.class))).thenReturn(event.getBody()); - assertNotNull(event.getVes()); - }); - } - - static List<Event> getValidEvents() throws IOException { - return EventUtils.eventsFromDirectory(Paths.get(dataDirectory.toString() + "/valid_data/"), metadata); - } - - static List<Event> getInvalidEvents() throws IOException { - return EventUtils.eventsFromDirectory(Paths.get(dataDirectory.toString() + "/invalid_data/"), metadata); + static List<Arguments> getValidEvents() { + ArgumentCreator creator = (Path path, EventMetadata metadata) -> { + Path testEventPath = Paths.get(path.toString()+"/test.xml"); + Path metadataPath = Paths.get(path.toString()+"/metadata.json"); + EventMetadata eventMetadata = null; + try { + eventMetadata = new Gson().fromJson(new String(Files.readAllBytes(metadataPath)), EventMetadata.class); + } catch (IOException e) { + fail("Failed to read contents of Metadata"); + } + Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testEventPath), eventMetadata); + return Arguments.of(testEvent); + }; + return EventUtils.generateEventArguments(dataDirectory, "/28.550", creator); } } diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DataRouterUtilsTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DataRouterUtilsTest.java index b2e6308..c308840 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DataRouterUtilsTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/DataRouterUtilsTest.java @@ -28,6 +28,7 @@ import static org.mockito.Mockito.times; import static org.mockito.Mockito.verify; import static org.mockito.Mockito.when; +import io.undertow.server.HttpServerExchange; import java.io.ByteArrayInputStream; import java.net.HttpURLConnection; import java.net.URL; @@ -38,6 +39,7 @@ import java.nio.file.Paths; import com.google.gson.Gson; import com.google.gson.JsonObject; import com.google.gson.JsonParser; +import java.util.HashMap; import org.junit.Test; import org.junit.runner.RunWith; import org.onap.dcaegen2.services.pmmapper.exceptions.ProcessEventException; @@ -162,14 +164,16 @@ public class DataRouterUtilsTest { URL mockURL = mock(URL.class); HttpsURLConnection mockConnection = mock(HttpsURLConnection.class, RETURNS_DEEP_STUBS); when(mockConnection.getResponseCode()).thenReturn(503); - + EventMetadata metadata = new EventMetadata(); + metadata.setFileFormatType(MeasConverter.LTE_FILE_TYPE); when(mockURL.openConnection()).thenReturn(mockConnection); when(mockURL.getProtocol()).thenReturn("https"); when(mockMapperConfig.getDmaapDRDeleteEndpoint()).thenReturn("dmaap-dr-node/delete/"); when(mockMapperConfig.getSubscriberIdentity()).thenReturn("12"); PowerMockito.whenNew(URL.class).withAnyArguments().thenReturn(mockURL); - Event testEvent = EventUtils.makeMockEvent("", mock(EventMetadata.class)); + Event testEvent = new Event(mock( + HttpServerExchange.class, RETURNS_DEEP_STUBS), "", metadata, new HashMap<>(), "12"); assertThrows(ProcessEventException.class, () -> DataRouterUtils.processEvent(mockMapperConfig, testEvent)); } } 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 index f51ec5c..c3412eb 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasConverterTest.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -19,21 +19,25 @@ */
package org.onap.dcaegen2.services.pmmapper.utils;
import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.mockito.Mockito.RETURNS_DEEP_STUBS;
+import static org.mockito.Mockito.mock;
-import java.io.StringReader;
+import io.undertow.server.HttpServerExchange;
import java.io.StringWriter;
+import java.util.HashMap;
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.onap.dcaegen2.services.pmmapper.model.Event;
+import org.onap.dcaegen2.services.pmmapper.model.EventMetadata;
+import org.onap.dcaegen2.services.pmmapper.model.measurement.lte.MeasCollecFile;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -68,16 +72,23 @@ public class MeasConverterTest { }
@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);
+ public void convertToMeasCollec_throws_mappingException() {
+ EventMetadata metadata = new EventMetadata();
+ metadata.setFileFormatType(MeasConverter.LTE_FILE_TYPE);
+ Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), "xmlString", metadata, new HashMap<>(), "");
+ assertThrows(MappingException.class, () -> {
+ objUnderTest.convert(event);
+ });
+ }
+ @Test
+ public void convertToMeasData_throws_mappingException() {
+ EventMetadata metadata = new EventMetadata();
+ metadata.setFileFormatType(MeasConverter.NR_FILE_TYPE);
+ Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), "xmlString", metadata, new HashMap<>(), "");
assertThrows(MappingException.class, () -> {
- objUnderTest.convert("xmlString");
+ objUnderTest.convert(event);
});
}
-}
+
+}
\ No newline at end of file diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitterTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitterTest.java index 5028464..82921e6 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitterTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/MeasSplitterTest.java @@ -1,6 +1,6 @@ /*-
* ============LICENSE_START=======================================================
- * Copyright (C) 2019 Nordix Foundation.
+ * Copyright (C) 2019-2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -18,98 +18,84 @@ * ============LICENSE_END=========================================================
*/
package org.onap.dcaegen2.services.pmmapper.utils;
+import static junit.framework.TestCase.fail;
import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.nio.file.Path;
import java.nio.file.Paths;
-import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
-import javax.xml.bind.JAXBException;
+import java.util.Properties;
-import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.extension.ExtendWith;
-import org.mockito.Mock;
+import org.junit.jupiter.params.ParameterizedTest;
+import org.junit.jupiter.params.provider.Arguments;
+import org.junit.jupiter.params.provider.MethodSource;
+
import org.mockito.Mockito;
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.MapperConfig;
-import org.onap.dcaegen2.services.pmmapper.model.MeasCollecFile;
-import io.undertow.server.HttpServerExchange;
+import utils.ArgumentCreator;
import utils.EventUtils;
@ExtendWith(MockitoExtension.class)
class MeasSplitterTest {
private static final String baseDir = "src/test/resources/split_test/";
private MeasSplitter objUnderTest;
- private MeasConverter converter;
- @Mock
- HttpServerExchange exchange;
- @Mock
- EventMetadata meta;
- @Mock
- Event event;
- @Mock
- MapperConfig config;
@BeforeEach
void setup() {
- converter = new MeasConverter();
- objUnderTest = new MeasSplitter(converter);
- }
-
- void setupBaseEvent() {
- Mockito.when(event.getHttpServerExchange()).thenReturn(exchange);
- Mockito.when(event.getMetadata()).thenReturn(meta);
- Mockito.when(event.getMdc()).thenReturn(new HashMap<>());
- Mockito.when(event.getMetadata()).thenReturn(meta);
- Mockito.when(event.getPublishIdentity()).thenReturn("");
+ objUnderTest = new MeasSplitter(new MeasConverter());
}
-
@Test
void no_measData() {
String inputPath = baseDir + "no_measdata";
+ EventMetadata metadata = new EventMetadata();
+ metadata.setFileFormatType(MeasConverter.LTE_FILE_TYPE);
String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml"));
- Mockito.when(event.getBody()).thenReturn(inputXml);
+ Event testEvent = EventUtils.makeMockEvent(inputXml, metadata);
- Assertions.assertThrows(NoSuchElementException.class, () -> objUnderTest.split(event));
+ assertThrows(NoSuchElementException.class, () -> objUnderTest.split(testEvent));
}
- @Test
- void typeA_returns_only_one_event() throws JAXBException {
- String inputPath = baseDir + "meas_results_typeA";
- String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml"));
- MeasCollecFile measToBeSplit = converter.convert(inputXml);
- setupBaseEvent();
- Mockito.when(event.getBody()).thenReturn(inputXml);
- Mockito.when(event.getMeasCollecFile()).thenReturn(measToBeSplit);
-
- List<Event> splitEvents = objUnderTest.split(event);
- assertEquals(1,splitEvents.size());
+ @ParameterizedTest
+ @MethodSource("getEvents")
+ void testSplit(int numberOfEvents, String[] measInfoIds, Event testEvent) {
+ List<Event> splitEvents = objUnderTest.split(testEvent);
+ assertEquals(numberOfEvents, splitEvents.size());
+ for (int i = 0; i<splitEvents.size(); i++) {
+ String measInfoId = splitEvents.get(i).getMeasurement()
+ .getMeasurementData().get().get(0).getMeasurementInfo().get(0).getMeasInfoId();
+ assertEquals(measInfoIds[i], measInfoId);
+ }
}
- @Test
- void typeC_returns_multiple_events() throws JAXBException {
- String inputPath = baseDir + "meas_results_typeC";
- String inputXml = EventUtils.fileContentsToString(Paths.get(inputPath + ".xml"));
- setupBaseEvent();
- Mockito.when(event.getBody()).thenReturn(inputXml);
- MeasCollecFile measToBeSplit = converter.convert(inputXml);
- Mockito.when(event.getMeasCollecFile()).thenReturn(measToBeSplit);
-
- List<Event> splitEvents = objUnderTest.split(event);
- assertEquals(3,splitEvents.size());
- for (int i = 0; i < splitEvents.size(); i++) {
- String measInfoId = splitEvents.get(i).getMeasCollecFile()
- .getMeasData().get(0).getMeasInfo().get(0).getMeasInfoId();
- Assertions.assertEquals(measInfoId, "measInfoId" + (i + 1));
- }
+ private static List<Arguments> getEvents() {
+ ArgumentCreator splitterCreator = (Path path, EventMetadata metadata) -> {
+ Path propsPath = Paths.get(path.toString()+"/split.props");
+ Path testEventPath = Paths.get(path.toString()+"/test.xml");
+ Properties splitProperties = new Properties();
+ try {
+ splitProperties.load(new FileInputStream(propsPath.toFile()));
+ } catch (IOException e) {
+ fail("Failed to load properties for test");
+ }
+ int numberOfEvents = Integer.parseInt(splitProperties.getProperty("eventCount"));
+ String [] measInfoIds = splitProperties.getProperty("measInfoIds").split(",");
+ Event testEvent = EventUtils.makeMockEvent(EventUtils.fileContentsToString(testEventPath), metadata);
+ return Arguments.of(numberOfEvents, measInfoIds, testEvent);
+ };
+ return EventUtils.generateEventArguments(Paths.get(baseDir), "/nr", splitterCreator);
}
}
diff --git a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidatorTest.java b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidatorTest.java index aca0fe6..cc39563 100644 --- a/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidatorTest.java +++ b/src/test/java/org/onap/dcaegen2/services/pmmapper/utils/XMLValidatorTest.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019 - 2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -20,35 +20,43 @@ package org.onap.dcaegen2.services.pmmapper.utils; -import static org.junit.jupiter.api.Assertions.assertFalse; +import static junit.framework.TestCase.fail; +import static org.junit.Assert.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; -import static org.junit.jupiter.api.Assertions.assertTrue; +import static org.mockito.Mockito.RETURNS_DEEP_STUBS; +import static org.mockito.Mockito.mock; +import io.undertow.server.HttpServerExchange; +import java.io.FileInputStream; import java.io.IOException; import java.nio.file.Path; import java.nio.file.Paths; +import java.util.HashMap; import java.util.List; +import java.util.Properties; 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.Arguments; import org.junit.jupiter.params.provider.MethodSource; import org.mockito.junit.jupiter.MockitoExtension; import org.onap.dcaegen2.services.pmmapper.model.Event; +import org.onap.dcaegen2.services.pmmapper.model.EventMetadata; +import utils.ArgumentCreator; import utils.EventUtils; @ExtendWith(MockitoExtension.class) class XMLValidatorTest { - private static final Path metadata = Paths.get("src/test/resources/valid_metadata.json"); private static final Path dataDirectory = Paths.get("src/test/resources/xml_validator_test/test_data/"); - private static final Path xsd = Paths.get("src/main/resources/measCollec_plusString.xsd"); + private static final Path schemas = Paths.get("src/main/resources/schemas/"); private XMLValidator objUnderTest; @BeforeEach void setup() { - objUnderTest = new XMLValidator(xsd); + objUnderTest = new XMLValidator(schemas); } @Test @@ -62,26 +70,38 @@ class XMLValidatorTest { assertThrows(NullPointerException.class, () -> objUnderTest.validate(null)); } - @ParameterizedTest - @MethodSource("getValidEvents") - void testValidEventsPass(Event testEvent) { - assertTrue(objUnderTest.validate(testEvent)); + @Test + void testInvalidSchemaDirectory() { + assertThrows(IllegalArgumentException.class, () -> new XMLValidator(Paths.get("fake dir"))); } - @ParameterizedTest - @MethodSource("getInvalidEvents") - void testInvalidEventsFail(Event testEvent) { - assertFalse(objUnderTest.validate(testEvent)); + @Test + void testInvalidSchemaFormat() { + assertThrows(IllegalArgumentException.class, () -> new XMLValidator(Paths.get("src/test/resources/invalid_configs"))); } - private static List<Event> getValidEvents() throws IOException { - Path validDataDirectory = Paths.get(dataDirectory.toString() + "/valid/"); - return EventUtils.eventsFromDirectory(validDataDirectory, metadata); + @ParameterizedTest + @MethodSource("getEvents") + void testXmlValidation(boolean validity, Event testEvent) { + assertEquals(validity, objUnderTest.validate(testEvent)); } - private static List<Event> getInvalidEvents() throws IOException { - Path invalidDataDirectory = Paths.get(dataDirectory.toString() + "/invalid/"); - return EventUtils.eventsFromDirectory(invalidDataDirectory, metadata); + private static List<Arguments> getEvents() { + ArgumentCreator creator = (Path path, EventMetadata metadata) -> { + Path props = Paths.get(path.toString()+"/validity.props"); + Path testEventPath = Paths.get(path.toString()+"/test.xml"); + Properties validityProps = new Properties(); + try { + validityProps.load(new FileInputStream(props.toFile())); + } catch (IOException e) { + fail("Failed to load properties for test"); + } + boolean valid = Boolean.parseBoolean(validityProps.getProperty("valid")); + Event testEvent = new Event(mock( + HttpServerExchange.class, RETURNS_DEEP_STUBS), + EventUtils.fileContentsToString(testEventPath), metadata, new HashMap<>(), ""); + return Arguments.of(valid, testEvent); + }; + return EventUtils.generateEventArguments(dataDirectory, "/nr", creator); } - } diff --git a/src/test/java/utils/ArgumentCreator.java b/src/test/java/utils/ArgumentCreator.java new file mode 100644 index 0000000..a552a0c --- /dev/null +++ b/src/test/java/utils/ArgumentCreator.java @@ -0,0 +1,36 @@ +/*- + * ============LICENSE_START======================================================= + * Copyright (C) 2019 - 2020 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 utils; + +import java.nio.file.Path; +import org.junit.jupiter.params.provider.Arguments; +import org.onap.dcaegen2.services.pmmapper.model.EventMetadata; + +public interface ArgumentCreator { + + /** + * Makes an Argument containing an event from an path to an XML body and a corresponding metadata object. + * @param path path to file containing xml. + * @param metadata instance of a metadata object with fileFormatType set. + * @return Arguments containing what is necessary for a test to complete its checks. + */ + public Arguments makeArgument(Path path, EventMetadata metadata); +} diff --git a/src/test/java/utils/EventUtils.java b/src/test/java/utils/EventUtils.java index 0051629..ffa02b0 100644 --- a/src/test/java/utils/EventUtils.java +++ b/src/test/java/utils/EventUtils.java @@ -1,6 +1,6 @@ /*- * ============LICENSE_START======================================================= - * Copyright (C) 2019 Nordix Foundation. + * Copyright (C) 2019-2020 Nordix Foundation. * ================================================================================ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -29,13 +29,17 @@ import io.undertow.server.HttpServerExchange; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.stream.Collectors; +import java.util.stream.Stream; +import junit.framework.TestCase; +import org.junit.jupiter.params.provider.Arguments; 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.utils.MeasConverter; public class EventUtils { @@ -55,6 +59,27 @@ public class EventUtils { .map(contents -> EventUtils.makeMockEvent(contents, eventMetadata)) .collect(Collectors.toList()); } + /** + * Create a List of Arguments containing an Event (Defaults to LTE events), and an expected outcome. + * Fails test in the event of failure to read a file. + * @param baseDirectory Directory containing multiple formats of events separated by a directory. + * @param nrQualifier String representing a unique part of the path that will exist only in the NR path. + * @param argCreator Callback to method that will generate the appropriate set of arguments for each test. + */ + public static List<Arguments> generateEventArguments(Path baseDirectory, String nrQualifier, ArgumentCreator argCreator ) { + List<Arguments> events = new ArrayList<>(); + try (Stream<Path> paths = Files.list(baseDirectory)) { + paths.filter(Files::isDirectory).forEach(path -> { + String fileFormatType = path.toString().contains(nrQualifier) ? MeasConverter.NR_FILE_TYPE : MeasConverter.LTE_FILE_TYPE; + EventMetadata eventMetadata = new EventMetadata(); + eventMetadata.setFileFormatType(fileFormatType); + events.addAll(getEventsArgument(path, eventMetadata, argCreator)); + }); + } catch (IOException e) { + TestCase.fail("IOException occurred while generating test data"); + } + return events; + } /** * reads contents of file into a string. @@ -75,15 +100,14 @@ public class EventUtils { * Makes an event with a mock http server exchange, empty mdc and publish identity * @param body body for the event. * @param eventMetadata metadata for the event. - * @return event with mock HttpServerExchange + * @return event with mock HttpServerExchange. */ public static Event makeMockEvent(String body, EventMetadata eventMetadata) { Event event = new Event(mock(HttpServerExchange.class, RETURNS_DEEP_STUBS), body, eventMetadata, new HashMap<>(), ""); - event.setMeasCollecFile(new MeasCollecFile()); + event.setMeasurement(new MeasConverter().convert(event)); return event; } - /** * Makes an event with a mock http server exchange and empty mdc * @param body body for the event. @@ -95,5 +119,16 @@ public class EventUtils { return new Event(mockHttpServerExchange, body, eventMetadata, new HashMap<>(), publishIdentity); } + private static List<Arguments> getEventsArgument(Path basePath, EventMetadata metadata, ArgumentCreator argCreator) { + List<Arguments> events = new ArrayList<>(); + try (Stream<Path> paths = Files.list(basePath)) { + paths.filter(Files::isDirectory).forEach(path->{ + events.add(argCreator.makeArgument(path, metadata)); + }); + } catch (IOException e) { + TestCase.fail("IOException occurred while generating test data"); + } + return events; + } } diff --git a/src/test/resources/filter_test/meas_results_filtered.xml b/src/test/resources/filter_test/lte/meas_results/expected.xml index af45364..af45364 100644 --- a/src/test/resources/filter_test/meas_results_filtered.xml +++ b/src/test/resources/filter_test/lte/meas_results/expected.xml diff --git a/src/test/resources/filter_test/meas_results.xml b/src/test/resources/filter_test/lte/meas_results/test.xml index 5825e7b..5825e7b 100644 --- a/src/test/resources/filter_test/meas_results.xml +++ b/src/test/resources/filter_test/lte/meas_results/test.xml diff --git a/src/test/resources/filter_test/meas_results_manyInfo_filtered.xml b/src/test/resources/filter_test/lte/meas_results_manyinfo/expected.xml index 4a887d5..4a887d5 100644 --- a/src/test/resources/filter_test/meas_results_manyInfo_filtered.xml +++ b/src/test/resources/filter_test/lte/meas_results_manyinfo/expected.xml diff --git a/src/test/resources/filter_test/meas_results_manyInfo.xml b/src/test/resources/filter_test/lte/meas_results_manyinfo/test.xml index 2b87912..2b87912 100644 --- a/src/test/resources/filter_test/meas_results_manyInfo.xml +++ b/src/test/resources/filter_test/lte/meas_results_manyinfo/test.xml diff --git a/src/test/resources/filter_test/meas_type_and_r_filtered.xml b/src/test/resources/filter_test/lte/meas_type_and_r/expected.xml index f2146f7..f2146f7 100644 --- a/src/test/resources/filter_test/meas_type_and_r_filtered.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r/expected.xml diff --git a/src/test/resources/filter_test/meas_type_and_r.xml b/src/test/resources/filter_test/lte/meas_type_and_r/test.xml index 0d99e39..0d99e39 100644 --- a/src/test/resources/filter_test/meas_type_and_r.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r/test.xml diff --git a/src/test/resources/filter_test/meas_type_and_r_manyMeasvalue_filtered.xml b/src/test/resources/filter_test/lte/meas_type_and_r_many_measvalue/expected.xml index 9f185a4..9f185a4 100644 --- a/src/test/resources/filter_test/meas_type_and_r_manyMeasvalue_filtered.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r_many_measvalue/expected.xml diff --git a/src/test/resources/filter_test/meas_type_and_r_manyMeasvalue.xml b/src/test/resources/filter_test/lte/meas_type_and_r_many_measvalue/test.xml index 691882c..691882c 100644 --- a/src/test/resources/filter_test/meas_type_and_r_manyMeasvalue.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r_many_measvalue/test.xml diff --git a/src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml b/src/test/resources/filter_test/lte/meas_type_and_r_manyinfo/expected.xml index b517a7d..b517a7d 100644 --- a/src/test/resources/filter_test/meas_type_and_r_manyInfo_filtered.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r_manyinfo/expected.xml diff --git a/src/test/resources/filter_test/meas_type_and_r_manyInfo.xml b/src/test/resources/filter_test/lte/meas_type_and_r_manyinfo/test.xml index dd35dfc..dd35dfc 100644 --- a/src/test/resources/filter_test/meas_type_and_r_manyInfo.xml +++ b/src/test/resources/filter_test/lte/meas_type_and_r_manyinfo/test.xml diff --git a/src/test/resources/filter_test/nr/meas_results/expected.xml b/src/test/resources/filter_test/nr/meas_results/expected.xml new file mode 100644 index 0000000..834b54a --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_results/expected.xml @@ -0,0 +1,22 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity localDn="Dublin" swVersion="r0.1"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/> + <repPeriod duration="PT900S"/> + <measTypes>a b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>1 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_results/test.xml b/src/test/resources/filter_test/nr/meas_results/test.xml new file mode 100644 index 0000000..0b84ff6 --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_results/test.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z a zz b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/filter_test/nr/meas_results_manyinfo/expected.xml b/src/test/resources/filter_test/nr/meas_results_manyinfo/expected.xml new file mode 100644 index 0000000..1f9cfbf --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_results_manyinfo/expected.xml @@ -0,0 +1,32 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity localDn="Dublin" swVersion="r0.1"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/> + <repPeriod duration="PT900S"/> + <measTypes>a b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>1 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + <measInfo measInfoId="some measInfoId2"> + <job jobId="jobId"/> + <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/> + <repPeriod duration="PT900S"/> + <measTypes>a b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>1 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_results_manyinfo/test.xml b/src/test/resources/filter_test/nr/meas_results_manyinfo/test.xml new file mode 100644 index 0000000..217d339 --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_results_manyinfo/test.xml @@ -0,0 +1,44 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="this will be filtered out"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z aa zz bb</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z a zz b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + <measInfo measInfoId="some measInfoId2"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z a zz b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/filter_test/nr/meas_type_and_r/expected.xml b/src/test/resources/filter_test/nr/meas_type_and_r/expected.xml new file mode 100644 index 0000000..74090c6 --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r/expected.xml @@ -0,0 +1,24 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_type_and_r/test.xml b/src/test/resources/filter_test/nr/meas_type_and_r/test.xml new file mode 100644 index 0000000..e55d303 --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r/test.xml @@ -0,0 +1,26 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="2">z</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="2">99</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/expected.xml b/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/expected.xml new file mode 100644 index 0000000..afc8e6f --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/expected.xml @@ -0,0 +1,30 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measTypes></measTypes>
+ <measType p="1">a</measType>
+ <measType p="2">b</measType>
+ <measValue measObjLdn="some measObjLdn 1">
+ <r p="1">1</r>
+ <r p="2">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ <measValue measObjLdn="some measObjLdn 3">
+ <r p="1">111</r>
+ <r p="2">222</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/test.xml b/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/test.xml new file mode 100644 index 0000000..f268ca2 --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r_many_measvalue/test.xml @@ -0,0 +1,36 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measTypes></measTypes>
+ <measType p="1">a</measType>
+ <measType p="2">b</measType>
+ <measType p="3">c</measType>
+ <measValue measObjLdn="some measObjLdn 1">
+ <r p="1">1</r>
+ <r p="2">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ <measValue measObjLdn="some measObjLdn 2">
+ <r p="88">88</r>
+ <r p="99">99</r>
+ <suspect>false</suspect>
+ </measValue>
+ <measValue measObjLdn="some measObjLdn 3">
+ <r p="1">111</r>
+ <r p="2">222</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/expected.xml b/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/expected.xml new file mode 100644 index 0000000..03c42ab --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/expected.xml @@ -0,0 +1,36 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ <measInfo measInfoId="some measInfoId2">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/test.xml b/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/test.xml new file mode 100644 index 0000000..beda93f --- /dev/null +++ b/src/test/resources/filter_test/nr/meas_type_and_r_manyinfo/test.xml @@ -0,0 +1,54 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData">
+ <fileHeader fileFormatVersion="32.435 V10.0" vendorName="FooBar Ltd" dnPrefix="some dnPrefix">
+ <fileSender senderName="Dublin"/>
+ <MeasData beginTime="2018-10-02T12:00:00+01:00"/>
+ </fileHeader>
+ <measData>
+ <measuredEntity localDn="Dublin" swVersion="r0.1"/>
+ <measInfo measInfoId="some measInfoId">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="2">z</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="2">99</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ <measInfo measInfoId="filter will disregard this measInfo">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">aa</measType>
+ <measType p="2">z</measType>
+ <measType p="3">bb</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="2">99</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ <measInfo measInfoId="some measInfoId2">
+ <job jobId="jobId"/>
+ <granPeriod duration="PT900S" endTime="2018-10-02T12:15:00Z"/>
+ <repPeriod duration="PT900S"/>
+ <measType p="1">a</measType>
+ <measType p="2">z</measType>
+ <measType p="3">b</measType>
+ <measValue measObjLdn="some measObjLdn">
+ <r p="1">1</r>
+ <r p="2">99</r>
+ <r p="3">2</r>
+ <suspect>false</suspect>
+ </measValue>
+ </measInfo>
+ </measData>
+ <fileFooter>
+ <MeasData endTime="2018-10-02T12:15:00+01:00"/>
+ </fileFooter>
+</MeasDataFile>
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_results/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/meas_results/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_results/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_results/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/meas_results/test.xml new file mode 100644 index 0000000..29747dc --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_results/test.xml @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>a b c</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>76 27 98</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/test.xml new file mode 100644 index 0000000..1757f4a --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r/test.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="some Job Id"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measType p="1">a</measType> + <measType p="2">b</measType> + <measType p="3">c</measType> + <measValue measObjLdn="some measObjLdn"> + <r p="1">86</r> + <r p="2">67</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/test.xml new file mode 100644 index 0000000..3a0c608 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_type_and_r_many_meas_values/test.xml @@ -0,0 +1,34 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="some Job Id"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measType p="1">a</measType> + <measType p="2">b</measType> + <measType p="3">c</measType> + <measValue measObjLdn="some measObjLdn"> + <r p="1">86</r> + <r p="2">67</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + <measValue measObjLdn="some other measObjLdn"> + <r p="1">5</r> + <r p="2">6</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/test.xml new file mode 100644 index 0000000..23f9429 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/meas_types_and_meas_results_many_meas_values/test.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>a b c</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>76 27 98</measResults> + <suspect>false</suspect> + </measValue> + <measValue measObjLdn="some other objLdn"> + <measResults>1 2 9</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/test.xml new file mode 100644 index 0000000..30bb82b --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/no_measdata/test.xml @@ -0,0 +1,11 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/metadata.json b/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/test.xml b/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/test.xml new file mode 100644 index 0000000..92fd1ff --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/28.550/no_sw_version/test.xml @@ -0,0 +1,28 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="28.550 V1"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity localDn="Dublin"/> + <measInfo measInfoId="some measInfoId"> + <job jobId="some Job Id"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measType p="1">a</measType> + <measType p="2">b</measType> + <measType p="3">c</measType> + <measValue measObjLdn="some measObjLdn"> + <r p="1">86</r> + <r p="2">67</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/mapper_test/mapping_data/32.435/meas_results/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/meas_results/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_results/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ 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/32.435/meas_results/test.xml index 269fdf1..269fdf1 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/meas_results.xml +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_results/test.xml diff --git a/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file 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/32.435/meas_type_and_r/test.xml index 8ff79df..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/32.435/meas_type_and_r/test.xml diff --git a/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r_many_meas_values/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r_many_meas_values/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r_many_meas_values/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r_many_meas_values.xml b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r_many_meas_values/test.xml index 1b1dc26..1b1dc26 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/meas_type_and_r_many_meas_values.xml +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_type_and_r_many_meas_values/test.xml diff --git a/src/test/resources/mapper_test/mapping_data/32.435/meas_types_and_meas_results_many_meas_values/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/meas_types_and_meas_results_many_meas_values/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_types_and_meas_results_many_meas_values/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/meas_types_and_meas_results_many_meas_values.xml b/src/test/resources/mapper_test/mapping_data/32.435/meas_types_and_meas_results_many_meas_values/test.xml index 4ed9f95..4ed9f95 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/meas_types_and_meas_results_many_meas_values.xml +++ b/src/test/resources/mapper_test/mapping_data/32.435/meas_types_and_meas_results_many_meas_values/test.xml diff --git a/src/test/resources/mapper_test/mapping_data/32.435/no_measdata/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/no_measdata/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/no_measdata/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/no_measdata.xml b/src/test/resources/mapper_test/mapping_data/32.435/no_measdata/test.xml index 855b2e9..855b2e9 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/no_measdata.xml +++ b/src/test/resources/mapper_test/mapping_data/32.435/no_measdata/test.xml diff --git a/src/test/resources/mapper_test/mapping_data/32.435/no_sw_version/metadata.json b/src/test/resources/mapper_test/mapping_data/32.435/no_sw_version/metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/mapper_test/mapping_data/32.435/no_sw_version/metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/mapper_test/mapping_data/valid_data/no_sw_version.xml b/src/test/resources/mapper_test/mapping_data/32.435/no_sw_version/test.xml index bc435c0..bc435c0 100644 --- a/src/test/resources/mapper_test/mapping_data/valid_data/no_sw_version.xml +++ b/src/test/resources/mapper_test/mapping_data/32.435/no_sw_version/test.xml diff --git a/src/test/resources/metadata/invalid_metadata.json b/src/test/resources/metadata/invalid_metadata.json new file mode 100644 index 0000000..31600b0 --- /dev/null +++ b/src/test/resources/metadata/invalid_metadata.json @@ -0,0 +1,11 @@ +{ + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/metadata/valid_4g_metadata.json b/src/test/resources/metadata/valid_4g_metadata.json new file mode 100644 index 0000000..5a84d99 --- /dev/null +++ b/src/test/resources/metadata/valid_4g_metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "lteRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.32.435#measCollec", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/metadata/valid_5g_metadata.json b/src/test/resources/metadata/valid_5g_metadata.json new file mode 100644 index 0000000..3456b7c --- /dev/null +++ b/src/test/resources/metadata/valid_5g_metadata.json @@ -0,0 +1,12 @@ +{ + "productName": "NrRadio", + "vendorName": "Ericsson", + "lastEpochMicrosec": "1538478000000", + "sourceName": "oteNB5309", + "startEpochMicrosec": "1538478900000", + "timeZoneOffset": "UTC+05.00", + "location": "ftpes://192.168.0.101:22/ftp/rop/A20161224.1045-1100.bin.gz", + "compression": "gzip", + "fileFormatType": "org.3GPP.28.550#measData", + "fileFormatVersion": "V9" +}
\ No newline at end of file diff --git a/src/test/resources/split_test/lte/type_a_1_event/split.props b/src/test/resources/split_test/lte/type_a_1_event/split.props new file mode 100644 index 0000000..3598e18 --- /dev/null +++ b/src/test/resources/split_test/lte/type_a_1_event/split.props @@ -0,0 +1,2 @@ +eventCount=1 +measInfoIds=Singular measInfoId
\ No newline at end of file diff --git a/src/test/resources/split_test/lte/type_a_1_event/test.xml b/src/test/resources/split_test/lte/type_a_1_event/test.xml new file mode 100644 index 0000000..b49f7f0 --- /dev/null +++ b/src/test/resources/split_test/lte/type_a_1_event/test.xml @@ -0,0 +1,23 @@ +<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender localDn="Dublin"/> + <measCollec beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <managedElement swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="Singular measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z a zz b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <measCollec endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</measCollecFile> diff --git a/src/test/resources/split_test/lte/type_c_3_events/split.props b/src/test/resources/split_test/lte/type_c_3_events/split.props new file mode 100644 index 0000000..35d90f4 --- /dev/null +++ b/src/test/resources/split_test/lte/type_c_3_events/split.props @@ -0,0 +1,2 @@ +eventCount=3 +measInfoIds=First measInfoId,Second measInfoId,Third measInfoId
\ No newline at end of file diff --git a/src/test/resources/split_test/lte/type_c_3_events/test.xml b/src/test/resources/split_test/lte/type_c_3_events/test.xml new file mode 100644 index 0000000..7680f9d --- /dev/null +++ b/src/test/resources/split_test/lte/type_c_3_events/test.xml @@ -0,0 +1,49 @@ +<measCollecFile xmlns="http://www.3gpp.org/ftp/specs/archive/32_series/32.435#measCollec"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender localDn="Dublin"/> + <measCollec beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <managedElement swVersion="r0.1" localDn="Dublin1"/> + <measInfo measInfoId="First measInfoId"> + <job jobId="jobId1"/> + <granPeriod endTime="2001-10-02T12:15:00Z" duration="PT100S"/> + <repPeriod duration="PT100S"/> + <measTypes>z1 a1 zz1 b1</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>1 11 111 1111</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <measData> + <managedElement swVersion="r0.2" localDn="Dublin2"/> + <measInfo measInfoId="Second measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2002-10-02T12:15:00Z" duration="PT200S"/> + <repPeriod duration="PT200S"/> + <measTypes>z2 a2 zz2 b2</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>2 22 222 2222</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <measData> + <managedElement swVersion="r0.3" localDn="Dublin3"/> + <measInfo measInfoId="Third measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2003-10-02T12:15:00Z" duration="PT300S"/> + <repPeriod duration="PT300S"/> + <measTypes>z3 a3 zz3 b3</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>3 33 333 3333</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <measCollec endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</measCollecFile> diff --git a/src/test/resources/split_test/nr/type_a_1_event/split.props b/src/test/resources/split_test/nr/type_a_1_event/split.props new file mode 100644 index 0000000..3598e18 --- /dev/null +++ b/src/test/resources/split_test/nr/type_a_1_event/split.props @@ -0,0 +1,2 @@ +eventCount=1 +measInfoIds=Singular measInfoId
\ No newline at end of file diff --git a/src/test/resources/split_test/nr/type_a_1_event/test.xml b/src/test/resources/split_test/nr/type_a_1_event/test.xml new file mode 100644 index 0000000..f88e0c5 --- /dev/null +++ b/src/test/resources/split_test/nr/type_a_1_event/test.xml @@ -0,0 +1,23 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="Singular measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measTypes>z a zz b</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>99 1 27 2</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/split_test/nr/type_c_3_events/split.props b/src/test/resources/split_test/nr/type_c_3_events/split.props new file mode 100644 index 0000000..35d90f4 --- /dev/null +++ b/src/test/resources/split_test/nr/type_c_3_events/split.props @@ -0,0 +1,2 @@ +eventCount=3 +measInfoIds=First measInfoId,Second measInfoId,Third measInfoId
\ No newline at end of file diff --git a/src/test/resources/split_test/nr/type_c_3_events/test.xml b/src/test/resources/split_test/nr/type_c_3_events/test.xml new file mode 100644 index 0000000..ccbb09b --- /dev/null +++ b/src/test/resources/split_test/nr/type_c_3_events/test.xml @@ -0,0 +1,49 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin1"/> + <measInfo measInfoId="First measInfoId"> + <job jobId="jobId1"/> + <granPeriod endTime="2001-10-02T12:15:00Z" duration="PT100S"/> + <repPeriod duration="PT100S"/> + <measTypes>z1 a1 zz1 b1</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>1 11 111 1111</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <measData> + <measuredEntity swVersion="r0.2" localDn="Dublin2"/> + <measInfo measInfoId="Second measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2002-10-02T12:15:00Z" duration="PT200S"/> + <repPeriod duration="PT200S"/> + <measTypes>z2 a2 zz2 b2</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>2 22 222 2222</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <measData> + <measuredEntity swVersion="r0.3" localDn="Dublin3"/> + <measInfo measInfoId="Third measInfoId"> + <job jobId="jobId"/> + <granPeriod endTime="2003-10-02T12:15:00Z" duration="PT300S"/> + <repPeriod duration="PT300S"/> + <measTypes>z3 a3 zz3 b3</measTypes> + <measValue measObjLdn="objLdn"> + <measResults>3 33 333 3333</measResults> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/xml_validator_test/test_data/invalid/no_file_header.xml b/src/test/resources/xml_validator_test/test_data/lte/no_file_header/test.xml index 8e5669f..8e5669f 100644 --- a/src/test/resources/xml_validator_test/test_data/invalid/no_file_header.xml +++ b/src/test/resources/xml_validator_test/test_data/lte/no_file_header/test.xml diff --git a/src/test/resources/xml_validator_test/test_data/lte/no_file_header/validity.props b/src/test/resources/xml_validator_test/test_data/lte/no_file_header/validity.props new file mode 100644 index 0000000..80da24e --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/lte/no_file_header/validity.props @@ -0,0 +1 @@ +valid=false
\ No newline at end of file diff --git a/src/test/resources/xml_validator_test/test_data/invalid/no_managed_element.xml b/src/test/resources/xml_validator_test/test_data/lte/no_managed_element/test.xml index b1b3d68..b1b3d68 100644 --- a/src/test/resources/xml_validator_test/test_data/invalid/no_managed_element.xml +++ b/src/test/resources/xml_validator_test/test_data/lte/no_managed_element/test.xml diff --git a/src/test/resources/xml_validator_test/test_data/lte/no_managed_element/validity.props b/src/test/resources/xml_validator_test/test_data/lte/no_managed_element/validity.props new file mode 100644 index 0000000..80da24e --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/lte/no_managed_element/validity.props @@ -0,0 +1 @@ +valid=false
\ No newline at end of file diff --git a/src/test/resources/xml_validator_test/test_data/valid/no_measdata.xml b/src/test/resources/xml_validator_test/test_data/lte/no_measdata/test.xml index 5b8eb5a..5b8eb5a 100644 --- a/src/test/resources/xml_validator_test/test_data/valid/no_measdata.xml +++ b/src/test/resources/xml_validator_test/test_data/lte/no_measdata/test.xml diff --git a/src/test/resources/xml_validator_test/test_data/lte/no_measdata/validity.props b/src/test/resources/xml_validator_test/test_data/lte/no_measdata/validity.props new file mode 100644 index 0000000..6e5af27 --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/lte/no_measdata/validity.props @@ -0,0 +1 @@ +valid=true
\ No newline at end of file diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_file_header/test.xml b/src/test/resources/xml_validator_test/test_data/nr/no_file_header/test.xml new file mode 100644 index 0000000..3450b98 --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_file_header/test.xml @@ -0,0 +1,22 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <measData> + <measuredEntity swVersion="r0.1" localDn="Dublin"/> + <measInfo measInfoId="some meas info id"> + <job jobId="some jobId"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="PT900S"/> + <repPeriod duration="PT900S"/> + <measType p="1">a</measType> + <measType p="2">b</measType> + <measType p="3">c</measType> + <measValue measObjLdn="some measObjLdn"> + <r p="1">86</r> + <r p="2">67</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_file_header/validity.props b/src/test/resources/xml_validator_test/test_data/nr/no_file_header/validity.props new file mode 100644 index 0000000..80da24e --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_file_header/validity.props @@ -0,0 +1 @@ +valid=false
\ No newline at end of file diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_measdata/test.xml b/src/test/resources/xml_validator_test/test_data/nr/no_measdata/test.xml new file mode 100644 index 0000000..fb141ad --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_measdata/test.xml @@ -0,0 +1,10 @@ +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_measdata/validity.props b/src/test/resources/xml_validator_test/test_data/nr/no_measdata/validity.props new file mode 100644 index 0000000..6e5af27 --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_measdata/validity.props @@ -0,0 +1 @@ +valid=true
\ No newline at end of file diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/test.xml b/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/test.xml new file mode 100644 index 0000000..0d4216e --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/test.xml @@ -0,0 +1,27 @@ +<?xml version="1.0" encoding="UTF-8"?> +<MeasDataFile xmlns="http://www.3gpp.org/ftp/specs/archive/28_series/28.550#measData"> + <fileHeader dnPrefix="some dnPrefix" vendorName="FooBar Ltd" + fileFormatVersion="32.435 V10.0"> + <fileSender senderName="Dublin"/> + <MeasData beginTime="2018-10-02T12:00:00+01:00"/> + </fileHeader> + <measData> + <measInfo measInfoId="some measInfoId"> + <job jobId="some job Id"/> + <granPeriod endTime="2018-10-02T12:15:00Z" duration="some duration"/> + <repPeriod duration="PT900S"/> + <measType p="1">a</measType> + <measType p="2">b</measType> + <measType p="3">c</measType> + <measValue measObjLdn="some measObjLdn"> + <r p="1">86</r> + <r p="2">67</r> + <r p="3">14</r> + <suspect>false</suspect> + </measValue> + </measInfo> + </measData> + <fileFooter> + <MeasData endTime="2018-10-02T12:15:00+01:00"/> + </fileFooter> +</MeasDataFile> diff --git a/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/validity.props b/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/validity.props new file mode 100644 index 0000000..80da24e --- /dev/null +++ b/src/test/resources/xml_validator_test/test_data/nr/no_measured_entity/validity.props @@ -0,0 +1 @@ +valid=false
\ No newline at end of file |