Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Config element fix for versionless feature #304

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -292,15 +292,30 @@ private void validateConfigElements(DOMDocument domDocument, List<Diagnostic> di
}
for (Diagnostic tempDiagnostic : tempDiagnosticsList) {
String configElement = tempDiagnostic.getSource();
Set<String> includedFeaturesCopy = new HashSet<String>(includedFeatures);
Set<String> compatibleFeaturesList = featureGraph.getAllEnabledBy(configElement);
includedFeaturesCopy.retainAll(compatibleFeaturesList);
Set<String> includedFeaturesCopy = getCompatibleFeatures(includedFeatures, compatibleFeaturesList);
if (includedFeaturesCopy.isEmpty()) {
diagnosticsList.add(tempDiagnostic);
}
}
}

/**
* get compatible features for both versioned and versionless features
*
* @param includedFeatures ll selected features
* @param compatibleFeaturesList enabled by feature list
* @return any compitable feature list
*/
private Set<String> getCompatibleFeatures(Set<String> includedFeatures, Set<String> compatibleFeaturesList) {
Set<String> versionLessCompatibleFeatureList = compatibleFeaturesList.stream()
.map(f -> LibertyUtils.stripVersion(f))
.collect(Collectors.toSet());
return includedFeatures.stream().filter(included ->
compatibleFeaturesList.contains(included) || versionLessCompatibleFeatureList.contains(included)
).collect(Collectors.toSet());
}

/**
* validate platform element. checks for
* 1) if platform is invalid
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -665,4 +665,26 @@ public void testValidPlatformDiagnostic() throws BadLocationException {

XMLAssert.testDiagnosticsFor(serverXML, null, null, serverXMLURI);
}

@Test
public void testConfigElementVersionLess() throws JAXBException {
assertTrue(featureList.exists());
FeatureService.getInstance().readFeaturesFromFeatureListFile(new ArrayList<Feature>(), libWorkspace, featureList);
String serverXML1 = String.join(newLine,
"<server description=\"Sample Liberty server\">",
" <featureManager>",
" <feature>servlet</feature>",
" <platform>jakartaee-9.1</platform>",
" </featureManager>",
" <webApplication contextRoot=\"/app-name\" location=\"app-name.war\" />",
" <httpEndpoint id=\"defaultHttpEndpoint\" httpPort=\"9080\" httpsPort=\"9443\"/>",
" <ssl id=\"defaultSSLConfig\" trustDefaultCerts=\"true\" />",
"</server>"
);
Diagnostic configForMissingFeature = new Diagnostic();
configForMissingFeature.setRange(r(7, 3, 7, 57));
configForMissingFeature.setCode(LibertyDiagnosticParticipant.MISSING_CONFIGURED_FEATURE_CODE);
configForMissingFeature.setMessage(LibertyDiagnosticParticipant.MISSING_CONFIGURED_FEATURE_MESSAGE);
XMLAssert.testDiagnosticsFor(serverXML1, null, null, serverXMLURI,configForMissingFeature);
}
}
Loading