diff options
author | Joseph O'Leary <joseph.o.leary@est.tech> | 2020-07-20 10:26:16 +0000 |
---|---|---|
committer | Gerrit Code Review <gerrit@onap.org> | 2020-07-20 10:26:16 +0000 |
commit | bd0a411d6f04f92d222af6a63bd2b7ecc3edd0a2 (patch) | |
tree | 34a84a1f044bb102225abed856412656fbfa117d /src/test/java/utils/EventUtils.java | |
parent | ba384eeb3cc007ff1d48db04fecc9356069456c5 (diff) | |
parent | c62f765c1ed65829e126807e1e7a91388bb1c322 (diff) |
Merge "Adjust pm-mapper to accept new schema."
Diffstat (limited to 'src/test/java/utils/EventUtils.java')
-rw-r--r-- | src/test/java/utils/EventUtils.java | 22 |
1 files changed, 19 insertions, 3 deletions
diff --git a/src/test/java/utils/EventUtils.java b/src/test/java/utils/EventUtils.java index ffa02b0..934c191 100644 --- a/src/test/java/utils/EventUtils.java +++ b/src/test/java/utils/EventUtils.java @@ -26,6 +26,8 @@ import static org.mockito.Mockito.mock; import com.google.gson.Gson; import io.undertow.server.HttpServerExchange; + +import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; @@ -43,6 +45,8 @@ import org.onap.dcaegen2.services.pmmapper.utils.MeasConverter; public class EventUtils { + private static final String LTE_QUALIFIER = File.separator + "lte"; + private static final String NR_QUALIFIER = File.separator + "nr"; /** * Reads contents of files inside the eventBodyDirectory, combines contents with metadata to make an Event Object. @@ -59,18 +63,18 @@ 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 ) { + public static List<Arguments> generateEventArguments(Path baseDirectory, 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; + String fileFormatType = readFileFormatFromPath(path.toString()); EventMetadata eventMetadata = new EventMetadata(); eventMetadata.setFileFormatType(fileFormatType); events.addAll(getEventsArgument(path, eventMetadata, argCreator)); @@ -81,6 +85,18 @@ public class EventUtils { return events; } + private static String readFileFormatFromPath(String path) { + if (path.contains(NR_QUALIFIER)) { + return MeasConverter.NR_FILE_TYPE; + } + else if (path.contains(LTE_QUALIFIER)) { + return MeasConverter.LTE_FILE_TYPE; + } + else { + return MeasConverter.NOT_SUPPORTED_TYPE; + } + } + /** * reads contents of file into a string. * fails a tests in the event failure occurs. |