Search in sources :

Example 6 with ExtensionOperationDescriptorModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty in project mule by mulesoft.

the class ExportedArtifactsCollectorTestCase 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 : 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) HeisenbergOperations(org.mule.test.heisenberg.extension.HeisenbergOperations) Mock(org.mockito.Mock) Optional.of(java.util.Optional.of) ExtensionsTypeLoaderFactory(org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory) RunWith(org.junit.runner.RunWith) Shape(org.mule.test.metadata.extension.model.shapes.Shape) TypeToken(com.google.common.reflect.TypeToken) 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) Method(java.lang.reflect.Method) VeganAttributes(org.mule.test.vegan.extension.VeganAttributes) Before(org.junit.Before) Set(java.util.Set) Test(org.junit.Test) Mockito.when(org.mockito.Mockito.when) ClassLoaderModelProperty(org.mule.runtime.extension.api.property.ClassLoaderModelProperty) Result(org.mule.runtime.extension.api.runtime.operation.Result) IsCollectionWithSize.hasSize(org.hamcrest.collection.IsCollectionWithSize.hasSize) ExtensionModel(org.mule.runtime.api.meta.model.ExtensionModel) List(java.util.List) MockitoJUnitRunner(org.mockito.runners.MockitoJUnitRunner) Matchers.containsInAnyOrder(org.hamcrest.Matchers.containsInAnyOrder) 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 7 with ExtensionOperationDescriptorModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty in project mule by mulesoft.

the class OperationReturnTypeModelValidatorTestCase method before.

@Before
public void before() {
    ExtensionOperationDescriptorModelProperty modelProperty = new ExtensionOperationDescriptorModelProperty(methodElement);
    when(extensionModel.getOperationModels()).thenReturn(asList(operationModel));
    when(operationModel.getOutput()).thenReturn(new ImmutableOutputModel("Message.Payload", toMetadataType(String.class), false, emptySet()));
    when(operationModel.getName()).thenReturn("operation");
    when(operationModel.getModelProperty(ExtensionOperationDescriptorModelProperty.class)).thenReturn(Optional.of(modelProperty));
    when(methodElement.getReturnType()).thenReturn(new TypeWrapper(String.class, typeLoader));
    visitableMock(operationModel);
}
Also used : ImmutableOutputModel(org.mule.runtime.extension.api.model.ImmutableOutputModel) ExtensionOperationDescriptorModelProperty(org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty) TypeWrapper(org.mule.runtime.module.extension.internal.loader.java.type.runtime.TypeWrapper) Before(org.junit.Before)

Example 8 with ExtensionOperationDescriptorModelProperty

use of org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty 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)

Aggregations

ExtensionOperationDescriptorModelProperty (org.mule.runtime.module.extension.internal.loader.java.type.property.ExtensionOperationDescriptorModelProperty)8 Method (java.lang.reflect.Method)5 Optional (java.util.Optional)5 ImplementingMethodModelProperty (org.mule.runtime.module.extension.internal.loader.java.property.ImplementingMethodModelProperty)5 List (java.util.List)4 ExtensionModel (org.mule.runtime.api.meta.model.ExtensionModel)4 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)4 ExtensionParameter (org.mule.runtime.module.extension.api.loader.java.type.ExtensionParameter)4 String.format (java.lang.String.format)3 Arrays.asList (java.util.Arrays.asList)3 Before (org.junit.Before)3 ClassTypeLoader (org.mule.metadata.api.ClassTypeLoader)3 HasOperationDeclarer (org.mule.runtime.api.meta.model.declaration.fluent.HasOperationDeclarer)3 ParameterModel (org.mule.runtime.api.meta.model.parameter.ParameterModel)3 ExtensionsTypeLoaderFactory (org.mule.runtime.extension.api.declaration.type.ExtensionsTypeLoaderFactory)3 ClassLoaderModelProperty (org.mule.runtime.extension.api.property.ClassLoaderModelProperty)3 ComponentExecutorModelProperty (org.mule.runtime.module.extension.api.loader.java.property.ComponentExecutorModelProperty)3 MethodElement (org.mule.runtime.module.extension.api.loader.java.type.MethodElement)3 ParameterDeclarationContext (org.mule.runtime.module.extension.internal.loader.utils.ParameterDeclarationContext)3 ReflectiveOperationExecutorFactory (org.mule.runtime.module.extension.internal.runtime.execution.ReflectiveOperationExecutorFactory)3