Skip to content

Commit

Permalink
FIPS-10343/FIPS-11544 :: Validate only non-abstract value sets
Browse files Browse the repository at this point in the history
Change-Id: I567721aabadde8e3328a67e8764d43c83a4f7681
  • Loading branch information
hd42 committed May 7, 2024
1 parent d0c57e9 commit a166879
Show file tree
Hide file tree
Showing 8 changed files with 38 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
<setEntry value="spotbugs-annotations@default:default"/>
</setAttribute>
<setAttribute key="selected_workspace_bundles">
<setEntry value="org.faktorips.devtools.abstraction.eclipse@default:default"/>
<setEntry value="org.faktorips.devtools.abstraction.eclipse@1:true"/>
<setEntry value="org.faktorips.devtools.abstraction.plainjava@default:default"/>
<setEntry value="org.faktorips.devtools.abstraction@default:default"/>
<setEntry value="org.faktorips.devtools.ant@default:default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -395,7 +395,7 @@
<setEntry value="spotbugs-annotations@default:default"/>
</setAttribute>
<setAttribute key="selected_workspace_bundles">
<setEntry value="org.faktorips.devtools.abstraction.eclipse@default:default"/>
<setEntry value="org.faktorips.devtools.abstraction.eclipse@1:true"/>
<setEntry value="org.faktorips.devtools.abstraction.plainjava@default:default"/>
<setEntry value="org.faktorips.devtools.abstraction@default:default"/>
<setEntry value="org.faktorips.devtools.ant@default:default"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -275,7 +275,9 @@ protected void validateThis(MessageList result, IIpsProject ipsProject) {
if (getValueDatatype() != null) {
validateValueSetType(result);
}
validateValueSet(result);
if (!getValueSet().isAbstract()) {
validateValueSet(result);
}
validateChangingOverTimeFlag(result);
validateAbstractDatatype(result);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,9 @@ protected void validateContent(MessageList list, IIpsProject ipsProject, IPolicy
}

}
if (valueSetToValidate.isEmpty() && !modelValueSet.isContainsNull()) {
String text = Messages.ConfiguredValueSet_error_msg_mandatoryAttribute;
if (valueSetToValidate.isEmpty() && !modelValueSet.isContainsNull() && !modelValueSet.isAbstract()) {
String text = MessageFormat.format(Messages.ConfiguredValueSet_error_msg_mandatoryAttribute,
getPolicyCmptTypeAttribute());
list.add(new Message(MSGCODE_MANDATORY_VALUESET_IS_EMPTY, text, Message.ERROR, this,
PROPERTY_VALUE_SET));
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ConfiguredDefault_msgValueNotParsable=The value {0} is not a {1}.

ConfiguredValueSet_caption={0}Value set of {1}
ConfiguredValueSet_error_msg_abstractValueSet=Must specify a concrete set of values\!
ConfiguredValueSet_error_msg_mandatoryAttribute=The attribute is marked as mandatory in the model. The value set must contain at least one value.
ConfiguredValueSet_error_msg_mandatoryAttribute=The attribute {0} is marked as mandatory in the model. The value set must contain at least one value.
ConfiguredValueSet_msgInvalidAttributeValueset=This value set configuration element can not be validated against the value set of the attribute, because the value set of the attribute is not valid.

DateBasedProductCmptNamingStrategy_msgWrongFormat=The {0} identification has the wrong format\. Expected format: {1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ ConfiguredDefault_msgValueNotParsable=Der Wert {0} ist kein {1}.

ConfiguredValueSet_caption={0}Wertemenge {1}
ConfiguredValueSet_error_msg_abstractValueSet=Es muss eine konkrete Wertemenge angegeben werden.
ConfiguredValueSet_error_msg_mandatoryAttribute=Das Attribut ist ein Pflichtattribut. Die Wertemenge muss mindestens einen Wert enthalten.
ConfiguredValueSet_error_msg_mandatoryAttribute=Das Attribut {0} ist ein Pflichtattribut. Die Wertemenge muss mindestens einen Wert enthalten.
ConfiguredValueSet_msgInvalidAttributeValueset=Der Wertebereich und der Wert dieses Konfigurationselements kann nicht gegen den Wertebereich des Attributs gepr\u00FCft werden, da der Wertebereich des Attributs nicht g\u00FCltig ist.

DateBasedProductCmptNamingStrategy_msgWrongFormat=Die {0}-Id hat ein falsche Format. Erwartetes Format\: {1}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,21 @@ public void testValidateEmptyMandatory() {
hasSeverity(Severity.WARNING));
}

@Test
public void testValidateEmptyMandatory_AbstractIsOk() {
pcType.setConfigurableByProductCmptType(true);
attribute.setName("mandatory");
attribute.setDatatype(Datatype.STRING.getQualifiedName());
attribute.setValueSetType(ValueSetType.ENUM);
attribute.setValueSetConfiguredByProduct(true);
attribute.getValueSet().setContainsNull(false);
attribute.getValueSet().setAbstract(true);

MessageList ml = attribute.validate(ipsProject);

assertThat(ml, isEmpty());
}

@Test
public void testValidateNothingToOverwrite() throws Exception {
attribute.setName("name");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import static org.faktorips.abstracttest.matcher.ValueSetMatchers.empty;
import static org.faktorips.testsupport.IpsMatchers.hasMessageCode;
import static org.faktorips.testsupport.IpsMatchers.hasSeverity;
import static org.faktorips.testsupport.IpsMatchers.isEmpty;
import static org.faktorips.testsupport.IpsMatchers.lacksMessageCode;
import static org.hamcrest.CoreMatchers.instanceOf;
import static org.hamcrest.CoreMatchers.is;
Expand Down Expand Up @@ -248,6 +249,18 @@ public void testValidate_MandatoryValueSetIsEmptyInModel() {
assertThat(ml, hasMessageCode(IConfiguredValueSet.MSGCODE_MANDATORY_VALUESET_IS_EMPTY));
}

@Test
public void testValidate_MandatoryValueSetIsAbstractInModel() {
attribute.setDatatype("Integer");
attribute.changeValueSetType(ValueSetType.ENUM);
attribute.getValueSet().setContainsNull(false);
attribute.getValueSet().setAbstract(true);
configuredValueSet.changeValueSetType(ValueSetType.ENUM);

MessageList ml = configuredValueSet.validate(ipsProject);
assertThat(ml, isEmpty());
}

@Test
public void testValidate_ValueSetTypeMismatch() {
setUpRangeIntegerAttr();
Expand Down

0 comments on commit a166879

Please sign in to comment.