-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MIGENG-138 WIR Complexity rules and tests - WIP (#17)
* MIGENG-138 WIR Complexity rules and tests - WIP * MIGENG-138 WIR Complexity rules and tests - WIP * MIGENG-138: complete Complexity rules * MIGENG-138: complete Complexity rules * MIGENG-138 Fixed Agenda Groups focusing order (#3) * MIGENG-138: Integration test with added Complexity rules scenarios * Update src/main/java/org/jboss/xavier/analytics/pojo/output/workload/inventory/WorkloadInventoryReportModel.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/pojo/output/workload/inventory/WorkloadInventoryReportModel.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/pojo/output/workload/inventory/WorkloadInventoryReportModel.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/pojo/output/workload/inventory/WorkloadInventoryReportModel.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/functions/HelperFunctions.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/functions/HelperFunctions.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/functions/HelperFunctions.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/java/org/jboss/xavier/analytics/functions/HelperFunctions.java Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/resources/org/jboss/xavier/analytics/rules/workload/inventory/Complexity.drl Co-Authored-By: Marco Rizzi <[email protected]> * Update src/main/resources/org/jboss/xavier/analytics/rules/workload/inventory/Complexity.drl Co-Authored-By: Marco Rizzi <[email protected]> * MIGENG-138: Complexity rule & test changes as per review * MIGENG-138: Complexity rule & test changes as per review
- Loading branch information
Showing
8 changed files
with
1,003 additions
and
19 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
src/main/java/org/jboss/xavier/analytics/functions/HelperFunctions.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,55 @@ | ||
package org.jboss.xavier.analytics.functions; | ||
|
||
import java.util.Arrays; | ||
|
||
public class HelperFunctions | ||
{ | ||
public static int round(double value) | ||
{ | ||
return (int) Math.round(value); | ||
} | ||
|
||
public static boolean isSupportedOS(String osToCheck) | ||
{ | ||
return Arrays.stream(OSSupport.values()).anyMatch(value -> osToCheck.toLowerCase().contains(value.getName().toLowerCase()) && value.isSupported()); | ||
} | ||
|
||
public static boolean isUnsupportedOS(String osToCheck) | ||
{ | ||
return Arrays.stream(OSSupport.values()).anyMatch(value -> osToCheck.toLowerCase().contains(value.getName().toLowerCase()) && !value.isSupported()); | ||
} | ||
|
||
public static boolean isUndetectedOS(String osToCheck) | ||
{ | ||
return Arrays.stream(OSSupport.values()).noneMatch(value -> osToCheck.toLowerCase().contains(value.getName().toLowerCase())); | ||
} | ||
|
||
public enum OSSupport{ | ||
RHEL("Red Hat Enterprise Linux", true), | ||
SUSE("SUSE Linux Enterprise Server", true), | ||
WINDOWS("Windows",true), | ||
ORACLE("Oracle Enterprise Linux",false), | ||
CENTOS("CentOS",false), | ||
DEBIAN("Debian",false), | ||
UBUNTU("Ubuntu",false); | ||
|
||
private final String name; | ||
private final boolean isSupported; | ||
|
||
OSSupport(String name, boolean isSupported) | ||
{ | ||
this.name = name; | ||
this.isSupported = isSupported; | ||
} | ||
|
||
boolean isSupported() | ||
{ | ||
return this.isSupported; | ||
} | ||
|
||
public String getName() | ||
{ | ||
return this.name; | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
100 changes: 100 additions & 0 deletions
100
src/main/resources/org/jboss/xavier/analytics/rules/workload/inventory/Complexity.drl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
package org.jboss.xavier.analytics.rules.workload.inventory; | ||
|
||
import org.jboss.xavier.analytics.pojo.input.workload.inventory.VMWorkloadInventoryModel | ||
import org.jboss.xavier.analytics.pojo.output.workload.inventory.WorkloadInventoryReportModel | ||
import java.util.HashSet; | ||
|
||
import function org.jboss.xavier.analytics.functions.HelperFunctions.isSupportedOS; | ||
import function org.jboss.xavier.analytics.functions.HelperFunctions.isUnsupportedOS; | ||
import function org.jboss.xavier.analytics.functions.HelperFunctions.isUndetectedOS; | ||
|
||
dialect "java" | ||
agenda-group "Complexity" | ||
lock-on-active true | ||
auto-focus false | ||
|
||
rule "No_Flag_Supported_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
flagsIMS == null, | ||
osDescription != null, | ||
isSupportedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_EASY) | ||
} | ||
end | ||
|
||
rule "One_Flag_Supported_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
flagsIMS != null, | ||
flagsIMS.size() == 1, | ||
osDescription != null, | ||
isSupportedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_MEDIUM) | ||
} | ||
end | ||
|
||
rule "More_Than_One_Flag_Supported_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
flagsIMS != null, | ||
flagsIMS.size() > 1, | ||
osDescription != null, | ||
isSupportedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_HARD) | ||
} | ||
end | ||
|
||
rule "No_Flags_Not_Supported_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
flagsIMS == null, | ||
osDescription != null, | ||
isUnsupportedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_MEDIUM) | ||
} | ||
end | ||
|
||
rule "One_Or_More_Flags_Not_Supported_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
flagsIMS != null, | ||
flagsIMS.size() >= 1, | ||
osDescription != null, | ||
isUnsupportedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_HARD) | ||
} | ||
end | ||
|
||
rule "Not_Detected_OS" | ||
when | ||
workloadInventoryReport : WorkloadInventoryReportModel( | ||
osDescription != null, | ||
isUndetectedOS(osDescription) | ||
) | ||
then | ||
modify(workloadInventoryReport) | ||
{ | ||
setComplexity(WorkloadInventoryReportModel.COMPLEXITY_UNKNOWN) | ||
} | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.