Commit e58dca9e authored by Romain Bioteau's avatar Romain Bioteau
Browse files

Update warning message when no form is selected to distinct overview and

instantiation mapping
parent 1d54d7ff
......@@ -94,6 +94,7 @@ queryParameterDoesNotExistInExpression=Query parameter {1} is missing for Query
invalidInternalFormMapping=Invalid {0}. {1} doesn't exists.
entryFormMapping=entry form mapping
overviewFormMapping=overview page mapping
instantiationFormMapping=instantiation form mapping
invalidURLFormMapping=External URL form type is selected and no url is defined.
duplicatedFormName=Invalid {0}. Other mapping have the same name but have different id in: {1}
sequenceFlow_Without_Target_Element=This sequence flow has no target. You may delete it.
......@@ -105,7 +106,7 @@ invalidMultipleFileContractInput=Invalid initial content for document {0}. A sin
invalidFileContractInputType=Invalid initial content for document {0}. A FILE contract input is expected but a {1} contract input has been found.
invalidSingleFileContractInput=Invalid initial content for document {0}. A multiple FILE contract input is expected but a single FILE contract input has been found.
missingFileContractInput=Invalid initial content for document {0}. No FILE contract input has been found.
emptyFormMappingWarning=UI designer form type is selected and no target form is defined. An autogenerated form will be used in the development environment ONLY.
emptyFormMappingWarning=UI designer form type is selected and no target form is defined for {0}. An autogenerated form will be used in the development environment ONLY.
cannotUseThisStartEventTypeWithAContract=An instantiation contract cannot be used with this start event type. Use the none start event.
failedToRetrieveLeftOperandType=Failed to retrieve left operand type: {0}
methodDoesnotExistInLeftOperandType=The method {0}({1}) does not exist for {2}
......
......@@ -16,6 +16,7 @@ package org.bonitasoft.studio.validation.constraints.process;
import static org.bonitasoft.studio.model.expression.builders.ExpressionBuilder.anExpression;
import static org.bonitasoft.studio.model.process.builders.FormMappingBuilder.aFormMapping;
import static org.bonitasoft.studio.model.process.builders.PoolBuilder.aPool;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
......@@ -30,14 +31,27 @@ import org.junit.Test;
public class FormMappingContentConstraintTest {
@Test
public void should_fail_if_form_mapping_is_INTERNAL_and_has_no_target_form() throws Exception {
public void should_fail_if_form_mapping_is_INTERNAL_and_has_no_target_overview_form() throws Exception {
final FormMappingContentConstraint internalFormMappingConstraint = new FormMappingContentConstraint();
final IValidationContext validationContext = aValidationContext(aFormMapping().withType(FormMappingType.INTERNAL).havingTargetForm(anExpression())
.build());
final IValidationContext validationContext = aValidationContext(aPool()
.havingOverviewFormMapping(aFormMapping().withType(FormMappingType.INTERNAL).havingTargetForm(anExpression()))
.build().getOverviewFormMapping());
internalFormMappingConstraint.performBatchValidation(validationContext);
verify(validationContext).createFailureStatus(Messages.bind(Messages.emptyFormMappingWarning, Messages.overviewFormMapping));
}
@Test
public void should_fail_if_form_mapping_is_INTERNAL_and_has_no_target_instantiation_form() throws Exception {
final FormMappingContentConstraint internalFormMappingConstraint = new FormMappingContentConstraint();
final IValidationContext validationContext = aValidationContext(aPool()
.havingFormMapping(aFormMapping().withType(FormMappingType.INTERNAL).havingTargetForm(anExpression()))
.build().getFormMapping());
internalFormMappingConstraint.performBatchValidation(validationContext);
verify(validationContext).createFailureStatus(Messages.emptyFormMappingWarning);
verify(validationContext).createFailureStatus(Messages.bind(Messages.emptyFormMappingWarning, Messages.instantiationFormMapping));
}
@Test
......
......@@ -17,9 +17,13 @@ package org.bonitasoft.studio.validation.constraints.process;
import static com.google.common.base.Preconditions.checkArgument;
import static com.google.common.base.Strings.isNullOrEmpty;
import java.util.Objects;
import org.bonitasoft.studio.model.expression.Expression;
import org.bonitasoft.studio.model.process.FormMapping;
import org.bonitasoft.studio.model.process.MainProcess;
import org.bonitasoft.studio.model.process.ProcessPackage;
import org.bonitasoft.studio.model.process.Task;
import org.bonitasoft.studio.validation.constraints.AbstractLiveValidationMarkerConstraint;
import org.bonitasoft.studio.validation.i18n.Messages;
import org.eclipse.core.runtime.IStatus;
......@@ -59,12 +63,17 @@ public class FormMappingContentConstraint extends AbstractLiveValidationMarkerCo
if (formMapping.eContainer() instanceof MainProcess) {
return ctx.createFailureStatus(Messages.formMappingAtDiagramLevel_ModelInconsistency);
} else {
return ctx.createFailureStatus(Messages.emptyFormMappingWarning);
return ctx.createFailureStatus(Messages.bind(Messages.emptyFormMappingWarning, formMappingType(formMapping)));
}
}
return ctx.createSuccessStatus();
}
private String formMappingType(final FormMapping formMapping) {
return Objects.equals(formMapping.eContainingFeature(), ProcessPackage.Literals.RECAP_FLOW__OVERVIEW_FORM_MAPPING) ? Messages.overviewFormMapping
: formMapping.eContainer() instanceof Task ? Messages.entryFormMapping : Messages.instantiationFormMapping;
}
private IStatus doValidateURLMapping(final IValidationContext ctx, final FormMapping formMapping) {
return isNullOrEmpty(formMapping.getUrl()) ? ctx.createFailureStatus(Messages.invalidURLFormMapping) : ctx
.createSuccessStatus();
......
......@@ -231,6 +231,7 @@ public class Messages extends NLS {
public static String nameUnicityConstraintContractInput;
public static String nameUnicityConstraintVariable;
public static String formMappingAtDiagramLevel_ModelInconsistency;
public static String instantiationFormMapping;
static {
// initialize resource bundle
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment