Search in sources :

Example 11 with Problem

use of org.mule.runtime.extension.api.loader.Problem in project mule by mulesoft.

the class PrivilegedApiValidator method validate.

@Override
public void validate(ExtensionModel model, ProblemsReporter problemsReporter) throws IllegalModelDefinitionException {
    final boolean hasPrivilegedPackages = model.getPrivilegedPackages() != null && !model.getPrivilegedPackages().isEmpty();
    final boolean hasPrivilegedArtifacts = model.getPrivilegedArtifacts() != null && !model.getPrivilegedArtifacts().isEmpty();
    if (hasPrivilegedPackages != hasPrivilegedArtifacts) {
        if (hasPrivilegedPackages) {
            problemsReporter.addError(new Problem(model, NO_PRIVILEGED_ARTIFACTS_ERROR));
        } else {
            problemsReporter.addError(new Problem(model, NO_PRIVILEGED_PACKAGES_ERROR));
        }
    }
}
Also used : Problem(org.mule.runtime.extension.api.loader.Problem)

Example 12 with Problem

use of org.mule.runtime.extension.api.loader.Problem in project mule by mulesoft.

the class TransactionalParametersValidatorTestCase method transactionalActionIsReservedWord.

@Test
public void transactionalActionIsReservedWord() {
    when(txParameter.getModelProperty(any())).thenReturn(Optional.empty());
    validator.validate(extensionModel, problemsReporter);
    List<Problem> errors = problemsReporter.getErrors();
    assertThat(errors, hasSize(1));
    Problem problem = errors.get(0);
    assertThat(problem.getComponent(), is(sourceModel));
    assertThat(problem.getMessage(), containsString("defines a parameter named: 'transactionalAction', which is a reserved word"));
}
Also used : Problem(org.mule.runtime.extension.api.loader.Problem) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Example 13 with Problem

use of org.mule.runtime.extension.api.loader.Problem in project mule by mulesoft.

the class TransactionalParametersValidatorTestCase method transactionalParameterCantBePlacedInParameterGroupWithShowInDsl.

@Test
public void transactionalParameterCantBePlacedInParameterGroupWithShowInDsl() {
    when(parameterGroupModel.isShowInDsl()).thenReturn(true);
    validator.validate(extensionModel, problemsReporter);
    List<Problem> errors = problemsReporter.getErrors();
    assertThat(errors, hasSize(1));
    Problem problem = errors.get(0);
    assertThat(problem.getComponent(), is(sourceModel));
    assertThat(problem.getMessage(), containsString("Transactional parameters can't be placed inside of Parameter Groups with 'showInDsl' option."));
}
Also used : Problem(org.mule.runtime.extension.api.loader.Problem) SmallTest(org.mule.tck.size.SmallTest) Test(org.junit.Test)

Aggregations

Problem (org.mule.runtime.extension.api.loader.Problem)13 ProblemsReporter (org.mule.runtime.extension.api.loader.ProblemsReporter)5 String.format (java.lang.String.format)4 MetadataType (org.mule.metadata.api.model.MetadataType)4 ObjectType (org.mule.metadata.api.model.ObjectType)4 MetadataTypeVisitor (org.mule.metadata.api.visitor.MetadataTypeVisitor)4 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 ExtensionModelValidator (org.mule.runtime.extension.api.loader.ExtensionModelValidator)4 Optional (java.util.Optional)3 Set (java.util.Set)3 Test (org.junit.Test)3 ArrayType (org.mule.metadata.api.model.ArrayType)3 JAVA (org.mule.metadata.api.model.MetadataFormat.JAVA)3 NamedObject (org.mule.runtime.api.meta.NamedObject)3 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)3 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)3 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)3 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)3 Collection (java.util.Collection)2 HashSet (java.util.HashSet)2