@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.of(MetadataKeyBuilder.newKey("HARVESTED").build()); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.of(MetadataKeyBuilder.newKey("APPLE").build()); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) throws MetadataResolvingException, ConnectionException { return ImmutableSet.<MetadataKey>builder() .addAll(TestMetadataResolverUtils.getKeys(context)) .add(newKey(String.format(STARTED_KEY_MASK, STARTED)).build()) .build(); }
public static Set<MetadataKey> getKeys(MetadataContext context) throws ConnectionException { return context.getConnection().map(c -> { MetadataConnection connection = (MetadataConnection) c; return connection.getEntities().stream().map(e -> MetadataKeyBuilder.newKey(e).build()).collect(toSet()); }).orElse(emptySet()); }
private MetadataKeyBuilder getKeyFromField(Object resolvedKey, DeclaringMemberModelProperty declaringMemberModelProperty, ReflectionCache reflectionCache) throws Exception { return newKey(valueOf(getFieldValue(resolvedKey, declaringMemberModelProperty.getDeclaringField().getName(), reflectionCache))); }
@Override public Set<MetadataKey> getKeys(MetadataContext context) { return Arrays.stream(KeyIds.values()).map(e -> MetadataKeyBuilder.newKey(e.name()).build()).collect(Collectors.toSet()); }
@Override public MetadataKey resolveChilds(MetadataContext context, LocationKey partial) throws MetadataResolvingException, ConnectionException { // This is incomplete but you get the idea if (AMERICA.equalsIgnoreCase(partial.getContinent())) { if (ARGENTINA.equalsIgnoreCase(partial.getCountry())) { return newKey(AMERICA).withDisplayName(AMERICA) .withChild(newKey(ARGENTINA) .withChild(newKey(BUENOS_AIRES)) .withChild(newKey(LA_PLATA))) .build(); } return buildAmericaKey(); } else if (EUROPE.equalsIgnoreCase(partial.getContinent())) { return buildEuropeKey(); } else { throw new MetadataResolvingException("Invalid Continent", FailureCode.INVALID_METADATA_KEY); } }
return newKey(valueOf(resolvedKey)).build();
@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, ""); } }
@Test public void getDsqlQueryAutomaticGeneratedOutputMetadata() throws Exception { location = QUERY_LOCATION; MetadataKey dsqlKey = newKey(DSQL_QUERY).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> entityMetadata = getComponentDynamicMetadata(dsqlKey); assertThat(entityMetadata.isSuccess(), is(true)); MetadataType generatedType = entityMetadata.get().getModel().getOutput().getType(); assertThat(generatedType, is(instanceOf(ArrayType.class))); assertCircleType((ObjectType) ((ArrayType) generatedType).getType()); }
@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()); }
@Test @Ignore("MULE-14190: Revamp MetadataScope annotation") public void shouldInheritExtensionResolvers() throws Exception { location = Location.builder().globalName(SHOULD_INHERIT_EXTENSION_RESOLVERS).addProcessorsPart().addIndexPart(0).build(); final MetadataResult<MetadataKeysContainer> metadataKeysResult = metadataService.getMetadataKeys(location); assertSuccessResult(metadataKeysResult); final Set<MetadataKey> metadataKeys = getKeysFromContainer(metadataKeysResult.get()); assertThat(metadataKeys.size(), is(1)); assertThat(metadataKeys, hasItems(metadataKeyWithId("APPLE"))); final ComponentMetadataDescriptor<OperationModel> metadataDescriptor = getSuccessComponentDynamicMetadataWithKey(newKey("APPLE").build()); final OperationModel typedModel = metadataDescriptor.getModel(); assertExpectedOutput(typedModel, typeLoader.load(Apple.class), void.class); }
@Test public void getNativeQueryOutputMetadata() throws Exception { location = builder().globalName(NATIVE_QUERY_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(); assertCircleType((ObjectType) generatedType); }
@Test public void enumMetadataKey() throws IOException { location = Location.builder().globalName(ENUM_METADATA_KEY).addProcessorsPart().addIndexPart(0).build(); ComponentMetadataDescriptor metadataDescriptor = getSuccessComponentDynamicMetadata(newKey("MAMMAL").build()); final ComponentModel typedModel = metadataDescriptor.getModel(); assertExpectedType(getParameter(typedModel, "content"), TYPE_LOADER.load(Bear.class), true); }
@Test public void booleanMetadataKey() throws IOException { location = Location.builder().globalName(BOOLEAN_METADATA_KEY).addProcessorsPart().addIndexPart(0).build(); MetadataResult<ComponentMetadataDescriptor<OperationModel>> result = metadataService.getOperationMetadata(location, newKey("true").build()); assertSuccessResult(result); assertExpectedType(getParameter(result.get().getModel(), "content"), TYPE_LOADER.load(SwordFish.class), true); }