Skip to content

Commit 4b8adeb

Browse files
Updated os description logic to keep equals ignore match with guest os display name
1 parent c1a9f41 commit 4b8adeb

2 files changed

Lines changed: 1 addition & 57 deletions

File tree

utils/src/main/java/com/cloud/utils/StringUtils.java

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ public static List<String> csvTagsToList(final String tags) {
124124

125125
/**
126126
* Converts a List of tags to a comma separated list
127-
* @param tagsList
127+
* @param tags
128128
* @return String containing a comma separated list of tags
129129
*/
130130

@@ -313,30 +313,4 @@ private static <T> List<List<T>> partitionList(final List<T> originalList, final
313313
public static String toCSVList(final List<String> csvList) {
314314
return join(csvList, ",");
315315
}
316-
317-
/**
318-
* Calculates minimum number of edits required to convert from one string to another string.
319-
* @param str1 String that needs editing
320-
* @param str2 Target string that is required/expected after editing
321-
* @return minimum number of edits required to convert str1 to str2
322-
*/
323-
public static int minimumEditDistance(String str1, String str2) {
324-
int str1Length = str1.length();
325-
int str2Length = str2.length();
326-
int[][] auxiliaryArray = new int[str1Length + 1][str2Length + 1];
327-
328-
for (int i = 0; i <= str1Length; i++) {
329-
for (int j = 0; j <= str2Length; j++) {
330-
if (i == 0)
331-
auxiliaryArray[i][j] = j;
332-
else if (j == 0)
333-
auxiliaryArray[i][j] = i;
334-
else if (str1.charAt(i - 1) == str2.charAt(j - 1))
335-
auxiliaryArray[i][j] = auxiliaryArray[i - 1][j - 1];
336-
else
337-
auxiliaryArray[i][j] = 1 + Integer.min(Integer.min(auxiliaryArray[i][j - 1], auxiliaryArray[i - 1][j]), auxiliaryArray[i - 1][j - 1]);
338-
}
339-
}
340-
return auxiliaryArray[str1Length][str2Length];
341-
}
342316
}

utils/src/test/java/com/cloud/utils/StringUtilsTest.java

Lines changed: 0 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -258,34 +258,4 @@ public void testToCSVList() {
258258
String output = StringUtils.toCSVList(Arrays.asList(input.split(",")));
259259
assertTrue(input.equals(output));
260260
}
261-
262-
@Test
263-
public void testZeroEditDistance() {
264-
String str1 = "Other 32-bit";
265-
String str2 = "Other 32-bit";
266-
int minDistance = StringUtils.minimumEditDistance(str1, str2);
267-
assertEquals(minDistance, 0);
268-
}
269-
270-
@Test
271-
public void testBestMatchStringWithEditDistance() {
272-
String str1 = "FreeBSD 11 (32bit)";
273-
String str2 = "FreeBSD 12 (64bit)";
274-
String targetString = "FreeBSD 64bit";
275-
int minDistanceStr1 = StringUtils.minimumEditDistance(str1, targetString);
276-
int minDistanceStr2 = StringUtils.minimumEditDistance(str2, targetString);
277-
// the best match will be str2, so expecting less edit distance
278-
assertTrue(minDistanceStr2 < minDistanceStr1);
279-
}
280-
281-
@Test
282-
public void testCompletelyDifferentStringsWithEditDistance() {
283-
String str1 = "Other (32-bit)";
284-
String str2 = "SCO OpenServer 5";
285-
String targetString = "Other 32-bit";
286-
int minDistanceStr1 = StringUtils.minimumEditDistance(str1, targetString);
287-
int minDistanceStr2 = StringUtils.minimumEditDistance(str2, targetString);
288-
// the best match will be str1, so expecting less edit distance
289-
assertTrue(minDistanceStr1 < minDistanceStr2);
290-
}
291261
}

0 commit comments

Comments
 (0)