### Question:
Utils { public static String getPsuVersion(String lsInventory) { logger.entering(); String result = null; Pattern patternOne = Pattern.compile( "WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.)\\d+\\(ID:(\\d+)\\.\\d+\\)"); Pattern patternTwo = Pattern.compile( "WLS PATCH SET UPDATE (\\d+\\.\\d+\\.\\d+\\.\\d+\\.[1-9]\\d+)"); for (String line: lsInventory.split("\\n")) { Matcher matchPatternOne = patternOne.matcher(line); Matcher matchPatternTwo = patternTwo.matcher(line); if (matchPatternOne.find()) { result = matchPatternOne.group(1) + matchPatternOne.group(2); logger.fine("Found PSU in inventory {0}, in {1}", result, line); break; } else if (matchPatternTwo.find()) { result = matchPatternTwo.group(1); logger.fine("Found PSU in inventory {0}, in {1}", result, line); break; } } logger.exiting(result); return result; } private  Utils(); static void copyResourceAsFile(String resourcePath, String destPath, boolean markExec); static void copyLocalFile(Path sourcePath, Path destPath, boolean markExec); static void copyLocalDirectory(Path sourcePath, Path destPath, boolean markExec); static void setProxyIfRequired(String httpProxyUrl, String httpsProxyUrl, String nonProxyHosts); static String writeDockerfile(String destPath, String template, DockerfileOptions options, boolean dryRun); static void writeResolvedFiles(List<Path> paths, List<Object> options); static void deleteFilesRecursively(String pathDir); static int compareVersions(String thisVersion, String otherVersion); static boolean isEmptyString(String s); static Properties getBaseImageProperties(String dockerImage, String tmpDir); static String findProxyUrl(String proxyUrl, String protocol); static String getPasswordFromInputs(String passwordStr, Path passwordFile, String passwordEnv); static String getEnvironmentProperty(String name); static String getBuildWorkingDir(); static String getOpatchVersionFromZip(String fileName); static boolean validatePatchIds(List<String> patches, boolean rigid); static void setOracleHome(List<Path> responseFiles, DockerfileOptions options); static void setInventoryLocation(String inventoryLocFile, DockerfileOptions options); static String getMessage(@PropertyKey(resourceBundle = "ImageTool") String key, Object... params); static void removeIntermediateDockerImages(String buildId); static String getPsuVersion(String lsInventory); @SafeVarargs static List<T> list(Collection<? extends T> start, T... elements);  }### Answer:
@Test void getPsuVersionFromInventoryOldStyle() throws IOException { Path inventoryPath = Paths.get("./src/test/resources/utilsTest/lsinventory.txt"); String inventoryStr = new String(Files.readAllBytes(inventoryPath)); assertEquals("12.2.1.4.191220", Utils.getPsuVersion(inventoryStr), "Utils.getPsuVersion is failing"); }
@Test void getPsuVersionFromInventoryIdStyle() throws IOException { Path inventoryPath = Paths.get("./src/test/resources/utilsTest/lsinventoryWithID.txt"); String inventoryStr = new String(Files.readAllBytes(inventoryPath)); assertEquals("12.2.1.3.200227", Utils.getPsuVersion(inventoryStr), "Utils.getPsuVersion is failing"); }