Skip to content
This repository has been archived by the owner on Jul 11, 2022. It is now read-only.

Commit

Permalink
Merge pull request #16 from lzoubek/bugs/1080909
Browse files Browse the repository at this point in the history
[BZ 1080909] DynaGroup expression evaluator is not strict when grouping by resource configuration property
  • Loading branch information
pilhuhn committed Apr 22, 2014
2 parents 44960d4 + 21bb0b2 commit 4c111ac
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.pluginConfiguration pluginConf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.pluginConfigurationDefinition pluginConfDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue = :arg2 " + //
" AND simple.configuration = pluginConf " + //
" AND simpleDef.configurationDefinition = pluginConfDef " + //
Expand All @@ -81,7 +81,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue LIKE :arg2 ESCAPE '" + escapeChar + "'" + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
Expand All @@ -103,7 +103,7 @@ private String[][] getSuccessTestCases() {
" SELECT simple.stringValue FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
" AND simple.name = simpleDef.name AND simpleDef.type != 'PASSWORD' " + //
Expand All @@ -112,7 +112,7 @@ private String[][] getSuccessTestCases() {
" SELECT res.id FROM Resource res " + //
" JOIN res.resourceConfiguration conf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.resourceConfigurationDefinition confDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue = :arg2 " + //
" AND simple.configuration = conf " + //
" AND simpleDef.configurationDefinition = confDef " + //
Expand Down Expand Up @@ -150,7 +150,7 @@ private String[][] getSuccessTestCases() {
"SELECT res.id FROM Resource res " + //
" JOIN res.pluginConfiguration pluginConf, PropertySimple simple, PropertyDefinition simpleDef " + //
" JOIN res.resourceType.pluginConfigurationDefinition pluginConfDef " + //
" WHERE simple.name LIKE :arg1 ESCAPE '" + escapeChar + "'" + //
" WHERE simple.name = :arg1 " + //
" AND simple.stringValue IS NULL " + //
" AND simple.configuration = pluginConf " + //
" AND simpleDef.configurationDefinition = pluginConfDef " + //
Expand Down Expand Up @@ -811,6 +811,16 @@ public String[] getExpressions() {
});
}

@Test(expectedExceptions = InvalidExpressionException.class, expectedExceptionsMessageRegExp = "Unrecognized.*")
public void doNotAllowEmptyProperty() throws Exception {
evaluateExpressions(new ExpressionGenerator() {
@Override
public String[] getExpressions() {
return new String[] { "resource.greatGreatGrandParent.resourceConfiguration[] = 1" };
}
});
}

private String cleanUp(String result) {
return result.replaceAll("\\s+", " ").trim();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ private void parseExpression(String expression) throws InvalidExpressionExceptio
addJoinCondition(joinCondition);
addJoinCondition(definitionJoinCondition);

populatePredicateCollections(PROP_SIMPLE_ALIAS + ".name", "%" + propertyName + "%", false, false);
populatePredicateCollections(PROP_SIMPLE_ALIAS + ".name", propertyName, false, false);
populatePredicateCollections(PROP_SIMPLE_ALIAS + ".stringValue", value);

whereStatics.add(PROP_SIMPLE_ALIAS + ".configuration = " + joinCondition.alias);
Expand Down

0 comments on commit 4c111ac

Please sign in to comment.