Search in sources :

Example 16 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataNoRefDynamicConfigurationTestCase method resolveMetadataWithNoRefDynamicConfig.

@Test
public void resolveMetadataWithNoRefDynamicConfig() throws Exception {
    location = builder().globalName(RESOLVER_WITH_IMPLICIT_DYNAMIC_CONFIG).addProcessorsPart().addIndexPart(0).build();
    MetadataKey key = newKey(AMERICA).withChild(newKey(USA).withChild(newKey(SAN_FRANCISCO))).build();
    final MetadataResult<ComponentMetadataDescriptor<OperationModel>> metadataResult = getComponentDynamicMetadata(key);
    assertFailureResult(metadataResult, 1);
    assertMetadataFailure(metadataResult.getFailures().get(0), "Configuration used for Metadata fetch cannot be dynamic", INVALID_CONFIGURATION, MetadataResolvingException.class.getName(), COMPONENT, "");
}
Also used : MetadataResolvingException(org.mule.runtime.api.metadata.MetadataResolvingException) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 17 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class MetadataOperationTestCase method metadataKeyDefaultValue.

@Test
public void metadataKeyDefaultValue() throws Exception {
    location = Location.builder().globalName(METADATA_KEY_DEFAULT_VALUE).addProcessorsPart().addIndexPart(0).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location);
    assertSuccessResult(result);
    MetadataType type = result.get().getModel().getOutput().getType();
    assertThat(type, is(instanceOf(ObjectType.class)));
    ObjectType objectType = (ObjectType) type;
    assertThat(objectType.getFields(), hasSize(2));
    objectType.getFields().forEach(f -> assertThat(f.getKey().getName().getLocalPart(), isOneOf(TIRES, BRAND)));
    Optional<MetadataKey> metadataKeyOptional = result.get().getMetadataAttributes().getKey();
    assertThat(metadataKeyOptional.isPresent(), is(true));
    assertThat(metadataKeyOptional.get().getId(), is(CAR));
}
Also used : ObjectType(org.mule.metadata.api.model.ObjectType) MetadataType(org.mule.metadata.api.model.MetadataType) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) NullMetadataKey(org.mule.runtime.extension.api.metadata.NullMetadataKey) Test(org.junit.Test)

Example 18 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class QueryMetadataTestCase method getNativeQueryOutputArrayMetadata.

@Test
public void getNativeQueryOutputArrayMetadata() throws Exception {
    location = builder().globalName(NATIVE_QUERY_LIST_FLOW).addProcessorsPart().addIndexPart(0).build();
    MetadataKey nativeKey = newKey(NATIVE_QUERY).build();
    MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(nativeKey);
    assertThat(entityMetadata.isSuccess(), is(true));
    MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType();
    assertThat(generatedType, is(instanceOf(ArrayType.class)));
    assertCircleType((ObjectType) ((ArrayType) generatedType).getType());
}
Also used : ArrayType(org.mule.metadata.api.model.ArrayType) ExtensionsTestUtils.toMetadataType(org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType) MetadataType(org.mule.metadata.api.model.MetadataType) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) ComponentMetadataDescriptor(org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor) Test(org.junit.Test)

Example 19 with MetadataKey

use of org.mule.runtime.api.metadata.MetadataKey in project mule by mulesoft.

the class QueryMetadataTestCase method getEntityKeys.

@Test
public void getEntityKeys() throws Exception {
    MetadataResult<MetadataKeysContainer> metadataKeysResult = metadataService.getEntityKeys(QUERY_LOCATION);
    assertThat(metadataKeysResult.isSuccess(), is(true));
    MetadataKeysContainer container = metadataKeysResult.get();
    Set<MetadataKey> metadataKeys = container.getKeys(container.getCategories().iterator().next()).get();
    assertThat(metadataKeys.size(), is(2));
    assertThat(metadataKeys, hasItems(metadataKeyWithId(CIRCLE), metadataKeyWithId(SQUARE)));
}
Also used : MetadataKeysContainer(org.mule.runtime.api.metadata.MetadataKeysContainer) MetadataKey(org.mule.runtime.api.metadata.MetadataKey) Test(org.junit.Test)

Aggregations

MetadataKey (org.mule.runtime.api.metadata.MetadataKey)19 Test (org.junit.Test)13 ComponentMetadataDescriptor (org.mule.runtime.api.metadata.descriptor.ComponentMetadataDescriptor)9 NullMetadataKey (org.mule.runtime.extension.api.metadata.NullMetadataKey)7 MetadataType (org.mule.metadata.api.model.MetadataType)5 MetadataKeysContainer (org.mule.runtime.api.metadata.MetadataKeysContainer)4 MetadataResolvingException (org.mule.runtime.api.metadata.MetadataResolvingException)3 ExtensionsTestUtils.toMetadataType (org.mule.test.module.extension.internal.util.ExtensionsTestUtils.toMetadataType)3 ImmutableSet (com.google.common.collect.ImmutableSet)2 Set (java.util.Set)2 ArrayType (org.mule.metadata.api.model.ArrayType)2 OperationModel (org.mule.runtime.api.meta.model.operation.OperationModel)2 TypeKeysResolver (org.mule.runtime.api.metadata.resolving.TypeKeysResolver)2 Type (java.lang.reflect.Type)1 Arrays (java.util.Arrays)1 Collection (java.util.Collection)1 List (java.util.List)1 BiConsumer (java.util.function.BiConsumer)1 Collectors.joining (java.util.stream.Collectors.joining)1 Inject (javax.inject.Inject)1