Search in sources :

Example 46 with OperationModel

use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.

the class ExportedPackagesValidatorTestCase method withMethod.

private void withMethod(OperationModel operationModel, Optional<Method> optionalMethod) {
    when(operationModel.getModelProperty(ImplementingMethodModelProperty.class)).thenReturn(optionalMethod.map(ImplementingMethodModelProperty::new));
    when(operationModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(optionalMethod.map(method -> new ExtensionOperationDescriptorModelProperty(new MethodWrapper(method, loader))));
}
Also used : CoreMatchers.is(org.hamcrest.CoreMatchers.is) Optional.empty(java.util.Optional.empty) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel) Apple(org.mule.tck.testmodels.fruit.Apple) MethodWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.MethodWrapper) Mock(org.mockito.Mock) Optional.of(java.util.Optional.of) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) CoreMatchers.not(org.hamcrest.CoreMatchers.not) RunWith(org.junit.runner.RunWith) Shape(org.mule.test.metadata.extension.model.shapes.Shape) TypeToken(com.google.common.reflect.TypeToken) IsEmptyCollection(org.hamcrest.collection.IsEmptyCollection) ExtensionsTestUtils.mockParameters(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.mockParameters) Arrays.asList(java.util.Arrays.asList) ExtensionModelTestUtils.visitableMock(org.mule.runtime.api.util.ExtensionModelTestUtils.visitableMock) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) IntrospectionUtils.getApiMethods(org.mule.runtime.module.extension.internal.util.IntrospectionUtils.getApiMethods) ClassTypeLoader(org.mule.metadata.api.ClassTypeLoader) Problem(org.mule.runtime.extension.api.loader.Problem) ApiTestClass(org.mule.test.module.extension.api.ApiTestClass) Method(java.lang.reflect.Method) VeganAttributes(org.mule.test.vegan.extension.VeganAttributes) Before(org.junit.Before) CoreMatchers.containsString(org.hamcrest.CoreMatchers.containsString) ProblemsReporter(org.mule.runtime.extension.api.loader.ProblemsReporter) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ClassLoaderModelProperty(org.mule.runtime.extension.api.property.ClassLoaderModelProperty) InternalTestClass(org.mule.test.module.extension.internal.InternalTestClass) Result(org.mule.runtime.extension.api.runtime.operation.Result) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) List(java.util.List) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Type(java.lang.reflect.Type) OutputModel(org.mule.runtime.api.meta.model.OutputModel) Optional(java.util.Optional) ImplementingMethodModelProperty(org.mule.runtime.module.extension.internal.loader.java.property.ImplementingMethodModelProperty) ExtensionOperationDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty) Mockito.mock(org.mockito.Mockito.mock) ExtensionOperationDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty) MethodWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.MethodWrapper)

Example 47 with OperationModel

use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.

the class ExportedPackagesValidatorTestCase method setUpValidExtension.

private void setUpValidExtension() {
    OutputModel appleList = mockOutputModel(ApiTestClass.class);
    OperationModel firstOperation = mockOperationModel(appleList, mockOutputModel(ApiTestClass.class));
    withMethod(firstOperation, getApiMethods(ApiTestClass.class).stream().filter(m -> m.getName().equals("someOperation")).findFirst());
    when(extensionModel.getOperationModels()).thenReturn(asList(firstOperation));
    visitableMock(firstOperation);
}
Also used : ApiTestClass(org.mule.test.module.extension.api.ApiTestClass) OutputModel(org.mule.runtime.api.meta.model.OutputModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 48 with OperationModel

use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.

the class ExportedPackagesValidatorTestCase method mockOperationModel.

private OperationModel mockOperationModel(OutputModel output, OutputModel attributes, ParameterModel... params) {
    OperationModel op = mock(OperationModel.class);
    when(op.getOutput()).thenReturn(output);
    when(op.getOutputAttributes()).thenReturn(attributes);
    if (params != null) {
        mockParameters(op, params);
    }
    return op;
}
Also used : OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 49 with OperationModel

use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.

the class ExtensionDescriptionDocumenterTestCase method assertDescriptionsSingleConfig.

private void assertDescriptionsSingleConfig(ExtensionModel extensionModel) {
    assertThat(extensionModel.getConfigurationModels(), hasSize(1));
    assertThat(extensionModel.getOperationModels(), hasSize(1));
    OperationModel withParameterGroup = extensionModel.getOperationModels().get(0);
    assertDescription(withParameterGroup, "Operation with parameter group");
    List<ParameterModel> operationParams = withParameterGroup.getAllParameterModels();
    assertDescription(operationParams.get(0), "value param description");
    assertDescription(operationParams.get(1), "First Description");
    assertDescription(operationParams.get(2), "Second Description");
    ConfigurationModel config = extensionModel.getConfigurationModels().get(0);
    assertDescription(extensionModel, "Test Extension Description with single config");
    assertDescription(config, DEFAULT_CONFIG_DESCRIPTION);
    assertDescription(config.getAllParameterModels().get(0), "Config parameter");
    assertDescription(config.getAllParameterModels().get(1), "Config Parameter with an Optional value");
    assertThat(config.getOperationModels(), hasSize(1));
    assertDescription(config.getOperationModels().get(0), "Operation with description");
    ConnectionProviderModel provider = config.getConnectionProviders().get(0);
    assertDescription(provider, "Provider description");
    assertDescription(provider.getAllParameterModels().get(0), "Connection Param Description");
    assertDescription(provider.getAllParameterModels().get(1), "First Description");
    assertDescription(provider.getAllParameterModels().get(2), "Second Description");
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) ConnectionProviderModel(org.mule.runtime.api.meta.model.connection.ConnectionProviderModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Example 50 with OperationModel

use of org.mule.runtime.api.meta.model.operation.OperationModel in project mule by mulesoft.

the class ExtensionDescriptionDocumenterTestCase method assertDescriptionsMultipleConfigs.

private void assertDescriptionsMultipleConfigs(ExtensionModel declaration) {
    List<ConfigurationModel> configurations = declaration.getConfigurationModels();
    assertDescription(declaration, "Test Extension Description");
    assertThat(configurations, hasSize(2));
    ConfigurationModel first = configurations.get(1);
    assertDescription(first, "This is some Config documentation.");
    assertDescription(first.getConnectionProviders().get(0), "Another Provider Documentation");
    assertDescription(first.getConnectionProviders().get(1), "Provider Documentation");
    ConfigurationModel second = configurations.get(0);
    assertDescription(second, "This is some Another Config documentation.");
    assertDescription(second.getConnectionProviders().get(0), "Another Provider Documentation");
    List<ParameterModel> params = first.getAllParameterModels();
    assertDescription(params.get(0), "Config parameter");
    assertDescription(params.get(1), "Config Parameter with an Optional value");
    assertDescription(params.get(2), EXPIRATION_POLICY_DESCRIPTION);
    assertDescription(params.get(3), "Group parameter 1");
    assertDescription(params.get(4), "Group parameter 2");
    assertDescription(params.get(5), "Param with alias");
    List<OperationModel> operations = declaration.getOperationModels();
    OperationModel operation = getOperationByName(operations, "operation");
    assertDescription(operation, "Test Operation");
    assertDescription(operation.getAllParameterModels().get(0), "test value");
    OperationModel inheritedOperation = getOperationByName(operations, "inheritedOperation");
    assertDescription(inheritedOperation, "Inherited Operation Documentation");
    assertDescription(inheritedOperation.getAllParameterModels().get(0), "parameter documentation for an inherited operation.");
    OperationModel greetFriend = getOperationByName(operations, "greetFriend");
    assertDescription(greetFriend, "This method greets a friend");
    assertDescription(greetFriend.getAllParameterModels().get(0), "This is one of my friends");
    assertDescription(greetFriend.getAllParameterModels().get(1), "Some other friend");
    List<OperationModel> connectedOperations = first.getOperationModels();
    OperationModel connectedOpe = connectedOperations.get(0);
    assertDescription(connectedOpe, "Test Operation with blank parameter description");
    assertDescription(connectedOpe.getAllParameterModels().get(0), "");
}
Also used : ConfigurationModel(org.mule.runtime.api.meta.model.config.ConfigurationModel) ParameterModel(org.mule.runtime.api.meta.model.parameter.ParameterModel) OperationModel(org.mule.runtime.api.meta.model.operation.OperationModel)

Aggregations

OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)96 Test (org.junit.Test)68 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)29 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)27 ConfigurationModel (org.mule.runtime.api.meta.model.config.ConfigurationModel)15 SmallTest (org.mule.tck.size.SmallTest)14 Optional (java.util.Optional)13 SourceModel (org.mule.runtime.api.meta.model.source.SourceModel)12 MetadataType (org.mule.metadata.api.model.MetadataType)11 List (java.util.List)10 Set (java.util.Set)9 ConnectionProviderModel (org.mule.runtime.api.meta.model.connection.ConnectionProviderModel)9 Optional.empty (java.util.Optional.empty)8 IdempotentExtensionWalker (org.mule.runtime.api.meta.model.util.IdempotentExtensionWalker)8 ObjectType (org.mule.metadata.api.model.ObjectType)7 OutputModel (org.mule.runtime.api.meta.model.OutputModel)7 ConstructModel (org.mule.runtime.api.meta.model.construct.ConstructModel)7 HasOperationModels (org.mule.runtime.api.meta.model.operation.HasOperationModels)7 ExtensionWalker (org.mule.runtime.api.meta.model.util.ExtensionWalker)7 OperationComponentModelModelProperty (org.mule.runtime.config.internal.dsl.model.extension.xml.property.OperationComponentModelModelProperty)6