ProcessMessageStartEventMessageNameValidator implements ModelElementValidator<StartEvent> { @Override public void validate( final StartEvent element, final ValidationResultCollector validationResultCollector) { if (element.getScope() instanceof Process) { element.getEventDefinitions().stream() .filter(MessageEventDefinition.class::isInstance) .map(MessageEventDefinition.class::cast) .forEach(definition -> validateMessageName(definition, validationResultCollector)); } } ProcessMessageStartEventMessageNameValidator(final ExpressionLanguage expressionLanguage); @Override Class<StartEvent> getElementType(); @Override void validate(
      final StartEvent element, final ValidationResultCollector validationResultCollector);  }
@Test public void shouldLetValidMessageNameExpressionsPass() { when(mockResult.isFailure()).thenReturn(false); when(mockResult.getType()).thenReturn(ResultType.STRING); sutValidator.validate(START_EVENT, mockResultCollector); verifyNoInteractions(mockResultCollector); }
@Test public void shoulAddErrorIfEvaluationFailed() { when(mockResult.isFailure()).thenReturn(true); when(mockResult.getFailureMessage()).thenReturn("Test failure message"); sutValidator.validate(START_EVENT, mockResultCollector); verify(mockResultCollector) .addError( 0, "Expected constant expression but found 'expression', which could not be evaluated without context: Test failure message"); }
@Test public void shoulAddErrorIfEvaluationDoesNotReturnString() { when(mockResult.isFailure()).thenReturn(false); when(mockResult.getType()).thenReturn(ResultType.NUMBER); sutValidator.validate(START_EVENT, mockResultCollector); verify(mockResultCollector) .addError( 0, "Expected constant expression of type String for message name 'expression', but was NUMBER"); }