Skip to content

Commit

Permalink
MARP-975 Handle Feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
tvtphuc-axonivy committed Dec 23, 2024
1 parent f1f9aee commit 8ab4b1f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -763,28 +763,19 @@ public boolean syncFirstPublishedDateOfAllProducts() {
}

private String getCompatibilityRange(String productId) {
List<String> versions =
versionService.getVersionsForDesigner(productId).stream().map(VersionAndUrlModel::getVersion).toList();
if (ObjectUtils.isEmpty(versions)) {
return null;
}

if (versions.size() == 1) {
return splitVersion(versions.get(0));
}

String currentMaxVersion = versions.get(0);
boolean isMoreThan1InMaxVersion = versions.stream()
.filter(version -> version.startsWith(
currentMaxVersion.substring(0, currentMaxVersion.indexOf(DOT_SEPARATOR)))).toList().size() > 1;

String maxValue = isMoreThan1InMaxVersion ? splitVersion(currentMaxVersion).concat(PLUS) : splitVersion(
currentMaxVersion);
String minValue = splitVersion(versions.get(versions.size() - 1));

return getPrefixOfVersion(minValue).equals(getPrefixOfVersion(maxValue)) ?
minValue.concat(PLUS) :
minValue.concat(DASH_SEPARATOR).concat(maxValue);
return Optional.of(versionService.getVersionsForDesigner(productId))
.filter(ObjectUtils::isNotEmpty)
.map(versions -> versions.stream().map(VersionAndUrlModel::getVersion).toList())
.map(versions -> {
if (versions.size() == 1) {
return splitVersion(versions.get(0)).concat(PLUS);
}
String maxValue = splitVersion(versions.get(0)).concat(PLUS);
String minValue = splitVersion(versions.get(versions.size() - 1));
return getPrefixOfVersion(minValue).equals(getPrefixOfVersion(maxValue)) ?
minValue.concat(PLUS) :
minValue.concat(DASH_SEPARATOR).concat(maxValue);
}).orElse(null);
}

private String splitVersion(String version) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -421,13 +421,13 @@ void testGetCompatibilityRangeAfterFetchProductDetail() {
assertEquals(result.getCompatibilityRange(),"10.0+");

result = productService.fetchProductDetail(MOCK_PRODUCT_ID, true);
assertEquals(result.getCompatibilityRange(),"10.0-11.3");
assertEquals(result.getCompatibilityRange(),"10.0-11.3+");

result = productService.fetchProductDetail(MOCK_PRODUCT_ID, true);
assertEquals(result.getCompatibilityRange(),"10.0-11.3+");

result = productService.fetchProductDetail(MOCK_PRODUCT_ID, true);
assertEquals(result.getCompatibilityRange(),"10.0-12.0");
assertEquals(result.getCompatibilityRange(),"10.0-12.0+");
}

@Test
Expand Down

0 comments on commit 8ab4b1f

Please sign in to comment.