use of org.mule.runtime.api.meta.model.OutputModel in project mule by mulesoft.
the class ExportedPackagesValidatorTestCase method setUpInvalidExtension.
private void setUpInvalidExtension() {
OutputModel appleList = mockOutputModel(InternalTestClass.class);
OperationModel firstOperation = mockOperationModel(appleList, mockOutputModel(InternalTestClass.class));
withMethod(firstOperation, getApiMethods(InternalTestClass.class).stream().filter(m -> m.getName().equals("someOperation")).findFirst());
ParameterModel parameter = mockParameterModel(Shape.class);
OutputModel resultList = mockOutputModel(new TypeToken<List<Result<Apple, VeganAttributes>>>() {
}.getType());
OperationModel secondOperation = mockOperationModel(resultList, mockOutputModel(List.class), parameter);
withMethod(secondOperation, empty());
when(extensionModel.getOperationModels()).thenReturn(asList(firstOperation, secondOperation));
visitableMock(firstOperation, secondOperation);
}
use of org.mule.runtime.api.meta.model.OutputModel in project mule by mulesoft.
the class MetadataOutputDelegate method getOutputMetadata.
/**
* Given a {@link MetadataKey} of a type and a {@link MetadataContext}, resolves the {@link MetadataType} of the Components's
* output using the {@link OutputTypeResolver} associated to the current component.
*
* @param context {@link MetadataContext} of the Metadata resolution
* @param key {@link MetadataKey} of the type which's structure has to be resolved
* @return a {@link MetadataResult} with the {@link MetadataType} of the component's output
*/
private MetadataResult<MetadataType> getOutputMetadata(final MetadataContext context, final Object key) {
OutputModel output = ((HasOutputModel) component).getOutput();
if (isVoid(output.getType()) || !output.hasDynamicType()) {
return success(output.getType());
}
try {
MetadataType metadata = resolverFactory.getOutputResolver().getOutputType(context, key);
if (isMetadataResolvedCorrectly(metadata, true)) {
return success(adaptToListIfNecessary(metadata, key, context));
}
MetadataFailure failure = newFailure().withMessage("Error resolving Output Payload metadata").withFailureCode(NO_DYNAMIC_TYPE_AVAILABLE).withReason(NULL_TYPE_ERROR).onOutputPayload();
return failure(output.getType(), failure);
} catch (Exception e) {
return failure(output.getType(), newFailure(e).onOutputAttributes());
}
}
use of org.mule.runtime.api.meta.model.OutputModel in project mule by mulesoft.
the class ExportedArtifactsCollectorTestCase method setup.
@Before
public void setup() {
ClassLoaderModelProperty classLoaderModelProperty = new ClassLoaderModelProperty(getClass().getClassLoader());
when(extensionModel.getModelProperty(ClassLoaderModelProperty.class)).thenReturn(of(classLoaderModelProperty));
OutputModel appleList = mockOutputModel(new TypeToken<List<Apple>>() {
}.getType());
OperationModel firstOperation = mockOperationModel(appleList, mockOutputModel(List.class));
withMethod(firstOperation, getApiMethods(HeisenbergOperations.class).stream().filter(m -> m.getName().equals("callGusFring")).findFirst());
ParameterModel parameter = mockParameterModel(Shape.class);
OutputModel resultList = mockOutputModel(new TypeToken<List<Result<Apple, VeganAttributes>>>() {
}.getType());
OperationModel secondOperation = mockOperationModel(resultList, mockOutputModel(List.class), parameter);
withMethod(secondOperation, empty());
when(extensionModel.getOperationModels()).thenReturn(asList(firstOperation, secondOperation));
visitableMock(firstOperation, secondOperation);
collector = new ExportedArtifactsCollector(extensionModel);
}
use of org.mule.runtime.api.meta.model.OutputModel in project mule by mulesoft.
the class ExportedArtifactsCollectorTestCase method mockOutputModel.
private OutputModel mockOutputModel(Type type) {
OutputModel om = mock(OutputModel.class);
when(om.getType()).thenReturn(loader.load(type));
return om;
}
use of org.mule.runtime.api.meta.model.OutputModel in project mule by mulesoft.
the class ExportedPackagesValidatorTestCase method mockOutputModel.
private OutputModel mockOutputModel(Type type) {
OutputModel om = mock(OutputModel.class);
when(om.getType()).thenReturn(loader.load(type));
return om;
}
Aggregations